script_core

package
v1.3.7-alpha1022 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: AGPL-3.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GlobalPrefs = map[string]string{
	"plugins_folder":           "MAGENI_NVT_DIR",
	"include_folders":          "MAGENI_NVT_DIR",
	"max_hosts":                "30",
	"max_checks":               "10",
	"be_nice":                  "yes",
	"log_whole_attack":         "no",
	"log_plugins_name_at_load": "no",
	"optimize_test":            "yes",
	"network_scan":             "no",
	"non_simult_ports":         "139, 445, 3389, Services/irc",
	"plugins_timeout":          "5",
	"scanner_plugins_timeout":  "5",
	"safe_checks":              "yes",
	"auto_enable_dependencies": "yes",
	"drop_privileges":          "no",

	"report_host_details":     "yes",
	"db_address":              "",
	"cgi_path":                "/cgi-bin:/scripts",
	"checks_read_timeout":     "5",
	"unscanned_closed":        "yes",
	"unscanned_closed_udp":    "yes",
	"timeout_retry":           "3",
	"expand_vhosts":           "yes",
	"test_empty_vhost":        "no",
	"open_sock_max_attempts":  "5",
	"time_between_request":    "0",
	"nasl_no_signature_check": "yes",
}

Functions

func GetExtLib

func GetExtLib(ctx *ExecContext) map[string]func(params *executor.NaslBuildInMethodParam) interface{}

func GetNaslLibKeys

func GetNaslLibKeys() map[string]interface{}

func GetPortBannerByCache

func GetPortBannerByCache(ctx *ExecContext, port int) (string, error)

func NaslScan

func NaslScan(hosts, ports string, opts ...NaslScriptConfigOptFunc) chan *NaslKBs

func PatchEngine

func PatchEngine(engine *ScriptEngine)

func Ping

func Ping(ctx *ExecContext)

func ServiceScan

func ServiceScan(ctx *ExecContext)

临时的,用于测试

Types

type ExecContext

type ExecContext struct {
	Host       string
	Ports      string
	Kbs        *NaslKBs
	Proxies    []string
	MethodHook map[string]func(origin NaslBuildInMethod, engine *ExecContext, params *executor.NaslBuildInMethodParam) (interface{}, error)
	ScriptObj  *NaslScriptInfo
	Debug      bool
	// contains filtered or unexported fields
}

func NewExecContext

func NewExecContext() *ExecContext

type IpPacket

type IpPacket struct {
	Data   string
	Ip_hl  uint8
	Ip_v   uint8
	Ip_tos uint8
	Ip_len uint16
	Ip_id  uint16
	Ip_off uint16
	Ip_ttl uint8
	Ip_p   uint8
	Ip_sum uint16
	Ip_src string
	Ip_dst string
}

type NaslBuildInMethod

type NaslBuildInMethod func(ctx *ExecContext, params *executor.NaslBuildInMethodParam) (interface{}, error)

type NaslKBs

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

func NewNaslKBs

func NewNaslKBs() *NaslKBs

func (*NaslKBs) AddKB

func (n *NaslKBs) AddKB(name string, value interface{}) error

func (*NaslKBs) GetData

func (n *NaslKBs) GetData() map[string]interface{}

func (*NaslKBs) GetKB

func (n *NaslKBs) GetKB(name string) interface{}

func (*NaslKBs) GetKBByPattern

func (n *NaslKBs) GetKBByPattern(name string) (res map[string]interface{})

func (*NaslKBs) SetKB

func (n *NaslKBs) SetKB(name string, value interface{}) error

type NaslScriptConfig

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

func NewNaslScriptConfig

func NewNaslScriptConfig() *NaslScriptConfig

type NaslScriptConfigOptFunc

type NaslScriptConfigOptFunc func(c *NaslScriptConfig)

func WithConditions

func WithConditions(script ...any) NaslScriptConfigOptFunc

func WithFamily

func WithFamily(family string) NaslScriptConfigOptFunc

func WithIgnoreRequirementsError

func WithIgnoreRequirementsError(b bool) NaslScriptConfigOptFunc

func WithPlugins

func WithPlugins(plugins ...string) NaslScriptConfigOptFunc

func WithPreference

func WithPreference(p interface{}) NaslScriptConfigOptFunc

func WithProxy

func WithProxy(proxies ...string) NaslScriptConfigOptFunc

func WithRiskHandle

func WithRiskHandle(f func(any)) NaslScriptConfigOptFunc

type NaslScriptInfo

type NaslScriptInfo struct {
	OriginFileName string
	Hash           string
	OID            string
	CVE            []string
	ScriptName     string
	Script         string
	Tags           map[string]interface{}
	Version        string
	Category       string
	Family         string
	Copyright      string
	Dependencies   []string // 依赖脚本

	Xrefs           map[string]string
	Preferences     map[string]interface{}
	RequirePorts    []string // 前置条件断言
	RequireKeys     []string // 前置条件断言
	ExcludeKeys     []string // 前置条件断言
	RequireUdpPorts []string // 前置条件断言
	BugtraqId       []int
	MandatoryKeys   []string // 前置条件断言
	Timeout         int      // milliseconds
	RecvTimeout     int      // milliseconds
	Vhosts          []*NaslVhost
	Ip              string
	// contains filtered or unexported fields
}

func NewNaslScriptObject

func NewNaslScriptObject() *NaslScriptInfo

func NewNaslScriptObjectFromNaslScript

func NewNaslScriptObjectFromNaslScript(s *schema.NaslScript) *NaslScriptInfo

func (*NaslScriptInfo) Save

func (n *NaslScriptInfo) Save() error

type NaslVhost

type NaslVhost struct {
	Hostname string
	Source   string
}

type Preference

type Preference struct {
	Name    string
	Type    string
	Default string
}

func LoadPreferenceFromMap

func LoadPreferenceFromMap(prefs map[string]any) (res []*Preference)

type ScriptEngine

type ScriptEngine struct {
	*log.Logger

	Kbs *NaslKBs

	MethodHook map[string]func(origin NaslBuildInMethod, engine *ExecContext, params *executor.NaslBuildInMethodParam) (interface{}, error)
	// contains filtered or unexported fields
}

func NewScriptEngine

func NewScriptEngine() *ScriptEngine

func NewScriptEngineWithConfig

func NewScriptEngineWithConfig(cfg *NaslScriptConfig) *ScriptEngine

func (*ScriptEngine) AddEngineHooks

func (engine *ScriptEngine) AddEngineHooks(hooks func(engine *executor.Executor))

func (*ScriptEngine) AddExcludeScripts

func (engine *ScriptEngine) AddExcludeScripts(names ...string)

func (*ScriptEngine) AddMethodHook

func (engine *ScriptEngine) AddMethodHook(name string, f func(origin NaslBuildInMethod, engine *ExecContext, params *executor.NaslBuildInMethodParam) (interface{}, error))

func (*ScriptEngine) AddScriptLoadedHook

func (engine *ScriptEngine) AddScriptLoadedHook(hook func(info *NaslScriptInfo))

func (*ScriptEngine) AddScriptPatch

func (e *ScriptEngine) AddScriptPatch(lib string, handle func(string2 string) string)

func (*ScriptEngine) Debug

func (engine *ScriptEngine) Debug(debug ...bool)

func (*ScriptEngine) DescriptionExec

func (engine *ScriptEngine) DescriptionExec(code, name string) (*NaslScriptInfo, error)

func (*ScriptEngine) GetAllPreference

func (e *ScriptEngine) GetAllPreference() map[string][]*Preference

func (*ScriptEngine) GetRootScripts

func (e *ScriptEngine) GetRootScripts() map[string]*NaslScriptInfo

func (*ScriptEngine) LoadCategory

func (e *ScriptEngine) LoadCategory(category string)

func (*ScriptEngine) LoadFamilys

func (e *ScriptEngine) LoadFamilys(family string)

func (*ScriptEngine) LoadScript

func (engine *ScriptEngine) LoadScript(script any) error

func (*ScriptEngine) LoadWithConditions

func (e *ScriptEngine) LoadWithConditions(conditions map[string]any)

func (*ScriptEngine) NewExecEngine

func (e *ScriptEngine) NewExecEngine(ctx *ExecContext) *executor.Executor

func (*ScriptEngine) Scan

func (e *ScriptEngine) Scan(hosts string, ports string) chan *ExecContext

func (*ScriptEngine) ScanSingle

func (e *ScriptEngine) ScanSingle(host string, ports string) (*ExecContext, error)

func (*ScriptEngine) SetCache

func (engine *ScriptEngine) SetCache(b bool)

func (*ScriptEngine) SetDependencies

func (e *ScriptEngine) SetDependencies(p string)

func (*ScriptEngine) SetGoroutineNum

func (engine *ScriptEngine) SetGoroutineNum(num int)

func (*ScriptEngine) SetIncludePath

func (e *ScriptEngine) SetIncludePath(p string)

func (*ScriptEngine) SetNaslLibsPath

func (engine *ScriptEngine) SetNaslLibsPath(path string)

func (*ScriptEngine) SetPreference

func (e *ScriptEngine) SetPreference(oid string, k string, v any)

func (*ScriptEngine) SetPreferenceByScriptName

func (e *ScriptEngine) SetPreferenceByScriptName(script string, k string, v any)

func (*ScriptEngine) SetScriptFilter

func (engine *ScriptEngine) SetScriptFilter(filter func(script *NaslScriptInfo) bool)
func (engine *ScriptEngine) GetScriptMuxByName(name string) *sync.Mutex {
	engine.scriptExecMutexsLock.Lock()
	defer engine.scriptExecMutexsLock.Unlock()
	if v, ok := engine.scriptExecMutexs[name]; ok {
		return v
	}
	engine.scriptExecMutexs[name] = &sync.Mutex{}
	return engine.scriptExecMutexs[name]
}

func (*ScriptEngine) ShowScriptTree

func (e *ScriptEngine) ShowScriptTree()

Jump to

Keyboard shortcuts

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