-
Notifications
You must be signed in to change notification settings - Fork 0
/
tool.sh
executable file
·77 lines (74 loc) · 1.67 KB
/
tool.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
source .env
source "$LOAD_ENV"
APPLET_AID=A0000001157000000000000043433102
case $1 in
read-current)
gp \
-d \
-r "$READER" \
--connect "$CONNECT_AID" \
--key-enc "$ENC_KEY" \
--key-mac "$MAC_KEY" \
--key-dek "$KEK_KEY" \
--applet "$APPLET_AID" \
--apdu "8010000000" \
| grep -A1 "80100000" | tail -1
;;
read-backup)
gp \
-d \
-r "$READER" \
--connect "$CONNECT_AID" \
--key-enc "$ENC_KEY" \
--key-mac "$MAC_KEY" \
--key-dek "$KEK_KEY" \
--applet "$APPLET_AID" \
--apdu "8012000000" \
| grep -A1 "80120000" | tail -1
;;
backup)
gp \
-d \
-r "$READER" \
--connect "$CONNECT_AID" \
--key-enc "$ENC_KEY" \
--key-mac "$MAC_KEY" \
--key-dek "$KEK_KEY" \
--applet "$APPLET_AID" \
--apdu "8014000000" \
| grep -A1 "80140000" | tail -1
;;
restore)
gp \
-d \
-r "$READER" \
--connect "$CONNECT_AID" \
--key-enc "$ENC_KEY" \
--key-mac "$MAC_KEY" \
--key-dek "$KEK_KEY" \
--applet "$APPLET_AID" \
--apdu "8016000000" \
| grep -A1 "80160000" | tail -1
;;
write)
if [[ "$2" =~ ^[0-9]{18}$ ]]; then
gp \
-d \
-r "$READER" \
--connect "$CONNECT_AID" \
--key-enc "$ENC_KEY" \
--key-mac "$MAC_KEY" \
--key-dek "$KEK_KEY" \
--applet "$APPLET_AID" \
--apdu "8018000009${2}" \
| grep -A1 "80180000" | tail -1
else
echo "Usage: $0 write <raw IMSI>"
exit 1
fi
;;
*)
echo "Usage: $0 {read-current|read-backup|backup|restore|write}"
exit 1
esac