Challenge Info
description:This’ve got a binary that can list directories as root, try it out !! ssh to saturn.picoctf.net:59803, and run the binary named “bin” once connected. Login as ctf-player with the password, af86add3
author: Junias Bonou
Attempts
Upon connecting, I ran pwd
and ls
to see what we have:
1 | ctf-player@pico-chall$ pwd |
I tried navigating around with cd
, until I finally found something interesting:
1 | ctf-player@pico-chall$ cd .. |
A challenge folder, which the flag is probably inside of. Unfortunately, we can’t navigate into it. Next, I tried seeing if sudo was available, to no success.
1 | ctf-player@pico-chall$ sudo |
Finally, I want back to ctf-player to try and execute the binary we’re given. Unfortunately, upon trying to execute it, I’m met with a problem:
1 | ctf-player@pico-chall$ ls |
Okay, so lets try setting the SECRET_DIR
environment variable:
1 | ctf-player@pico-chall$ export SECRET_DIR=/ |
Understanding the Challenge
The binary called “bin” that we’ve been executing, reads directories with root permissions, so when we set SECRET_DIR=/
, it read everything in / as root. Using this information, we can use the environment variable to poke around different directories, starting with /challenge
:
1 | ctf-player@pico-chall$ export SECRET_DIR=/challenge |
So, while /challenge
didn’t yield any success, /root
shows us where the flag is, and that it’s in a .txt
. Which is great and all, but how can we actually read the contents of it? As seen previously, bin
only reads directories, so it doesn’t serve any use… unless we can chain commands…
Solution
1 | ctf-player@pico-chall$ export SECRET_DIR="ls /root | cat /root/flag.txt" |
flag: picoCTF{Power_t0_man!pul4t3_3nv_1670f174}