diff --git a/common/config_struct.go b/common/config_struct.go index 87d13ba..e40323c 100644 --- a/common/config_struct.go +++ b/common/config_struct.go @@ -32,6 +32,7 @@ type Config struct { DisableBrute bool // 禁用暴力破解 DisablePing bool // 禁用Ping检测 DisableTcpProbe bool // 禁用TCP补充探测 + DisableSubnetProbe bool // 禁用网段预筛 // 扫描模式 Mode string // 扫描模式 @@ -200,7 +201,8 @@ func NewConfig() *Config { ModuleThreadNum: 10, DisableBrute: false, DisablePing: false, - DisableTcpProbe: false, + DisableTcpProbe: false, + DisableSubnetProbe: false, // 扫描模式 Mode: DefaultScanMode, diff --git a/common/flag.go b/common/flag.go index f6bfd2e..a3f24d7 100644 --- a/common/flag.go +++ b/common/flag.go @@ -113,6 +113,7 @@ func Flag(Info *HostInfo) error { flag.Int64Var(&fv.GlobalTimeout, "gt", 180, i18n.GetText("flag_global_timeout")) flag.BoolVar(&fv.DisablePing, "np", false, i18n.GetText("flag_disable_ping")) flag.BoolVar(&fv.DisableTcpProbe, "ntp", false, i18n.GetText("flag_disable_tcp_probe")) + flag.BoolVar(&fv.DisableSubnetProbe, "nsp", false, i18n.GetText("flag_disable_subnet_probe")) flag.StringVar(&fv.LocalPlugin, "local", "", i18n.GetText("flag_local_plugin")) flag.BoolVar(&fv.AliveOnly, "ao", false, i18n.GetText("flag_alive_only")) diff --git a/common/flag_config.go b/common/flag_config.go index b2b4d3a..79c23da 100644 --- a/common/flag_config.go +++ b/common/flag_config.go @@ -41,6 +41,7 @@ type FlagVars struct { GlobalTimeout int64 DisablePing bool DisableTcpProbe bool + DisableSubnetProbe bool LocalPlugin string AliveOnly bool DisableBrute bool @@ -150,6 +151,7 @@ func BuildConfigFromFlags(fv *FlagVars) *Config { DisableBrute: fv.DisableBrute, DisablePing: fv.DisablePing, DisableTcpProbe: fv.DisableTcpProbe, + DisableSubnetProbe: fv.DisableSubnetProbe, // 扫描模式 Mode: fv.ScanMode, diff --git a/common/i18n/locales/en.yaml b/common/i18n/locales/en.yaml index c308cf6..8916b6b 100644 --- a/common/i18n/locales/en.yaml +++ b/common/i18n/locales/en.yaml @@ -30,6 +30,8 @@ flag_disable_ping: other: "Disable ping detection" flag_disable_tcp_probe: other: "Disable TCP supplementary probe" +flag_disable_subnet_probe: + other: "Disable subnet pre-filter (optimization that skips empty /24 subnets in large scans)" flag_local_plugin: other: "Specify local plugin name (e.g.: cleaner, systeminfo, keylogger)" flag_debug: diff --git a/common/i18n/locales/zh.yaml b/common/i18n/locales/zh.yaml index 94eb728..c4ee421 100644 --- a/common/i18n/locales/zh.yaml +++ b/common/i18n/locales/zh.yaml @@ -30,6 +30,8 @@ flag_disable_ping: other: "禁用ping探测" flag_disable_tcp_probe: other: "禁用TCP补充探测" +flag_disable_subnet_probe: + other: "禁用网段预筛(大规模扫描时跳过空 /24 网段的优化)" flag_local_plugin: other: "指定本地插件名称 (如: cleaner, systeminfo, keylogger 等)" flag_debug: diff --git a/core/port_scan.go b/core/port_scan.go index 05e2ba9..9a95820 100644 --- a/core/port_scan.go +++ b/core/port_scan.go @@ -147,7 +147,7 @@ func EnhancedPortScan(ctx context.Context, hosts []string, ports string, timeout session.LogDebug(i18n.Tr("port_scan_debug_start", len(hosts), config.ThreadNum)) // 大规模扫描预筛:跨多个 /24 时先做网段探活,跳过空网段 - if len(hosts) > subnetProbeThreshold { + if !config.DisableSubnetProbe && len(hosts) > subnetProbeThreshold { hosts = probeSubnets(ctx, hosts, time.Duration(timeout)*time.Second, session) if len(hosts) == 0 { session.LogInfo(i18n.GetText("port_scan_no_alive_subnet")) diff --git a/pkg/fscan/scanner.go b/pkg/fscan/scanner.go index 9a397b7..c5845f6 100644 --- a/pkg/fscan/scanner.go +++ b/pkg/fscan/scanner.go @@ -411,6 +411,7 @@ func buildFlagVars(config Config, target Target) *common.FlagVars { GlobalTimeout: 180, DisablePing: config.DisablePing, DisableTcpProbe: config.DisableTCPProbe, + DisableSubnetProbe: config.DisableSubnetProbe, AliveOnly: false, DisableBrute: config.DisableBrute, MaxRetries: maxRetries, diff --git a/pkg/fscan/types.go b/pkg/fscan/types.go index 615e7ff..02428a7 100644 --- a/pkg/fscan/types.go +++ b/pkg/fscan/types.go @@ -133,9 +133,10 @@ type Config struct { ModuleThreads int MaxRetries int - DisablePing bool - DisableTCPProbe bool - DisableBrute bool + DisablePing bool + DisableTCPProbe bool + DisableSubnetProbe bool + DisableBrute bool Usernames []string Passwords []string diff --git a/web/api/scan.go b/web/api/scan.go index 320908d..6858f0b 100644 --- a/web/api/scan.go +++ b/web/api/scan.go @@ -38,8 +38,9 @@ type ScanRequest struct { ThreadNum int `json:"thread_num"` Timeout int `json:"timeout"` ModuleThreadNum int `json:"module_thread_num"` - DisablePing bool `json:"disable_ping"` - DisableBrute bool `json:"disable_brute"` + DisablePing bool `json:"disable_ping"` + DisableBrute bool `json:"disable_brute"` + DisableSubnetProbe bool `json:"disable_subnet_probe"` AliveOnly bool `json:"alive_only"` // 认证 @@ -199,6 +200,7 @@ func (h *ScanHandler) runScan(req ScanRequest) { } fv.DisablePing = req.DisablePing fv.DisableBrute = req.DisableBrute + fv.DisableSubnetProbe = req.DisableSubnetProbe fv.AliveOnly = req.AliveOnly fv.Username = req.Username fv.Password = req.Password