1. c0mp1led
Challenge Description: We recently received a .pyc file but we can’t see the content inside it. Before we run it, could you please take a look and find out what’s in it?
→ unzip c0mp1led.zip
Archive: c0mp1led.zip
[c0mp1led.zip] c0mp1led.pyc password:
inflating: c0mp1led.pyc
→ file c0mp1led.pyc
c0mp1led.pyc: data
.pyc files are created by the Python interpreter when a .py file is imported. They contain the “compiled bytecode” of the imported module/program so that the “translation” from source code to bytecode (which only needs to be done once) can be skipped on subsequent imports if the .pyc is newer than the corresponding .py file, thus speeding startup a little. But it’s still interpreted.
With linux native binary strings we can view most of the strings that are present in a binary file. Lets use that to see if the flag is hardcoded.
→ strings -d c0mp1led.pyc
z;This function greets to
the person passed in as
parameter
Hello,
. Good morning!N
print
name
c0mp1led.py
xor ctfc
zIThis function greets to
the person passed in as
parameterr
hello
584f527bZ
6433636f6d70316cZ
655f447d)
bytearray
fromhex
decoder
functio
where is the flag?N)
<module>
→ uncompyle6 c0mp1led.pyc
It seems that the flag hides in the fla() function. We can skip the rest of the code by calling only this function.
→ cat flag.py
→ python flag.py
XOR{d3comp1le_D}
2. PS1
Challenge Description: What file format is this .ps1 and why it’s so unreadable?
→ unzip PS1.zip
Archive: PS1.zip
[PS1.zip] command.ps1 password: xor2020
inflating: command.ps1
→ ls
command.ps1 PS1.zip
→ cat command.ps1
As we can see it’s obfuscated (shoutout to Daniel Bohannon). We can manually deobfuscate it by rearranging the indexed chars, but to save some time we can use PSDecode. You can install this module both on Linux and Windows by copying it to your pwsh modules path.
→ Get-Content .\commands.ps1 | PSDecode
Invoke-WebRequest -Uri “https://flag.xor.al/?flag=XOR{invok3_0bfusc4tion.ps1}”
3. xhRReq
Challenge Description: While doing our weekly scans on our website, we found this weird java script file but we don’t understand nothing of it and developers don’t remember to put it there.. Could you please tell us if this is harmful?
→ unzip xhRReq.zip
Archive: xhRReq.zip
[xhRReq.zip] obfuscated.js password: xor2020
inflating: obfuscated.js
→ cat obfuscated.js
Even though it’s obfuscated, from the challenge name and from the code structure we can see that it’s a XMLHttpRequest. We’re going to focus on _v0.open() function since it’s used to make a request to a specific url.
This function is using _cs variable and it’s indexed chars. We are going to reorder these chars and decode them since they’re hex encoded.
_cs[1] = \x47\x45\x54
_cs[12] = \x68\x74\x74
_cs[3] = \x70\x73\x3a
_cs[2] = \x2f\x2f\x63
_cs[8] = \x6f\x6e
_cs[9] = \x74\x72
_cs[10] = \x6f\x6c\x63
_cs[4] = \x2e\x63\x6f
_cs[5] = \x6d\x2f\x31"
_cs[7] = \x38\x39\x65
_cs[6] = \x37\x36\x61
+ "8"
→ echo ‘\x47\x45\x54’ ‘\x68\x74\x74’ ‘\x70\x73\x3a’ ‘\x2f\x2f\x63’ ‘\x6f\x6e’ ‘\x74\x72’ ‘\x6f\x6c\x63’ ‘\x2e\x63\x6f’ ‘\x6d\x2f\x31’ ‘\x38\x39\x65’ ‘\x37\x36\x61’ ‘8’
GET htt ps: //c on tr olc .co m/1 89e 76a 8
This page is password protected. If we look again at the html file we can see an alert that pops up on error with message ‘xor2020’. Let’s use this as a password and view the flag.
<button type="button" onclick="myFunc()" onerror=alert('xor2020')">Change Content</button>
I hope you had fun solving these challenges and learning something new.