mirror of
https://github.com/shadow1ng/fscan.git
synced 2025-07-13 21:02:44 +08:00
fix: -hf的一个问题 修复#412的问题
This commit is contained in:
parent
86b6faec79
commit
0235bf5af5
@ -148,6 +148,29 @@ func ParsePass(Info *HostInfo) error {
|
||||
LogInfo(fmt.Sprintf("从文件加载URL: %d 个", len(urls)))
|
||||
}
|
||||
|
||||
// 从文件加载主机列表
|
||||
if HostsFile != "" {
|
||||
hosts, err := Readfile(HostsFile)
|
||||
if err != nil {
|
||||
return fmt.Errorf("读取主机文件失败: %v", err)
|
||||
}
|
||||
|
||||
tmpHosts := make(map[string]struct{})
|
||||
for _, host := range hosts {
|
||||
if host != "" {
|
||||
if _, ok := tmpHosts[host]; !ok {
|
||||
tmpHosts[host] = struct{}{}
|
||||
if Info.Host == "" {
|
||||
Info.Host = host
|
||||
} else {
|
||||
Info.Host += "," + host
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
LogInfo(fmt.Sprintf("从文件加载主机: %d 个", len(hosts)))
|
||||
}
|
||||
|
||||
// 从文件加载端口列表
|
||||
if PortsFile != "" {
|
||||
ports, err := Readfile(PortsFile)
|
||||
|
@ -107,7 +107,7 @@ func parseIP(ip string) []string {
|
||||
|
||||
switch {
|
||||
case ip == "192":
|
||||
return parseIP("192.168.0.0/8")
|
||||
return parseIP("192.168.0.0/16")
|
||||
case ip == "172":
|
||||
return parseIP("172.16.0.0/12")
|
||||
case ip == "10":
|
||||
|
@ -16,7 +16,7 @@ const (
|
||||
)
|
||||
|
||||
// 插件分类映射表 - 所有插件名使用小写
|
||||
var pluginGroups = map[string][]string{
|
||||
var PluginGroups = map[string][]string{
|
||||
ModeAll: {
|
||||
"webtitle", "webpoc", // web类
|
||||
"mysql", "mssql", "redis", "mongodb", "postgres", // 数据库类
|
||||
@ -78,12 +78,12 @@ func ParseScanMode(mode string) {
|
||||
// 默认使用All模式
|
||||
ScanMode = ModeAll
|
||||
LogInfo(fmt.Sprintf("未识别的模式,使用默认模式: %s", ModeAll))
|
||||
LogInfo(fmt.Sprintf("包含插件: %v", pluginGroups[ModeAll]))
|
||||
LogInfo(fmt.Sprintf("包含插件: %v", PluginGroups[ModeAll]))
|
||||
}
|
||||
|
||||
// GetPluginsForMode 获取指定模式下的插件列表
|
||||
func GetPluginsForMode(mode string) []string {
|
||||
plugins, exists := pluginGroups[mode]
|
||||
plugins, exists := PluginGroups[mode]
|
||||
if exists {
|
||||
return plugins
|
||||
}
|
||||
|
14
Core/ICMP.go
14
Core/ICMP.go
@ -57,7 +57,7 @@ func handleAliveHosts(chanHosts chan string, hostslist []string, isPing bool) {
|
||||
if isPing {
|
||||
protocol = "PING"
|
||||
}
|
||||
fmt.Printf("目标 %-15s 存活 (%s)\n", ip, protocol)
|
||||
Common.LogSuccess(fmt.Sprintf("目标 %-15s 存活 (%s)", ip, protocol))
|
||||
}
|
||||
|
||||
AliveHosts = append(AliveHosts, ip)
|
||||
@ -76,7 +76,7 @@ func probeWithICMP(hostslist []string, chanHosts chan string) {
|
||||
}
|
||||
|
||||
Common.LogError(fmt.Sprintf("ICMP监听失败: %v", err))
|
||||
fmt.Println("正在尝试无监听ICMP探测...")
|
||||
Common.LogInfo("正在尝试无监听ICMP探测...")
|
||||
|
||||
// 尝试无监听ICMP探测
|
||||
conn2, err := net.DialTimeout("ip4:icmp", "127.0.0.1", 3*time.Second)
|
||||
@ -87,8 +87,8 @@ func probeWithICMP(hostslist []string, chanHosts chan string) {
|
||||
}
|
||||
|
||||
Common.LogError(fmt.Sprintf("ICMP连接失败: %v", err))
|
||||
fmt.Println("当前用户权限不足,无法发送ICMP包")
|
||||
fmt.Println("切换为PING方式探测...")
|
||||
Common.LogInfo("当前用户权限不足,无法发送ICMP包")
|
||||
Common.LogInfo("切换为PING方式探测...")
|
||||
|
||||
// 降级使用ping探测
|
||||
RunPing(hostslist, chanHosts)
|
||||
@ -100,8 +100,7 @@ func printAliveStats(hostslist []string) {
|
||||
if len(hostslist) > 1000 {
|
||||
arrTop, arrLen := ArrayCountValueTop(AliveHosts, Common.LiveTop, true)
|
||||
for i := 0; i < len(arrTop); i++ {
|
||||
output := fmt.Sprintf("B段 %-16s 存活主机数: %d", arrTop[i]+".0.0/16", arrLen[i])
|
||||
Common.LogSuccess(output)
|
||||
Common.LogSuccess(fmt.Sprintf("%s.0.0/16 存活主机数: %d", arrTop[i], arrLen[i]))
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,8 +108,7 @@ func printAliveStats(hostslist []string) {
|
||||
if len(hostslist) > 256 {
|
||||
arrTop, arrLen := ArrayCountValueTop(AliveHosts, Common.LiveTop, false)
|
||||
for i := 0; i < len(arrTop); i++ {
|
||||
output := fmt.Sprintf("C段 %-16s 存活主机数: %d", arrTop[i]+".0/24", arrLen[i])
|
||||
Common.LogSuccess(output)
|
||||
Common.LogSuccess(fmt.Sprintf("%s.0/24 存活主机数: %d", arrTop[i], arrLen[i]))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,21 +36,20 @@ func Scan(info Common.HostInfo) {
|
||||
LocalScan = true
|
||||
|
||||
// 定义本地模式允许的插件
|
||||
validLocalPlugins := map[string]bool{
|
||||
"localinfo": true,
|
||||
// 添加其他 ModeLocal 中定义的插件
|
||||
validLocalPlugins := make(map[string]bool)
|
||||
for _, plugin := range Common.PluginGroups[Common.ModeLocal] {
|
||||
validLocalPlugins[plugin] = true
|
||||
}
|
||||
|
||||
if Common.ScanMode != "" && Common.ScanMode != Common.ModeLocal {
|
||||
// 如果指定了模式但不是 ModeLocal,检查是否是合法的单插件
|
||||
// 如果没有指定扫描模式或为默认的All,设置为 ModeLocal
|
||||
if Common.ScanMode == "" || Common.ScanMode == "All" {
|
||||
Common.ScanMode = Common.ModeLocal
|
||||
} else if Common.ScanMode != Common.ModeLocal {
|
||||
// 不是完整模式时,检查是否是合法的单插件
|
||||
if !validLocalPlugins[Common.ScanMode] {
|
||||
Common.LogError(fmt.Sprintf("无效的本地模式插件: %s, 仅支持 localinfo", Common.ScanMode))
|
||||
return
|
||||
}
|
||||
// ScanMode 保持为单插件名
|
||||
} else {
|
||||
// 没有指定模式或指定了 ModeLocal,使用完整的本地模式
|
||||
Common.ScanMode = Common.ModeLocal
|
||||
}
|
||||
|
||||
if Common.ScanMode == Common.ModeLocal {
|
||||
@ -65,22 +64,24 @@ func Scan(info Common.HostInfo) {
|
||||
// Web模式
|
||||
WebScan = true
|
||||
|
||||
// 定义Web模式允许的插件
|
||||
validWebPlugins := map[string]bool{
|
||||
"webtitle": true,
|
||||
"webpoc": true,
|
||||
// 从 pluginGroups 获取Web模式允许的插件
|
||||
validWebPlugins := make(map[string]bool)
|
||||
for _, plugin := range Common.PluginGroups[Common.ModeWeb] {
|
||||
validWebPlugins[plugin] = true
|
||||
}
|
||||
|
||||
if Common.ScanMode != "" && Common.ScanMode != Common.ModeWeb {
|
||||
// 如果指定了模式但不是 ModeWeb,检查是否是合法的单插件
|
||||
// 如果没有指定扫描模式,默认设置为 ModeWeb
|
||||
if Common.ScanMode == "" || Common.ScanMode == "All" {
|
||||
Common.ScanMode = Common.ModeWeb
|
||||
}
|
||||
|
||||
// 如果不是 ModeWeb,检查是否是合法的单插件
|
||||
if Common.ScanMode != Common.ModeWeb {
|
||||
if !validWebPlugins[Common.ScanMode] {
|
||||
Common.LogError(fmt.Sprintf("无效的Web插件: %s, 仅支持 webtitle 和 webpoc", Common.ScanMode))
|
||||
return
|
||||
}
|
||||
// ScanMode 保持为单插件名
|
||||
} else {
|
||||
// 没有指定模式或指定了 ModeWeb,使用完整的Web模式
|
||||
Common.ScanMode = Common.ModeWeb
|
||||
}
|
||||
|
||||
var targetInfos []Common.HostInfo
|
||||
|
Loading…
Reference in New Issue
Block a user