Armageddon - HTB Write-up

Hello guys! hope you all are doing good. In this blog post, I would like to explain my methodology that I used for pwning the Armageddon box. I hope this would add some educational value for someone who is just starting up with penetration testing. (I am just a wanna be penetration tester. Feel free to point out my mistakes 😜)

1.1 Methodology - Information Gathering

Lets begin by running a Nmap scan. The nmap scan shows that a web application is running on port 80. On checking the CMS technology in use and its version, I could find that the application is built on Drupal 7.


1.2 Methodology - Initial Foothold

Vulnerability Exploited: Drupal 7 CVE-2018-7600. 

Vulnerability Explanation: A remote code execution vulnerability exists within multiple subsystems of Drupal 7.x and 8.x. This potentially allows attackers to exploit multiple attack vectors on a Drupal site, which could result in the site being completely compromised. 

Severity: Highly Critical

Ref: https://github.com/dreadlocked/Drupalgeddon2.git

Using the PoC found on the above github, got initial access on the box.


 

This shell only allows execution of one command and the state of the terminal is not maintained. Hence, I uploaded a php backdoor using the above shell prompt.


4.3 Methodology - Reconnaissance

As seen in the previous screenshot, I currently have privileges of apache user. Looking at /etc/passwd file, I could see that there is a user account “brucetherealadmin”. Looking to escalate privileges to brucetherealadmin. 

Further, found credentials for mysql database in “sites/default/settings.php”.


4.4 Methodology - Local Privilege Escalation

Logging into mysql using the database as “drupal”, found that the database contains below tables. Of these, users' tables seem to be of interest. 



Found hashed password for brucetherealadmin.



Cracked the hash value using hashcat.



Local User Account: "brucetherealadmin"

Local User Password: "booboo"

Using the initial information gathering, port 22 (SSH) was seen open. Using the local user account credentials to login through ssh.


4.5 Methodology - Enumeration

While checking for services running, I could see that snap is running. Ran linPEAS for further enumeration. 



Based on linPEAS results, found out that brucetherealadmin had permission to install snap packages as root, without credentials. 

4.6 Methodology - Root Privilege Escalation

Vulnerability Exploited: Dirty Sock Local Privilege Escalation

Vulnerability Explanation: In January 2019, current versions of Ubuntu Linux were found to be vulnerable to local privilege escalation due to a bug in the snapd API.

Severity: Critical

Ref: https://www.exploit-db.com/exploits/46362

Used the below python script to create a PoC snap package. The snap package will create a new user “dirty_sock” and will add this newly created user to /etc/sudoers with rights to run all commands as sudo.



Installed the PoC snap package in devmode.



As seen in the above screenshot, a new user account “dirty_sock” is created. Changed user account to “dirty_sock”.



Dirty_sock has permissions to run all the commands as sudo. Read the flag from /root/root.txt.


Thank you!!



Comments

Popular posts from this blog

An Overview of SRUM Forensics

Sparta - 100 (EASY)

Easy-ELF! Reversing.kr Walkthrough