03. Python Wrangling - PicoCTF 2021 Writeup
Python scripts are invoked kind of like programs in the Terminal...
Category: General Skills | Author: Syreal | Points: 10
Hello All ๐,
This can be a bit tricky especially if you don't know much about python programming. If you don't, download and install python and mess around with it a bit. If you already know how to move around a bit, go ahead and download all three files given.
There are three files: the 'ende.py' is obviously a python script file, the other two turn out to be plain text files if we open them with notepad. We will first open the python script.
You will notice that running it on the python interpreter will not give any output. This is because this is a python module. To run this, we will first open the command prompt or the terminal. Our first task will be to move to the place where the files were downloaded.
cd Downloads
Once we're in the right folder, we will run the python script using python.
python ende.py
If Python is installed correctly, we should get an error as follows.
Usage: ende.py (-e/-d) [file]
This is good because we now know how to open this file! So the name of the script file should be followed by -e or -d and then the name of the file. In this case the encrypted file. As a side note, -e means encrypt while -d means to decrypt. Since we need decrypting we will use -d.
So we will try again with the correct parameters. 'pw.txt' has 'pw' in it while the other one has a '.en' extension to it. So we can assume that 'pw.txt' contains the key while the other one is the actual file to decrypt. Entering the following code actually executes the command this time.
python ende.py -d flag.txt.en
Now it asks for a password, which we will provide from the 'pw.txt' file. Now you might get an error like 'cryptography is not identified'. This is because you don't have the cryptography library installed. Use the following command to install it.
pip install cryptography
Once you have it successfully installed, you can run that command again and it will output the flag! Either way congratulations, you just completed the challenge!