diff --git a/Common/Log.go b/Common/Log.go index 699a897..d13e7d9 100644 --- a/Common/Log.go +++ b/Common/Log.go @@ -108,7 +108,7 @@ func formatLogMessage(entry *LogEntry) string { // printLog 根据日志级别打印日志 func printLog(entry *LogEntry) { - if LogLevel != "debug" && entry.Level == LogLevelDebug { + if LogLevel != "debug" && (entry.Level == LogLevelDebug || entry.Level == LogLevelError) { return } @@ -173,7 +173,7 @@ func LogDebug(msg string) { }) } -// LogInfo 记录进度信息 +// LogBase 记录进度信息 func LogBase(msg string) { handleLog(&LogEntry{ Level: LogLevelBase, @@ -183,6 +183,7 @@ func LogBase(msg string) { } // LogInfo 记录信息日志 +// [*] func LogInfo(msg string) { handleLog(&LogEntry{ Level: LogLevelInfo, @@ -192,6 +193,7 @@ func LogInfo(msg string) { } // LogSuccess 记录成功日志,并更新最后成功时间 +// [+] func LogSuccess(result string) { entry := &LogEntry{ Level: LogLevelSuccess, diff --git a/Common/Parse.go b/Common/Parse.go index fbe8065..d7f9ab4 100644 --- a/Common/Parse.go +++ b/Common/Parse.go @@ -43,7 +43,7 @@ func ParseUser() error { // 处理命令行参数指定的用户名列表 if Username != "" { usernames = strings.Split(Username, ",") - LogInfo(GetText("no_username_specified", len(usernames))) + LogBase(GetText("no_username_specified", len(usernames))) } // 从文件加载用户名列表 @@ -59,12 +59,12 @@ func ParseUser() error { usernames = append(usernames, user) } } - LogInfo(GetText("load_usernames_from_file", len(fileUsers))) + LogBase(GetText("load_usernames_from_file", len(fileUsers))) } // 去重处理 usernames = RemoveDuplicate(usernames) - LogInfo(GetText("total_usernames", len(usernames))) + LogBase(GetText("total_usernames", len(usernames))) // 更新所有字典的用户名列表 for name := range Userdict { @@ -113,7 +113,7 @@ func parsePasswords() { } } Passwords = pwdList - LogInfo(GetText("load_passwords", len(pwdList))) + LogBase(GetText("load_passwords", len(pwdList))) } // 从文件加载密码列表 @@ -130,7 +130,7 @@ func parsePasswords() { } } Passwords = pwdList - LogInfo(GetText("load_passwords_from_file", len(passes))) + LogBase(GetText("load_passwords_from_file", len(passes))) } } @@ -161,7 +161,7 @@ func parseHashes() { LogError(GetText("invalid_hash", line)) } } - LogInfo(GetText("load_valid_hashes", validCount)) + LogBase(GetText("load_valid_hashes", validCount)) } // parseURLs 解析URL目标配置 @@ -201,7 +201,7 @@ func parseURLs() { } if len(URLs) > 0 { - LogInfo(GetText("load_urls", len(URLs))) + LogBase(GetText("load_urls", len(URLs))) } } @@ -240,7 +240,7 @@ func parseHosts(Info *HostInfo) error { Info.Host += "," + hostStr } - LogInfo(GetText("load_hosts_from_file", len(hosts))) + LogBase(GetText("load_hosts_from_file", len(hosts))) } return nil @@ -270,7 +270,7 @@ func parsePorts() error { // 更新全局端口配置 Ports = portBuilder.String() - LogInfo(GetText("load_ports_from_file")) + LogBase(GetText("load_ports_from_file")) return nil } @@ -279,7 +279,7 @@ func parsePorts() error { // 更新全局排除端口配置 func parseExcludePorts() { if ExcludePorts != "" { - LogInfo(GetText("exclude_ports", ExcludePorts)) + LogBase(GetText("exclude_ports", ExcludePorts)) // 确保排除端口被正确设置到全局配置中 // 这将由PortScan函数在处理端口时使用 } @@ -316,7 +316,7 @@ func ReadFileLines(filename string) ([]string, error) { return nil, err } - LogInfo(GetText("read_file_success", filename, lineCount)) + LogBase(GetText("read_file_success", filename, lineCount)) return content, nil } @@ -392,12 +392,12 @@ func processPortsConfig() { } else { Ports += "," + AddPorts } - LogInfo(GetText("extra_ports", AddPorts)) + LogBase(GetText("extra_ports", AddPorts)) } // 确保排除端口配置被记录 if ExcludePorts != "" { - LogInfo(GetText("exclude_ports_applied", ExcludePorts)) + LogBase(GetText("exclude_ports_applied", ExcludePorts)) } } @@ -411,7 +411,7 @@ func processExtraCredentials() { Userdict[dict] = append(Userdict[dict], users...) Userdict[dict] = RemoveDuplicate(Userdict[dict]) } - LogInfo(GetText("extra_usernames", AddUsers)) + LogBase(GetText("extra_usernames", AddUsers)) } // 处理额外密码 @@ -419,7 +419,7 @@ func processExtraCredentials() { passes := strings.Split(AddPasswords, ",") Passwords = append(Passwords, passes...) Passwords = RemoveDuplicate(Passwords) - LogInfo(GetText("extra_passwords", AddPasswords)) + LogBase(GetText("extra_passwords", AddPasswords)) } } @@ -465,7 +465,7 @@ func setupSocks5Proxy() error { // 使用Socks5代理时禁用Ping(无法通过代理进行ICMP) DisablePing = true - LogInfo(GetText("socks5_proxy", Socks5Proxy)) + LogBase(GetText("socks5_proxy", Socks5Proxy)) return nil } @@ -499,7 +499,7 @@ func setupHttpProxy() error { return fmt.Errorf(GetText("proxy_format_error", err)) } - LogInfo(GetText("http_proxy", HttpProxy)) + LogBase(GetText("http_proxy", HttpProxy)) return nil } diff --git a/Common/ParseIP.go b/Common/ParseIP.go index 8b9e66e..7fd9e8c 100644 --- a/Common/ParseIP.go +++ b/Common/ParseIP.go @@ -35,7 +35,7 @@ func ParseIP(host string, filename string, nohosts ...string) (hosts []string, e host = hostport[0] hosts = parseIPList(host) Ports = hostport[1] - LogInfo(GetText("host_port_parsed", Ports)) + LogBase(GetText("host_port_parsed", Ports)) } } else { // 解析主机地址 @@ -48,7 +48,7 @@ func ParseIP(host string, filename string, nohosts ...string) (hosts []string, e LogError(GetText("read_host_file_failed", err)) } else { hosts = append(hosts, fileHosts...) - LogInfo(GetText("extra_hosts_loaded", len(fileHosts))) + LogBase(GetText("extra_hosts_loaded", len(fileHosts))) } } } @@ -58,7 +58,7 @@ func ParseIP(host string, filename string, nohosts ...string) (hosts []string, e // 去重并排序 hosts = removeDuplicateIPs(hosts) - LogInfo(GetText("final_valid_hosts", len(hosts))) + LogBase(GetText("final_valid_hosts", len(hosts))) // 检查解析结果 if len(hosts) == 0 && len(HostPort) == 0 && (host != "" || filename != "") { @@ -160,7 +160,7 @@ func parseCIDR(cidr string) []string { // 转换为IP范围 ipRange := calculateIPRange(ipNet) hosts := parseIPRange(ipRange) - LogInfo(GetText("parse_cidr_to_range", cidr, ipRange)) + LogBase(GetText("parse_cidr_to_range", cidr, ipRange)) return hosts } @@ -188,7 +188,7 @@ func calculateIPRange(cidr *net.IPNet) string { end := bcst.String() result := fmt.Sprintf("%s-%s", start, end) - LogInfo(GetText("cidr_range", result)) + LogBase(GetText("cidr_range", result)) return result } @@ -264,7 +264,7 @@ func parseShortIPRange(startIP, endSuffix string) []string { allIP = append(allIP, fmt.Sprintf("%s.%d", prefixIP, i)) } - LogInfo(GetText("generate_ip_range", prefixIP, startNum, prefixIP, endNum)) + LogBase(GetText("generate_ip_range", prefixIP, startNum, prefixIP, endNum)) return allIP } @@ -333,7 +333,7 @@ func parseFullIPRange(startIP, endIP string) []string { allIP = append(allIP, ip) } - LogInfo(GetText("generate_ip_range_full", startIP, endIP, len(allIP))) + LogBase(GetText("generate_ip_range_full", startIP, endIP, len(allIP))) return allIP } @@ -356,7 +356,7 @@ func parseSubnet8(subnet string) []string { firstOctet := strings.Split(baseIP, ".")[0] var sampleIPs []string - LogInfo(GetText("parse_subnet", firstOctet)) + LogBase(GetText("parse_subnet", firstOctet)) // 预分配足够的容量以提高性能 // 每个二级网段10个IP,共256*256个二级网段 @@ -388,7 +388,7 @@ func parseSubnet8(subnet string) []string { } } - LogInfo(GetText("sample_ip_generated", len(sampleIPs))) + LogBase(GetText("sample_ip_generated", len(sampleIPs))) return sampleIPs } @@ -445,7 +445,7 @@ func readIPFile(filename string) ([]string, error) { for _, host := range hosts { HostPort = append(HostPort, fmt.Sprintf("%s:%s", host, portPart)) } - LogInfo(GetText("parse_ip_port", line)) + LogBase(GetText("parse_ip_port", line)) } else { LogError(GetText("invalid_ip_port_format", line)) } @@ -453,7 +453,7 @@ func readIPFile(filename string) ([]string, error) { // 处理纯IP格式 hosts := parseIPList(line) ipList = append(ipList, hosts...) - LogInfo(GetText("parse_ip_address", line)) + LogBase(GetText("parse_ip_address", line)) } } @@ -463,7 +463,7 @@ func readIPFile(filename string) ([]string, error) { return ipList, err } - LogInfo(GetText("file_parse_complete", len(ipList))) + LogBase(GetText("file_parse_complete", len(ipList))) return ipList, nil } @@ -505,7 +505,7 @@ func excludeHosts(hosts []string, nohosts []string) []string { // 排序以保持结果的稳定性 sort.Strings(result) - LogInfo(GetText("hosts_excluded", len(excludeList))) + LogBase(GetText("hosts_excluded", len(excludeList))) return result } diff --git a/Core/ICMP.go b/Core/ICMP.go index 99638fc..b0686cf 100644 --- a/Core/ICMP.go +++ b/Core/ICMP.go @@ -80,7 +80,7 @@ func handleAliveHosts(chanHosts chan string, hostslist []string, isPing bool) { // 保留原有的控制台输出 if !Common.Silent { - Common.LogSuccess(Common.GetText("target_alive", ip, protocol)) + Common.LogInfo(Common.GetText("target_alive", ip, protocol)) } } livewg.Done() @@ -107,7 +107,7 @@ func probeWithICMP(hostslist []string, chanHosts chan string) { return } - Common.LogError(Common.GetText("icmp_connect_failed", err)) + Common.LogBase(Common.GetText("icmp_connect_failed", err)) Common.LogBase(Common.GetText("insufficient_privileges")) Common.LogBase(Common.GetText("switching_to_ping")) @@ -121,7 +121,7 @@ func printAliveStats(hostslist []string) { if len(hostslist) > 1000 { arrTop, arrLen := ArrayCountValueTop(AliveHosts, Common.LiveTop, true) for i := 0; i < len(arrTop); i++ { - Common.LogSuccess(Common.GetText("subnet_16_alive", arrTop[i], arrLen[i])) + Common.LogInfo(Common.GetText("subnet_16_alive", arrTop[i], arrLen[i])) } } @@ -129,7 +129,7 @@ func printAliveStats(hostslist []string) { if len(hostslist) > 256 { arrTop, arrLen := ArrayCountValueTop(AliveHosts, Common.LiveTop, false) for i := 0; i < len(arrTop); i++ { - Common.LogSuccess(Common.GetText("subnet_24_alive", arrTop[i], arrLen[i])) + Common.LogInfo(Common.GetText("subnet_24_alive", arrTop[i], arrLen[i])) } } } diff --git a/Core/LocalScanner.go b/Core/LocalScanner.go index 81cd264..edfd57b 100644 --- a/Core/LocalScanner.go +++ b/Core/LocalScanner.go @@ -27,7 +27,7 @@ func (s *LocalScanStrategy) Description() string { // Execute 执行本地扫描策略 func (s *LocalScanStrategy) Execute(info Common.HostInfo, ch *chan struct{}, wg *sync.WaitGroup) { - Common.LogInfo("执行本地信息收集") + Common.LogBase("执行本地信息收集") // 验证插件配置 if err := validateScanPlugins(); err != nil { @@ -81,7 +81,7 @@ func (s *LocalScanStrategy) LogPluginInfo() { // 如果是自定义模式,直接显示用户指定的插件 if isCustomMode { - Common.LogInfo(fmt.Sprintf("本地模式: 使用指定插件: %s", strings.Join(allPlugins, ", "))) + Common.LogBase(fmt.Sprintf("本地模式: 使用指定插件: %s", strings.Join(allPlugins, ", "))) return } @@ -95,9 +95,9 @@ func (s *LocalScanStrategy) LogPluginInfo() { } if len(applicablePlugins) > 0 { - Common.LogInfo(fmt.Sprintf("本地模式: 使用本地插件: %s", strings.Join(applicablePlugins, ", "))) + Common.LogBase(fmt.Sprintf("本地模式: 使用本地插件: %s", strings.Join(applicablePlugins, ", "))) } else { - Common.LogInfo("本地模式: 未找到可用的本地插件") + Common.LogBase("本地模式: 未找到可用的本地插件") } } diff --git a/Core/PortScan.go b/Core/PortScan.go index cc7bdb4..32bc3fc 100644 --- a/Core/PortScan.go +++ b/Core/PortScan.go @@ -63,7 +63,7 @@ func EnhancedPortScan(hosts []string, ports string, timeout int64) []string { // 记录开放端口 atomic.AddInt64(&count, 1) aliveMap.Store(addr, struct{}{}) - Common.LogSuccess("端口开放 " + addr) + Common.LogInfo("端口开放 " + addr) Common.SaveResult(&Common.ScanResult{ Time: time.Now(), Type: Common.PORT, Target: host, Status: "open", Details: map[string]interface{}{"port": port}, @@ -128,7 +128,7 @@ func EnhancedPortScan(hosts []string, ports string, timeout int64) []string { sb.WriteString(" Banner:[" + strings.TrimSpace(info.Banner) + "]") } - Common.LogSuccess(sb.String()) + Common.LogInfo(sb.String()) } } @@ -146,6 +146,6 @@ func EnhancedPortScan(hosts []string, ports string, timeout int64) []string { return true }) - Common.LogSuccess(fmt.Sprintf("扫描完成, 发现 %d 个开放端口", count)) + Common.LogBase(fmt.Sprintf("扫描完成, 发现 %d 个开放端口", count)) return aliveAddrs } diff --git a/Core/Scanner.go b/Core/Scanner.go index 59e7f49..eedcd8d 100644 --- a/Core/Scanner.go +++ b/Core/Scanner.go @@ -53,19 +53,19 @@ func (s *Scanner) selectStrategy(info Common.HostInfo) { switch { case Common.LocalMode: s.strategy = NewLocalScanStrategy() - Common.LogInfo("已选择本地扫描模式") + Common.LogBase("已选择本地扫描模式") case len(Common.URLs) > 0: s.strategy = NewWebScanStrategy() - Common.LogInfo("已选择Web扫描模式") + Common.LogBase("已选择Web扫描模式") default: s.strategy = NewServiceScanStrategy() - Common.LogInfo("已选择服务扫描模式") + Common.LogBase("已选择服务扫描模式") } } // Scan 执行整体扫描流程 func (s *Scanner) Scan(info Common.HostInfo) { - Common.LogInfo("开始信息扫描") + Common.LogBase("开始信息扫描") lib.Inithttp() // 并发控制初始化 @@ -86,7 +86,7 @@ func (s *Scanner) finishScan() { Common.ProgressBar.Finish() fmt.Println() } - Common.LogSuccess(fmt.Sprintf("扫描已完成: %v/%v", Common.End, Common.Num)) + Common.LogBase(fmt.Sprintf("扫描已完成: %v/%v", Common.End, Common.Num)) } // 任务执行通用框架 @@ -158,7 +158,7 @@ func logScanPlan(tasks []ScanTask) { planInfo.WriteString(fmt.Sprintf(" - %s: %d 个目标\n", plugin, count)) } - Common.LogInfo(planInfo.String()) + Common.LogBase(planInfo.String()) } // 初始化进度条 @@ -199,7 +199,7 @@ func scheduleScanTask(pluginName string, target Common.HostInfo, ch *chan struct // 完成任务,释放资源 duration := time.Since(startTime) if Common.ShowScanPlan { - Common.LogInfo(fmt.Sprintf("完成 %s 扫描 %s:%s (耗时: %.2fs)", + Common.LogBase(fmt.Sprintf("完成 %s 扫描 %s:%s (耗时: %.2fs)", pluginName, target.Host, target.Ports, duration.Seconds())) } @@ -217,7 +217,7 @@ func scheduleScanTask(pluginName string, target Common.HostInfo, ch *chan struct func executeSingleScan(pluginName string, info Common.HostInfo) { plugin, exists := Common.PluginManager[pluginName] if !exists { - Common.LogInfo(fmt.Sprintf("扫描类型 %v 无对应插件,已跳过", pluginName)) + Common.LogBase(fmt.Sprintf("扫描类型 %v 无对应插件,已跳过", pluginName)) return } diff --git a/Core/ServiceScanner.go b/Core/ServiceScanner.go index cef839e..e3cbc64 100644 --- a/Core/ServiceScanner.go +++ b/Core/ServiceScanner.go @@ -46,7 +46,7 @@ func (s *ServiceScanStrategy) Execute(info Common.HostInfo, ch *chan struct{}, w return } - Common.LogInfo("开始主机扫描") + Common.LogBase("开始主机扫描") // 输出插件信息 s.LogPluginInfo() @@ -64,7 +64,7 @@ func (s *ServiceScanStrategy) performHostScan(hosts []string, info Common.HostIn // 主机存活检测 if s.shouldPerformLivenessCheck(hosts) { hosts = CheckLive(hosts, Common.UsePing) - Common.LogInfo(fmt.Sprintf("存活主机数量: %d", len(hosts))) + Common.LogBase(fmt.Sprintf("存活主机数量: %d", len(hosts))) } // 端口扫描 @@ -76,7 +76,7 @@ func (s *ServiceScanStrategy) performHostScan(hosts []string, info Common.HostIn // 执行漏洞扫描 if len(targetInfos) > 0 { - Common.LogInfo("开始漏洞扫描") + Common.LogBase("开始漏洞扫描") ExecuteScanTasks(targetInfos, s, ch, wg) } } @@ -93,7 +93,7 @@ func (s *ServiceScanStrategy) discoverAlivePorts(hosts []string) []string { // 根据扫描模式选择端口扫描方式 if len(hosts) > 0 { alivePorts = EnhancedPortScan(hosts, Common.Ports, Common.Timeout) - Common.LogInfo(fmt.Sprintf("存活端口数量: %d", len(alivePorts))) + Common.LogBase(fmt.Sprintf("存活端口数量: %d", len(alivePorts))) } // 合并额外指定的端口 @@ -101,7 +101,7 @@ func (s *ServiceScanStrategy) discoverAlivePorts(hosts []string) []string { alivePorts = append(alivePorts, Common.HostPort...) alivePorts = Common.RemoveDuplicate(alivePorts) Common.HostPort = nil - Common.LogInfo(fmt.Sprintf("存活端口数量: %d", len(alivePorts))) + Common.LogBase(fmt.Sprintf("存活端口数量: %d", len(alivePorts))) } return alivePorts @@ -176,7 +176,7 @@ func (s *ServiceScanStrategy) LogPluginInfo() { // 如果是自定义模式,直接显示用户指定的插件 if isCustomMode { - Common.LogInfo(fmt.Sprintf("使用指定插件: %s", strings.Join(allPlugins, ", "))) + Common.LogBase(fmt.Sprintf("使用指定插件: %s", strings.Join(allPlugins, ", "))) return } @@ -190,9 +190,9 @@ func (s *ServiceScanStrategy) LogPluginInfo() { } if len(applicablePlugins) > 0 { - Common.LogInfo(fmt.Sprintf("使用服务插件: %s", strings.Join(applicablePlugins, ", "))) + Common.LogBase(fmt.Sprintf("使用服务插件: %s", strings.Join(applicablePlugins, ", "))) } else { - Common.LogInfo("未找到可用的服务插件") + Common.LogBase("未找到可用的服务插件") } } diff --git a/Core/WebScanner.go b/Core/WebScanner.go index d825765..92e33a2 100644 --- a/Core/WebScanner.go +++ b/Core/WebScanner.go @@ -27,7 +27,7 @@ func (s *WebScanStrategy) Description() string { // Execute 执行Web扫描策略 func (s *WebScanStrategy) Execute(info Common.HostInfo, ch *chan struct{}, wg *sync.WaitGroup) { - Common.LogInfo("开始Web扫描") + Common.LogBase("开始Web扫描") // 验证插件配置 if err := validateScanPlugins(); err != nil { @@ -94,7 +94,7 @@ func (s *WebScanStrategy) LogPluginInfo() { // 如果是自定义模式,直接显示用户指定的插件 if isCustomMode { - Common.LogInfo(fmt.Sprintf("Web扫描模式: 使用指定插件: %s", strings.Join(allPlugins, ", "))) + Common.LogBase(fmt.Sprintf("Web扫描模式: 使用指定插件: %s", strings.Join(allPlugins, ", "))) return } @@ -108,9 +108,9 @@ func (s *WebScanStrategy) LogPluginInfo() { } if len(applicablePlugins) > 0 { - Common.LogInfo(fmt.Sprintf("Web扫描模式: 使用Web插件: %s", strings.Join(applicablePlugins, ", "))) + Common.LogBase(fmt.Sprintf("Web扫描模式: 使用Web插件: %s", strings.Join(applicablePlugins, ", "))) } else { - Common.LogInfo("Web扫描模式: 未找到可用的Web插件") + Common.LogBase("Web扫描模式: 未找到可用的Web插件") } } diff --git a/Core/nmap-service-probes.txt b/Core/nmap-service-probes.txt index a503108..b565155 100644 --- a/Core/nmap-service-probes.txt +++ b/Core/nmap-service-probes.txt @@ -7401,9 +7401,9 @@ match http m|^HTTP/1\.[01] \d\d\d.*