红队笔记 - PowerView进行AD列举

admin 2021年9月26日08:52:04评论78 views字数 4047阅读13分29秒阅读模式


        虽然下面给出了对我来说最有用的命令,但这仅仅是PowerView能做的事情的一个表面。

        

PowerView可以在这里使用

https://github.com/PowerShellMafia/PowerSploit/blob/master/Recon/PowerView.ps1


# Get all users in the current domainGet-DomainUser | select -ExpandProperty cn
# Get all computers in the current domainGet-DomainComputer
# Get all domains in current forestGet-ForestDomain
# Get domain/forest trustsGet-DomainTrustGet-ForestTrust
# Get information for the DA groupGet-DomainGroup "Domain Admins"
# Find members of the DA groupGet-DomainGroupMember "Domain Admins" | select -ExpandProperty membername
# Find interesting shares in the domain, ignore default sharesFind-DomainShare -ExcludeStandard -ExcludePrint -ExcludeIPC
# Get OUs for current domainGet-DomainOU -FullData
# Get computers in an OU# %{} is a looping statementGet-DomainOU -name Servers | %{ Get-DomainComputer -SearchBase $_.distinguishedname } | select dnshostname
# Get GPOs applied to a specific OUGet-DomainOU *WS* | select gplinkGet-DomainGPO -Name "{3E04167E-C2B6-4A9A-8FB7-C811158DC97C}"
# Get Restricted Groups set via GPOs, look for interesting group memberships forced via domainGet-DomainGPOLocalGroup -ResolveMembersToSIDs | select GPODisplayName, GroupName, GroupMemberOf, GroupMembers
# Find principals that can create new GPOs in the domainGet-DomainObjectAcl -SearchBase "CN=Policies,CN=System,DC=targetdomain,DC=com" -ResolveGUIDs | ?{ $_.ObjectAceType -eq "Group-Policy-Container" } | select ObjectDN, ActiveDirectoryRights, SecurityIdentifier
# Find principals that can link GPOs to OUsGet-DomainOU | Get-DomainObjectAcl -ResolveGUIDs | ? { $_.ObjectAceType -eq "GP-Link" -and $_.ActiveDirectoryRights -match "WriteProperty" } | select ObjectDN, SecurityIdentifier
# Get incoming ACL for a specific objectGet-DomainObjectAcl -SamAccountName "Domain Admins" -ResolveGUIDs | Select IdentityReference,ActiveDirectoryRights
# Find interesting ACLs for the entire domain, show in a readable (left-to-right) formatFind-InterestingDomainAcl | select identityreferencename,activedirectoryrights,acetype,objectdn | ?{$_.IdentityReferenceName -NotContains "DnsAdmins"} | ft
# Get interesting outgoing ACLs for a specific user or group# ?{} is a filter statementFind-InterestingDomainAcl -ResolveGUIDs | ?{$_.IdentityReference -match "Domain Admins"} | select ObjectDN,ActiveDirectoryRights


应用锁定器

        

        识别本地AppLocker策略。寻找豁免的二进制文件或绕过的路径。


Get-AppLockerPolicy -Effective | select -ExpandProperty RuleCollections


根据相应组策略的区分名称,获取远程AppLocker策略(例如,你可以在BloodHound中识别这一点)


Get-AppLockerPolicy -Domain -LDAP "LDAP://targetdomain.com/CN={16641EA1-8DD3-4B33-A17F-9F259805B8FF},CN=Policies,CN=System,DC=targetdomain,DC=com"  | select -expandproperty RuleCollections


其他绕过技术:


  • 如果只允许 (Microsoft-) 签名的二进制文件,请使用LOLBAS。

  • 如果C:Windows允许二进制文件(默认行为),请尝试将二进制文件放到C:WindowsTemp或C:WindowsTasks。如果此目录树中没有可写的子目录但存在可写的文件,请将文件写入备用数据流(例如 JScript 脚本)并从那里执行。

  • 将您的二进制文件包装在一个 DLL 文件中,并在rundll32未强制执行 DLL 时执行它们以绕过可执行规则(默认行为)。

  • 如果允许像 Python 这样的二进制文件,请使用它们。如果这不起作用,请尝试其他技术,例如将 JScript 包装在 HTA 文件中或运行带有wmic.

  • 否则提升你的特权。AppLocker 规则通常不会对(本地)管理用户强制执行。



PowerShell受限语言模式


        有时你可能会发现自己处于一个强制执行受限语言模式(CLM)的PowerShell会话中。当你在一个执行AppLocker的环境中操作时,通常会出现这种情况(见上文)。

    

        你可以通过轮询以下变量来确定你处于受限语言模式,以获得当前的语言模式。对于不受限制的会话,它将显示FullLanguage,而对于CLM,则显示ConstrainedLanguage。


$ExecutionContext.SessionState.LanguageMode


        由于PowerShell的关键功能被封锁,CLM的限制将阻止你的许多利用尝试。绕过CLM与绕过上面讨论的AppLocker基本相同。另一种绕过CLM的方法是绕过AppLocker来执行执行自定义PowerShell运行空间的二进制文件(例如Stracciatella),这将是不受约束的。


        另一个快速和肮脏的绕过方法是使用内联函数,这有时是有效的。例如,如果whoami被封锁了,可以尝试以下方法。


&{whoami}



LAPS


        本地管理密码解决方案(LAPS)是微软在活动目录域范围内管理本地管理密码的产品。它经常为注册的机器的本地管理用户生成强大而独特的密码。这个密码属性和它的过期时间然后被写入活动目录中的计算机对象。默认情况下,对LAPS密码的读取权限只授予域管理员,但经常被委托给特殊组。


        读取LAPSPassword的权限授予用户或组读取ms-Mcs-AdmPwd属性的能力,从而获得本地管理员密码。你可以使用例如BloodHound或PowerView来寻找这个属性。如果我们知道我们对一台机器有正确的ReadLAPSPassword权限,我们也可以使用PowerView来读取密码。


Get-DomainComputer -identity LAPS-COMPUTER -properties ms-Mcs-AdmPwd


        我们还可以使用LAPSToolkit.ps1来识别域中哪些机器使用LAPS,以及哪些负责人被允许读取LAPS密码。如果我们在这个组中,我们也可以用这个工具获得当前的LAPS密码。


# Get computers running LAPS, along with their passwords if we're allowed to read thoseGet-LAPSComputers
# Get groups allowed to read LAPS passwordsFind-LAPSDelegatedGroups



续集


红队笔记 - PowerShell AMSI Bypass





相关推荐: Github渗透测试工具库-2021版

目录前言漏洞练习平台花式扫描器信息搜索工具WEBwindows域渗透工具FUZZ漏洞利用及攻击框架中间人攻击及钓鱼密码破解二进制及代码分析工具EXP编写框架及工具隐写各类安全资料各类CTF资源各类编程资源Python福利甲方安全工程师生存指南蜜罐远控工具合集1…

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2021年9月26日08:52:04
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   红队笔记 - PowerView进行AD列举http://cn-sec.com/archives/551442.html

发表评论

匿名网友 填写信息