HTTP redirect bypass (unintended 😁), PHP code execution through file upload to get a reverse shell. User with hardcoded SQL credentials on server, privesc with custom binary with no
As I am an idiot, I reinstalled my distribution without making a backup of my files 🙈 So I don’t have any screenshot or payloads I used for this box to show you
With a basic
nmap we found only two ports: 22 and 80.
The running web server seems to be a portfolio, we can also note a login page for the administrator.
I thought it would be great to access this admin page, but I did not found any valid credentials to log myself in. What I did instead was:
- Use BurpSuite to intercept my requests to the
- Change the
302 -> /loginredirection code to
200 -> /adminon response
- Now got access to the page without login-in
Of course after reading other solutions, this one was really unintented, the ‘normal’ way was to make an SQL injection in the login form.
Now that we are on the admin page, we can upload some pictures in order to display them on the homepage. The first thing that came to my mind was to upload a PHP reverse shell:
If we upload it and visit it we got our nice reverse shell working!
We are in the machine, but need to privesc as a user. Looking in the server’s directory I found an intersting
We try to log as the mentioned user with the given password. It does not works. Maybe it is some valid SQL credentials? I also found a
mysqldump binary on the system, which – pay attention – dumps a given MySQL schema.
We then get a new password:
admin:Th3s3usW4sK1ng. Maybe this one is the user’s password? We can log-in with
We now need to get as
By looking into
/bin/ we get an interesting binary
sysinfo running with
This binary basically fetches information on the system and outputs it on stdout.
Here, the vulnerability is: the binary executes some commands (such as
lsblk -l…) without an absolute path to them. We can easilly create our own
lswh binary and change our
$PATH to trick this program to execute our code as
This is what I did:
By now we only have to cat
/root/root.txt, or create ourselves a reverse shell, add our SSH key to the box, or anything!
Sorry for this bad writeup, I lost all my files, payloads and notes but I tryied my best.