mirror of
https://github.com/shadow1ng/fscan.git
synced 2026-02-09 02:09:17 +08:00
refactor: 调整扫描逻辑
This commit is contained in:
@@ -886,9 +886,6 @@ var (
|
||||
Command string
|
||||
SkipFingerprint bool
|
||||
|
||||
// 本地扫描配置
|
||||
LocalScan bool
|
||||
|
||||
// 文件配置
|
||||
HostsFile string // 原HostFile
|
||||
UsersFile string // 原Userfile
|
||||
@@ -897,6 +894,8 @@ var (
|
||||
PortsFile string // 原PortFile
|
||||
|
||||
// Web配置
|
||||
TargetURL string // 原URL
|
||||
URLsFile string // 原UrlFile
|
||||
URLs []string // 原Urls
|
||||
WebTimeout int64 = 5
|
||||
HttpProxy string // 原Proxy
|
||||
|
||||
@@ -200,9 +200,6 @@ func Flag(Info *HostInfo) {
|
||||
flag.StringVar(&Command, "c", "", "指定要执行的系统命令(支持ssh和wmiexec)")
|
||||
flag.BoolVar(&SkipFingerprint, "skip", false, "跳过端口指纹识别")
|
||||
|
||||
// 本地扫描配置
|
||||
flag.BoolVar(&LocalScan, "local", false, "启用本地扫描模式")
|
||||
|
||||
// 文件配置
|
||||
flag.StringVar(&HostsFile, "hf", "", "从文件中读取目标主机列表")
|
||||
flag.StringVar(&UsersFile, "userf", "", "从文件中读取用户名字典")
|
||||
@@ -211,6 +208,8 @@ func Flag(Info *HostInfo) {
|
||||
flag.StringVar(&PortsFile, "portf", "", "从文件中读取端口列表")
|
||||
|
||||
// Web配置
|
||||
flag.StringVar(&TargetURL, "u", "", "指定目标URL")
|
||||
flag.StringVar(&URLsFile, "uf", "", "从文件中读取URL列表")
|
||||
flag.StringVar(&Cookie, "cookie", "", "设置HTTP请求Cookie")
|
||||
flag.Int64Var(&WebTimeout, "wt", 5, "设置Web请求超时时间(单位:秒)")
|
||||
flag.StringVar(&HttpProxy, "proxy", "", "设置HTTP代理服务器")
|
||||
|
||||
@@ -3,7 +3,6 @@ package Common
|
||||
import (
|
||||
"bufio"
|
||||
"encoding/hex"
|
||||
"flag"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"os"
|
||||
@@ -114,6 +113,40 @@ func ParsePass(Info *HostInfo) error {
|
||||
LogInfo(fmt.Sprintf("加载有效哈希值: %d 个", validCount))
|
||||
}
|
||||
|
||||
// 处理直接指定的URL列表
|
||||
if TargetURL != "" {
|
||||
urls := strings.Split(TargetURL, ",")
|
||||
tmpUrls := make(map[string]struct{})
|
||||
for _, url := range urls {
|
||||
if url != "" {
|
||||
if _, ok := tmpUrls[url]; !ok {
|
||||
tmpUrls[url] = struct{}{}
|
||||
URLs = append(URLs, url)
|
||||
}
|
||||
}
|
||||
}
|
||||
LogInfo(fmt.Sprintf("加载URL: %d 个", len(URLs)))
|
||||
}
|
||||
|
||||
// 从文件加载URL列表
|
||||
if URLsFile != "" {
|
||||
urls, err := Readfile(URLsFile)
|
||||
if err != nil {
|
||||
return fmt.Errorf("读取URL文件失败: %v", err)
|
||||
}
|
||||
|
||||
tmpUrls := make(map[string]struct{})
|
||||
for _, url := range urls {
|
||||
if url != "" {
|
||||
if _, ok := tmpUrls[url]; !ok {
|
||||
tmpUrls[url] = struct{}{}
|
||||
URLs = append(URLs, url)
|
||||
}
|
||||
}
|
||||
}
|
||||
LogInfo(fmt.Sprintf("从文件加载URL: %d 个", len(urls)))
|
||||
}
|
||||
|
||||
// 从文件加载端口列表
|
||||
if PortsFile != "" {
|
||||
ports, err := Readfile(PortsFile)
|
||||
@@ -171,16 +204,9 @@ func Readfile(filename string) ([]string, error) {
|
||||
|
||||
// ParseInput 解析和验证输入参数配置
|
||||
func ParseInput(Info *HostInfo) error {
|
||||
// 检查必要的目标参数
|
||||
if Info.Host == "" && HostsFile == "" {
|
||||
LogError("未指定扫描目标")
|
||||
flag.Usage()
|
||||
return fmt.Errorf("必须指定扫描目标")
|
||||
}
|
||||
|
||||
// 如果是本地扫描模式,输出提示
|
||||
if LocalScan {
|
||||
LogInfo("已启用本地扫描模式")
|
||||
// 所有目标参数为空时表示本地扫描模式
|
||||
if Info.Host == "" && HostsFile == "" && TargetURL == "" && URLsFile == "" {
|
||||
LogInfo("未指定扫描目标,将以本地模式运行")
|
||||
}
|
||||
|
||||
// 配置基本参数
|
||||
|
||||
@@ -18,7 +18,7 @@ const (
|
||||
// 插件分类映射表 - 所有插件名使用小写
|
||||
var pluginGroups = map[string][]string{
|
||||
ModeAll: {
|
||||
"webtitle", "webpoc", "fcgi", // web类
|
||||
"webtitle", "webpoc", // web类
|
||||
"mysql", "mssql", "redis", "mongodb", "postgres", // 数据库类
|
||||
"oracle", "memcached", "elasticsearch", "rabbitmq", "kafka", "activemq", "cassandra", "neo4j", // 数据库类
|
||||
"ftp", "ssh", "telnet", "smb", "rdp", "vnc", "netbios", "ldap", "smtp", "imap", "pop3", "snmp", "modbus", "rsync", // 服务类
|
||||
@@ -33,7 +33,7 @@ var pluginGroups = map[string][]string{
|
||||
"postgres", "oracle", "memcached", "elasticsearch", "rabbitmq", "kafka", "activemq", "cassandra", "neo4j",
|
||||
},
|
||||
ModeWeb: {
|
||||
"webtitle", "webpoc", "fcgi",
|
||||
"webtitle", "webpoc",
|
||||
},
|
||||
ModeService: {
|
||||
"ftp", "ssh", "telnet", "smb", "rdp", "vnc", "netbios", "ldap", "smtp", "imap", "pop3", "modbus", "rsync",
|
||||
|
||||
Reference in New Issue
Block a user