PicoCTF Python Wrangling Writeup — Run a Python Script to Decrypt the Flag
Download ende.py, pw.txt and flag.txt.en. Run python3 ende.py -d flag.txt.en and paste the password from pw.txt when prompted — the script decrypts and prints the flag. Platform: picoGym Verified against: vivian-dai'
Download ende.py, pw.txt and flag.txt.en. Run python3 ende.py -d flag.txt.en and paste the password from pw.txt when prompted — the script decrypts and prints the flag.
- Platform: picoGym
- Verified against: vivian-dai's picoCTF 2021 writeups
- Category: General Skills
- Difficulty: Beginner
- Tools: python3cat
Challenge description
The challenge hands you an encrypted flag, the script that encrypted it, and the password. The skill being tested is running someone else's script correctly.
Provided:
ende.py,pw.txt,flag.txt.en
Step 1 — Read the script's usage
Run the script with no arguments (or -h) to see how it expects to be called:
$ python3 ende.py
Usage: ende.py (-e/-d) [file]
-e encrypts, -d decrypts, and the second argument is the file to work on. Skimming the source also shows it uses the cryptography library's Fernet — if you get an import error, install it with pip install cryptography.
Step 2 — Get the password
The password is simply stored in pw.txt:
$ cat pw.txt
[PASSWORD]
Step 3 — Decrypt the flag
Run the script in decrypt mode on the encrypted file and paste the password when it asks:
$ python3 ende.py -d flag.txt.en
Please enter the password: [PASSWORD]
picoCTF{***}
To skip the copy-paste, pipe the password in: cat pw.txt | python3 ende.py -d flag.txt.en.
🚩 picoCTF{ flag intentionally hidden }
The flag is deliberately hidden — follow the method, you've earned it. 💪
Key takeaways
Nothing here is hidden — the challenge is about reading a usage message and wiring the pieces together:
- Run unknown scripts with no arguments or
-hfirst to see their usage - Missing modules are fixed with
pip install, not by editing the script - Piping input into a program avoids interactive prompts
Originally published on CTFdojo — join the CTFdojo Discord to discuss writeups and get notified about new ones.
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.