summaryrefslogtreecommitdiffstats
path: root/src/host/layer23/src
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2017-09-24 15:45:56 +0330
committerVadim Yanitskiy <vyanitskiy@sysmocom.de>2021-03-25 14:23:57 +0100
commit5e8dc8bc2c480b9fe452b218f6e56e223bd4e9b4 (patch)
treed1b7cc631161c897c396c5a22b0d998ca8b5514c /src/host/layer23/src
parent45cc12d6658547ddd1466a7c3201c5d006008ddd (diff)
mobile/vty: add IMSI/TMSI clone command
Diffstat (limited to 'src/host/layer23/src')
-rw-r--r--src/host/layer23/src/mobile/vty_interface.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/host/layer23/src/mobile/vty_interface.c b/src/host/layer23/src/mobile/vty_interface.c
index 073303ca..2cf17ba1 100644
--- a/src/host/layer23/src/mobile/vty_interface.c
+++ b/src/host/layer23/src/mobile/vty_interface.c
@@ -438,6 +438,56 @@ 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)")
+{
+ const char *imsi = argv[1];
+ struct osmocom_ms *ms;
+ char *error;
+
+ ms = get_ms(argv[0], vty);
+ if (!ms)
+ return CMD_WARNING;
+
+ error = gsm_check_imsi(imsi);
+ if (error) {
+ vty_out(vty, "%s%s", error, VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ osmo_strlcpy(ms->subscr.imsi, imsi, GSM_IMSI_LENGTH);
+ vty_out(vty, "Forced to use the following IMSI: %s%s",
+ ms->subscr.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\")")
{
@@ -2914,6 +2964,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);