- Published on
PCC '23 - Rev - Literal Byte Bolt
- Authors
- Name
- Ali Taqi Wajid
- @alitaqiwajid
Challenge Description
Solution
We're given a rev-llb.zip
file, unzipping the file gives us the following files:
Well, PyArmor
, something I don't have much experience with. According to it's github page
Pyarmor is a command-line tool designed for obfuscating Python scripts, binding obfuscated scripts to specific machines, and setting expiration dates for obfuscated scripts.
So, we have a python script that's obfuscated, and we need to deobfuscate it. Let's see what we can do. Looking at flag.py
# Pyarmor 8.4.4 (trial), 000000, non-profits, 2023-12-06T04:50:52.041087
from pyarmor_runtime_000000 import __pyarmor__
__pyarmor__(__name__, __file__, b'PY000000\x00\x03\x08\x00U\r\r\n\x80\x00\x01\x00\x08\x00\x00\x00\x04\x00\x00\x00@\x00\x00\x00\x00\x05\x00\x00\x12\t\x04\x00o~\xe2$\xe6\xeaH\x08mq\\Y\xf4\xf5j\x07\x00\x00\x00\x00\x00\x00\x00\x00\xdbMa\x83\xfe \x19\xd2\xae\x10\r\xdb\x96\xe3\xac\x10\x89a\x1f\x98\xe71_)7\xf1\xd4\x84\xc6J\x14T\xda\x1bW\xd2\x8aW:\xad\x18\x8c\x12\xf6\x17]\xe9\xf4\xd1n\xb9d\xf7\xa1B\xb3\xe39\x1a\x9d\xad\'~@\xa0a7\\\x81\xa1\x80R\xc8\xa0\xbb\xfb\xb9X\xad\x1b_\xa7\xdfbU\x96\x9f\x97w}\x95\x9a\xe2\xbc;ky]gq,~(\xe0\xb6\x87W\xe2\xe9\x93\xf5\xb1\x92\xd3\xbf\xa03\xd0\xe5b\xf71\xa8\xb1\xb3\n5\xcf\xfd\x81\xb2\x88\xdd(|!mb\x81\xab&\xd4<\xbf\x10\x8f\xa3\x88\x8b\xb9\x03\x8f\xe1F\xb2\xa8\x99i\xa4m\x1e\xad\x7f\xe9WI\x1c\xc2tON8\x90\'\x93\x1a\x07*h\xa1R|4e\xce\xd0:4T\x9e\xe1k\xfa\xa0\x1b\xbbU4:\x93`:\xda(\\\xc2\xc7\x00\x8d|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3\x96\xdb\xdb\xf7\x1b\xb0\xdd\xb2\xd4%\xed\x9dw&\xec\xf7U\xbe\xfb\\}\x19q)\x7fA\xc7\xe0k\xa5kq\x9b`\x8eI&\xc1F!Y\x9b\xbe\x9dqi\x81\xdb\xe0\x14\x96\x01\xa6\xc1.&#\xb5\x84C\x85,\xe5@1c\xa6H\x12=\x13\x9b\xfb_\xb5\xd4\xc9\xcd\xbcLu\xb2\x1a\xea2;/YV\x8fua(\x18a\x82\xe1\xe6oZ\xe8\x16\xaf_f\xc0\xd2O\xdd\x84\xd8:]\xfa\x9eWV\xf3\x87\xa7\x88\x8f+\x12\xca\x80\xc6h\xb48\xa7\x00\xf6\x14Ig>"\xfd-\xebBv\x18\xb2\xf2\xcd\xde\xc8m\x12\x02\x83\x08\xea\xce\x13\xc5\xaaB6\x0e\x0b\xea\xe8\xeaI\x0c\x15\x80\x12\x01\x15\xdf6\xed&\x14\x03\xa3\xf2\x86\xb0sL\xb5^b\x12N\x0e\xab\xec\xd3\xb7e,\xda\xeb\x8f\xe9\x88_\x86\xa9\x98!\x04H\xb9\xda\xe12EWn\xbb\xe0_"\x8ah\x89\xb8D\x92\xfb\x0c\n-\xeb\xdc\xc34\xa6\xb1U^\xf4\xf3jV\x85\x9d\x945\x9f#\xa1\xde\x16-\x12\xd3\x03e:\x8a_<\xf0`\xe8nxC\xccM\xf8\xb4\x85\xa3k\xe7Y\x9f\xfe\x86y\xb0j\x88\xe2&\xf5\xb0\x8ef\xac\x86\xe4\x12\x06\xd0{[\xca\xecj\xbe\xaa\xc8\xa2\xffakO\xb2\x8aE%N\x8c\xa0\x8d')
Well, this seems useless to even think about manually deobfuscating it. Let's see what happens if we try and run it
Well, it asks for inputs and upon closing; it closes. Let's see what happens if we try and run it with strace
So, it seems like the python process spawns another child process; maps the python file in memory of the child process and then executes it.
What if, we attach GDB to this process and search for PCC
in memory? Maybe it's kept in plaintext.
Firstly, finding the PID of the process
Now, attaching GDB to the process
sudo gdb pid=5941
Now, since we have pwndbg
, we can simply search for the string PCC
in memory:
If anyone knows a better way of doing this, or how you can de-obfuscate the script, please let me know.