forked from utkusen/socialhunter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
313 lines (271 loc) · 8.63 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
package main
import (
"crypto/tls"
"flag"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"os"
"strings"
"time"
"github.com/fatih/color"
"github.com/gammazero/workerpool"
"github.com/gocolly/colly/v2"
)
/*
Samsung Galaxy J6+ User Agent
-----------------------------
"Mozilla/5.0 (Linux; Android 10; SM-J610F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Mobile Safari/537.36"
Samsung Duos User Agent
-----------------------
"Mozilla/5.0 (Linux; Android 4.4.4; SM-G360H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Mobile Safari/537.36"
*/
//var userAgent string = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.74 Safari/537.36"
var userAgent string = "Mozilla/5.0 (Linux; Android 10; SM-J610F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Mobile Safari/537.36"
var queue int
func main() {
fmt.Println(`
Utku Sen's
\ \ / /
\ \ / /
\ \_/ /
\ /
socialhunter
/ _ \
/ / \ \
/ / \ \
/_/ \_\
utkusen.com
`)
numWorker := flag.Int("w", 5, "Number of worker.")
requestTimeOut := flag.Int("t", 5, "Request time out")
urlFile := flag.String("f", "", "Path of the URL file")
flag.Parse()
if *urlFile == "" {
fmt.Println("Please specify all arguments!")
flag.PrintDefaults()
os.Exit(1)
}
file, err := ioutil.ReadFile(*urlFile)
if err != nil {
fmt.Println(err)
return
}
urls := strings.Split(string(file), EndOfLine)
queue = len(urls)
fmt.Println("Total URLs:", queue)
wp := workerpool.New(*numWorker)
for _, url := range urls {
url := url
wp.Submit(func() {
fmt.Println("Checking:", url)
action(url, *requestTimeOut)
})
}
wp.StopWait()
color.Cyan("Scan Completed")
}
func action(url string, requestTimeOut int) {
if requestTimeOut == 0 {
requestTimeOut = 5
}
sl := visitor(url, 10, requestTimeOut)
checkTakeover(removeDuplicateStr(sl))
color.Magenta("Finished Checking: " + url)
queue--
fmt.Println("Remaining URLs:", queue)
}
func stringInSlice(a string, list *[]string) bool {
for _, b := range *list {
if b == a {
return true
}
}
return false
}
func checkTakeover(socialLinks []string) {
var alreadyChecked []string
for _, value := range socialLinks {
foundLink := strings.Split(value, "|")[0]
socialLink := strings.Split(value, "|")[1]
if stringInSlice(socialLink, &alreadyChecked) {
continue
}
alreadyChecked = append(alreadyChecked, socialLink)
if len(socialLink) > 60 || strings.Contains(socialLink, "intent/tweet") || strings.Contains(socialLink, "twitter.com/share") || strings.Contains(socialLink, "twitter.com/privacy") || strings.Contains(socialLink, "facebook.com/home") || strings.Contains(socialLink, "instagram.com/p/") {
continue
}
u, err := url.Parse(socialLink)
if err != nil {
continue
}
domain := u.Host
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
if strings.Contains(domain, "facebook.com") {
if strings.Count(socialLink, ".") > 1 {
socialLink = "https://" + strings.Split(socialLink, ".")[1] + "." + strings.Split(socialLink, ".")[2]
}
socialLink = strings.Replace(socialLink, "www.", "", -1)
tempLink := strings.Replace(socialLink, "facebook.com", "tr-tr.facebook.com", -1)
resp, err := http.Get(tempLink)
if err != nil {
continue
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
continue
}
if strings.Contains(string(body), "Sayfa Bulunamadı") {
color.Green("Possible Takeover: " + socialLink + " at " + foundLink)
}
}
if strings.Contains(domain, "tiktok.com") {
if strings.Count(strings.Replace(socialLink, "www.", "", -1), ".") > 1 {
continue
}
client := &http.Client{Transport: tr}
req, err := http.NewRequest("GET", socialLink, nil)
if err != nil {
continue
}
req.Header.Set("User-Agent", userAgent)
resp, err := client.Do(req)
if err != nil {
continue
}
defer resp.Body.Close()
if resp.StatusCode == 404 {
color.Green("Possible Takeover: " + socialLink + " at " + foundLink)
}
}
if strings.Contains(domain, "instagram.com") {
if strings.Count(strings.Replace(socialLink, "www.", "", -1), ".") > 1 {
continue
}
if !strings.Contains(socialLink, "instagram.com/") {
continue
}
tempLink := "https://www.picuki.com/profile/" + strings.Split(socialLink, "instagram.com/")[1]
client := &http.Client{Transport: tr}
req, err := http.NewRequest("GET", tempLink, nil)
if err != nil {
continue
}
req.Header.Set("User-Agent", userAgent)
resp, err := client.Do(req)
if err != nil {
continue
}
defer resp.Body.Close()
if resp.StatusCode == 404 {
color.Green("Possible Takeover: " + socialLink + " at " + foundLink)
}
}
if strings.Contains(domain, "twitter.com") {
if strings.Count(strings.Replace(socialLink, "www.", "", -1), ".") > 1 {
continue
}
u, _ := url.Parse(socialLink)
userName := u.Path
tempLink := "https://nitter.net" + userName
client := &http.Client{}
req, err := http.NewRequest("GET", tempLink, nil)
if err != nil {
continue
}
req.Header.Set("User-Agent", userAgent)
resp, err := client.Do(req)
if err != nil {
continue
}
defer resp.Body.Close()
if resp.StatusCode == 404 {
color.Green("Possible Takeover: " + socialLink + " at " + foundLink)
}
}
}
}
func removeDuplicateStr(strSlice []string) []string {
allKeys := make(map[string]bool)
list := []string{}
for _, item := range strSlice {
if _, value := allKeys[item]; !value {
allKeys[item] = true
list = append(list, item)
}
}
return list
}
func visitor(visitURL string, maxDepth int, requestTimeOut int) []string {
socialDomains := []string{"twitter.com", "instagram.com", "facebook.com", "twitch.tv", "tiktok.com"}
var socialLinks []string
var visitedLinks []string
denyList := []string{".js", ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".svg", ".mp4", ".webm", ".mp3", ".csv", ".ogg", ".wav", ".flac", ".aac", ".wma", ".wmv", ".avi", ".mpg", ".mpeg", ".mov", ".mkv", ".zip", ".rar", ".7z", ".tar", ".iso", ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf", ".txt", ".rtf", ".odt", ".ods", ".odp", ".odg", ".odf", ".odb", ".odc", ".odm", ".avi", ".mpg", ".mpeg", ".mov", ".mkv", ".zip", ".rar", ".7z", ".tar", ".iso", ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf", ".txt", ".rtf", ".odt", ".ods", ".odp", ".odg", ".odf", ".odb", ".odc", ".odm", ".mp4", ".webm", ".mp3", ".ogg", ".wav", ".flac", ".aac", ".wma", ".wmv", ".avi", ".mpg", ".mpeg", ".mov", ".mkv", ".zip", ".rar", ".7z", ".tar", ".iso", ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf", ".txt", ".rtf", ".odt", ".ods", ".odp", ".odg", ".odf", ".odb", ".odc", ".odm", ".mp4", ".webm", ".mp3", ".ogg", ".wav", ".flac", ".aac", ".wma", ".wmv", ".avi", ".mpg", ".mpeg", ".mov", ".mkv", ".zip", ".rar", ".7z", ".tar", ".iso", ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf", ".txt", ".rtf", ".odt"}
//SONI
//fmt.Println("{ ", visitURL, " }")
if requestTimeOut == 0 {
requestTimeOut = 5
}
c := colly.NewCollector()
c.UserAgent = userAgent
c.SetRequestTimeout(time.Duration(requestTimeOut) * time.Second)
c.MaxDepth = maxDepth
c.AllowURLRevisit = false //there is a bug in colly that prevents this from working. We have to check it manually
u, err := url.Parse(visitURL)
if err != nil {
panic(err)
}
domain := u.Host
path := u.Path
c.OnHTML("a[href]", func(e *colly.HTMLElement) {
link := e.Request.AbsoluteURL(e.Attr("href"))
//SONI
//fmt.Println("-------> ", link)
u2, err := url.Parse(link)
if err != nil {
panic(err)
}
linkDomain := u2.Host
for _, domain := range socialDomains {
//SONI
//fmt.Println("linkDomain --> ", linkDomain, " Domain --> ", domain)
if strings.Contains(linkDomain, domain) {
socialLinks = append(socialLinks, e.Request.URL.String()+"|"+link)
}
//SONI
//domain = "SONI.PK"
}
// SONI
//fmt.Println("linkDomain --> ", linkDomain, " Domain --> ", domain)
if strings.Contains(linkDomain, domain) {
// SONI
//fmt.Println("-----------> linkDomain --> ", linkDomain, " Domain --> ", domain)
visitFlag := true
for _, extension := range denyList {
if strings.Contains(strings.ToLower(link), extension) {
visitFlag = false
}
}
for _, value := range visitedLinks {
if strings.ToLower(link) == value {
visitFlag = false
}
}
// SONI
//fmt.Println("u2.Path -> ", u2.Path, " path -> ", path)
if !strings.HasPrefix(u2.Path, path) {
visitFlag = false
}
if visitFlag {
visitedLinks = append(visitedLinks, link)
e.Request.Visit(link)
}
}
})
c.Visit(visitURL)
return socialLinks
}