Skip to content

Commit

Permalink
feat: add phone, email, google options
Browse files Browse the repository at this point in the history
Made improvement
- add phone, email options(-p, -e)
- add google options(-g)
- update README
  • Loading branch information
piaolin committed May 7, 2023
1 parent 7616e21 commit 2688491
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 34 deletions.
40 changes: 30 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. [email protected],[email protected]
-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
Expand All @@ -61,6 +66,21 @@ To search for more than one user:
./DetectDee detect -n piaolin,blue
```

To search for email:
```shell
./DetectDee detect -e [email protected],[email protected]
```

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
Expand Down
39 changes: 29 additions & 10 deletions README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. [email protected],[email protected]
-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
Expand All @@ -57,6 +62,20 @@ Global Flags:
```shell
./DetectDee detect -n piaolin,blue
```
邮箱搜索:
```shell
./DetectDee detect -e [email protected],[email protected]
```

电话搜索:
```shell
./DetectDee detect -p 15822575984,13188524682
```

显示Google搜索(需要自行查看):
```shell
./DetectDee detect -n piaolin,blue -g
```

指定网站搜索:
```shell
Expand Down
56 changes: 42 additions & 14 deletions cmd/detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ type detectArgsType struct {
precisely bool
retry int
file string
google bool
email []string
phone []string
//unique bool
}

Expand All @@ -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. [email protected],[email protected]")
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)
Expand Down Expand Up @@ -104,17 +110,34 @@ 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)
}
}
}
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
Expand All @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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???")
}
Expand Down

0 comments on commit 2688491

Please sign in to comment.