USB ducker
foren100
Description: This file was captured from one of the computers at the Internet cafe. We think that the hacker was using this computer at that time. Try to get his secret documents. ( flag format is flag{…} )
Attachment: (none)
Webpage: https://mega.nz/#!NVJ1kZCR!mDxd7V0rHtMStePa-tUEHPW-SyAxQ6f1zRDCTxX8y3M
Hint: (none)
PS: If you are here just for the script there’s a much better and more updated version at https://github.com/TeamRocketIst/ctf-usb-keyboard-parser
Another USB pcap, after analysing it with wireshark we can see that we have two devices one is a keyboard(bInterfaceClass: HID: 0x3) and the other is a mouse(Unknown)…
Mouse
Keyboard
We can clearly see we that HID: 0x3 is a keyboard by searching for strings in wireshark EDIT -> Find Packet
I actually tried to see what the hacker did with the mouse but didn’t found anything special just a straight line of clicks you could parse the mouse inputs with tshark like this for example:1
tshark -r task.pcap -Y "usb.transfer_type == 0x01 && usb.bInterfaceClass!=3" -Tfields -e usb.capdata > mouse
Moving on to the keyboard since the mouse didn’t got us anything special we just got the output from the keyboard1
tshark -r task.pcap -Y "usb.transfer_type == 0x01 && usb.bInterfaceClass==3" -Tfields -e usb.capdata > keyboard
Now the tricky part here is, the hacker used the arrow keys! making it harder to make a script to spit out the keyboard inputs, well during the CTF I got frustrated, and choose to make it by hand by looking at the table on https://usb.org/sites/default/files/documents/hut1_12v2.pdf (table 12). The keyboard inputs can be read like this:
1 | |-> The value of the keypressed you can "decode" this value from the table 12 above |
When the CTF finished I ended up doing a script to do this (it’s not perfect there is alot of more things to consider).
1 | #!/usr/bin/python |
Now running the script
1 | teamrocketist@Debian ~/D/H/c/h/f/for100> python key2.py |
The flag is flag{k3yb0ard_sn4ke_2.0}