Xray使用教程
简介
Xray
是长亭科技开发的一款漏扫工具。- 支持多种扫描方式和漏洞类型。
- 可自定义
POC
(Proof of Concept
)概念验证,即漏洞验证程序。
俺是在 乌雲安全 看到了这个工具的使用,作为一个
脚本小子初学者,这里做一下笔记。
使用
webscan
参数
参数 | 作用 |
---|---|
--list, -l | list plugins |
--plugins value, --plugin value, --plug value | specify the plugins to run, separated by ',' |
--poc value, -p value | specify the poc to run, separated by ',' |
--listen value | use proxy resource collector, value is proxy addr, (example: 127.0.0.1:1111) |
--basic-crawler value, --basic value | use a basic spider to crawl the target and scan the requests |
--browser-crawler value, --browser value | use a browser spider to crawl the target and scan the requests |
--url-file value, --uf value | read urls from a local file and scan these urls, one url per line |
--burp-file value, --bf value | read requests from burpsuite exported file as targets |
--url value, -u value | scan a single url |
--data value, -d value | data string to be sent through POST (e.g. 'username=admin') |
--raw-request FILE, --rr FILE | load http raw request from a FILE |
--force-ssl, --fs | force usage of SSL/HTTPS for raw-request |
--json-output FILE, --jo FILE | output xray results to FILE in json format |
--html-output FILE, --ho FILE | output xray result to FILE in HTML format |
--webhook-output value, --wo value | post xray result to url in json format |
主动扫描
- 使用
--basic-crawler
模块实现爬虫+扫描功能。
$ ./xray webscan --basic-crawler {target_ip} --html-output {target_html}
爬取并扫描
{target_ip}
并将结果输出到{target_html}
中。
- 目标
html
报告会在当前目录下生成。
被动代理
- 作为中间人进行处理报文信息。
此时代理能够拿到完整的请求报文,如果使用
HTTPS
依然可以获得明文信息。
- 提前安装插件
switchyomega
并导入Xray
的证书。
./xray genca
上述命令生成证书后,自行导入到对应浏览器中。
- 启动代理。
./xray webscan --listen {listen_socket} --html-output {target_html}
- 得到最后一行即启动成功。
└─$ ./xray webscan --listen 127.0.0.1:7777 --html-output result.html
____ ___.________. ____. _____.___.
\ \/ /\_ __ \ / _ \ \__ | |
\ / | _ _/ / /_\ \ / | |
/ \ | | \/ | \ \____ |
\___/\ \ |____| /\____|_ / / _____/
\_/ \_/ \_/ \/
Version: 1.7.1/f725e41e/COMMUNITY
[INFO] 2021-04-11 10:42:03 [default:entry.go:198] Loading config file from config.yaml
[WARN] 2021-04-11 10:42:03 [default:webscan.go:222] disable these plugins as that's not an advanced version, [thinkphp struts fastjson shiro]
Enabled plugins: [crlf-injection path-traversal xxe brute-force cmd-injection dirscan ssrf phantasm jsonp redirect sqldet upload baseline xss]
[INFO] 2021-04-11 10:42:04 [phantasm:phantasm.go:170] 252 pocs have been loaded (debug level will show more details)
These plugins will be disabled as reverse server is not configured, check out the reference to fix this error.
Ref: https://docs.xray.cool/#/configration/reverse
Plugins:
poc-yaml-dlink-cve-2019-16920-rce
poc-yaml-jenkins-cve-2018-1000600
poc-yaml-jira-cve-2019-11581
poc-yaml-jira-ssrf-cve-2019-8451
poc-yaml-mongo-express-cve-2019-10758
poc-yaml-pandorafms-cve-2019-20224-rce
poc-yaml-ruijie-eg-rce
poc-yaml-saltstack-cve-2020-16846
poc-yaml-solr-cve-2017-12629-xxe
poc-yaml-supervisord-cve-2017-11610
poc-yaml-weblogic-cve-2017-10271
ssrf/ssrf/default
xxe/xxe/blind
[INFO] 2021-04-11 10:42:06 [collector:mitm.go:214] loading cert from ./ca.crt and ./ca.key
[INFO] 2021-04-11 10:42:06 [collector:mitm.go:269] starting mitm server at 127.0.0.1:7777
- 在
switchyomega
插件中配置好代理。
- 在浏览器中打开你想要扫描的网站,代理会自动进行扫描。
配置文件
域限制
- 为了防止对无用的域进行扫描,在
config.yaml
文件中可以配置黑白名单。
restriction: # 代理能够访问的资源限制, 以下各项为空表示不限制
hostname_allowed: [] # 允许访问的 Hostname,支持格式如 t.com、*.t.com、1.1.1.1、1.1.1.1/24、1.1-4.1.1-8
hostname_disallowed: # 不允许访问的 Hostname,支持格式如 t.com、*.t.com、1.1.1.1、1.1.1.1/24、1.1-4.1.1-8
- '*google*'
- '*github*'
- '*.gov.cn'
- '*.edu.cn'
- '*chaitin*'
- '*.xray.cool'
hostname_allowed
存放允许访问的域名,hostname_disallowed
存放不允许访问的域名(支持通配符)。
登录代理
- 设置用户登录。
basic_auth: # 基础认证的用户名密码
username: ""
password: ""
插件选择
baseline:
enabled: true
detect_cors_header_config: true # 检查 cors 相关配置
detect_server_error_page: true # 检查服务器错误信息
detect_system_path_leak: false # 检查响应是否包含系统路径泄露
detect_outdated_ssl_version: false # 检查 ssl 版本问题
detect_http_header_config: false # 检查 http 安全相关 header 是否配置
detect_cookie_httponly: false # 检查 set-cookie 时是否设置 http only
detect_china_id_card_number: false # 检查响应是否存在身份证号
detect_china_phone_number: false # 检查响应是否存在电话号码
detect_china_bank_card: false # 检查响应是否存在银行卡号
detect_private_ip: false # 检查响应是否包含内网 ip
brute-force:
enabled: true
username_dictionary: "" # 自定义用户名字典, 为空将使用内置 TOP10, 配置后将与内置字典**合并**
password_dictionary: "" # 自定义密码字典,为空将使用内置 TOP100, 配置后将与内置字典**合并**
cmd-injection:
enabled: true
crlf-injection:
enabled: true
dirscan:
enabled: true
depth: 1 # 检测深度,定义 http://t.com/a/ 深度为 1, http://t.com/a 深度为 0
dictionary: "" # 自定义检测字典, 配置后将与内置字典**合并**
fastjson:
enabled: true
jsonp:
enabled: true
path-traversal:
enabled: true
phantasm: # poc 插件
enabled: true
depth: 1
auto_load_poc: false # 除内置 poc 外,额外自动加载当前目录以 "poc-" 为文件名前缀的POC文件,等同于在 include_poc 中增加 "./poc-*"
exclude_poc: [] # 排除哪些 poc, 支持 glob 语法, 如: "/home/poc/*thinkphp*" 或 "poc-yaml-weblogic*"
include_poc: [] # 只使用哪些内置 poc 以及 额外加载哪些本地 poc, 支持 glob 语法, 如:"*weblogic*" 或 "/home/poc/*"
# 也可使用 --poc 仅运行 指定的内置或本地 poc,进行测试。
# 例如,可使用如下命令,仅运行当前目录下的 poc 且 不运行内置 poc 进行测试:
# webscan -poc ./poc-* -url http://example.com
通过
enable
开关,决定功能检测是否开启。
- 使用
--plugins
参数限制使用插件。
./xray webscan --listen 127.0.0.1:1111 --plugins xss,xxe,cmd_injection
双重代理
- 一般可以结合
BurpSuite
使用。
http:
proxy: "http://127.0.0.1:8080"