Giter Site home page Giter Site logo

zema1 / yarx Goto Github PK

View Code? Open in Web Editor NEW
392.0 8.0 51.0 2.38 MB

An awesome reverse engine for xray poc. | 一个自动化根据 xray poc 生成对应靶站的工具

License: MIT License

Go 99.28% Dockerfile 0.72%
xray xray-poc http-server rule-generation yaml-poc fake-data-generator

yarx's Introduction

Logo

在线体验    漏洞报告

Yarx 是什么

Yarx 来自于 x-r-a-y 的反向拼写,它能够根据 xray 的 yaml poc 规则全自动的生成一个满足规则要求的 Server,使用 xray 扫描该 Server 将会扫描出对应的漏洞。它的核心工作原理如下:

yarx-core

它的主要特性有:

  • 支持 status、header、body 等位置的响应变换
  • 支持 == contains submatch 等各种匹配模式
  • 支持动态变量的渲染和捕获以及多级规则的变量追踪
  • 支持绝大部分内置函数的解析和调用
  • 通过路由合并和智能排序等策略有效减少路由冲突
  • 平铺式规则处理逻辑,支持并发扫描
  • 支持捕获扫描事件做进一步分析联动

核心原理: https://koalr.me/posts/core-concept-of-yarx/

立即尝试

./xray webscan --plugins phantasm --html-output yarx.html --url https://yarx.koalr.me

running

几秒钟后你就会得到一个类似的漏洞报告: report.html

安装

  • Github Release

    https://github.com/zema1/yarx/releases 下载合适的版本然后从命令行运行即可

  • Docker Hub

    docker pull zemal/yarx:latest
  • 源码安装

    git clone https://github.com/zema1/yarx
    cd yarx
    go build -o yarx ./cmd/yarx

用法

USAGE:
   yarx [global options] [arguments...]

GLOBAL OPTIONS:
   --pocs value, -p value    load pocs from this dir
   --listen value, -l value  the http server listen address (default: "127.0.0.1:7788")
   --root value, -r value    load files form this directory if the requested path is not found

   --verbose, -V             verbose mode, which is  equivalent to --log-level debug (default: false)
   --help, -h                show help (default: false)

使用示例:

# 在8080端口创建一个 http 服务,这个服务将模拟 pocs 文件夹下的所有漏洞
./yarx -p ./pocs -l 0.0.0.0:8080

# 和上面类似,但当路径不存在时,会从 `./www/html` 加载文件
./yarx -p ./pocs -l 0.0.0.0:8080 -r ./www/html

running

你可以使用本仓库的 pocs 文件夹,也可以直接使用 xray 官方仓库的 https://github.com/chaitin/xray/tree/master/pocs 文件夹。本仓库仅仅是去掉了暂时不支持的 poc,后者除了在运行时会打印一点错误信息之外没有任何区别,我会定期同步数据来增加更多 poc。当然,你也可以指定自己编写的 poc。

开发

Yarx 也可以作为 go 的 package 来使用

yr := &yarx.Yarx{}
// err := yr.Parse([]byte("poc-data"))
err := yr.ParseFile("/path/to/a/yaml/poc")
if err != nil {
    panic(err)
}

// 每个成功加载的 poc 对应一个 MutationChain
// poc 中的 rule 则对应于 MutationRule
chains := yr.Chains()
rules := yr.Rules()
...

// 一键生成上述规则的 http handler
handler := yr.HTTPHandler()

// 事件处理
handler.OnRuleMatch(func(e *yarx.ScanEvent) {
})
handler.OnPocMatch(func(e *yarx.ScanEvent) {
    fmt.Println(e.RemoteAddr)
    fmt.Println(e.Request)
    fmt.Println(e.Response)
    fmt.Println(e.PocMatched)
    fmt.Println(e.RuleMatched)
})

// 启动服务
http.ListenAndServe(handler, "127.0.0.1:7788")

错误说明

Yarx 在解析 poc 的过程中可能会出现错误,这些 poc 不会被加载到最终的 http 服务中,遇到错误时不要惊慌,基本都是这几类问题:

  • 不支持路径本身太灵活的

    主要是 {{name}}.php/ 之类的路径,这些路径作为路由时无法与其他类似的规则区分开,目测无解(相信我,Yarx 已经尽了最大努力避免路由冲突)

  • 不支持 set 定义中存在复杂转换的情况,如:

    set:
      r0: randLowercase(8)
      r1: base64(r0) # 追踪这个变量太复杂,不打算支持
  • 不支持使用反连平台的,即 yaml 中有 newReverse() 调用的,后续有计划支持

如果你遇到其他类型的报错,可以提交一个 issue,带上报错的 yaml poc 即可,我会尽快处理。

规划

  • 支持 Docker 一键部署
  • 支持依赖反连平台的 POC
  • 支持依赖 request 的 POC

yarx's People

Contributors

zema1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yarx's Issues

Windows 平台package embed is not in GOROOT

师傅,在用源码编译的时候,win环境下执行go build -o yarx ./cmd/yarx命令会报错:server.go:6:2: package embed is not in GOROOT (D:\Go\src\embed),有的说执行go env -w GO111MODULE=off,但是还是无法编译,好像是路径的问题,想问下师傅这个问题如何解决呀

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.