From 2688491028baff49f82ea62c19175e7fa02d0774 Mon Sep 17 00:00:00 2001 From: lxy <1418676300@qq.com> Date: Sat, 6 May 2023 20:52:28 -0700 Subject: [PATCH] feat: add phone, email, google options Made improvement - add phone, email options(-p, -e) - add google options(-g) - update README --- README.md | 40 +++++++++++++++++++++++++++--------- README_ZH.md | 39 ++++++++++++++++++++++++++--------- cmd/detect.go | 56 ++++++++++++++++++++++++++++++++++++++------------- 3 files changed, 101 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 0ba5299..19b311d 100644 --- a/README.md +++ b/README.md @@ -30,16 +30,21 @@ Usage: DetectDee detect [flags] Flags: - -c, --check self-check - -f, --file string Site data file (default "data.json") - -h, --help help for detect - -n, --name strings name[s] - --nsfw Include checking of NSFW sites from default list. - --precisely Check precisely - -p, --proxy string Make requests over a proxy. e.g. socks5://127.0.0.1:1080 - -r, --retry int Retry times after request failed (default 3) - -s, --site strings Limit analysis to just the listed sites. Add multiple options to specify more than one site. - -t, --timeout int Time (in seconds) to wait for response to requests (default 10) + -c, --check self-check + -e, --email strings email[s], e.g. mail@gmail.com,45715485@qq.com + -f, --file string Site data file (default "data.json") + -g, --google Show google search result + -h, --help help for detect + -n, --name strings name[s], e.g. piaolin,poq79,SomeOneYouLike + --nsfw Include checking of NSFW sites from default list. + -p, --phone strings phone[s], e.g. 15725753684,13575558962 + --precisely Check precisely + --proxy string Make requests over a proxy. e.g. socks5://127.0.0.1:1080 + -r, --retry int Retry times after request failed (default 3) + -s, --site strings Limit analysis to just the listed sites. Add multiple op +tions to specify more than one site. + -t, --timeout int Time (in seconds) to wait for response to requests (defa +ult 10) Global Flags: -v, --verbose verbose output @@ -61,6 +66,21 @@ To search for more than one user: ./DetectDee detect -n piaolin,blue ``` +To search for email: +```shell +./DetectDee detect -e mail@gmail.com,test@163.com +``` + +To search for phone: +```shell +./DetectDee detect -p 15822575984,13188524682 +``` + +Show google search(please check yourself): +```shell +./DetectDee detect -n piaolin,blue -g +``` + To search in specified site: ```shell ./DetectDee detect -n piaolin -s github,v2ex diff --git a/README_ZH.md b/README_ZH.md index 3bc6951..69d9ea5 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -28,16 +28,21 @@ Usage: DetectDee detect [flags] Flags: - -c, --check self-check - -f, --file string Site data file (default "data.json") - -h, --help help for detect - -n, --name strings name[s] - --nsfw Include checking of NSFW sites from default list. - --precisely Check precisely - -p, --proxy string Make requests over a proxy. e.g. socks5://127.0.0.1:1080 - -r, --retry int Retry times after request failed (default 3) - -s, --site strings Limit analysis to just the listed sites. Add multiple options to specify more than one site. - -t, --timeout int Time (in seconds) to wait for response to requests (default 10) + -c, --check self-check + -e, --email strings email[s], e.g. mail@gmail.com,45715485@qq.com + -f, --file string Site data file (default "data.json") + -g, --google Show google search result + -h, --help help for detect + -n, --name strings name[s], e.g. piaolin,poq79,SomeOneYouLike + --nsfw Include checking of NSFW sites from default list. + -p, --phone strings phone[s], e.g. 15725753684,13575558962 + --precisely Check precisely + --proxy string Make requests over a proxy. e.g. socks5://127.0.0.1:1080 + -r, --retry int Retry times after request failed (default 3) + -s, --site strings Limit analysis to just the listed sites. Add multiple op +tions to specify more than one site. + -t, --timeout int Time (in seconds) to wait for response to requests (defa +ult 10) Global Flags: -v, --verbose verbose output @@ -57,6 +62,20 @@ Global Flags: ```shell ./DetectDee detect -n piaolin,blue ``` +邮箱搜索: +```shell +./DetectDee detect -e mail@gmail.com,test@163.com +``` + +电话搜索: +```shell +./DetectDee detect -p 15822575984,13188524682 +``` + +显示Google搜索(需要自行查看): +```shell +./DetectDee detect -n piaolin,blue -g +``` 指定网站搜索: ```shell diff --git a/cmd/detect.go b/cmd/detect.go index a0271fb..b9e4d74 100644 --- a/cmd/detect.go +++ b/cmd/detect.go @@ -24,6 +24,9 @@ type detectArgsType struct { precisely bool retry int file string + google bool + email []string + phone []string //unique bool } @@ -42,16 +45,19 @@ var ( ) func init() { - detectCmd.Flags().StringSliceVarP(&detectArgs.name, "name", "n", []string{}, "name[s]") + detectCmd.Flags().StringSliceVarP(&detectArgs.name, "name", "n", []string{}, "name[s], e.g. piaolin,poq79,SomeOneYouLike") + detectCmd.Flags().StringSliceVarP(&detectArgs.email, "email", "e", []string{}, "email[s], e.g. mail@gmail.com,45715485@qq.com") + detectCmd.Flags().StringSliceVarP(&detectArgs.phone, "phone", "p", []string{}, "phone[s], e.g. 15725753684,13575558962") //_ = detectCmd.MarkFlagRequired("name") detectCmd.Flags().StringSliceVarP(&detectArgs.site, "site", "s", []string{}, "Limit analysis to just the listed sites. Add multiple options to specify more than one site.") detectCmd.Flags().BoolVarP(&detectArgs.check, "check", "c", false, "self-check") - detectCmd.Flags().StringVarP(&detectArgs.proxy, "proxy", "p", "", "Make requests over a proxy. e.g. socks5://127.0.0.1:1080") + detectCmd.Flags().StringVar(&detectArgs.proxy, "proxy", "", "Make requests over a proxy. e.g. socks5://127.0.0.1:1080") detectCmd.Flags().IntVarP(&detectArgs.timeout, "timeout", "t", 10, "Time (in seconds) to wait for response to requests") detectCmd.Flags().BoolVar(&detectArgs.isNSFW, "nsfw", false, "Include checking of NSFW sites from default list.") detectCmd.Flags().IntVarP(&detectArgs.retry, "retry", "r", 3, "Retry times after request failed") detectCmd.Flags().BoolVar(&detectArgs.precisely, "precisely", false, "Check precisely") detectCmd.Flags().StringVarP(&detectArgs.file, "file", "f", "data.json", "Site data file") + detectCmd.Flags().BoolVarP(&detectArgs.google, "google", "g", false, "Show google search result") //detectCmd.Flags().BoolVar(&detectArgs.unique, "unique", false, "Make new requests client for each site") rootCmd.AddCommand(detectCmd) @@ -104,9 +110,26 @@ func detect(_ *cobra.Command, _ []string) { if detectArgs.check { log.Infoln("self check") } else { + // detect by name for _, name := range detectArgs.name { for site, siteBody := range siteDataMap { - go detectSite(name, site, siteBody) + go detectSite(name, site, "username", siteBody) + wg.Add(1) + } + } + + // detect by email + for _, email := range detectArgs.email { + for site, siteBody := range siteDataMap { + go detectSite(email, site, "email", siteBody) + wg.Add(1) + } + } + + // detect by phone + for _, phone := range detectArgs.phone { + for site, siteBody := range siteDataMap { + go detectSite(phone, site, "phone", siteBody) wg.Add(1) } } @@ -114,7 +137,7 @@ func detect(_ *cobra.Command, _ []string) { wg.Wait() } -func detectSite(name, site string, siteBody gjson.Result) { +func detectSite(name, site, nameType string, siteBody gjson.Result) { defer wg.Done() // flag for precisely mode @@ -126,7 +149,7 @@ func detectSite(name, site string, siteBody gjson.Result) { } // Check name - if nameCheck := siteBody.Get("nameCheck"); nameCheck.Exists() && len(nameCheck.Str) != 0 { + if nameCheck := siteBody.Get("nameCheck"); nameCheck.Exists() && len(nameCheck.Str) != 0 && nameType == "username" { match, err := regexp.MatchString(nameCheck.String(), name) if err != nil { log.Fatalln(err) @@ -143,12 +166,25 @@ func detectSite(name, site string, siteBody gjson.Result) { detectCount := len(detectReq) - 1 for index, detectData := range detectReq { + // check status if status := detectData.Get("status"); status.Exists() && !status.Bool() { log.Debugf(disableSiteInfo, name, site, site) break } retryTimes := 0 - if detectUser(name, site, index, retryTimes, detectCount, &flag, detectData) { + + if search := detectData.Get("search"); search.Exists() { + // google options + if detectArgs.google { + searchString := search.String() + if strings.Contains(searchString, "%s") { + searchString = fmt.Sprintf(searchString, name) + } + searchUrl := fmt.Sprintf(detectData.Get("searchUrl").String(), searchString) + log.Infof(searchInfo, name, site, searchUrl) + break + } + } else if strings.Contains(detectData.Get("type").String(), nameType) && detectUser(name, site, index, retryTimes, detectCount, &flag, detectData) { continue } else { break @@ -189,14 +225,6 @@ func detectUser(name, site string, requestTimes, retryTimes, detectCount int, fl if strings.Contains(url, "%s") { url = fmt.Sprintf(url, name) } - } else if search := detectData.Get("search"); search.Exists() { - searchString := search.String() - if strings.Contains(searchString, "%s") { - searchString = fmt.Sprintf(searchString, name) - } - searchUrl := fmt.Sprintf(detectData.Get("searchUrl").String(), searchString) - log.Infof(searchInfo, name, site, searchUrl) - return false } else { log.Fatalln("Why no URL???") }