KPMG Cyber Security Challenge 2016 writeups
bounty_hunter
i end up wasting hours of my time solving this challenge, just because we were trolled by the organizer. the system somehow did not accept the correct flag and one of the crew did actually said that the flag was wrong.
anyway the protocols statistic shows that the packet consist of some mail packets:
1 | ~/Desktop/kpmg/chal_mel ⌚ 15:30:45 |
i decided to go through the emails to get an idea of whats going on
we can see that looping is asking for dancing’s public key. he then attach an pgp encrypted jpg file(Marauder’s Map.JPG.gpg) in the subsequent mail. you can extract the encrypted file using NetworkMiner or do just like I did, manually
logically, looping had the file encrypted with dancing’s public key. therefore, we need to get dancing’s secret key in order to decrypt it. searching for frames which contains “.gpg”, i stumbled upon an FTP STOR request frame which seems to be uploading dancing-backup-key.gpg to an ftp server
we can extract the key from the pcap by following the tcp stream of the FTP-DATA protocol just a few frame after the STOR request and save it as a raw file
after importing dancing’s secret key to the keyring, we can try to decrypt the encrypted file.
1 | ~/Desktop/kpmg/bounty_hunter ⌚ 21:33:35 |
unfortunately, the file is password protected. running strings on the pcap did unearth some passwords, but none of them worked
1 | ~/Desktop/kpmg/bounty_hunter ⌚ 21:35:26 |
i ran through the pcap again in wireshark and remembered that SMTP AUTH request are made in base64. copying the pass from the SMTP packet and base64 decoded it did the trick. the encrypted file was decrypted successfully
1 | ~/Desktop/kpmg/bounty_hunter ⌚ 21:38:29 |
unfortunately nothing interesting was in the picture
going through the pcap again i was able to find another Marauder’s Map.JPG.gpg with different bytes on frame 592. decrypting it reveals us the flag
chal_mel
this was supposed to be an easy one, too bad i had my attention on another challenge. we were given with a pcap file full of http packets
1 | ~/Desktop/kpmg/chal_mel ⌚ 15:56:45 |
the first GET request path literally screams base64, and decoding it shows:
1 | ~/Desktop/kpmg/chal_mel ⌚ 15:57:12 |
that is obviously a jpg header. let’s try to decode all the GET request and redirect the stream to a jpg file
1 | ~/Desktop/kpmg/chal_mel ⌚ 15:57:59 |
zooming in the decoded picture reveals us the flag
cipher_text
we were given two files, a 64-bit elf binary and a text file containing some cipher. running strings on the binary give us a number of string references to “MEIPASS” which is a dead giveaway for PyInstaller
1 | ~/Desktop/cipher_text ⌚ 15:20:41 |
let’s try to recover pyc file from the binary using pyi-archive_viewer which came bundled with PyInstaller. read more about it HERE
1 | ~/Desktop/cipher_text ⌚ 15:23:21 |
now we can try to retrieve original python script from the pyc file using uncompyle6
1 | ~/Desktop/cipher_text ⌚ 15:36:39 |
uh-oh, looks like it cannot find the magic number in the header. this can be fixed by compiling our own pyc file and append the missing bytes to cipher2.pyc
1 | ~/Desktop/cipher_text ⌚ 15:40:30 |
let’s open cipher2_fix.py in a text editor and analyze the source code:
1 | # uncompyle6 version 2.9.6 |
the script just take the first character of the argument passed and return a string based on the dictionary. this looks simple to reverse
1 | import sys |
running the above script will generate us the flag
1 | ~/Desktop/kpmg/cipher_text2 ⌚ 15:54:43 |
serious_traffic
we were distributed a pcap file (again!) and upon inspecting the protocol statistics, we can see it’s populated mostly by http traffics
1 | ~/Desktop/kpmg/serious_traffic ⌚ 16:15:58 |
going through the http traffics we can conclude that the packets are captured conversations of metasploit’s meterpreter. i decided to focus on the victim packets (192.168.56.103) and inspect the data passed to the attacker (192.168.56.101). i also filter out the broadcasting packet (contains RECV) which the victim send to the attacker
if you look closely at each packet listed, you can see that in each post data is accompanied by the original command from the attacker after 16 bytes. therefore, we can just skim through the packets and only check for interesting commands. some of them are:
- stdapi_ui_get_keys (dump keylogged buffer)
- mimikatz_custom_command (mimikatz!)
to dump the keylogged buffer, i’ve tweak metasploit code in order to make it work with extracted hextream:
1 | # extracted from metasploit source code |
extracting the buffer reveals a base64 encoded string. but unfortunately it’s not our flag
1 | ~/Desktop/kpmg/serious_traffic ⌚ 17:52:03 |
now looking at the custom mimikatz command, we can see another base64 encoded string
cleaning and decoding it reveals our flag
1 | ~/Desktop/kpmg/serious_traffic ⌚ 17:56:04 |
hard_crypto
the challenge consist of two files - a text file containing description of the challenge and a password protected zip file
1 | ~/Desktop/kpmg/hard_crypto ⌚ 8:54:16 |
the last line of the text file was encoded with base32. decoding it will expose a base64 encoded string
1 | ~/Desktop/kpmg/hard_crypto ⌚ 9:15:32 |
the encoded text was actually not padded correctly but alas, we still get what we wanted
1 | <DATA>60514343475f42540a10270d5a1b04191e1b66344a551f191b013d185c094c75611631026079340a0b0a</DATA> |
the values of data and key looks like it was hex encoded, but decoding it will only spit out gibberish value
1 | ~/Desktop/kpmg/hard_crypto ⌚ 9:16:10 |
looking closely, the values was at the same length. maybe they are xored together
1 | ~/Desktop/kpmg/hard_crypto ⌚ 9:27:28 |
JACKPOT! now we can use the password to extract the zip file
the extracted file was not recognized when it was run though file command. looking at its hexdump, I was able to recognize it as a jpeg file from the 0xffdb marker
1 | ~/Desktop/kpmg/hard_crypto (copy) ⌚ 9:43:57 |
now let’s create a dummy jpg file with imagemagick and use that to append the missing header
1 | ~/Desktop/kpmg/hard_crypto (copy) ⌚ 9:44:44 |
viewing the image, we could see a qr code was embedded in the top right corner
after a little processing in gimp(crop, invert color and change input level) just upload it to an online qr decoder to get “STEGHIDE_PASS:5aZ=zrd+AQ!hf8qL”. looks like it’s a password to an embedded data in the image. now extract the data using steghide to get a text file containing the flag:
1 | ~/Desktop/kpmg/hard_crypto ⌚ 13:05:28 |