Description
Python scripts are invoked kind of like programs in the terminal. Download and use the provided python script, password file, and encrypted flag.
Setup
Download ende.py, pw.txt, and flag.txt.en from the challenge page.
wget <url>/ende.pywget <url>/pw.txtwget <url>/flag.txt.enSolution
Walk me through it- Step 1Read the passwordThe decryption password is stored in pw.txt. Print it so you can supply it to the script.bash
cat pw.txtLearn more
Storing a password in a separate file is a common pattern in software - rather than hard-coding credentials in the main script, they're kept in a dedicated file that can be protected with file system permissions or excluded from version control. In this challenge, the password file is provided to you intentionally as part of the puzzle.
In real applications you'd never want to store plaintext passwords in a file, but the pattern of reading configuration or secrets from a file is pervasive. Tools like
.envfiles,secrets.json, or environment variables serve the same purpose in production code. The key is that the secret is separate from the logic that uses it. - Step 2Decrypt the flagRun ende.py with -d. The argument convention varies; try the script's interactive prompt first, then fall back to argv or stdin redirection if it expects the password directly.bash
# Most common: prompt-driven, paste the password when askedpythonpython3 ende.py -d flag.txt.enbashbash# Argv-style: password as second positional argumentpythonpython3 ende.py -d flag.txt.en "$(cat pw.txt)"bashbash# Stdin-style: pipe the passwordpythonpython3 ende.py -d flag.txt.en < pw.txtLearn more
Command-line flags (like
-d) are arguments passed to a program to modify its behavior. The convention of-dfor "decrypt" and-efor "encrypt" is common across many cryptographic tools. Python scripts parse these using thesys.argvlist or theargparsemodule, which provides structured argument parsing with help text and type checking.The
.enfile extension likely stands for "encrypted" - a naming convention to distinguish encrypted files from their plaintext originals. The underlying cipher is almost always Fernet (AES-128-CBC + HMAC-SHA256 from thecryptographypackage), which is the canonical symmetric encryption primitive in modern Python. Since the password is given, no cracking is needed; this challenge is purely about reading the script and supplying its argument convention.Running Python scripts:
python3 script.pyinvokes the Python 3 interpreter onscript.py. The distinction betweenpythonandpython3matters on systems where Python 2 is still the default (older Linux distros). In CTF environments, always checkpython3 --versionfirst. You can also make scripts directly executable withchmod +x ende.pyand then run./ende.py -d flag.txt.enif the script has a shebang line (#!/usr/bin/env python3).
Flag
picoCTF{...}
The -d flag means decrypt; the password from pw.txt is the decryption key.