Skip to content
Startseite » picoCTF python wrangling

picoCTF python wrangling

This CTF challenge called python wrangling is about dealing with python on the commandline. You get a python script called “ende.py”, a file with the encrypted flag called “flag.txt.en” and a password file called “pw.txt”. Your goal is to use the python script from the commandline to get the decrypted flag using the password.

When you start the script from the commandline without any arguments you get a hint how to use the script:

$ python3 ende.py
Usage: ende.py (-e/-d) [file]

So let’s try to use it in the suggested way assuming the ‘-e’ option stands for ‘encrypting’ and the ‘-d’ option stands for ‘decrypting’:

$ python3 ende.py -d flag.txt.en
Please enter the password:

We are requested to enter a password. Now we could simply open the ‘pw.txt’ in another window and copy/paste the text, put I prefer to pipe the content of the ‘pw.txt’ file directly to the python script. On Linux you can show the content of a file using the ‘cat’ command and the ‘|’ operator to pipe the output from one command to the input of another command. To get the decrypted flag, you can type the following on command prompt:

$ cat pw.txt | python3 ende.py -d flag.txt.en
Please enter the password:picoCTF{flag}

So we’ve got the decrypted flag with a single line on the shell.

Leave a Reply

Your email address will not be published. Required fields are marked *