PicoCTF Python Wrangling Writeup — Run a Python Script to Decrypt the Flag

Misc 2026-11-26 · picoGym · By CTFdojo · ⏱ ...
𝕏 Share
TL;DR

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.

PlatformpicoGym
Verified againstvivian-dai's picoCTF 2021 writeups
CategoryGeneral Skills
DifficultyBeginner
Tools python3 cat

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

Stuck? Try a hint before reading the solution

Hint 1

Run the script without arguments to see how it wants to be called.

Hint 2

-d decrypts; the password it asks for is in pw.txt.

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:

Resources

New to CTFs? Start here: beginner's guide to CTFs — what a CTF is, the categories, the tools and a step-by-step plan.

CTFdojo
CTFdojo
Community of ethical hackers writing beginner-friendly CTF writeups and guides.

Got a question or a different approach?

Discuss this writeup with the community on the CTFdojo Discord.

Join the Discord →