Challenge Description
You have complete power with nano. Think you can get the flag?
Approach
This challenge drops you into a nano text editor session on a remote server. The goal is to escape the editor environment and read the flag file. This is a classic GTFOBins-style challenge — nano has built-in capabilities to execute shell commands and read files, which can be leveraged to break out of the restricted environment.
Key capabilities of nano that are useful here:
-
Read File (Ctrl+R): Insert the contents of another file into the current buffer. This can be used to directly read
/flag.txtor similar flag file paths. -
Execute Command (Ctrl+R, then Ctrl+X in older nano / Ctrl+T in some versions): After pressing Ctrl+R (Read File), pressing Ctrl+X or Ctrl+T switches to “Execute Command” mode. This allows you to run arbitrary shell commands and pipe their output into the editor buffer.
-
Spawn a shell: Using the execute command feature, you can run
sh,bash, orreset; sh 1>&0 2>&0to get a full interactive shell.
According to GTFOBins, nano can be used to:
- Read files directly
- Execute arbitrary commands
- Spawn interactive shells
Solution
Method 1: Read the flag file directly with Ctrl+R
- Connect to the challenge server (SSH or netcat).
- You are dropped into
nano. - Press Ctrl+R (Read File).
- Type the path to the flag file, e.g.,
/flag.txtor/home/ctf/flag.txt, and press Enter. - The flag contents are inserted into the buffer and displayed on screen.
Common flag file locations to try:
/flag.txt/flag/home/ctf/flag.txt/root/flag.txt~/flag.txt
Method 2: Execute a command to find and read the flag
- In
nano, press Ctrl+R (Read File). - Press Ctrl+X (or Ctrl+T depending on version) to switch to “Execute Command” mode.
- Type:
cat /flag.txtand press Enter. - The flag is inserted into the editor buffer.
If you don’t know where the flag is:
- Execute:
find / -name "flag*" 2>/dev/null - This shows all files with “flag” in the name.
- Then read the discovered file.
Method 3: Spawn a full shell
- Press Ctrl+R, then Ctrl+X (or Ctrl+T).
- Type:
reset; bash 1>&0 2>&0and press Enter. - You now have a full shell. Use
ls,find, andcatto locate and read the flag.
Method 4: Use Ctrl+T directly (some nano versions)
- Press Ctrl+T (Execute Command / Spell Check depending on version).
- Type:
cat /flag.txt - The output appears in the buffer.
Solution Script
python3 solve.py
Flag
picoCTF{...} (placeholder - actual flag varies per instance)