readIMSI, writeIMSI

This commit is contained in:
Neels Hofmeyr 2020-02-24 21:31:01 +01:00
parent 0866f3a036
commit c24fdd1ad7
1 changed files with 19 additions and 10 deletions

View File

@ -285,23 +285,16 @@ public class IMSIPseudo extends Applet implements ToolkitInterface, ToolkitConst
private void showIMSI() {
/* 3GPP TS 31.102 4.2.2: IMSI */
byte[] IMSI = new byte[9];
byte[] msg = {'C', 'u', 'r', 'r', 'e', 'n', 't', ' ', 'I', 'M', 'S', 'I', ':', ' ',
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '};
gsmFile.select((short) SIMView.FID_DF_GSM);
gsmFile.select((short) SIMView.FID_EF_IMSI);
try {
gsmFile.readBinary((short)0, IMSI, (short)0, (short)9);
byte IMSI[] = readIMSI();
mi2str(msg, (byte)14, (byte)16, IMSI, false);
showMsgAndWaitKey(msg);
} catch (SIMViewException e) {
showError(e.getReason());
return;
}
mi2str(msg, (byte)14, (byte)16, IMSI, false);
showMsgAndWaitKey(msg);
}
private void handleMenuResponseMain() {
@ -343,4 +336,20 @@ public class IMSIPseudo extends Applet implements ToolkitInterface, ToolkitConst
byte mi[] = str2mi(imsi, MI_IMSI);
showMsgAndWaitKey(hexdump(mi));
}
private byte[] readIMSI()
{
gsmFile.select((short) SIMView.FID_DF_GSM);
gsmFile.select((short) SIMView.FID_EF_IMSI);
byte[] IMSI = new byte[9];
gsmFile.readBinary((short)0, IMSI, (short)0, (short)9);
return IMSI;
}
private void writeIMSI(byte mi[])
{
gsmFile.select((short) SIMView.FID_DF_GSM);
gsmFile.select((short) SIMView.FID_EF_IMSI);
gsmFile.updateBinary((short)0, mi, (short)0, (short)mi.length);
}
}