当前位置:网站首页>Nuclei (2) Advanced - In-depth understanding of workflows, Matchers and Extractors
Nuclei (2) Advanced - In-depth understanding of workflows, Matchers and Extractors
2022-08-04 23:19:00 【Test Dev Kevin】
前面的文章中介绍了nuclei的基础使用方法,可以参考文章:
POCSimulated attack weapon——Nuclei入门(一)
Next, I will focus on explainingnuclei中的三个概念,Workflows、Mathcer和Extractors.These will help you write more complex and efficient detection scripts!
workflows
WorkflowsAllows users to customize the execution order of templates,这是使用nuclei最高效的方式,It is officially recommended that users use customWorkflowsThis reduces scan time,提升扫描效率!
- Basic Workflow
例如,定义workflow 扫描files目录下如下yaml
workflows:
- template: files/git-config.yaml
- template: files/svn-config.yaml
- template: files/env-file.yaml
- template: files/backup-files.yaml
- tags: xss,ssrf,cve,lfi
- 条件工作流
首先确认springboot-detect.yaml是否正确执行,如果OK,则运行subtemplates下的template,实例如下:
id: springboot-workflow
info:
name: Springboot Security Checks
author: dwisiswant0
workflows:
- template: security-misconfiguration/springboot-detect.yaml
subtemplates:
- template: cves/CVE-2018-1271.yaml
- template: cves/CVE-2018-1271.yaml
- template: cves/CVE-2020-5410.yaml
- template: vulnerabilities/springboot-actuators-jolokia-xxe.yaml
- template: vulnerabilities/springboot-h2-db-rce.yaml
运行workflows
nuclei -list http_urls.txt -w workflows/my-workflow.yaml
Matchers
Mathcer顾明思议,Just provide some rules,to compare and match the response results!There are six types in common use
mathcer,如下所示:
- status Integer Comparisons of Part
- size Content Length of Part
- word Part for a protocol
- regex Part for a protocol
- binary Part for a protocol
- dsl Part for a protocol
For example, you want to compare and match the response code,写法如下:
matchers:
# Match the status codes
- type: status
# Some status codes we want to match
status:
- 200
When you want to do complex matching of response codes,可以使用dsl
matchers:
- type: dsl
dsl:
- "len(body)<1024 && status_code==200"
- "contains(toupper(body), md5(cookie))"
The meaning of the previous example is that the length of the matching response body is less than1024 并且状态码是200
Judge capitalizedbody中是否包括cookie的md5sum
使用condition: and\or Multiple conditions can be matched,Default multiple conditions areand的关系
官方实例如下:
matchers:
# Match the body word
- type: word
# Some words we want to match
words:
- "[core]"
- "[config]"
# Both words must be found in the response body
condition: and
# We want to match request body (default)
part: body
详情请参考 https://nuclei.projectdiscovery.io/templating-guide/operators/matchers/
Extractors
Extractors Also check the results,与matchers相比,It can display the content that satisfies the rules,Also he has different typesExtractors,如下所示:
1. regex - Extract data from response based on a Regular Expression.
2. kval - Extract key: value/key=value formatted data from Response Header/Cookie
3. json - Extract data from JSON based response in JQ like syntax.
4. xpath - Extract xpath based data from HTML Response
例如:
extractors:
- type: xpath # type of the extractor
attribute: href # attribute value to extract (optional)
xpath:
- "/html/body/div/p[2]/a" # xpath value for extraction
5. dsl - Extract data from the response based on a DSL expressions.
详情请参考https://nuclei.projectdiscovery.io/templating-guide/operators/extractors/
由于使用nuclei时间尚浅,关于Extractors和Matchers,Personally, I don't think there's a big difference in usage!
Both are verifications of the results,与matchers相比,ExtractorsIt can display the content that satisfies the rules!If you need to write complex response validation,Then it takes time to researchdsl了.
如何从nuclei中受益
当使用了nuclei一段时间后,Personally I think it is actually usednucleiThe most valuable is the variety insidetemplate,We can look at eachtemplatescript to learn attack methods,And also according to the insidereference to view the details of the vulnerability,This is particularly helpful for the relevant accumulation of safety knowledge!As for the sending of the attack request,This is actually a lot easier,我们是否使用nuclei其实都无所谓的,举个简单的例子,关于CVE-2020-9484的 yaml脚本定义如下:
id: CVE-2020-9484
info:
name: Apache Tomcat Remote Command Execution
author: dwisiswant0
severity: high
description: |
When using Apache Tomcat versions 10.0.0-M1 to 10.0.0-M4, 9.0.0.M1 to 9.0.34, 8.5.0 to 8.5.54 and 7.0.0 to 7.0.103 if
a) an attacker is able to control the contents and name of a file on the server; and
b) the server is configured to use the PersistenceManager with a FileStore; and
c) the PersistenceManager is configured with sessionAttributeValueClassNameFilter="null" (the default unless a SecurityManager is used) or a sufficiently lax filter to allow the attacker provided object to be deserialized; and
d) the attacker knows the relative file path from the storage location used by FileStore to the file the attacker has control over; then, using a specifically crafted request, the attacker will be able to trigger remote code execution via deserialization of the file under their control.
Note that all of conditions a) to d) must be true for the attack to succeed.
reference:
- http://packetstormsecurity.com/files/157924/Apache-Tomcat-CVE-2020-9484-Proof-Of-Concept.html
- https://nvd.nist.gov/vuln/detail/CVE-2020-9484
- https://lists.apache.org/thread.html/r77eae567ed829da9012cadb29af17f2df8fa23bf66faf88229857bb1%40%3Cannounce.tomcat.apache.org%3E
- https://lists.apache.org/thread.html/[email protected]%3Cusers.tomcat.apache.org%3E
classification:
cvss-metrics: CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H
cvss-score: 7
cve-id: CVE-2020-9484
cwe-id: CWE-502
tags: cve,cve2020,apache,tomcat,rce
requests:
- method: GET
headers:
Cookie: "JSESSIONID=../../../../../usr/local/tomcat/groovy"
path:
- "{
{BaseURL}}/index.jsp"
matchers-condition: and
matchers:
- type: status
status:
- 500
- type: word
part: body
words:
- "Exception"
- "ObjectInputStream"
- "PersistentManagerBase"
condition: and
这个脚本中,The easiest is probablyrequests:Part of the attack script code,我们用jmeter Or the way you write your own code can be easily simulated!而description:部分以及reference:Parts are what we need to focus on!It is also our deep understandingpocBest example of an attack!
边栏推荐
- MySQL的安装与卸载
- 从“草原牛”到“数字牛”:蒙牛的数字化转型之道
- I was rejected by the leader for a salary increase, and my anger rose by 9.5K after switching jobs. This is my mental journey
- 3年,从3K涨薪到20k?真是麻雀啄了牛屁股 — 雀食牛逼呀
- 【内存操作函数内功修炼】memcpy + memmove + memcmp + memset(四)
- Service Mesh landing path
- 【3D建模制作技巧分享】ZBrush纹理贴图怎么导入
- The Controller layer code is written like this, concise and elegant!
- [QNX Hypervisor 2.2用户手册]10.5 vdev ioapic
- Will we still need browsers in the future?(feat. Maple words Maple language)
猜你喜欢
PID控制器改进笔记之七:改进PID控制器之防超调设定
应用联合、体系化推进。集团型化工企业数字化转型路径
956. 最高的广告牌
4-《PyTorch深度学习实践》-反向传播
一点点读懂thermal(一)
【3D建模制作技巧分享】ZBrush纹理贴图怎么导入
[Mock Interview - 10 Years of Work] Are more projects an advantage?
Implementing class target method exception using proxy object execution
基于Appian低代码平台开发一个SpaceX网站
地面高度检测/平面提取与检测(Fast Plane Extraction in Organized Point Clouds Using Agglomerative Hierarchical Clu)
随机推荐
各行各业都受到重创,游戏行业却如火如荼,如何加入游戏模型师职业
xss总结
现在学习次世代3D游戏建模还能找到高薪好工作吗
Service Mesh落地路径
TypeScript - the use of closure functions
Vscode连接远程服务器(一套配置成功)
【3D建模制作技巧分享】ZBrush如何使用Z球
Shell expect 实战案例
【软件测试】常用ADB命令
线上虚拟展馆展示具有哪些优势
【SSR服务端渲染+CSR客户端渲染+post请求+get请求+总结】
PZK学C语言之字符串函数(一)
特征工程资料汇总
【3D建模制作技巧分享】ZBrush模型制作流程:地精
Shell编程之循环语句与函数的使用
注解@EnableAutoConfiguration的作用以及如何使用
【3D建模制作技巧分享】ZBrush如何设置笔刷快捷键
基于深度学习的路面坑洞检测(详细教程)
加解密在线工具和进制转化在线工具
文章占位 文章占位