mirror of
https://github.com/shadow1ng/fscan.git
synced 2025-07-13 21:02:44 +08:00
refactor: 大型重构
This commit is contained in:
parent
bdeabec67e
commit
1278a0355f
@ -7,7 +7,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -15,7 +14,6 @@ func Parse(Info *HostInfo) {
|
|||||||
ParseUser()
|
ParseUser()
|
||||||
ParsePass(Info)
|
ParsePass(Info)
|
||||||
ParseInput(Info)
|
ParseInput(Info)
|
||||||
ParseScantype(Info)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParseUser 解析用户名配置,支持直接指定用户名列表或从文件读取
|
// ParseUser 解析用户名配置,支持直接指定用户名列表或从文件读取
|
||||||
@ -319,49 +317,6 @@ func ParseInput(Info *HostInfo) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParseScantype 解析扫描类型并设置对应的端口
|
|
||||||
func ParseScantype(Info *HostInfo) error {
|
|
||||||
// 先处理特殊扫描类型
|
|
||||||
specialTypes := map[string]string{
|
|
||||||
"service": ServicePorts,
|
|
||||||
"db": DbPorts,
|
|
||||||
"web": WebPorts,
|
|
||||||
"all": AllPorts,
|
|
||||||
"main": MainPorts,
|
|
||||||
"port": MainPorts + "," + WebPorts,
|
|
||||||
"icmp": "", // ICMP不需要端口
|
|
||||||
}
|
|
||||||
|
|
||||||
// 如果是特殊扫描类型
|
|
||||||
if customPorts, isSpecial := specialTypes[ScanMode]; isSpecial {
|
|
||||||
// 专门处理 all 类型
|
|
||||||
if ScanMode == "all" {
|
|
||||||
Ports = AllPorts // 直接设置为 1-65535
|
|
||||||
} else if Ports == MainPorts+","+WebPorts {
|
|
||||||
Ports = customPorts
|
|
||||||
}
|
|
||||||
fmt.Printf("[*] 扫描类型: %s, 目标端口: %s\n", ScanMode, Ports)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查是否是注册的插件类型
|
|
||||||
plugin, validType := PluginManager[ScanMode]
|
|
||||||
if !validType {
|
|
||||||
showmode()
|
|
||||||
return fmt.Errorf("无效的扫描类型: %s", ScanMode)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 如果是插件扫描且使用默认端口配置
|
|
||||||
if Ports == MainPorts+","+WebPorts {
|
|
||||||
if plugin.Port > 0 {
|
|
||||||
Ports = strconv.Itoa(plugin.Port)
|
|
||||||
}
|
|
||||||
fmt.Printf("[*] 扫描类型: %s, 目标端口: %s\n", plugin.Name, Ports)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// showmode 显示所有支持的扫描类型
|
// showmode 显示所有支持的扫描类型
|
||||||
func showmode() {
|
func showmode() {
|
||||||
fmt.Println("[!] 指定的扫描类型不存在")
|
fmt.Println("[!] 指定的扫描类型不存在")
|
||||||
|
@ -9,6 +9,20 @@ import (
|
|||||||
|
|
||||||
// ParsePort 解析端口配置字符串为端口号列表
|
// ParsePort 解析端口配置字符串为端口号列表
|
||||||
func ParsePort(ports string) []int {
|
func ParsePort(ports string) []int {
|
||||||
|
// 预定义的端口组
|
||||||
|
portGroups := map[string]string{
|
||||||
|
"service": ServicePorts,
|
||||||
|
"db": DbPorts,
|
||||||
|
"web": WebPorts,
|
||||||
|
"all": AllPorts,
|
||||||
|
"main": MainPorts,
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查是否匹配预定义组
|
||||||
|
if definedPorts, exists := portGroups[ports]; exists {
|
||||||
|
ports = definedPorts
|
||||||
|
}
|
||||||
|
|
||||||
if ports == "" {
|
if ports == "" {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user