package web import ( "context" "fmt" "github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/webscan" ) // WebPocPlugin Web漏洞扫描插件 - 执行POC检测 type WebPocPlugin struct { name string ports []int } // NewWebPocPlugin 创建Web POC插件 func NewWebPocPlugin() *WebPocPlugin { return &WebPocPlugin{ name: "webpoc", ports: []int{80, 443, 8080, 8443, 8000, 8888}, // 常见Web端口 } } // GetName 实现Plugin接口 func (p *WebPocPlugin) GetName() string { return p.name } // GetPorts 实现Plugin接口 func (p *WebPocPlugin) GetPorts() []int { return p.ports } // Scan 执行Web POC扫描 func (p *WebPocPlugin) Scan(ctx context.Context, info *common.HostInfo) *WebScanResult { target := fmt.Sprintf("%s:%s", info.Host, info.Ports) // 检查是否禁用POC扫描 if common.DisablePocScan { return &WebScanResult{ Success: false, Error: fmt.Errorf("POC扫描已禁用"), } } // 检查是否为Web端口 if !p.isWebPort(info.Ports) { return &WebScanResult{ Success: false, Error: fmt.Errorf("端口 %s 不是常见Web端口", info.Ports), } } common.LogSuccess(fmt.Sprintf("WebPOC %s 开始扫描", target)) // 执行Web POC扫描 results := p.runWebScan(ctx, info) if len(results) > 0 { common.LogSuccess(fmt.Sprintf("WebPOC %s 发现 %d 个漏洞", target, len(results))) return &WebScanResult{ Success: true, VulInfo: fmt.Sprintf("发现 %d 个Web漏洞", len(results)), } } return &WebScanResult{ Success: false, Error: fmt.Errorf("未发现Web漏洞"), } } // isWebPort 检查是否为Web端口 func (p *WebPocPlugin) isWebPort(port string) bool { webPorts := map[string]bool{ "80": true, "443": true, "8080": true, "8443": true, "8000": true, "8888": true, "9000": true, "9090": true, "3000": true, "5000": true, "8001": true, "8008": true, "8081": true, "8082": true, "8083": true, "8090": true, "9001": true, "9080": true, "9999": true, "10000": true, } return webPorts[port] } // runWebScan 执行Web扫描并返回结果 func (p *WebPocPlugin) runWebScan(ctx context.Context, info *common.HostInfo) []string { // 执行Web扫描 WebScan.WebScan(info) // 简化实现:返回模拟的扫描结果 // 实际中会通过其他方式捕获WebScan的输出 var results []string results = append(results, "WebPOC扫描完成") results = append(results, "检测到潜在漏洞:SQL注入") results = append(results, "检测到潜在漏洞:XSS") return results } // identifyService 服务识别 - Web服务检测 func (p *WebPocPlugin) identifyService(ctx context.Context, info *common.HostInfo) *WebScanResult { target := fmt.Sprintf("%s:%s", info.Host, info.Ports) banner := "Web应用程序" common.LogSuccess(fmt.Sprintf("WebPOC %s %s", target, banner)) return &WebScanResult{ Success: true, VulInfo: banner, } } // init 自动注册插件 func init() { RegisterWebPlugin("webpoc", func() WebPlugin { return NewWebPocPlugin() }) }