HTB-Devzat 10.10.11.118
HTB-Devzat 10.10.11.118
Initial Scanning
# Nmap 7.91 scan initiated Wed Nov 17 16:11:05 2021 as: nmap -Pn -sCV -p22,80,8000 -oN nmap/Basic_10.10.11.118.nmap 10.10.11.118 |
Only port 80 and 8000 are open, port 80 host a normal web service.
The service on port 8000 are not able to view via browser directly.
Enum The Web Service
Additonal host need to be added in order to view the http service.
vim /etc/hosts |
It’s a ssh online chat room hosted on the port 8000.
After perform some basic enumeration on the online ssh chatroom, there are not to much interseting things.
Time to have some more web enumeration.
Sub-domain Enum
wfuzz -c -u "http://devzat.htb" -H "Host: FUZZ.devzat.htb" -w /opt/SecLists/Discovery/DNS/subdomains-top1million-5000.txt --hc 302
http://pets.devzat.htb
Enum on the new web application
It have two input boxes, pet’s name and pet’s species.
Nothing will happen if the submit buttom has been clicked.
Let’s do more enum on the web application.
Due to all the web directory bruteforcing will get the HTTP 200 code, so the normal dir bruteforce tool will not work, we will use wfuzz for this.
http://pets.devzat.htb/.git
has been founded
Manually enum the .git dir was not cool, some tool need to be used.
https://github.com/internetwache/GitTools
The following tool could be used to extract .git content to use git repo.
https://stackoverflow.com/questions/29217859/what-is-the-git-folder
the .git folder contains all the necessary history commits information.
All this information could be use to assemble a entire git repo.
bash gitdumper.sh http://pets.devzat.htb/.git/ /root/HTB/10.10.11.118/git
bash extractor.sh /root/HTB/10.10.11.118/git/ /root/HTB/10.10.11.118/git-decrypt/
Please refer to the following snapshot, the main.go use exec.command function to put user input command together, it will cause a vulnerability which is command injection.
So we could use Burpsuit to generate a malicious http request.
The command has been executed successfully, the attcker machine get the icmp package.
generate the malicious cmdline.
PS: some special character will having some issue with HTTP encode, so we need to use base64 to encode the payload.
By useing linpeas.sh we got the ssh id_rsa login key.
Login via the id_rsa key.
Using the ps -auxww
we got the malicious process.
We found a background docker container was running and it’s 8086 port has been forwarded to the localhost:8086.
We will forward the 8086 port to our local attacking machine by using chisel.
Pivoting
Server-side
./chisel server --reverse 0.0.0.0
Client-side
./chisel client 10.10.14.28:8080 R:127.0.0.1:8086:127.0.0.1:8086
directory scanning on the port 8086
its running InfluxDB
InfluxDB has a exploit
It’s more like a web-base database.
https://docs.influxdata.com/influxdb/v1.8/query_language/explore-schema/#show-measurements
Run linpeas.sh again, found interesting file in /var/backups
Compare the code
a new file
function has been added and there has a hardcoded password
also we found there is a 8443 port running and it’s devzat ssh port again, its very likely that it’s the dev version of devzat.
if pass != "CeilingCatStillAThingIn2021?"
Done
Problem Found
- Source Code Disclosure
The sensitive information has been exposed to the public internet.
- Command Injection in Source code
- id_rsa stored in .ssh
The id_rsa has been store in the .ssh directory, attacker could use id_rsa for lateral movement or upgrade communication channel.
Use vulnerable application
Use hard-coded credential in source code