概述

SharpView 是 PowerView 的 .NET / C# 移植版本,而 PowerView 是 PowerSploit 工具集中非常经典的 Active Directory 枚举工具之一。

PowerView 主要用于在域环境中进行信息收集,例如枚举域用户、域组、计算机、ACL、委派关系、信任关系、共享目录、会话信息等。它本质上不是“漏洞利用工具”,而是一个 AD 枚举与关系分析工具,常用于为后续攻击路径选择提供信息基础。

过去,PowerShell 是很多进攻性工具的首选脚本语言,但随着安全产品的发展,PowerShell 的行为越来越容易被监控和检测,例如:

  • PowerShell Script Block Logging
  • PowerShell Transcription
  • AMSI
  • EDR 对 PowerShell 行为的检测

枚举方向

用于确认当前域环境的基本情况。

  • 域名
  • 域 SID
  • 域控地址
  • 当前用户
  • 当前机器
  • 当前登录上下文

域信息

  • 域基础信息
Get-domain
  • 域控信息
Get-DomainController
  • 查看域SID
Get-DomainSID
  • 查看域策略
Get-DomainPolicyData
- 域策略里重点关注:
			密码长度要求
			密码复杂度
			账户锁定策略
			Kerberos 票据有效期

用户信息

  • 所有域用户
    Get-DomainUser
    
    • 查看关键属性
Get-DomainUser -Properties samaccountname,description,memberof,pwdlastset,lastlogontimestamp,useraccountcontrol
  • 查询指定用户
Get-DomainUser -Identity username

查询配置了SPN的用户

配置了 SPN 的用户通常和 Kerberoasting 有关。

Get-DomainUser -SPN -Properties samaccountname,serviceprincipalname

查询不需要Kerberos预认证的用户

这类用户可能和 AS-REP Roasting 有关。

Get-DomainUser -PreauthNotRequired -Properties samaccountname,useraccountcontrol

组枚举

组枚举用于确认域内有哪些权限组,以及哪些用户属于高权限组。

  • 所有组
Get-DomainGroup
  • 查看指定组
Get-DomainGroupMember -Identity "Domain Admins"
  • 递归查看嵌套组成员
Get-DomainGroupMember -Identity "Domain Admins" -Recurse
  • 查看本地管理员相关组:
Get-DomainGroupMember -Identity "Administrators" -Recurse

计算机枚举

计算机枚举用于确认域内机器、服务器、域控、文件服务器、数据库服务器等目标。

  • 枚举所有域计算机

Get-DomainComputer ``` - 只显示常用字段:

Get-DomainComputer -Properties dnshostname,operatingsystem,lastlogontimestamp
  • 查询服务器系统
Get-DomainComputer -LDAPFilter "(operatingsystem=*Server*)" -Properties dnshostname,operatingsystem
  • 查找域控
Get-DomainController

ACL/DACL枚举

ACL / DACL 枚举是 PowerView 的重点功能之一。

它用于查看某个 AD 对象上,谁对谁拥有什么权限。

常见可利用权限包括:

GenericAll
GenericWrite
WriteDACL
WriteOwner
AddMember
ForceChangePassword
AllExtendedRights
  • 查看某个对象的 ACL
Get-DomainObjectAcl -Identity target -ResolveGUIDs
  • 查看某个组对象的 ACL:
Get-DomainObjectAcl -Identity "Domain Admins" -ResolveGUIDs
  • 查找当前用户对哪些对象有权限
# 先把当前用户名转换成 SID
Convert-NameToSid username

# 用SID过滤ACL
$sid = Convert-NameToSid username 
Get-DomainObjectAcl -ResolveGUIDs | Where-Object {$_.SecurityIdentifier -eq $sid}

PowerView 提供了一个比较常用的函数:

Find-InterestingDomainAcl -ResolveGUIDs

它会尝试找出比较有价值的 ACL 关系。

手动筛选危险权限

Get-DomainObjectAcl -ResolveGUIDs | Where-Object {
    $_.ActiveDirectoryRights -match "GenericAll|GenericWrite|WriteDacl|WriteOwner|ExtendedRight"
}

委派枚举

委派枚举主要用于查找 Kerberos 委派相关配置。

常见委派类型:

非约束委派 Unconstrained Delegation
约束委派 Constrained Delegation
基于资源的约束委派 RBCD
  • 查找非约束委派机器
Get-DomainComputer -Unconstrained -Properties dnshostname,useraccountcontrol
  • 查找非约束委派用户
Get-DomainUser -Unconstrained -Properties samaccountname,useraccountcontrol
  • 查找约束委派用户
Get-DomainUser -TrustedToAuth -Properties samaccountname,msds-allowedtodelegateto
  • 查找约束委派机器
Get-DomainComputer -TrustedToAuth -Properties dnshostname,msds-allowedtodelegateto
  • 查找 RBCD 配置

RBCD 主要看机器对象上的:

msDS-AllowedToActOnBehalfOfOtherIdentity

枚举命令:

Get-DomainComputer -LDAPFilter "(msDS-AllowedToActOnBehalfOfOtherIdentity=*)" -Properties dnshostname,msds-allowedtoactonbehalfofotheridentity