Documentation ¶
Index ¶
- Variables
- func DebugExec(code string, init ...bool)
- func Exec(code string, init ...bool)
- func ExecFile(path string) error
- func GetNaslLibKeys() map[string]interface{}
- func GetPortBannerByCache(engine *Engine, port int) (string, error)
- func NaslScan(hosts, ports string, opts ...NaslScriptConfigOptFunc) (map[string]any, error)
- func RemoveDatabase() error
- func ScanTarget(target string, opts ...NaslScriptConfigOptFunc) (map[string]any, error)
- func ServiceScan(hosts string, ports string, proxies ...string) ([]*fp.MatchResult, error)
- func UpdateDatabase(p string)
- type Engine
- func (e *Engine) AddNaslLibPatch(lib string, handle func(string2 string) string)
- func (engin *Engine) CallNativeFunction(name string, mapParam map[string]interface{}, sliceParam []interface{}) (interface{}, error)
- func (e *Engine) Compile(code string) error
- func (engine *Engine) Debug(bool2 ...bool)
- func (e *Engine) Eval(code string) error
- func (e *Engine) EvalInclude(name string) error
- func (e *Engine) GetCompiler() *visitors.Compiler
- func (engine *Engine) GetKBData() map[string]interface{}
- func (engine *Engine) GetScriptObject() *NaslScriptInfo
- func (e *Engine) GetVirtualMachine() *yakvm.VirtualMachine
- func (engine *Engine) InitBuildInLib()
- func (e *Engine) IsDebug() bool
- func (e *Engine) LoadScript(path string) (*NaslScriptInfo, error)
- func (engine *Engine) RegisterBuildInMethodHook(name string, ...)
- func (e *Engine) RunFile(path string) error
- func (e *Engine) RunScript(script *NaslScriptInfo) error
- func (e *Engine) SafeEval(code string) (err error)
- func (e *Engine) SafeRunFile(path string) (err error)
- func (engine *Engine) ServiceScan(target string, ports string) ([]*fp.MatchResult, error)
- func (engine *Engine) SetDependenciesPath(path string)
- func (e *Engine) SetDescription(b bool)
- func (engine *Engine) SetIncludePath(path string)
- func (engine *Engine) SetKBs(kbs *NaslKBs)
- func (engine *Engine) SetProxies(proxies ...string)
- func (engine *Engine) UnRegisterBuildInMethodHook(name string)
- type IpPacket
- type NaslBuildInMethod
- type NaslBuildInMethodParam
- type NaslKBs
- type NaslScriptConfig
- type NaslScriptConfigOptFunc
- func WithConditions(script ...any) NaslScriptConfigOptFunc
- func WithFamily(family string) NaslScriptConfigOptFunc
- func WithPlugins(plugins ...string) NaslScriptConfigOptFunc
- func WithPreference(p interface{}) NaslScriptConfigOptFunc
- func WithProxy(proxies ...string) NaslScriptConfigOptFunc
- func WithRiskHandle(f func(any)) NaslScriptConfigOptFunc
- type NaslScriptInfo
- func NewNaslScriptObject() *NaslScriptInfo
- func NewNaslScriptObjectFromDb(originName string) (*NaslScriptInfo, error)
- func NewNaslScriptObjectFromFile(path string) (*NaslScriptInfo, error)
- func NewNaslScriptObjectFromNaslScript(s *yakit.NaslScript) *NaslScriptInfo
- func QueryAllScripts(script ...any) []*NaslScriptInfo
- type NaslVhost
- type ScriptEngine
- func (engine *ScriptEngine) AddEngineHooks(hooks func(engine *Engine))
- func (engine *ScriptEngine) AddExcludeScripts(names ...string)
- func (engine *ScriptEngine) Debug(debug ...bool)
- func (engine *ScriptEngine) GetKBData() map[string]interface{}
- func (e *ScriptEngine) GetRootScripts() map[string]*NaslScriptInfo
- func (e *ScriptEngine) LoadFamilys(family string)
- func (engine *ScriptEngine) LoadScript(script any) bool
- func (e *ScriptEngine) LoadWithConditions(conditions map[string]any)
- func (e *ScriptEngine) Scan(host string, ports string) error
- func (e *ScriptEngine) ScanTarget(target string) error
- 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 (engine *ScriptEngine) SetScriptFilter(filter func(script *NaslScriptInfo) bool)
Constants ¶
This section is empty.
Variables ¶
View Source
var Exports = map[string]any{ "UpdateDatabase": UpdateDatabase, "RemoveDatabase": RemoveDatabase, "QueryAllScripts": QueryAllScripts, "ScanTarget": ScanTarget, "Scan": NaslScan, "plugin": WithPlugins, "family": WithFamily, "riskHandle": WithRiskHandle, "proxy": WithProxy, "conditions": WithConditions, "preference": WithPreference, }
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",
}
View Source
var NaslLib = make(map[string]func(engine *Engine, params *NaslBuildInMethodParam) interface{})
Functions ¶
func GetNaslLibKeys ¶
func GetNaslLibKeys() map[string]interface{}
func GetPortBannerByCache ¶ added in v1.2.2
func NaslScan ¶ added in v1.2.6
func NaslScan(hosts, ports string, opts ...NaslScriptConfigOptFunc) (map[string]any, error)
func RemoveDatabase ¶ added in v1.2.6
func RemoveDatabase() error
func ScanTarget ¶ added in v1.2.6
func ScanTarget(target string, opts ...NaslScriptConfigOptFunc) (map[string]any, error)
func ServiceScan ¶ added in v1.2.2
临时的,用于测试
func UpdateDatabase ¶ added in v1.2.6
func UpdateDatabase(p string)
Types ¶
type Engine ¶
type Engine struct { Kbs *NaslKBs // contains filtered or unexported fields }
func NewWithKbs ¶ added in v1.2.2
func (*Engine) AddNaslLibPatch ¶ added in v1.2.2
func (*Engine) CallNativeFunction ¶
func (*Engine) EvalInclude ¶ added in v1.2.2
func (*Engine) GetCompiler ¶
func (*Engine) GetScriptObject ¶ added in v1.2.2
func (engine *Engine) GetScriptObject() *NaslScriptInfo
func (*Engine) GetVirtualMachine ¶
func (e *Engine) GetVirtualMachine() *yakvm.VirtualMachine
func (*Engine) InitBuildInLib ¶ added in v1.2.2
func (engine *Engine) InitBuildInLib()
func (*Engine) LoadScript ¶
func (e *Engine) LoadScript(path string) (*NaslScriptInfo, error)
func (*Engine) RegisterBuildInMethodHook ¶ added in v1.2.2
func (engine *Engine) RegisterBuildInMethodHook(name string, hook func(origin NaslBuildInMethod, engine *Engine, params *NaslBuildInMethodParam) (interface{}, error))
func (engine *Engine) 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 (*Engine) RunScript ¶ added in v1.2.2
func (e *Engine) RunScript(script *NaslScriptInfo) error
func (*Engine) SafeRunFile ¶
func (*Engine) ServiceScan ¶ added in v1.2.2
func (*Engine) SetDependenciesPath ¶ added in v1.2.2
func (*Engine) SetDescription ¶
func (*Engine) SetIncludePath ¶
func (*Engine) SetProxies ¶ added in v1.2.2
func (e *Engine) MarkScriIsLoadptIsLoaded(scriptName string) { e.loadedScriptsLock.Lock() defer e.loadedScriptsLock.Unlock() e.loadedScripts[scriptName] = struct{}{} }
func (e *Engine) IsScriptLoaded(scriptName string) bool { e.loadedScriptsLock.Lock() defer e.loadedScriptsLock.Unlock() _, ok := e.loadedScripts[scriptName] return ok }
func (*Engine) UnRegisterBuildInMethodHook ¶ added in v1.2.2
type NaslBuildInMethod ¶
type NaslBuildInMethod func(engine *Engine, params *NaslBuildInMethodParam) (interface{}, error)
type NaslBuildInMethodParam ¶
type NaslBuildInMethodParam struct {
// contains filtered or unexported fields
}
func NewNaslBuildInMethodParam ¶
func NewNaslBuildInMethodParam() *NaslBuildInMethodParam
type NaslKBs ¶ added in v1.2.2
type NaslKBs struct {
// contains filtered or unexported fields
}
func NewNaslKBs ¶ added in v1.2.2
func NewNaslKBs() *NaslKBs
func (*NaslKBs) GetKBByPattern ¶ added in v1.2.2
type NaslScriptConfig ¶ added in v1.2.2
type NaslScriptConfig struct {
// contains filtered or unexported fields
}
func NewNaslScriptConfig ¶ added in v1.2.2
func NewNaslScriptConfig() *NaslScriptConfig
type NaslScriptConfigOptFunc ¶ added in v1.2.2
type NaslScriptConfigOptFunc func(c *NaslScriptConfig)
func WithConditions ¶ added in v1.2.6
func WithConditions(script ...any) NaslScriptConfigOptFunc
func WithFamily ¶ added in v1.2.6
func WithFamily(family string) NaslScriptConfigOptFunc
func WithPlugins ¶ added in v1.2.6
func WithPlugins(plugins ...string) NaslScriptConfigOptFunc
func WithPreference ¶ added in v1.2.6
func WithPreference(p interface{}) NaslScriptConfigOptFunc
func WithProxy ¶ added in v1.2.6
func WithProxy(proxies ...string) NaslScriptConfigOptFunc
func WithRiskHandle ¶ added in v1.2.6
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 NewNaslScriptObjectFromDb ¶ added in v1.2.2
func NewNaslScriptObjectFromDb(originName string) (*NaslScriptInfo, error)
func NewNaslScriptObjectFromFile ¶ added in v1.2.2
func NewNaslScriptObjectFromFile(path string) (*NaslScriptInfo, error)
func NewNaslScriptObjectFromNaslScript ¶ added in v1.2.2
func NewNaslScriptObjectFromNaslScript(s *yakit.NaslScript) *NaslScriptInfo
func QueryAllScripts ¶ added in v1.2.6
func QueryAllScripts(script ...any) []*NaslScriptInfo
func (*NaslScriptInfo) Save ¶
func (n *NaslScriptInfo) Save() error
type ScriptEngine ¶ added in v1.2.2
type ScriptEngine struct { Kbs *NaslKBs // contains filtered or unexported fields }
func NewScriptEngine ¶ added in v1.2.2
func NewScriptEngine() *ScriptEngine
func NewScriptEngineWithConfig ¶ added in v1.2.6
func NewScriptEngineWithConfig(cfg *NaslScriptConfig) *ScriptEngine
func (*ScriptEngine) AddEngineHooks ¶ added in v1.2.2
func (engine *ScriptEngine) AddEngineHooks(hooks func(engine *Engine))
func (*ScriptEngine) AddExcludeScripts ¶ added in v1.2.2
func (engine *ScriptEngine) AddExcludeScripts(names ...string)
func (*ScriptEngine) Debug ¶ added in v1.2.2
func (engine *ScriptEngine) Debug(debug ...bool)
func (*ScriptEngine) GetKBData ¶ added in v1.2.2
func (engine *ScriptEngine) GetKBData() map[string]interface{}
func (*ScriptEngine) GetRootScripts ¶ added in v1.2.2
func (e *ScriptEngine) GetRootScripts() map[string]*NaslScriptInfo
func (*ScriptEngine) LoadFamilys ¶ added in v1.2.2
func (e *ScriptEngine) LoadFamilys(family string)
func (*ScriptEngine) LoadScript ¶ added in v1.2.2
func (engine *ScriptEngine) LoadScript(script any) bool
func (*ScriptEngine) LoadWithConditions ¶ added in v1.2.6
func (e *ScriptEngine) LoadWithConditions(conditions map[string]any)
func (*ScriptEngine) Scan ¶ added in v1.2.2
func (e *ScriptEngine) Scan(host string, ports string) error
func (*ScriptEngine) ScanTarget ¶ added in v1.2.2
func (e *ScriptEngine) ScanTarget(target string) error
func (*ScriptEngine) SetDependencies ¶ added in v1.2.2
func (e *ScriptEngine) SetDependencies(p string)
func (*ScriptEngine) SetGoroutineNum ¶ added in v1.2.2
func (engine *ScriptEngine) SetGoroutineNum(num int)
func (*ScriptEngine) SetIncludePath ¶ added in v1.2.2
func (e *ScriptEngine) SetIncludePath(p string)
func (*ScriptEngine) SetNaslLibsPath ¶ added in v1.2.2
func (engine *ScriptEngine) SetNaslLibsPath(path string)
func (*ScriptEngine) SetScriptFilter ¶ added in v1.2.2
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] }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.