From aab443d3973dd9da924a1d713fff4f2b501ed351 Mon Sep 17 00:00:00 2001 From: M4rtin Hsu Date: Wed, 20 Dec 2023 15:11:10 +0800 Subject: [PATCH] Remove fofa email field --- internal/cli/parser.go | 14 +++++++------- internal/cli/update.go | 6 +++--- internal/fofa/fofa_api.go | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/internal/cli/parser.go b/internal/cli/parser.go index ca4af4d..77af1a6 100644 --- a/internal/cli/parser.go +++ b/internal/cli/parser.go @@ -95,8 +95,8 @@ type config struct { // fofa 地址 FoFaURL string FoFaOpenURL string - FoFaEmail string - FoFaKey string + // FoFaEmail string + FoFaKey string // 脱敏密码 FoFaKeyFake string Proxy string @@ -127,7 +127,7 @@ var ( func initOptions() { rand.Seed(time.Now().UnixNano()) args = new(Options) - args.FoFaEmail = os.Getenv("FOFA_EMAIL") + // args.FoFaEmail = os.Getenv("FOFA_EMAIL") args.FoFaKey = utils.HiddenUrlKey(false, os.Getenv("FOFA_KEY")) args.FoFaKeyFake = os.Getenv("FOFA_KEY") args.FoFaURL = "https://fofa.info" @@ -145,7 +145,7 @@ func init() { flags.StringVar(&args.ConfigFile, "config", args.ConfigFile, "fofax configuration file.The file reading order("+strings.Join(utils.ConfDefaultPath, ",")+")") createGroup( flags, "config", "CONFIGS", - flags.StringVarP(&args.FoFaEmail, "fofa-email", "email", args.FoFaEmail, "Fofa API Email"), + // flags.StringVarP(&args.FoFaEmail, "fofa-email", "email", args.FoFaEmail, "Fofa API Email"), flags.StringVarP(&args.FoFaKey, "fofakey", "key", args.FoFaKey, "Fofa API Key"), flags.StringVarP(&args.Proxy, "proxy", "p", "", "proxy for http like http://127.0.0.1:8080"), flags.StringVar(&args.FoFaURL, "fofa-url", args.FoFaURL, "Fofa api url"), @@ -396,10 +396,10 @@ func checkMutFlags() error { return nil } -// 检查 email,key +// 检查 key func checkFoFaInfo() { - if args.FoFaKey == "" || args.FoFaEmail == "" { - printer.Error("FoFaKey or FoFaEmail is empty") + if args.FoFaKey == "" { + printer.Error("FoFaKey is empty") os.Exit(1) } } diff --git a/internal/cli/update.go b/internal/cli/update.go index e339732..f160266 100644 --- a/internal/cli/update.go +++ b/internal/cli/update.go @@ -22,13 +22,13 @@ func updateTips(tagName string) error { return nil } latest, err := updateFoFaXVersionToLatest() + if err != nil { + return err + } if latest == nil { return errors.New("latest version is nil") } - if err != nil { - return err - } if !args.Update { bannerSite(fmt.Sprintf("New:\n\nVersion:%s\n\n%s\n", latest.Version, latest.Notes)) bannerSite("Please Use [./fofax -update] to download\n\n") diff --git a/internal/fofa/fofa_api.go b/internal/fofa/fofa_api.go index 5284d2e..1907c6c 100644 --- a/internal/fofa/fofa_api.go +++ b/internal/fofa/fofa_api.go @@ -75,8 +75,8 @@ func (f *FoFa) fetchByFields(fields string, queryStr string) bool { isOptionsArgs += "&full=true" } uri := fmt.Sprintf( - "/api/v1/search/all?email=%s&key=%s%s&qbase64=%s&size=%d&page=%d&fields=%s", - f.option.FoFaEmail, f.option.FoFaKey, isOptionsArgs, + "/api/v1/search/all?key=%s%s&qbase64=%s&size=%d&page=%d&fields=%s", + f.option.FoFaKey, isOptionsArgs, base64.StdEncoding.EncodeToString([]byte(queryStr)), perPage, f.page,