package web import ( "context" "fmt" "sync" "github.com/shadow1ng/fscan/common" ) // WebPlugin Web扫描插件接口 type WebPlugin interface { GetName() string GetPorts() []int Scan(ctx context.Context, info *common.HostInfo) *WebScanResult } // WebScanResult Web扫描结果 type WebScanResult struct { Success bool Title string // 网页标题 Status int // HTTP状态码 Server string // 服务器信息 Length int // 响应长度 VulInfo string // 漏洞信息(如果有) Error error } // Web插件注册表 var ( webPluginRegistry = make(map[string]func() WebPlugin) webPluginMutex sync.RWMutex ) // RegisterWebPlugin 注册Web插件 func RegisterWebPlugin(name string, creator func() WebPlugin) { webPluginMutex.Lock() defer webPluginMutex.Unlock() webPluginRegistry[name] = creator } // GetWebPlugin 获取指定Web插件 func GetWebPlugin(name string) WebPlugin { webPluginMutex.RLock() defer webPluginMutex.RUnlock() if creator, exists := webPluginRegistry[name]; exists { return creator() } return nil } // GetAllWebPlugins 获取所有已注册Web插件的名称 func GetAllWebPlugins() []string { webPluginMutex.RLock() defer webPluginMutex.RUnlock() var plugins []string for name := range webPluginRegistry { plugins = append(plugins, name) } return plugins } // IsWebPort 判断是否为Web端口 func IsWebPort(port int) bool { webPorts := []int{80, 443, 8080, 8443, 8000, 8888, 9000, 9090, 3000, 5000} for _, p := range webPorts { if p == port { return true } } return false } // BuildWebURL 构建Web URL func BuildWebURL(host string, port int) string { scheme := "http" if port == 443 || port == 8443 { scheme = "https" } if port == 80 || port == 443 { return fmt.Sprintf("%s://%s", scheme, host) } return fmt.Sprintf("%s://%s:%d", scheme, host, port) }