From 33f2b361861299c3f248dadb341e6b1aa8d6f72d Mon Sep 17 00:00:00 2001 From: ZacharyZcR Date: Mon, 21 Jul 2025 02:24:28 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E6=B8=85=E7=90=86=E6=97=A0=E7=94=A8?= =?UTF-8?q?=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Common/Flag.go | 89 -------------------------------------------------- 1 file changed, 89 deletions(-) diff --git a/Common/Flag.go b/Common/Flag.go index a8d7625..bb45dd0 100644 --- a/Common/Flag.go +++ b/Common/Flag.go @@ -161,95 +161,6 @@ func Flag(Info *HostInfo) { SetLanguage() } -// FlagFormRemote 解析远程扫描的命令行参数 -func FlagFromRemote(info *HostInfo, argString string) error { - if strings.TrimSpace(argString) == "" { - return fmt.Errorf("参数为空") - } - - args, err := parseEnvironmentArgs(argString) - if err != nil { - return fmt.Errorf("远程参数解析失败: %v", err) - } - - // 创建一个新的 FlagSet 用于远程参数解析,避免污染主命令行 - fs := flag.NewFlagSet("remote", flag.ContinueOnError) - - // 注册需要的远程 flag,注意使用 fs 而非 flag 包的全局变量 - fs.StringVar(&info.Host, "h", "", GetText("flag_host")) - fs.StringVar(&ExcludeHosts, "eh", "", GetText("flag_exclude_hosts")) - fs.StringVar(&Ports, "p", MainPorts, GetText("flag_ports")) - fs.StringVar(&ExcludePorts, "ep", "", GetText("flag_exclude_ports")) - fs.StringVar(&HostsFile, "hf", "", GetText("flag_hosts_file")) - fs.StringVar(&PortsFile, "pf", "", GetText("flag_ports_file")) - - fs.StringVar(&ScanMode, "m", "all", GetText("flag_scan_mode")) - fs.IntVar(&ThreadNum, "t", 10, GetText("flag_thread_num")) - fs.Int64Var(&Timeout, "time", 3, GetText("flag_timeout")) - fs.IntVar(&ModuleThreadNum, "mt", 10, GetText("flag_module_thread_num")) - fs.Int64Var(&GlobalTimeout, "gt", 180, GetText("flag_global_timeout")) - fs.IntVar(&LiveTop, "top", 10, GetText("flag_live_top")) - fs.BoolVar(&DisablePing, "np", false, GetText("flag_disable_ping")) - fs.BoolVar(&UsePing, "ping", false, GetText("flag_use_ping")) - fs.BoolVar(&EnableFingerprint, "fingerprint", false, GetText("flag_enable_fingerprint")) - fs.BoolVar(&LocalMode, "local", false, GetText("flag_local_mode")) - - fs.StringVar(&Username, "user", "", GetText("flag_username")) - fs.StringVar(&Password, "pwd", "", GetText("flag_password")) - fs.StringVar(&AddUsers, "usera", "", GetText("flag_add_users")) - fs.StringVar(&AddPasswords, "pwda", "", GetText("flag_add_passwords")) - fs.StringVar(&UsersFile, "userf", "", GetText("flag_users_file")) - fs.StringVar(&PasswordsFile, "pwdf", "", GetText("flag_passwords_file")) - fs.StringVar(&HashFile, "hashf", "", GetText("flag_hash_file")) - fs.StringVar(&HashValue, "hash", "", GetText("flag_hash_value")) - fs.StringVar(&Domain, "domain", "", GetText("flag_domain")) - fs.StringVar(&SshKeyPath, "sshkey", "", GetText("flag_ssh_key")) - - fs.StringVar(&TargetURL, "u", "", GetText("flag_target_url")) - fs.StringVar(&URLsFile, "uf", "", GetText("flag_urls_file")) - fs.StringVar(&Cookie, "cookie", "", GetText("flag_cookie")) - fs.Int64Var(&WebTimeout, "wt", 5, GetText("flag_web_timeout")) - fs.StringVar(&HttpProxy, "proxy", "", GetText("flag_http_proxy")) - fs.StringVar(&Socks5Proxy, "socks5", "", GetText("flag_socks5_proxy")) - - fs.StringVar(&PocPath, "pocpath", "", GetText("flag_poc_path")) - fs.StringVar(&Pocinfo.PocName, "pocname", "", GetText("flag_poc_name")) - fs.BoolVar(&PocFull, "full", false, GetText("flag_poc_full")) - fs.BoolVar(&DnsLog, "dns", false, GetText("flag_dns_log")) - fs.IntVar(&PocNum, "num", 20, GetText("flag_poc_num")) - fs.BoolVar(&DisablePocScan, "nopoc", false, GetText("flag_no_poc")) - - fs.StringVar(&RedisFile, "rf", "", GetText("flag_redis_file")) - fs.StringVar(&RedisShell, "rs", "", GetText("flag_redis_shell")) - fs.BoolVar(&DisableRedis, "noredis", false, GetText("flag_disable_redis")) - fs.StringVar(&RedisWritePath, "rwp", "", GetText("flag_redis_write_path")) - fs.StringVar(&RedisWriteContent, "rwc", "", GetText("flag_redis_write_content")) - fs.StringVar(&RedisWriteFile, "rwf", "", GetText("flag_redis_write_file")) - - fs.BoolVar(&DisableBrute, "nobr", false, GetText("flag_disable_brute")) - fs.IntVar(&MaxRetries, "retry", 3, GetText("flag_max_retries")) - - fs.StringVar(&Outputfile, "o", "result.txt", GetText("flag_output_file")) - fs.StringVar(&OutputFormat, "f", "txt", GetText("flag_output_format")) - fs.BoolVar(&DisableSave, "no", false, GetText("flag_disable_save")) - fs.BoolVar(&Silent, "silent", false, GetText("flag_silent_mode")) - fs.BoolVar(&NoColor, "nocolor", false, GetText("flag_no_color")) - fs.StringVar(&LogLevel, "log", LogLevelSuccess, GetText("flag_log_level")) - fs.BoolVar(&ShowProgress, "pg", false, GetText("flag_show_progress")) - fs.BoolVar(&ShowScanPlan, "sp", false, GetText("flag_show_scan_plan")) - fs.BoolVar(&SlowLogOutput, "slow", false, GetText("flag_slow_log_output")) - - fs.StringVar(&Shellcode, "sc", "", GetText("flag_shellcode")) - fs.StringVar(&Language, "lang", "zh", GetText("flag_language")) - - // 开始解析远程传入的参数 - if err := fs.Parse(args); err != nil { - return fmt.Errorf("远程参数解析失败: %v", err) - } - - return nil -} - // parseCommandLineArgs 处理来自环境变量和命令行的参数 func parseCommandLineArgs() { // 首先检查环境变量中的参数