summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2017-09-24 15:45:56 +0330
committerVadim Yanitskiy <axilirator@gmail.com>2018-11-21 11:00:55 +0700
commit1fda9312f4bb0fda2a968ca58196dbca11f8941a (patch)
treeaa587f6ae109a78f8fa5684e6d57af95f859e74b
parentc8de8cb1e126a18c0269571fba38310589dd9273 (diff)
mobile/vty: add IMSI/TMSI clone command
-rw-r--r--src/host/layer23/src/mobile/vty_interface.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/host/layer23/src/mobile/vty_interface.c b/src/host/layer23/src/mobile/vty_interface.c
index a0ad9937..7e59c5c7 100644
--- a/src/host/layer23/src/mobile/vty_interface.c
+++ b/src/host/layer23/src/mobile/vty_interface.c
@@ -432,6 +432,60 @@ DEFUN(show_forb_la, show_forb_la_cmd, "show forbidden location-area MS_NAME",
return CMD_SUCCESS;
}
+DEFUN(clone_tsmi, clone_tsmi_cmd, "clone tmsi MS_NAME [TMSI]",
+ "Spoof mobile identity\n"
+ "Force MS to use specified TMSI\n"
+ "Name of MS (see \"show ms\")\n"
+ "Specify required TMSI (e.g. 0xdeadbeef)")
+{
+ uint32_t tmsi = 0xffffffff;
+ struct osmocom_ms *ms;
+
+ ms = get_ms(argv[0], vty);
+ if (!ms)
+ return CMD_WARNING;
+
+ if (argc >= 2)
+ tmsi = strtoul(argv[1], NULL, 16);
+
+ ms->subscr.tmsi = tmsi;
+ vty_out(vty, "Forced to use the following TMSI: 0x%08X%s",
+ tmsi, VTY_NEWLINE);
+
+ return CMD_SUCCESS;
+}
+
+DEFUN(clone_imsi, clone_imsi_cmd, "clone imsi MS_NAME [IMSI]",
+ "Spoof mobile identity\n"
+ "Force MS to use specified IMSI\n"
+ "Name of MS (see \"show ms\")\n"
+ "Specify required IMSI (15 digits)")
+{
+ struct osmocom_ms *ms;
+ const char *imsi;
+ char *error;
+
+ ms = get_ms(argv[0], vty);
+ if (!ms)
+ return CMD_WARNING;
+
+ if (argc >= 2) {
+ imsi = argv[1];
+
+ error = gsm_check_imsi(imsi);
+ if (error) {
+ vty_out(vty, "%s%s", error, VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ }
+
+ strncpy(ms->subscr.imsi, imsi, GSM_IMSI_LENGTH);
+ vty_out(vty, "Forced to use the following IMSI: %s%s",
+ imsi, VTY_NEWLINE);
+
+ return CMD_SUCCESS;
+}
+
DEFUN(monitor_network, monitor_network_cmd, "monitor network MS_NAME",
"Monitor...\nMonitor network information\nName of MS (see \"show ms\")")
{
@@ -2863,6 +2917,8 @@ int ms_vty_init(void)
install_element(ENABLE_NODE, &service_cmd);
install_element(ENABLE_NODE, &test_reselection_cmd);
install_element(ENABLE_NODE, &delete_forbidden_plmn_cmd);
+ install_element(ENABLE_NODE, &clone_tsmi_cmd);
+ install_element(ENABLE_NODE, &clone_imsi_cmd);
#ifdef _HAVE_GPSD
install_element(CONFIG_NODE, &cfg_gps_host_cmd);