plugin

package
v0.0.0-...-3b6bae9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2025 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package plugin 加载插件、执行插件、获取插件信息,支持JSON/YAML和Go插件

Index

Constants

View Source
const (
	ONLY_AND = "only and in expr"
	ONLY_OR  = "only or in expr"
)

Variables

View Source
var GoPlugins map[string][]GoPlugin

GoPlugins GO插件集

View Source
var JSONPlugins map[string][]JSONPlugin

JSONPlugins JSON插件集

View Source
var LevelMap = map[string]int{
	"critical": 0,
	"high":     1,
	"medium":   2,
	"low":      3,
	"warn":     4,
}
View Source
var YAMLPlugins map[string][]YAMLPlugin

YAMLPlugins YAML插件集

Functions

func GetPlugins

func GetPlugins() (plugins []map[string]interface{})

GetPlugins 获取插件信息

func InitCelEnv

func InitCelEnv(c *CustomLib) (*cel.Env, error)

func Regist

func Regist(target string, plugin GoPlugin)

Regist 注册插件

func Scan

func Scan(task Task) (result []map[string]interface{})

Scan 开始插件扫描

Types

type Checker

type Checker struct {
	// contains filtered or unexported fields
}

type CustomLib

type CustomLib struct {
	EnvOptions        []cel.EnvOption
	ProgramOptionList []cel.ProgramOption
}
var Custom CustomLib

func (*CustomLib) CompileOptions

func (c *CustomLib) CompileOptions() []cel.EnvOption

func (*CustomLib) Evaluate

func (c *CustomLib) Evaluate(Expression string, v map[string]interface{}) (ref.Val, error)

func (*CustomLib) ProgramOptions

func (c *CustomLib) ProgramOptions() []cel.ProgramOption

type GoPlugin

type GoPlugin interface {
	Init() Plugin
	Check(netloc string, meta TaskMeta) bool
	GetResult() []Plugin
}

GoPlugin 插件接口

type JSONPlugin

type JSONPlugin struct {
	Target  string `json:"target"` // 插件对应资产类型
	Meta    Plugin `json:"meta,omitempty"`
	Request struct {
		Path     string            `json:"path"`
		PostData string            `json:"postdata,omitempty"`
		Headers  map[string]string `json:"headers,omitempty"`
	} `json:"request"`
	Verify struct {
		Type  string `json:"type"`
		Match string `json:"match"`
	} `json:"verify"`
	Extra bool
}

JSONPlugin JSON插件

type ListItem

type ListItem struct {
	Key   string
	Value []string
}

字符串键列表值对

type ListMap

type ListMap []ListItem

func (ListMap) MarshalYAML

func (r ListMap) MarshalYAML() (interface{}, error)

func (*ListMap) UnmarshalYAML

func (r *ListMap) UnmarshalYAML(unmarshal func(interface{}) error) error

type Plugin

type Plugin struct {
	PluginType string     `json:"plugintype,omitempty"` //插件类型
	Name       string     `json:"name"`
	Remarks    string     `json:"remarks"`
	Level      int        `json:"level"` //0:严重 1:高危 2:中危 3:低危 4:提示
	Type       string     `json:"type"`  //漏洞类型
	Author     string     `json:"author"`
	References References `json:"references"`
	Target     string     `json:"target,omitempty"`
	// json plugin
	Request  string `json:"request,omitempty"`
	Response string `json:"response,omitempty"`
	// yaml plugin
	Set        string `json:"set,omitempty"`
	Sets       string `json:"sets,omitempty"`
	Rules      string `json:"rules,omitempty"`
	Expression string `json:"expression,omitempty"`

	Reviewer      string    `bson:"reviewer" json:"reviewer"`
	ReviewStatus  uint      `bson:"reviewstatus" json:"reviewstatus"` //1:未审核 2: 审核中 3: 已审核
	ReviewOpinion string    `bson:"reviewopinion" json:"reviewopinion"`
	ApplyTime     time.Time `bson:"applytime" json:"applytime"`
	ReviewTime    time.Time `bson:"reviewtime" json:"reviewtime"`
	UpdateTime    time.Time `bson:"updatetime" json:"updatetime"`
}

Plugin 漏洞插件信息

type PocDetail

type PocDetail struct {
	Author        string    `yaml:"author"`
	Reference     []string  `yaml:"reference,omitempty"`
	Severity      string    `yaml:"severity"` //critical:严重 high:高危 medium:中危 low:低危 warn: 提示
	Description   string    `yaml:"description"`
	VulType       string    `yaml:"vultype"`
	KPID          string    `yaml:"kpid"`
	CVE           string    `yaml:"cve,omitempty"`
	Reviewer      string    `yaml:"reviewer"`
	ReviewStatus  uint      `yaml:"reviewstatus"`
	ReviewOpinion string    `yaml:"reviewopinion"`
	ApplyTime     time.Time `yaml:"applytime"`
	ReviewTime    time.Time `yaml:"reviewtime"`
	UpdateTime    time.Time `yaml:"updatetime"`
}

type References

type References struct {
	URL  string `json:"url,omitempty"` //参考链接
	CVE  string `json:"cve,omitempty"`
	KPID string `json:"kpid"`
}

References 插件附加信息

type Rule

type Rule struct {
	Request    RuleRequest   `yaml:"request"`
	Expression string        `yaml:"expression"`
	Output     yaml.MapSlice `yaml:"output,omitempty"`
	// contains filtered or unexported fields
}

func (*Rule) UnmarshalYAML

func (r *Rule) UnmarshalYAML(unmarshal func(interface{}) error) error

type RuleMap

type RuleMap struct {
	Key   string
	Value Rule
}

type RuleMapSlice

type RuleMapSlice []RuleMap

func (RuleMapSlice) MarshalYAML

func (m RuleMapSlice) MarshalYAML() (interface{}, error)

func (*RuleMapSlice) UnmarshalYAML

func (m *RuleMapSlice) UnmarshalYAML(unmarshal func(interface{}) error) error

type RuleRequest

type RuleRequest struct {
	Method          string            `yaml:"method,omitempty"`
	Path            string            `yaml:"path,omitempty"`
	Body            string            `yaml:"body,omitempty"`
	FollowRedirects bool              `yaml:"follow_redirects,omitempty"`
	Headers         map[string]string `yaml:"headers,omitempty"`
	// 以下字段用于tcp类漏洞验证
	Type     string `yaml:"type,omitempty"`
	Host     string `yaml:"host,omitempty"`
	Data     string `yaml:"data,omitempty"`
	DataType string `yaml:"data-type,omitempty"`
}

type Task

type Task struct {
	Type   string   `json:"type"`
	Netloc string   `json:"netloc"`
	Target string   `json:"target"` //扫描插件ID
	Meta   TaskMeta `json:"meta"`
}

Task 任务结构

type TaskMeta

type TaskMeta struct {
	System           string   `json:"system"`
	PathList         []string `json:"pathlist"`
	FileList         []string `json:"filelist"`
	PassList         []string `json:"passlist"`
	AppUser          string   `json:"appuser"`
	WeakPassInterval int      `json:"weakpassinterval"`
}

TaskMeta 任务额外信息

type TmpRule

type TmpRule struct {
	Request    RuleRequest   `yaml:"request"`
	Expression string        `yaml:"expression"`
	Output     yaml.MapSlice `yaml:"output"`
}

type YAMLPlugin

type YAMLPlugin struct {
	Target     string        `yaml:"target"`
	Name       string        `yaml:"name"`
	Set        yaml.MapSlice `yaml:"set,omitempty"`
	Sets       ListMap       `yaml:"sets"`
	Rules      RuleMapSlice  `yaml:"rules"`
	Expression string        `yaml:"expression"`
	Detail     PocDetail     `yaml:"detail"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL