Sitemap

Apache TomCat Service Exploit [CVE-2020–1938 ] — THM Writeup

3 min read2 days ago

--

Lab Link : TomGhost

Platform: TryHackMe

Author : ZODiAK

Get ZODiAK’s stories in your inbox

Join Medium for free to get updates from this writer.

Day 19

1- Recon

NMAP

Press enter or click to view image in full size

here i found a tomcat service use old version , i think this version have a vulnerability so lets search about

Press enter or click to view image in full size

2- Exploitation

nice , this version have a critical bug access to attacker read and write on files system ( CVE-2020–1938 ) , and exploit code is loaded on metasploit

Press enter or click to view image in full size

now use this exploit , and add rhosts(Target IP) and run

Press enter or click to view image in full size

exploit code is read a web.xml file and got data from this data i think i got login credentials , try login via SSH

Press enter or click to view image in full size

user.txt

3- Privilege Escalation

From skyfuck To Merlin

in skyfuck folder i found two files

i think tryhackme.asc this a signeture , however i will get this files on my kali machine to know what about

now lets crack this signeture by john the ripper to extract Passphrase

# convert file to hash
gpg2john tryhackme.asc > thm.hash
# crack hash
john --wordlist=/usr/share/wordlists/rockyou.txt thm.hash
Press enter or click to view image in full size

after crack hash i need to extract data from credentials.pgp file so i use this Passphrase i extracted , but first i need to import a key from tryhackme.asc follow command

gpg --import tryhackme.asc
gpg -d credential.pgp
Press enter or click to view image in full size

and done , login to server via merlin credintials

Press enter or click to view image in full size

From Merlin To Root

now after login to merlin i try to what i can use via root priv without password so i type sudo -l

Press enter or click to view image in full size

i can use zip via root priv to lets search about these to got anything help me i found GFOBins

Press enter or click to view image in full size

follow exploit command

# Create a file 
echo "test" > note.txt

# convert this file to zip but before convert i will add exploit code to got root
sudo zip test.zip note.txt -T --unzip-command="sh -c /bin/bash"
Press enter or click to view image in full size

root.txt

Press enter or click to view image in full size

Thanks For Reading ❤️

--

--

ZODiAK
ZODiAK