refactor: 默认扫描机制

This commit is contained in:
ZacharyZcR
2024-12-20 17:54:36 +08:00
parent 92c03e95a9
commit 8f1c5dbae9
2 changed files with 39 additions and 2 deletions
+20 -2
View File
@@ -4,6 +4,7 @@ import (
"fmt"
"github.com/shadow1ng/fscan/Common"
"github.com/shadow1ng/fscan/WebScan/lib"
"strconv"
"strings"
"sync"
)
@@ -114,12 +115,29 @@ func executeScans(targets []Common.HostInfo, ch *chan struct{}, wg *sync.WaitGro
if plugins := Common.GetPluginsForMode(mode); plugins != nil {
// 使用预设模式的插件组
for _, target := range targets {
for _, plugin := range plugins {
AddScan(plugin, target, ch, wg)
targetPort := target.Ports // 目标端口
for _, pluginName := range plugins {
// 获取插件信息
plugin, exists := Common.PluginManager[pluginName]
if !exists {
continue
}
// 检查插件是否有默认端口配置
if plugin.Port != 0 {
// 只有当目标端口匹配插件默认端口时才执行
if targetPort == strconv.Itoa(plugin.Port) {
AddScan(pluginName, target, ch, wg)
}
} else {
// 对于没有默认端口的插件(如web扫描),始终执行
AddScan(pluginName, target, ch, wg)
}
}
}
} else {
// 使用单个插件
// 对于单个插件模式,不进行端口匹配检查,直接执行
for _, target := range targets {
AddScan(mode, target, ch, wg)
}