Skip to main content

Enumeration

Run Nmap Scan

View Website

Untitled

Directory Bruteforcing (Run Gobuster)

SMB Enumeration

Administrative Website Enumeration

Untitled

SQL Injection Code

The website is vulnerable to SQL injection, which is filtering by username=GET['user'] AND password=GET['pass']. I used ;-- to comment out the query after my injection code.

Viewing the Dashboard

Untitled

Exploitation

Further Enumeration using Enum4Linux (User Enumeration)

We found 2 user accounts, which is kyle and john.

SSH Bruteforcing

Use the extracted username to bruteforce the password

Credentials

Exploit

Privilege Escalation

Kyle to John

Network Enumeration

Here we can enumerate port 3306 (mysql), 8080 (internal website), 25 (smtp)

MySql Enumeration

Here there’s no credentials other than user kyle

Enumerating SMTP

Using pspy64 to monitor process https://github.com/DominicBreuker/pspy Download the binary file pspy64 and upload the file to the victim computer for monitoring processes. (looking at cron)
Looking at the script, it seems like the files /bin/sh -c /usr/bin/cp /root/.scripts/disclaimer /etc/postfix/disclaimer and /usr/bin/cp /root/.scripts/master.cf /etc/postfix/master.cf are reset every minute which looks like we can exploit it. Check which groups we own
Finding smbgroup files that is not related to writer2_project
Finding filter group files
Nothing inside filter directory , there’s only disclaimer directory left. Viewing the File /etc/postfix/disclaimer
The script seems to be executed every minute or two when the mail is sent.
The disclaimer script is executed with user john permission. If we send a mail, the disclaimer script will be executed. Hence we can replace the original disclaimer script with the reverse shell included script, so we can gain a reverse shell of user john. Check disclaimer script privilege.
Since we are in the group, we can modify the script. Generate reverse shell code in base64 (I used python3 base64 code) Online - Reverse Shell Generator Modified script

Listen to Reverse Shell and Exploit

Replace modified Disclaimer script to the original disclaimer script
Port forward smtp to our localhost smtp
Send mail using swaks

Login to John using SSH

Copy attacker pc’s (Our PC’s) public ssh key and paste it (append) to /home/john/.ssh/authorized_keys
Login to SSH
Since the path /etc/ssh/ssh_host_ed25519_key requires privilege, I used sudo to ran ssh. Looking at the groups, john is also inside the management group

John to Root

Enumerate Management Group Files and Directories

/etc/apt/apt.conf.d is a directory (.d standing for directory) used for apt-get proxy settings. If you scroll up, we executed pspy64 to monitor the process and we’ve seen apt-get update getting executed every minute or two.

Checking for Permissions.

Since there’s no permission to write any of the files, we can make another one in this directory.

Invoking Reverse Shell inside apt update code

Online - Reverse Shell Generator
Generate a reverse shell code in base64 (I used python3 reverse shell) and replace the base64 code. The code invokes the command before apt-get update is called.

Listen to Reverse Shell and Exploit

Reference