VulnNet: dotpy - Write Up

Table of Contents
Link | Level | Creator |
---|---|---|
Here | Medium | TheCyb3rW0lf |
Reconn
We are scanning this machine first with nmap
to check which ports are open/close/filtered.
Good! We have a Python
web server running on port 8080.
Let’s browse to it.
The page request us to login/register. But I tried to navigate to a non-existing page
Mmmm a 403 page, requisting us to login…
So let’s do it, create a dummy user and login, so we can navigate to that page again…
Once loged in, navigate again to the non-existing page and let’s see something very interesting
The page show us the requested endpoint, maybe we can exploit this…
So I used the common {{7*7}}
exploit to check if it is vulnerable, and it returned 49!!
Foothold - User
So we can exploit this with the following code.
Where says ###CODE###
you can just put your system command, so let’s use burpsuite
to send the request with id
and see which user are we
Good! We are the web
user, let’s encode our shell to hex so we can run it, here you have the shell and the perfect encoding in a Cyberchef recipe !
Send it with burpsuite, and get your reverse shell with netcat
Perfect! We now have a reverse shell, so let’s first run sudo -l
to see if our user can run a command with any other user
Interesting, we can run pip3 install
with user system-adm
…
Reading the GTFOBins page, I created another reverse shell payload:
And now we can read the user’s flag!
Root
Once again with this new user, run sudo -l
and we get this output:
So we can exploit a Pythonpath vulnerability, in this easy steps:
- Create a malicious “python lib” named “zipfile.py” (That’s being used by the script
backup.py
) in/tmp
- Run this command
sudo PYTHONPATH=/tmp/ /usr/bin/python3 /opt/backup.py
And we rooted the machine!
That’s all from my side, hope you find this helpful!