HTB | Jarvis
Last updated
Last updated
This is the Box on Hack The Box Linux Privilege Escalation 101 Track. Find the box here.
SQL Injection - SQLMap
Command Injection
GTFObin - systemctl
IP: 10.10.10.143
Let's do directory fuzzing While clicking on the website we know it is running on php.
When I clicked on book room it took me to http://10.10.10.143/room.php?cod=1
URL
While trying '
at the end we broke the image meaning SQL injection is possible
Now we know the backend is MYSQL and it is vulnerable to SQL injection
I can try and dump username and password
Now we have the password, we can try and upload the cmd.php to the server and try to get the shell
Now let's upload the cmd.php
Now I can reach the server
I can get the reverse shell
and we are in
pepper is the owner of the file simpler.py
The script itself is a python3 script used to manage and provide statistics on the webserver:
Looking at the usage of the script, there is one interesting command line option Ping an IP
exec_ping
is called directly from the main if the -p
is given:
There’s a clear command injection in the exec_ping code where my input is read to the command
The problem is that I can’t use any of the forbidden characters
I tried exec_ping
to ping my own system and it worked.
I tried $(echo 4)
and it worked
Since I can run any command within $(),
I can try to get the shell
and we found user.txt
Let's copy LinEnum.sh to the box
and run ./LinEnum.sh
I’m specifically interested in /bin/systemctl
. This binary is a systemd utility which is responsible for Controlling the systemd system and service manager. That is, it creates and manages services. And in this case, only root and users in the group pepper (me) can run it, and it will run as root (because it is a SUID).
A service is defined by a .service file. The systemctl is used to link it to systemd, and then used again to start the service. What the service does is defined by the .service file.
Gtfobins has a page for systemctl, and it gives an example where a single command is executed and output to a file in tmp. I’ll modify that slightly to give me a shell.
Now I use systemctl to link this service:
Note: Make the at.servcie in /dev/shm for some reason it was not working for /tmp
and we are in. We found root.txt