forked from dvopsway/datasploit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
usernameOsint.py
executable file
·326 lines (293 loc) · 7.12 KB
/
usernameOsint.py
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
314
315
316
317
318
319
320
321
322
323
324
325
326
#!/usr/bin/env python
import tweepy
import re
from collections import Counter
import requests
import sys
import codecs
import config as cfg
import clearbit
import json
import time
import hashlib
from bs4 import BeautifulSoup
import os
import urllib
twitterex=0 #counter for identifying if twitter account is found
def git_user_details(username):
req = requests.get("https://api.github.com/users/%s" % (username))
return json.loads(req.content)
def usernamesearch(username):
data = {"username":username}
req = requests.post('https://usersearch.org/results_normal.php',data=data, verify=False)
soup=BeautifulSoup(req.content, "lxml")
atag=soup.findAll('a',{'class':'pretty-button results-button'})
profiles=[]
for at in atag:
if at.text=="View Profile":
profiles.append(at['href'])
return profiles
imglinks=[]
def extracting(prourl,tag,attribute,value,finattrib,profile):
res=requests.get(prourl)
soup=BeautifulSoup(res.content,"lxml")
img=soup.find(tag,{attribute:value})
if profile=="ask.fm":
img[finattrib]="http:"+img[finattrib]
imglinks.append(img[finattrib])
path=username+"/"+profile+".jpg"
urllib.urlretrieve(img[finattrib], path)
else:
imglinks.append(img[finattrib])
path=username+"/"+profile+".jpg"
urllib.urlretrieve(img[finattrib], path)
def profilepic(urls):
if len(urls) or git_data['avatar_url']:
if not os.path.exists(username):
os.makedirs(username)
if git_data.get("avatar_url", "") != "":
path=username+"/github.jpg"
urllib.urlretrieve(git_data['avatar_url'], path)
for url in urls:
if 'etsy' in url:
try:
tg='meta'
att='property'
val='og:image'
valx='content'
pro="etsy"
extracting(url,tg,att,val,valx,pro)
continue
except KeyError:
pass
elif 'gravatar' in url:
try:
tg='a'
att='class'
val='photo-0'
valx='href'
pro="gravatar"
extracting(url,tg,att,val,valx,pro)
continue
except KeyError:
pass
elif 'youtube' in url:
try:
tg='link'
att='itemprop'
val='thumbnailUrl'
valx='href'
pro="youtube"
extracting(url,tg,att,val,valx,pro)
continue
except KeyError:
pass
elif 'twitter' in url:
try:
tg='img'
att='class'
val='ProfileAvatar-image'
valx='src'
pro="twitter"
extracting(url,tg,att,val,valx,pro)
global twitterex
twitterex=1
continue
except KeyError:
pass
elif 'photobucket' in url:
try:
tg='img'
att='class'
val='avatar smallProfile'
valx='src'
pro="photobucket"
extracting(url,tg,att,val,valx,pro)
continue
except KeyError:
pass
elif 'pinterest' in url:
try:
tg='meta'
att='property'
val='og:image'
valx='content'
pro="pinterest"
extracting(url,tg,att,val,valx,pro)
continue
except KeyError:
pass
elif 'ebay' in url:
try:
tg='img'
att='class'
val='prof_img img'
valx='src'
pro="ebay"
extracting(url,tg,att,val,valx,pro)
continue
except KeyError:
pass
elif 'steam' in url:
try:
tg='link'
att='rel'
val='image_src'
valx='href'
pro="steam"
extracting(url,tg,att,val,valx,pro)
continue
except KeyError:
pass
elif 'deviantart' in url:
try:
tg='img'
att='class'
val='avatar float-left'
valx='src'
pro="deviantart"
extracting(url,tg,att,val,valx,pro)
continue
except KeyError:
pass
elif 'last.fm' in url:
try:
tg='img'
att='class'
val='avatar'
valx='src'
pro="last.fm"
extracting(url,tg,att,val,valx,pro)
continue
except KeyError:
pass
elif 'vimeo' in url:
try:
tg='meta'
att='property'
val='og:image'
valx='content'
pro="vimeo"
extracting(url,tg,att,val,valx,pro)
continue
except KeyError:
pass
elif 'vimeo' in url:
try:
tg='meta'
att='property'
val='og:image'
valx='content'
pro="vimeo"
extracting(url,tg,att,val,valx,pro)
continue
except KeyError:
pass
elif 'ask.fm' in url:
try:
tg='meta'
att='property'
val='og:image'
valx='content'
pro="ask.fm"
extracting(url,tg,att,val,valx,pro)
continue
except KeyError:
pass
elif 'tripadvisor' in url:
try:
tg='img'
att='class'
val='avatarUrl'
valx='src'
pro="tripadvisor"
extracting(url,tg,att,val,valx,pro)
continue
except KeyError:
pass
elif 'tumblr' in url:
try:
tg='link'
att='rel'
val='icon'
valx='href'
pro="tumblr"
extracting(url,tg,att,val,valx,pro)
continue
except KeyError:
pass
print "Profile pics will be saved in %s" % username
return imglinks
def twitterdetails(username):
auth = tweepy.OAuthHandler(cfg.twitter_consumer_key, cfg.twitter_consumer_secret)
auth.set_access_token(cfg.twitter_access_token, cfg.twiter_access_token_secret)
#preparing auth
api = tweepy.API(auth)
f = codecs.open("temptweets.txt","w+", encoding='utf-8')
#writing tweets to temp file- last 1000
for tweet in tweepy.Cursor(api.user_timeline, id=username).items(1000):
f.write(tweet.text.encode("utf-8"))
f.write("\n")
#extracting hashtags
f = codecs.open('temptweets.txt', 'r', encoding='utf-8')
q=f.read()
strings = re.findall(r'(?:\#+[\w_]+[\w\'_\-]*[\w_]+)', q) #Regex(s) Source: https://marcobonzanini.com/2015/03/09/mining-twitter-data-with-python-part-2/
#extracting users
tusers = re.findall(r'(?:@[\w_]+)', q)
f.close()
hashlist=[]
userlist=[]
for item in strings:
item=item.strip( '#' )
item=item.lower()
hashlist.append(item)
hashlist=hashlist[:10]
for itm in tusers:
itm=itm.strip( '@' )
itm=itm.lower()
userlist.append(itm)
userlist=userlist[:10]
return hashlist,userlist
username = sys.argv[1]
print "\t\t\t[+] Checking git user details\n"
try:
git_data = git_user_details(username)
print "Login: %s" % git_data['login']
print "avatar_url: %s" % git_data['avatar_url']
print "id: %s" % git_data['id']
print "Repos: %s" % git_data['repos_url']
print "Name: %s" % git_data['name']
print "Company: %s" % git_data['company']
print "Blog: %s" % git_data['blog']
print "Location: %s" % git_data['location']
print "Hireable: %s" % git_data['hireable']
print "Bio: %s" % git_data['bio']
print "On GitHub: %s" % git_data['created_at']
print "Last Activity: %s" % git_data['updated_at']
print "\n-----------------------------\n"
except:
print 'Git account do not exist on this username.'
print "\n\t\t\t[+] Username found on:\n"
links=usernamesearch(username)
for lnk in links:
print lnk
print "\n-----------------------------\n"
imagelinks=profilepic(links)
imagelinks.append(git_data.get("avatar_url", ""))
print "\t\t\t[+] Finding Profile Pics\n"
for x in imagelinks:
print x
print "\n\n-----------------------------\n"
if (twitterex==1):
#counting hashtag occurrence
hashlist,userlist=twitterdetails(username)
count= Counter(hashlist).most_common()
print "Top Hashtag Occurrence for user "+username+" based on last 1000 tweets"
for hash,cnt in count:
print "#"+hash+" : "+str(cnt)
print "\n"
#counting user occurrence
countu= Counter(userlist).most_common()
print "Top User Occurrence for user "+username+" based on last 1000 tweets"
for usr,cnt in countu:
print "@"+usr+" : "+str(cnt)