Documentation
¶
Index ¶
- Constants
- Variables
- func CallImageServiceXClient(serviceMethod string, args interface{}, reply interface{}) error
- func CallXClient(serviceMethod string, args interface{}, reply interface{}) error
- func CheckRequiredResource(resourceList []RequiredResource) error
- func CheckWorkerPerformance(workerPerformance int)
- func CloseRedisClient(client *redis.Client) error
- func DaemonStartWorker() bool
- func DeleteWorkerStatusFromRedis(client *redis.Client, workerID string) error
- func DoKeepAlive(ws *WorkerStatus) bool
- func GetRedisClient() (*redis.Client, error)
- func GetRoutingKeyByTopic(topicName string) string
- func GetServerTaskMQServer(topicName string) *machinery.Server
- func GetTopicByMQRoutingKey(routingKey string) string
- func GetTopicByTaskName(taskName string, workspaceGUID string) string
- func GetWorkerMQServer(topicName string, prefetchCount int) *machinery.Server
- func GetWorkerNameByDaemon() string
- func GetWorkerNameBySelf() string
- func IsCIDR(ip string) bool
- func KillWorker() bool
- func LoadCronTask() (err error)
- func LoadWorkerStatusFromRedis(client *redis.Client) (map[string]*WorkerStatus, error)
- func Notify(docId []string, data NotifyData) (err error)
- func PrepareWorkerConfig(opts *WorkerOption) bool
- func PrepareWorkerRunEnv() bool
- func PrepareWorkerServiceOptions(opts *WorkerOption) bool
- func ReloadCronTask()
- func ReloadWorkerRunEnv() bool
- func RunOnceTaskCron(taskId string) bool
- func SetCronTaskUpdateFlag(flag string) (err error)
- func SetWorkerStatusToRedis(client *redis.Client, workerID string, status *WorkerStatus) error
- func SetupCloseHandler()
- func StartCronTaskDamon()
- func StartMainTaskDamon()
- func StartRedisReverseProxy()
- func StartSaveRuntimeLog(source string)
- func StartServiceServer()
- func StartWorkerDaemon()
- func SyncTaskAsset(workspaceId string, taskId string) (result string)
- func SyncTaskHistoryVul(workspaceId string, taskId string, mongoClient *mongo.Client) (newVul, updateVul int)
- func Test(t *testing.T)
- func WatchWorkerProcess()
- type AssetSaveResultResp
- type Blacklist
- func (b *Blacklist) AddDomain(domain string)
- func (b *Blacklist) AddIP(ip string) error
- func (b *Blacklist) IsDomainBlocked(domain string) bool
- func (b *Blacklist) IsHostBlocked(host string) bool
- func (b *Blacklist) IsIPBlocked(ip string) bool
- func (b *Blacklist) LoadBlacklist(workspaceId string) bool
- type CheckTaskArgs
- type CronTaskJob
- type DingTalkNotify
- type DingTalkResponseInfo
- type FeishuNotify
- type FeishuResponseInfo
- type Honeypot
- type KeepAliveDaemonInfo
- type NewTaskArgs
- type NotifyData
- type NotifyExecutor
- type RedisLock
- type RedisProxyServer
- type RedisReverseServer
- type RequestResourceArgs
- type RequiredResource
- type ResourceResultArgs
- type RuntimeLogArgs
- type ScreenShotResultArgs
- type ServerChan
- type ServerChanResponseInfo
- type ServerOption
- type Service
- func (s *Service) CheckTask(ctx context.Context, args *CheckTaskArgs, replay *TaskStatusArgs) error
- func (s *Service) KeepAlive(ctx context.Context, args *WorkerStatus, replay *string) error
- func (s *Service) KeepDaemonAlive(ctx context.Context, args *string, replay *KeepAliveDaemonInfo) error
- func (s *Service) LoadWorkerConfig(ctx context.Context, args *string, replay *conf.Worker) error
- func (s *Service) LookupQueryData(ctx context.Context, args *db.QueryDocument, replay *db.QueryDocument) error
- func (s *Service) NewTask(ctx context.Context, args *execute.ExecutorTaskInfo, replay *bool) error
- func (s *Service) RequestResource(ctx context.Context, args *RequestResourceArgs, replay *ResourceResultArgs) error
- func (s *Service) SaveQueryData(ctx context.Context, args *[]db.QueryDocument, replay *string) error
- func (s *Service) SaveRuntimeLog(ctx context.Context, args *RuntimeLogArgs, replay *string) error
- func (s *Service) SaveScreenShotResult(ctx context.Context, args *[]ScreenShotResultArgs, replay *string) error
- func (s *Service) SaveTaskResult(ctx context.Context, args *TaskAssetDocumentResultArgs, replay *string) error
- func (s *Service) SaveVulResult(ctx context.Context, args *VulResultArgs, replay *string) error
- func (s *Service) UpdateTask(ctx context.Context, args *TaskStatusArgs, replay *bool) error
- func (s *Service) UploadScreenShotResult(ctx context.Context, args *[]ScreenShotResultArgs, replay *string) error
- type ServiceOptions
- type TaskAssetDocumentResultArgs
- type TaskResult
- type TaskSlice
- type TaskStatusArgs
- type TrieNode
- type VulResultArgs
- type WebOption
- type WorkerOption
- type WorkerRunTaskMode
- type WorkerStatus
- type WorkerTaskOption
Constants ¶
const ( CREATED string = "CREATED" //任务创建,但还没有开始执行 STARTED string = "STARTED" //任务在执行中 SUCCESS string = "SUCCESS" //任务执行完成,结果为SUCCESS FAILURE string = "FAILURE" //任务执行完成,结果为FAILURE TopicActive = "active" TopicFinger = "finger" TopicPassive = "passive" TopicPocscan = "pocscan" TopicCustom = "custom" TopicStandalone = "standalone" TopicMQPrefix = "nemo_mq" )
const ( EnvServiceHost = "SERVICE_HOST" EnvServicePort = "SERVICE_PORT" EnvServiceAuth = "SERVICE_AUTH" )
const ( SliceNone int = 0 SliceByLine int = 1 SliceByIP int = 2 SliceByPort int = 3 DefaultIpSliceNumber int = 64 DefaultPortSliceNumber int = 1000 TopPorts1000 = "" /* 3813-byte string literal not displayed */ TopPorts100 = "" /* 393-byte string literal not displayed */ TopPorts10 = "21-23,80,139,443,445,3306,3389,8080" )
Variables ¶
var ( RsaPrivateKeyText []byte RsaPublicKeyText []byte )
var ( TLSCertFile string TLSKeyFile string )
var CustomTaskWorkspaceMap = make(map[string]struct{})
CustomTaskWorkspaceMap 自定义任务关联的工作空间GUID
var WorkerName string
Functions ¶
func CallImageServiceXClient ¶
CallImageServiceXClient 调用图像服务的RPC远程调用
func CallXClient ¶
CallXClient RPC远程调用
func CheckRequiredResource ¶
func CheckRequiredResource(resourceList []RequiredResource) error
func CheckWorkerPerformance ¶
func CheckWorkerPerformance(workerPerformance int)
func CloseRedisClient ¶
func CloseRedisClient(client *redis.Client) error
func DeleteWorkerStatusFromRedis ¶
DeleteWorkerStatusFromRedis 从 Redis 中删除指定 workerID 的记录
func GetRedisClient ¶
func GetRedisClient() (*redis.Client, error)
func GetRoutingKeyByTopic ¶
func GetServerTaskMQServer ¶
func GetServerTaskMQServer(topicName string) *machinery.Server
GetServerTaskMQServer 根据server配置文件,获取到消息中心的连接
func GetTopicByMQRoutingKey ¶
func GetTopicByTaskName ¶
func GetWorkerMQServer ¶
GetWorkerMQServer 根据worker配置文件,获取到消息中心的连接
func GetWorkerNameByDaemon ¶
func GetWorkerNameByDaemon() string
func GetWorkerNameBySelf ¶
func GetWorkerNameBySelf() string
func LoadCronTask ¶
func LoadCronTask() (err error)
func LoadWorkerStatusFromRedis ¶
func LoadWorkerStatusFromRedis(client *redis.Client) (map[string]*WorkerStatus, error)
LoadWorkerStatusFromRedis 从 Redis 中读取 WorkerAliveStatus
func Notify ¶
func Notify(docId []string, data NotifyData) (err error)
func PrepareWorkerConfig ¶
func PrepareWorkerConfig(opts *WorkerOption) bool
func PrepareWorkerRunEnv ¶
func PrepareWorkerRunEnv() bool
func PrepareWorkerServiceOptions ¶
func PrepareWorkerServiceOptions(opts *WorkerOption) bool
func ReloadCronTask ¶
func ReloadCronTask()
func ReloadWorkerRunEnv ¶
func ReloadWorkerRunEnv() bool
func SetCronTaskUpdateFlag ¶
func SetWorkerStatusToRedis ¶
func SetWorkerStatusToRedis(client *redis.Client, workerID string, status *WorkerStatus) error
SetWorkerStatusToRedis 将 WorkerAliveStatus 存储到 Redis 中
func SetupCloseHandler ¶
func SetupCloseHandler()
func StartRedisReverseProxy ¶
func StartRedisReverseProxy()
func StartSaveRuntimeLog ¶
func StartSaveRuntimeLog(source string)
func SyncTaskAsset ¶
func SyncTaskHistoryVul ¶
Types ¶
type AssetSaveResultResp ¶
type AssetSaveResultResp struct { AssetTotal int `json:"assetTotal,omitempty"` AssetNew int `json:"assetNew,omitempty"` AssetUpdate int `json:"assetUpdate,omitempty"` HostTotal int `json:"hostTotal,omitempty"` HostNew int `json:"hostNew,omitempty"` HostUpdate int `json:"hostUpdate,omitempty"` ScreenShot int `json:"screenshot,omitempty"` VulTotal int `json:"vulTotal,omitempty"` VulNew int `json:"vulNew,omitempty"` VulUpdate int `json:"vulUpdate,omitempty"` }
func (*AssetSaveResultResp) String ¶
func (r *AssetSaveResultResp) String() string
type Blacklist ¶
type Blacklist struct {
// contains filtered or unexported fields
}
func NewBlacklist ¶
func NewBlacklist() *Blacklist
func (*Blacklist) IsDomainBlocked ¶
func (*Blacklist) IsHostBlocked ¶
func (*Blacklist) IsIPBlocked ¶
func (*Blacklist) LoadBlacklist ¶
type CheckTaskArgs ¶
type CronTaskJob ¶
type CronTaskJob struct {
TaskId string
}
type DingTalkNotify ¶
type DingTalkNotify struct {
Token string
}
func (*DingTalkNotify) Notify ¶
func (d *DingTalkNotify) Notify(message string) (err error)
type DingTalkResponseInfo ¶
type FeishuNotify ¶
type FeishuNotify struct {
Token string
}
func (*FeishuNotify) Notify ¶
func (f *FeishuNotify) Notify(message string) (err error)
type FeishuResponseInfo ¶
type Honeypot ¶
type Honeypot struct {
// contains filtered or unexported fields
}
func NewHoneypot ¶
func (*Honeypot) IsHoneypot ¶
type KeepAliveDaemonInfo ¶
type KeepAliveDaemonInfo struct { ManualReloadFlag bool ManualFileSyncFlag bool ManualUpdateOptionFlag bool WorkerRunOption *WorkerOption }
func DoDaemonKeepAlive ¶
func DoDaemonKeepAlive() (replay KeepAliveDaemonInfo, err error)
DoDaemonKeepAlive worker请求keepAlive
type NewTaskArgs ¶
type NewTaskArgs struct { TaskName string ConfigJSON string MainTaskID string LastRunTaskId string }
NewTaskArgs 新建任务请求与返回参数
type NotifyData ¶
type NotifyExecutor ¶
func NewNotifyExecutor ¶
func NewNotifyExecutor(category string, token string) NotifyExecutor
type RedisLock ¶
type RedisLock struct {
// contains filtered or unexported fields
}
func NewRedisLock ¶
type RedisProxyServer ¶
func NewRedisProxyServer ¶
func NewRedisProxyServer(reverseServerAddr string, localListenAddr string, authPass string) *RedisProxyServer
func (*RedisProxyServer) Start ¶
func (rp *RedisProxyServer) Start()
type RedisReverseServer ¶
func NewRedisReverseServer ¶
func NewRedisReverseServer(redisAddr string, listenAddr string, authPass string) *RedisReverseServer
func (*RedisReverseServer) Start ¶
func (rr *RedisReverseServer) Start()
type RequestResourceArgs ¶
type RequiredResource ¶
type ResourceResultArgs ¶
type RuntimeLogArgs ¶
type ScreenShotResultArgs ¶
type ServerChan ¶
type ServerChan struct {
Token string
}
func (*ServerChan) Notify ¶
func (s *ServerChan) Notify(message string) (err error)
type ServerChanResponseInfo ¶
type ServerOption ¶
type Service ¶
type Service struct{}
Service RPC服务
func (*Service) CheckTask ¶
func (s *Service) CheckTask(ctx context.Context, args *CheckTaskArgs, replay *TaskStatusArgs) error
CheckTask 检查任务在数据库中的状态:任务是否存在、是否被取消,任务状态、结果
func (*Service) KeepDaemonAlive ¶
func (s *Service) KeepDaemonAlive(ctx context.Context, args *string, replay *KeepAliveDaemonInfo) error
KeepDaemonAlive worker的daemon通过RPC,保持与server的心跳与同步
func (*Service) LoadWorkerConfig ¶
func (*Service) LookupQueryData ¶
func (s *Service) LookupQueryData(ctx context.Context, args *db.QueryDocument, replay *db.QueryDocument) error
func (*Service) RequestResource ¶
func (s *Service) RequestResource(ctx context.Context, args *RequestResourceArgs, replay *ResourceResultArgs) error
func (*Service) SaveQueryData ¶
func (*Service) SaveRuntimeLog ¶
SaveRuntimeLog 保存RuntimeLog
func (*Service) SaveScreenShotResult ¶
func (s *Service) SaveScreenShotResult(ctx context.Context, args *[]ScreenShotResultArgs, replay *string) error
SaveScreenShotResult 保存截图结果到本地文件
保存截图结果到本地文件 由于v3版本里service与web是可以分开部署的,所以截图结果保存到本地文件的方式需要修改;如果service与web部署在同一台机器,则可以直接保存到web目录下。 如果service与web部署在不同的机器,则需要通过rpc调用web的接口,将截图结果保存到web目录下。 保存逻辑判断为: 如果在server.yml中定义了imageService,检查host,port和auth均不为空的话,则调用imageService的rpc接口,将截图结果保存到web目录下; 否则,则保存到本地文件。
func (*Service) SaveTaskResult ¶
func (*Service) SaveVulResult ¶
func (*Service) UpdateTask ¶
UpdateTask 更新任务状态到数据库中
func (*Service) UploadScreenShotResult ¶
type ServiceOptions ¶
type ServiceOptions struct { ServiceHost string `long:"service" description:"Service host" json:"service_host" form:"service_host"` ServicePort int `long:"port" description:"Service port" default:"5001" json:"service_port" form:"service_port"` ServiceAuth string `long:"auth" description:"Service auth" json:"service_auth" form:"service_auth"` }
type TaskAssetDocumentResultArgs ¶
type TaskAssetDocumentResultArgs struct { WorkspaceId string MainTaskId string Result []db.AssetDocument }
type TaskResult ¶
type TaskSlice ¶
type TaskSlice struct { IpTarget []string DomainTarget []string Port string TaskMode int IpSliceNumber int PortSliceNumber int }
TaskSlice 任务切分
func (*TaskSlice) DoDomainSlice ¶
DoDomainSlice 对域名任务目标进行切分 只支持0,1两种模式
type TaskStatusArgs ¶
type TaskStatusArgs struct { WorkspaceId string TaskID string IsExist bool IsFinished bool State string Worker string Result string }
TaskStatusArgs 任务状态请求与返回参数
type VulResultArgs ¶
type VulResultArgs struct { WorkspaceId string MainTaskId string Result []db.VulDocument }
type WorkerOption ¶
type WorkerOption struct { ServiceOptions `group:"services"` WorkerTaskOption `group:"worker-tasks"` ConfigFile string `short:"f" long:"config-file" description:"config file" json:"default_config_file" form:"default_config_file"` NoProxy bool `` /* 128-byte string literal not displayed */ NoRedisProxy bool `long:"no-redis-proxy" description:"disable redis proxy configuration" json:"no_redis_proxy" form:"no_redis_proxy"` IpV6Support bool `long:"ipv6" description:"support ipv6 portscan" json:"ipv6" form:"ipv6"` }
var DaemonRunOption *WorkerOption
var WorkerRunOption *WorkerOption
func PrepareWorkerOptions ¶
func PrepareWorkerOptions() *WorkerOption
type WorkerRunTaskMode ¶
type WorkerRunTaskMode int
const ( TaskModeDefault WorkerRunTaskMode = iota TaskModeActive TaskModeFinger TaskModePassive TaskModePocscan TaskModeStandalone )
type WorkerStatus ¶
type WorkerStatus struct { sync.Mutex `json:"-"` // worker's task status WorkerName string `json:"worker_name"` WorkerTopics string `json:"worker_topic"` CreateTime time.Time `json:"create_time"` UpdateTime time.Time `json:"update_time"` TaskExecutedNumber int `json:"task_number"` TaskStartedNumber int `json:"started_number"` // worker's run status ManualReloadFlag bool `json:"manual_reload_flag"` ManualFileSyncFlag bool `json:"manual_file_sync_flag"` ManualUpdateOptionFlag bool `json:"manual_update_daemon_option"` CPULoad string `json:"cpu_load"` MemUsed string `json:"mem_used"` // worker's option WorkerRunOption []byte `json:"worker_run_option"` //worker当前运行的启动参数 WorkerUpdateOption []byte `json:"worker_update_option"` //worker需要更新的启动参数 // daemon option IsDaemonProcess bool `json:"is_daemon_process"` WorkerDaemonUpdateTime time.Time `json:"worker_daemon_update_time"` }
func GetWorkerStatusFromRedis ¶
func GetWorkerStatusFromRedis(client *redis.Client, workerID string) (*WorkerStatus, error)
GetWorkerStatusFromRedis 从 Redis 中读取指定 workerID 的 WorkerStatus
type WorkerTaskOption ¶
type WorkerTaskOption struct { Concurrency int `short:"c" long:"concurrency" description:"Number of concurrent workers" default:"2" json:"concurrency" form:"concurrency"` WorkerPerformance int `` /* 187-byte string literal not displayed */ WorkerRunTaskMode string `` /* 238-byte string literal not displayed */ WorkerTopic map[string]struct{} `json:"-"` }