Skip to content

Commit

Permalink
Merge pull request #25 from piaolin/dev
Browse files Browse the repository at this point in the history
feat: output statistics of the country to which the registered website belongs
  • Loading branch information
piaolin authored May 27, 2023
2 parents 8117f8d + d54e530 commit 4e9625a
Show file tree
Hide file tree
Showing 7 changed files with 1,232 additions and 24 deletions.
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<font color="red">*Disclaimer: This article and this tool are for technical discussion and sharing only. Illegal use is strictly prohibited.</font>

DetectDee: Hunt down social media accounts by **username, email or phone** across [social networks](site.md)
![example.gif](https://s2.loli.net/2023/04/30/FZ1QtKoGud4xVPW.gif)
![example.gif](https://s2.loli.net/2023/05/28/gpxRJqvWr21Ifmh.gif)
![screen.jpg](https://s2.loli.net/2023/05/13/XzV4EGKrbkURHQg.jpg)
## Feat
- Includes sites frequently used by **CyberSecurity practitioners**
Expand All @@ -27,6 +27,8 @@ go run .
[中文文档](README_ZH.md)
### Detect
```text
Hunt down social media accounts by username, email or phone across social networks
Usage:
DetectDee detect [flags]
Expand All @@ -37,15 +39,15 @@ Flags:
-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.
--nsfw Include checking of NSFW sites from default list.
-o, --output string Result file (default "result.txt")
-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)
-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)
--token string chatgpt api token
Global Flags:
-v, --verbose verbose output
Expand All @@ -67,6 +69,11 @@ To search for more than one user:
./DetectDee detect -n piaolin,blue
```

To search for more than one user and use ChatGPT for user tagging of results(need ChatGPT token):
```shell
./DetectDee detect -n piaolin,blue --token {ChatGPT Token}
```

To search for email:
```shell
./DetectDee detect -e [email protected],[email protected]
Expand Down
20 changes: 14 additions & 6 deletions README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<font color="red">*严正声明:本文与本工具仅限于技术讨论与分享,严禁用于非法途径。</font>

神探狄仁杰: 在[社交网络](site.md)上通过**用户名,电子邮件或电话**搜索社交媒体账户
![example.gif](https://s2.loli.net/2023/04/30/FZ1QtKoGud4xVPW.gif)
![example.gif](https://s2.loli.net/2023/05/28/gpxRJqvWr21Ifmh.gif)
![screen.jpg](https://s2.loli.net/2023/05/13/XzV4EGKrbkURHQg.jpg)
## 特性
- 集成**网络安全从业者**常用网站
Expand All @@ -25,6 +25,8 @@ go run .
[中文文档](README_ZH.md)
### 探测
```text
Hunt down social media accounts by username, email or phone across social networks
Usage:
DetectDee detect [flags]
Expand All @@ -35,15 +37,15 @@ Flags:
-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.
--nsfw Include checking of NSFW sites from default list.
-o, --output string Result file (default "result.txt")
-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)
-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)
--token string chatgpt api token
Global Flags:
-v, --verbose verbose output
Expand All @@ -63,6 +65,12 @@ Global Flags:
```shell
./DetectDee detect -n piaolin,blue
```

多用户名搜索,并使用ChatGPT对结果进行用户画像(需要ChatGPT Token):
```shell
./DetectDee detect -n piaolin,blue --token {ChatGPT Token}
```

邮箱搜索:
```shell
./DetectDee detect -e [email protected],[email protected]
Expand Down
100 changes: 97 additions & 3 deletions cmd/detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/tidwall/gjson"
"io/ioutil"
"regexp"
"sort"
"strings"
"sync"
"time"
Expand All @@ -29,6 +30,7 @@ type detectArgsType struct {
phone []string
output string
//unique bool
token string
}

var (
Expand All @@ -47,6 +49,9 @@ var (
nsfwInfo = "[!] %-15s %-15s: %s is nsfw\n"
writeContent = make(chan string)
writeDone = make(chan bool)
whoisMap sync.Map
detectResultMap sync.Map
chatgptUserLabel = "[+] %s ChatgptUserLabel: %s\n"
)

func init() {
Expand All @@ -64,6 +69,7 @@ func init() {
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().StringVarP(&detectArgs.output, "output", "o", "result.txt", "Result file")
detectCmd.Flags().StringVar(&detectArgs.token, "token", "", "chatgpt api token")

//detectCmd.Flags().BoolVar(&detectArgs.unique, "unique", false, "Make new requests client for each site")
rootCmd.AddCommand(detectCmd)
Expand Down Expand Up @@ -114,8 +120,21 @@ func detect(_ *cobra.Command, _ []string) {
}
}

for _, v := range detectArgs.name {
whoisMap.Store(v, make(map[string]int))
detectResultMap.Store(v, make([][]string, 0))
}
for _, v := range detectArgs.email {
whoisMap.Store(v, make(map[string]int))
detectResultMap.Store(v, make([][]string, 0))
}
for _, v := range detectArgs.phone {
whoisMap.Store(v, make(map[string]int))
detectResultMap.Store(v, make([][]string, 0))
}

// set delay for each requests to site
for site, siteBody := range siteDataMap {
// set delay for each requests to site
sleepMap[site] = 0
if sleep := siteBody.Get("sleep"); sleep.Exists() && sleep.Value() != nil {
sleepMap[site] = sleep.Int()
Expand Down Expand Up @@ -154,6 +173,53 @@ func detect(_ *cobra.Command, _ []string) {

wg.Wait()
writeDone <- true

fmt.Println()

for _, name := range detectArgs.name {

type registrantCountry struct {
registrantCountry string
count int
}

tmpMap, _ := whoisMap.Load(name)
userWhoisMap, _ := tmpMap.(map[string]int)

var country []registrantCountry
for k, v := range userWhoisMap {
country = append(country, registrantCountry{k, v})
}

sort.Slice(country, func(i, j int) bool {
return country[i].count > country[j].count // 降序
})
log.Infof("[+] %s Registrant Country: %v", name, country)

}
//tmpList, _ := detectResultMap.Load("piaolin")
//userResultList, _ := tmpList.([][]string)
//log.Infoln(userResultList)

if detectArgs.token != "" {

for _, name := range detectArgs.name {
tmpList, _ := detectResultMap.Load(name)
userResultList, _ := tmpList.([][]string)
urls := ""
for _, v := range userResultList {
urls += v[2]
urls += ", "
}
userLabel, err := utils.ChatUserLabel(detectArgs.token, urls)
if err != nil {
log.Debugln("[-] ", err)
} else {
log.Infof(chatgptUserLabel, name, userLabel.Choices[0].Message.Content)
}
}
}

log.Infof(detectCompletedInfo, detectArgs.output)
}

Expand All @@ -163,6 +229,8 @@ func detectSite(name, site, nameType string, siteBody gjson.Result) {
// flag for precisely mode
flag := false

url := siteBody.Get("url").String()

if siteBody.Get("isNSFW").Bool() && !detectArgs.isNSFW {
log.Debugf(nsfwInfo, name, site, site)
return
Expand All @@ -181,6 +249,8 @@ func detectSite(name, site, nameType string, siteBody gjson.Result) {
}
}

whoisData := siteBody.Get("whois")

detectReq := siteBody.Get("detect").Array()

detectCount := len(detectReq) - 1
Expand All @@ -204,15 +274,15 @@ func detectSite(name, site, nameType string, siteBody gjson.Result) {
log.Infof(searchInfo, name, site, searchUrl)
break
}
} else if strings.Contains(detectData.Get("type").String(), nameType) && detectUser(name, site, index, retryTimes, detectCount, &flag, detectData) {
} else if strings.Contains(detectData.Get("type").String(), nameType) && detectUser(name, site, url, index, retryTimes, detectCount, &flag, detectData, whoisData) {
continue
} else {
break
}
}
}

func detectUser(name, site string, requestTimes, retryTimes, detectCount int, flag *bool, detectData gjson.Result) bool {
func detectUser(name, site, originalUrl string, requestTimes, retryTimes, detectCount int, flag *bool, detectData gjson.Result, whoisData gjson.Result) bool {

// set header
header := make(map[string]string)
Expand Down Expand Up @@ -321,14 +391,38 @@ func detectUser(name, site string, requestTimes, retryTimes, detectCount int, fl
} else if !detectArgs.precisely {
// flag=true && precisely=false
log.Infof(existInfo, name, site, userPage)
writeWhois(name, site, whoisData)
writeResult(name, site, originalUrl)
writeContent <- fmt.Sprintf(existOutputInfo, name, site, userPage)
return false
} else if requestTimes == detectCount {
// flag=true && precisely=true && last request
log.Infof(existInfo, name, site, userPage)
writeWhois(name, site, whoisData)
writeResult(name, site, originalUrl)
writeContent <- fmt.Sprintf(existOutputInfo, name, site, userPage)
return true
} else {
return true
}
}

func writeResult(name, site, url string) {
tmpList, _ := detectResultMap.Load(name)
userResultList, _ := tmpList.([][]string)
userResultList = append(userResultList, []string{name, site, url})
detectResultMap.Store(name, userResultList)
}

func writeWhois(name, site string, whoisData gjson.Result) {
tmpMap, _ := whoisMap.Load(name)
userWhoisMap, _ := tmpMap.(map[string]int)

registrantCountry := whoisData.Get("RegistrantCountry").String()
if _, ok := userWhoisMap[registrantCountry]; ok {
userWhoisMap[registrantCountry] += 1
} else {
userWhoisMap[registrantCountry] = 1
}

}
Loading

0 comments on commit 4e9625a

Please sign in to comment.