Documentation ¶
Index ¶
- Variables
- func GetExtLib(ctx *ExecContext) map[string]func(params *executor.NaslBuildInMethodParam) interface{}
- func GetNaslLibKeys() map[string]interface{}
- func GetPortBannerByCache(ctx *ExecContext, port int) (string, error)
- func NaslScan(hosts, ports string, opts ...NaslScriptConfigOptFunc) chan *NaslKBs
- func PatchEngine(engine *ScriptEngine)
- func Ping(ctx *ExecContext)
- func ServiceScan(ctx *ExecContext)
- type ExecContext
- type IpPacket
- type NaslBuildInMethod
- type NaslKBs
- type NaslScriptConfig
- type NaslScriptConfigOptFunc
- func WithConditions(script ...any) NaslScriptConfigOptFunc
- func WithFamily(family string) NaslScriptConfigOptFunc
- func WithIgnoreRequirementsError(b bool) NaslScriptConfigOptFunc
- func WithPlugins(plugins ...string) NaslScriptConfigOptFunc
- func WithPreference(p interface{}) NaslScriptConfigOptFunc
- func WithProxy(proxies ...string) NaslScriptConfigOptFunc
- func WithRiskHandle(f func(any)) NaslScriptConfigOptFunc
- type NaslScriptInfo
- type NaslVhost
- type Preference
- type ScriptEngine
- func (engine *ScriptEngine) AddEngineHooks(hooks func(engine *executor.Executor))
- func (engine *ScriptEngine) AddExcludeScripts(names ...string)
- func (engine *ScriptEngine) AddMethodHook(name string, ...)
- func (engine *ScriptEngine) AddScriptLoadedHook(hook func(info *NaslScriptInfo))
- func (e *ScriptEngine) AddScriptPatch(lib string, handle func(string2 string) string)
- func (engine *ScriptEngine) Debug(debug ...bool)
- func (engine *ScriptEngine) DescriptionExec(code, name string) (*NaslScriptInfo, error)
- func (e *ScriptEngine) GetAllPreference() map[string][]*Preference
- func (e *ScriptEngine) GetRootScripts() map[string]*NaslScriptInfo
- func (e *ScriptEngine) LoadCategory(category string)
- func (e *ScriptEngine) LoadFamilys(family string)
- func (engine *ScriptEngine) LoadScript(script any) error
- func (e *ScriptEngine) LoadWithConditions(conditions map[string]any)
- func (e *ScriptEngine) NewExecEngine(ctx *ExecContext) *executor.Executor
- func (e *ScriptEngine) Scan(hosts string, ports string) chan *ExecContext
- func (e *ScriptEngine) ScanSingle(host string, ports string) (*ExecContext, error)
- func (engine *ScriptEngine) SetCache(b bool)
- func (e *ScriptEngine) SetDependencies(p string)
- func (engine *ScriptEngine) SetGoroutineNum(num int)
- func (e *ScriptEngine) SetIncludePath(p string)
- func (engine *ScriptEngine) SetNaslLibsPath(path string)
- func (e *ScriptEngine) SetPreference(oid string, k string, v any)
- func (e *ScriptEngine) SetPreferenceByScriptName(script string, k string, v any)
- func (engine *ScriptEngine) SetScriptFilter(filter func(script *NaslScriptInfo) bool)
- func (e *ScriptEngine) ShowScriptTree()
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)
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 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) GetKBByPattern ¶
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 Preference ¶
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()
Click to show internal directories.
Click to hide internal directories.