-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
97 lines (81 loc) · 1.98 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package main
import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"net/http"
"os"
"strings"
"sync"
"time"
)
type InputData struct {
License []string `json:"license"`
Authors []string `json:"authors"`
Categories []string `json:"categories"`
Sites []Site `json:"sites"`
}
type Site struct {
Name string `json:"name"`
URL string `json:"uri_check"`
ExistsCode int `json:"e_code"`
ExistsString string `json:"e_string"`
MissingCode int `json:"m_code"`
MissingString string `json:"m_string"`
Known []string `json:"known"`
Category string `json:"cat"`
Valid bool `json:"valid"`
}
const inputData = "https://raw.githubusercontent.com/WebBreacher/WhatsMyName/main/wmn-data.json"
const usage = "Usage: usersearch -u <username>"
func main() {
username := flag.String("u", "", "Username")
flag.Parse()
if *username == "" {
fmt.Println(usage)
os.Exit(1)
}
response, err := http.Get(inputData)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
body, err := ioutil.ReadAll(response.Body)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
var data InputData
err = json.Unmarshal(body, &data)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
var wg sync.WaitGroup
for i := 0; i < len(data.Sites); i++ {
wg.Add(1)
go func(site Site) {
defer wg.Done()
// These sites yield false positives
if site.Name == "aaha_chat" || site.Name == "ru_123rf" || site.Name == "Salon24" || site.Name == "olx" {
return
}
replacedURL := strings.Replace(site.URL, "{account}", *username, 1)
client := &http.Client{Timeout: 10 * time.Second}
response, err := client.Get(replacedURL)
if err != nil {
return
}
defer response.Body.Close()
body, err := ioutil.ReadAll(response.Body)
if err != nil {
return
}
if response.StatusCode == site.ExistsCode && strings.Contains(string(body), site.ExistsString) {
fmt.Println(replacedURL)
}
}(data.Sites[i])
}
wg.Wait()
}