USB Pcap Writeup
Muhammad Dzikra Muzaki
Head of Design @ Webmakers IDIt was a fun challenge from JOINTS 20 finals so I thought I’d share it.
Before I begin, if you want to take a crack at this problem you can click here, here, here, and here to download all the necessary files.
Okay, now that that's out of the way, we can start by analyzing the pcap file provided using wireshark. At first there seems like nothing is of our interest in the data being displayed. There is only one direction of traffic from the source address 2.1.1 to the destination address host.
However, we can see that the whole traffic has a type of INTERRUPT which signals a keypress from the device. Another interesting find is the leftover data carried by every package contains a single printable byte each. (That's curious...)
So to further analyze the traffic we want to display every leftover data by adding it as a column (or by pressing ctrl+shift+i), removing every other column, and export it as a csv.
Then, you'd want to convert it into a txt file and strip any trailing data (if there's any) by running this command in the terminal.
From the code segment above we can see that cut -d "," -f 1
is used to separate each fields by the comma and getting the first field only, cut -d "\"" -f 1
is used to remove the quotation marks from the remaining data, and grep -vE [FIELD_NAME]
is used to output everything except the field name which in our case would be "Leftover Capture Data" and the input and output filename would both be "leftover".
After that, let's move on to the simulated web page and the javascript.
Things are starting to make sense now. Based on this website (although explicitly written in the js code comments), each conditional statement represents an arrow key or the Enter key being pressed.
When you look at the leftover data, there is only five variants of bytes, either: 28, 4F, 50, 51, 52. (or in decimal: 40, 79, 80, 81, or 82)
These must be the arrow keys and the Enter!
The rest is probably the easier part, we only need to make a script to read the leftover data, convert each byte to its respective key, and simulate the entire thing.
Funny thing is, since we don't actually know which byte is what key, we need to do a little guesswork here, but, there are a few things we can rule out. The first is the Enter key, we can assume that the only separated byte that doesn't follow the sequence [40, 79, 80, 81, 82] is the Enter key. Also, since the starting highlighted position is on the upper left corner, we can rule out the left or up keys represent the first byte because it wouldn't make sense. What's left is just a few combinations and by using trial and error we would finally get the flag!
FLAG: joints20{pC4P_AND_It5_eZ1}