mirror of
https://github.com/shadow1ng/fscan.git
synced 2026-02-09 02:09:17 +08:00
合并dev。变动太大吗,又得重新优化输出,进度50%。rpc服务冲突,暂时删除
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user