手把手教你在自己的扫描器中,集(bai)成(piao)大名鼎鼎的漏扫描工具nuclei

nuclei其具备这强大功能与良好的生态,其包含的3622poc更是让笔者心动,故对其进行了一些研究,让nuclei可以集成到自己的扫描器中,以下抽离与nuclei相关的核心代码方便大家参考,如有问题可留言或私信我。不多哔哔,上代码。

package main

import (
	"fmt"
	"github.com/logrusorgru/aurora"
	"github.com/projectdiscovery/nuclei/v2/pkg/output"
	"github.com/projectdiscovery/nuclei/v2/pkg/protocols"
	"github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/protocolinit"
	"github.com/projectdiscovery/nuclei/v2/pkg/templates"
	"github.com/projectdiscovery/nuclei/v2/pkg/types"
	"go.uber.org/ratelimit"
)

//-------------------此中内容只是为了完成ExecuterOptions初始化 Start

type Writer struct{}

func (r *Writer) WriteStoreDebugData(host, templateID, eventType string, data string) {}

func (r *Writer) Close() {}
func (r *Writer) Colorizer() aurora.Aurora {
	return nil
}
func (r *Writer) WriteFailure(event output.InternalEvent) error          { return nil }
func (r *Writer) Write(w *output.ResultEvent) error                      { return nil }
func (r *Writer) Request(templateID, url, requestType string, err error) {}

type Progress struct{}

func (p *Progress) Stop()                                                    {}
func (p *Progress) Init(hostCount int64, rulesCount int, requestCount int64) {}
func (p *Progress) AddToTotal(delta int64)                                   {}
func (p *Progress) IncrementRequests()                                       {}
func (p *Progress) IncrementMatched()                                        {}
func (p *Progress) IncrementErrorsBy(count int64)                            {}
func (p *Progress) IncrementFailedRequestsBy(count int64)                    {}

//-------------------此中内容只是为了完成ExecuterOptions初始化 End
func main() {

	w := &Writer{}
	p := &Progress{}
	o := &types.Options{
		//nuclei扫描器包含配置项,根据自己需要配置,因无必填内容故省略
	}
	//初始化nuclei的客户端协议池;
	err := protocolinit.Init(o)
	if err != nil {
		fmt.Println("初始化Nuclei客户端协议池失败")
		return
	}
	//设置运行时,配置信息,以下均为必填内容
	eo := protocols.ExecuterOptions{
		Output:      w,                //输出
		Options:     o,                //扫描器基本配置
		Progress:    p,                //记录扫描进度
		RateLimiter: ratelimit.New(2), //是一个速度限制器限制发送的请求数量。
	}
	//单个poc的存放位置
	f := "yourFile\\http-missing-security-headers.yaml"
	poc, err := templates.Parse(f, nil, eo)
	if err != nil || poc == nil {
		fmt.Println("未成功获取poc")

	}
	//生成poc对应的运行时模板
	e := poc.Executer
	//设置目标地址
	target := "http://172.18.72.19/DVWA-master/login.php"
	//以包含放回的形式对目标执行poc
	err = e.ExecuteWithResults(target, func(result *output.InternalWrappedEvent) {
		//无关代码,单纯为了打印看效果
		for _, r := range result.Results {
			fmt.Println(r.TemplateID)
		}

	})

}
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
以下是一个示例代码,可以将一个文件夹的所有图像切割四份,并且保存在另一个文件夹: ```python import cv2 import os # 设置输入和输出文件夹路径 input_folder = "input_folder_path" output_folder = "output_folder_path" # 遍历输入文件夹的所有图像文件 for filename in os.listdir(input_folder): if filename.endswith(".jpg") or filename.endswith(".png"): # 读取图像 img = cv2.imread(os.path.join(input_folder, filename)) # 将图像切割四份 height, width, _ = img.shape half_height = height // 2 half_width = width // 2 top_left = img[0:half_height, 0:half_width] top_right = img[0:half_height, half_width:width] bottom_left = img[half_height:height, 0:half_width] bottom_right = img[half_height:height, half_width:width] # 将四份图像保存到输出文件夹 cv2.imwrite(os.path.join(output_folder, filename[:-4] + "_top_left.jpg"), top_left) cv2.imwrite(os.path.join(output_folder, filename[:-4] + "_top_right.jpg"), top_right) cv2.imwrite(os.path.join(output_folder, filename[:-4] + "_bottom_left.jpg"), bottom_left) cv2.imwrite(os.path.join(output_folder, filename[:-4] + "_bottom_right.jpg"), bottom_right) ``` 在这个示例代码,我们首先设置了输入和输出文件夹的路径。然后,我们遍历了输入文件夹的所有图像文件,并且对于每个图像,我们读取了它,将它切割四份,然后将四份图像保存到输出文件夹。在保存图像时,我们使用了原始文件名,并在文件名添加了一个后缀,以指示图像是从哪个部分切割而来的。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

方寸明光

你的鼓励将是我创作的最大动力

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

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

打赏作者

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

抵扣说明:

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

余额充值