Commit Graph

95 Commits

Author SHA1 Message Date
Harald Welte
844db577f2 change to own USB vendor/device ID
we shouldn't re-use the vendor/device ID usd by simtrace1, as the
protocol is incompatible and applications for simtrace 1 don't work with
simtrace2.   Also, there's a different processor architecutre in the
hardware.
2015-11-07 18:38:04 +01:00
Christina Quast
ad6f4d3fd2 replace.py: Moved replace func,mitm: addr book replace
Moved the replace function from mitm.py to replace.py.

This implementation is context insensitive for now. It would be
better, to have a mitm class or to pass state information to the
function. Because how else can the MITM code know, whether it gets
passed data to or from the sim card, to or from the phone?
2015-06-24 15:48:41 +02:00
Christina Quast
2cafadb2a1 ccid_select.py: added comment;this file is test code 2015-06-24 15:42:55 +02:00
Christina Quast
19ed529dee apdu_split.py: INS array updated,CLA sync disabled!
There are more instruction codes, after which data is expected
from the SIM card. Therefore, the array with commands known to
expect SIM card data has been extended. Feel free to extend it
even further.

!! ATTENTION !!
The only synchronization mechanism for parsing APDUs
(naively looking for a 0xA0 byte) is deactivated! It only worked
well for the sniffing mode, but getting out of sync is fatal for
the MITM mode.
!! A NEW MEANS OF SYNCHRONISATION HAS TO BE FOUND !!
2015-06-24 15:23:59 +02:00
Christina Quast
8271bd0145 simtrace.py: Find device without config change
The find_device() function was only called when the USB config was
altered. Now, it is called on every call of simtrace.py.
2015-06-19 13:49:48 +02:00
Christina Quast
ca0ebfdbd6 mitm.py: Bugfix: Always check for APDU_S_SEND_DATA
When the command a0 c0 00 00 16 was send, and the the bytes
a0 c0 00 00 where read first, and then only the byte 16 was read
from simtrace, the code never entered the if condition if cmd is not
None, and therefore never executed send_receive_cmd.

Bug fix: Check for state APDU_S_SEND_DATA after apdu_split (parsing)
the ACK-instruction byte, in case it was an instruction which requires
an answer from the SIM card.
2015-06-19 13:29:21 +02:00
Christina Quast
a929bc8850 ccid_raw.py: SendTransmit: Pass list instead of array
SCardTransmit expects the last function parameter cmd (the bytes
to be send) to be of type list, but we pass a binary array to
send_receive_cmd.
Therefore, the cmd array has to be converted using its function
tolist().
2015-06-19 13:24:38 +02:00
Christina Quast
ebd0fa9d43 gsmtap.py: Send ATR bytes as test command 2015-05-29 16:42:51 +02:00
Christina Quast
3742ef1cde simtrace.py: Comment to remove test func select_file 2015-05-18 18:31:51 +02:00
Christina Quast
4930ea6032 ccid.py: Removed read_bin command
The code was used as early debug code to read different files from
the SIM card and therefore acquire the IMSI, and other SIM card
specific information.

This only was useful for testing that the firmware worked properly.
Is is not needed for regular use cases.
2015-05-18 17:25:36 +02:00
Christina Quast
e0832d6a1f serial_pysim.py: Cleanup: early test code for serial pysim communication
The code changes the config to config number 2 and tries to connect
to the serial CCID reader. This only was useful in the early stage
of the project.
2015-05-18 17:19:45 +02:00
Christina Quast
ba486b61ad simtrace.py: remove unused cmd line option
The commands "cmd1", "cmd2", "cmd_poweron", "cmd_poweroff",
"cmd_get_slot_stat", "cmd_get_param" where early test commands,
but have not been used as such in moths.

A programmer, who wants to send commands to the smartcard, should
use the functions of ccid_raw.py (e.g. send_receive_cmd) instead.
2015-05-18 17:16:31 +02:00
Christina Quast
66224b7e1b Removed unused phone.py
The SIM card emulator re-uses the mitm.py code with an implementation
of SIM card requests and answers instead of phone.py.
2015-05-14 18:13:08 +02:00
Christina Quast
427ae3547a sniffer.py: Removed unused find_dev function 2015-05-14 18:12:05 +02:00
Christina Quast
020e5d6a5f mitm.py: Pass device to do_mitm function 2015-05-14 18:11:23 +02:00
Christina Quast
f25a760f6e simtrace.py: Cleaned up unused functions 2015-05-14 18:09:47 +02:00
Christina Quast
5cf676df61 sniffer.py: Removed redundant find_dev function 2015-05-14 17:21:34 +02:00
Christina Quast
425717d08b mitm,sniffer.py: Send APDUs to wireshark 2015-05-14 17:20:55 +02:00
Christina Quast
152e878bfe gsmtap.py: Ported from scapy to socket
With the python module scapy the headers of each layer have to be created
by hand. Furthermore, in order to use it, the program would have to be
started as root.

Using sockets would be the better. The reason for using scapy was, that
it was the first best thing that I found when searching for python
socket communication.
The next step would be to open and close the socket only once instead
of every time an APDU is send to wireshark.
Furthermore, the ATR probably has to be treated differently from APDU packets.
2015-05-14 17:19:28 +02:00
Christina Quast
59dae92398 apdu_split.py: Fixed off by one err in parsing
Parsing failed like in this dump:
('PTS: ', [255, 0])
('PTS: ', [255, 0, 255])
('APDU:', 'c0', 'a0 c0 00 00 16 c0 00 00 00 00 7f 20 02 00 00 00 00 00 09 91 00 17 04 00 00 00 83 8a 90')
ACK
('APDU:', 'a4', '00 a0 a4 00 00 02 7f 20 9f 16')
('APDU:', 'c0', 'a0 c0 00 00 16 c0 00 00 00 00 7f 20 02 00 00 00 00 00 09 91 00 17 04 00 83 8a 83 8a 90')

a0 c0 00 00 16 c0 00 00 00 00 7f 20 02 00 00 00 00 00 09 91 00 17 04 00 00 00 83 8a 90
00 a0 a4 00 00 02 7f 20 9f 16
a0 c0 00 00 16 c0 00 00 00 00 7f 20 02 00 00 00 00 00 09 91 00 17 04 00 83 8a 83 8a 90

So when data was sent, the next packet would always begin with the SW2 byte
(e.g. 00 a0 ..) instead of the instruction byte a0.
The problem was a wrong state change (to APDU_S_DATA instead of APDU_S_SW1)
2015-05-14 16:58:41 +02:00
Christina Quast
20e89af1bf apdu_split.py: Changed buf data type list to array
The data type of incoming and outgoing data should be the same
at all points of the program to make it consistent.
For this program the data type is array.array.
2015-05-14 16:55:38 +02:00
Christina Quast
2a9c063d6b gsmtap.py: gsmtap_send_apdu and test main function
ATRs should probably be treated differently?
Also, is there a performance penalty when using scapy instead of holding a connection open?
2015-05-12 19:31:04 +02:00
Christina Quast
b894691841 gsmtap.py: send example msg using scapy
The GSM message appears in wireshark when sniffing on localhost
2015-05-12 16:03:23 +02:00
Christina Quast
3735039b59 firmware, host: Changed vendor and product id
The code used a vendor and product id taken from Atmel example code.
Now it is changed to the vendor and product id, which was also previously
used in the original SIMtrace code.
2015-05-08 16:47:29 +02:00
Christina Quast
34d4eb3f5f mitm.py: Intercept phonebook request 2015-05-04 17:50:32 +02:00
Christina Quast
789a4013b4 Added pts parsing 2015-05-04 15:29:07 +02:00
Christina Quast
05ba5232db removed pySim dead link 2015-05-04 15:28:50 +02:00
Christina Quast
b6e005cec1 mitm.py: Working pts parsing and answer 2015-05-04 15:28:03 +02:00
Christina Quast
7c5d13401c constants.py: added atr 2015-05-04 15:27:26 +02:00
Christina Quast
fafa54b37c sm_emul: ff 00 ff is the ans to ff 00 ff 2015-05-03 18:02:33 +02:00
Christina Quast
08ea861b11 mitm.py: to be removed, hack to answer pts request 2015-05-03 16:34:32 +02:00
Christina Quast
6118146598 sm_emul: send ATR with 0x18 and answer to pts 2015-05-03 16:34:06 +02:00
Christina Quast
dace491c65 mitm.py: No ATR replacing 2015-05-03 15:48:09 +02:00
Christina Quast
0d98b9f53f python files: first PTS handling 2015-05-03 14:22:51 +02:00
Christina Quast
40670422c8 apdu_split.py: Recover from failure in parsing on 0xa0 2015-05-03 12:59:44 +02:00
Christina Quast
46a93672d3 mitm.py: Dirty hack for replacing ATR live 2015-04-21 23:00:52 +02:00
Christina Quast
fb91bb7069 Parsing ajusted: respond to phone requests 2015-04-18 14:34:08 +02:00
Christina Quast
158c1dd448 simtrace.py: Use mitm.py in phone and mitm mode 2015-04-17 20:34:09 +02:00
Christina Quast
5384061761 mitm.py: Added apdu splitter code 2015-04-16 11:10:59 +02:00
Christina Quast
9547e9f149 sniffer.py: Added apdu_split support 2015-04-14 22:18:30 +02:00
Christina Quast
51925a6bec apdu_split.py: Corrected last error 2015-04-14 21:04:14 +02:00
Christina Quast
d4c8b51e86 apdu_split working with test message 2015-04-14 15:53:13 +02:00
Christina Quast
e64aa5b878 apdu_split without C code remains 2015-04-14 15:07:33 +02:00
Christina Quast
79c2a3a0c8 apdu_split: first try 2015-04-14 14:55:13 +02:00
Christina Quast
2571458595 sniffer.py: Write out every received char 2015-04-13 22:40:40 +02:00
Christina Quast
2b8a18bf3a Sniffer with ringbuf, works SOMETIMES
* Sniffer uses phone endpoints for communication and the ringbuffer
    routines the phone communication uses
* Most times the Usart1 interrupt is not triggered, and therefore
    no values are recorded
2015-04-12 09:31:36 +02:00
Christina Quast
3a47a4f10e mitm.py: Decreased timeout 2015-04-11 18:16:14 +02:00
Christina Quast
94ddb91e33 mitm.py: New smartcard ATR, expanded pattern match 2015-04-11 12:29:41 +02:00
Christina Quast
f2e53f0553 array to hex function, reduced usb timeout 2015-04-11 08:42:38 +02:00
Christina Quast
362a4da94a simtrace.py: Sleep a sec after changing the config 2015-04-09 13:39:38 +02:00