WeChall - Py-Tong
Challenge
Py-Tong is a Warchall-backed Python exploitation challenge. The
WeChall page exposes the Python source, but the real solution is printed
only by the pytong wrapper binary on the Warchall SSH box,
because the wrapper sets the effective group needed to read the solution
file.
Source
Live source fetch from index.php?highlight=christmas
shows the essential logic:
1 | SOLUTION = '/home/level/12_pytong/pytong_solution.php' |
If main() returns True, the wrapper reads
and prints the solution file.
The wrapper binary (wrap.c) sets real UID/GID to
effective UID/GID (setgid bit on the binary grants group
level12 read access to the solution file):
1 | setreuid(geteuid(), geteuid()); |
Solution
The page hints that a race condition works, but is not required. A
FIFO (named pipe) is the clean route: it passes
os.path.exists(), and each open(...).read()
receives different content from a separate writer.
Key pitfall: paths containing tmp, proc,
random, full, zero, or
null are blocked — do not create the FIFO under
/tmp/.
On the Warchall SSH host:
1 | $ cd /home/level/12_pytong |
The first open().read() gets aaa, the
second gets bbb, so jjk != kwisatz and the
program enters the success branch.