Skip to content

raylax/rayx

Repository files navigation

xray poc 执行器

Go codecov Go Report Card

仅供个人学习、研究使用,请勿用于非法用途

使用

Releases页面包含最新下载地址

# 
curl -L https://github.com/raylax/rayx/releases/download/0.1.0/rayx_darwin_amd64 -o rayx
chmod +x rayx
./rayx -p _testdata/pocs -u http://localhost:1234

# zeroshell-cve-2019-12725-rce.yml - [H] √√√
# zimbra-cve-2019-9670-xxe.yml - [M]
# zzcms-zsmanage-sqli.yml - [E]

[H] 命中规则

[M] 未命中规则

[E] 执行错误

帮助 ./rayx -h

Usage:
  rayx [flags]

Flags:
      --cookie        (eg cookie1=value1,cookie2=value2)
      --header        (eg header1=value1,header1=value2)
  -h, --help          help for rayx
  -p, --poc string    POC file/folder (eg. path/to/poc,rce.yaml)
  -s, --sleep int     sleep seconds
  -t, --threads int   threads (default 1)
      --timeout int   timeout seconds (default 30)
  -u, --url string    target url (eg. https://httpbin.org)
  -v, --version       version for rayx

工作原理

使用语法分析器分析expression构造语法树以及上下文并执行,执行的过程是惰性的

表达式语法描述Expression.g4是根据yaml分析出来的,不是很完善。写完之后才发现有现成的cel-go可用 :(

name: poc-yaml-demo
manual: true
transport: http
set:
    r1: randomLowercase(16)
    r2: randomLowercase(16)
rules:
    r0:
        request:
            cache: true
            path: /a/{{r1}}
        expression: response.status == 200 
    r1:
        request:
            cache: true
            path: /b/{{r1}}
        expression: response.status == 200
expression: r0() && r1()
detail:
    author: raylax(raylax@inurl.org)
  1. 执行器首先解析最外层表达式r0() && r1()
  2. 解析rules.r0,由于依赖set.r1,所以计算set.r1
  3. 计算出所有依赖值后执行rules.r0,当rules.r0.expressionfalse时,整个POC验证失败,结束验证
  4. 如果rules.r0.expressiontrue则继续重复上述步骤
  5. set中的变量会缓存计算结果,也就是说如果set.r1=randomLowercase(16)重复使用set.r1的值是一样的
  6. 如果rules配置了cache: true同样会缓存结果

问题

  1. 由于暂未实现反连功能,所以使用反连的poc会报error - 'newReverse' undefined 错误