fscan/plugins/web/init.go
ZacharyZcR 4cd8ed5668 feat: 完成本地插件架构统一迁移
迁移所有本地插件到统一Plugin接口架构:
- socks5proxy/systemdservice: 网络代理和Linux服务持久化
- winregistry/winservice/winschtask/winstartup/winwmi: Windows持久化套件
- 所有插件消除BaseLocalPlugin继承,统一使用Plugin接口
- 保持原有功能完整性,支持跨平台编译标记
- 删除过度设计的继承体系,实现直接简洁实现
2025-08-26 14:39:53 +08:00

87 lines
1.8 KiB
Go

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)
}