-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathsocial_attacker.py
1597 lines (1469 loc) · 91.3 KB
/
social_attacker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
from modules import facebookphisher
from modules import linkedinphisher
from modules import twitterphisher
from modules import vkontaktephisher
import pandas
import numpy
import argparse
import time
import sys
import random
import mmap
import re
import traceback
from datetime import datetime
from time import sleep
# Markov Documentation:
# Facebook: Pulls out user written timeline posts, news article headlines and link descriptions
# LinkedIn: Pulls out recent activity thats been posted or liked
# Twitter: Pulls out all tweets
# VKontakte: Pulls out all timeline posts
#
# Usernames & Passwords for the accounts you wish to phish with
global facebook_username
global facebook_password
facebook_username = ""
facebook_password = ""
global linkedin_username
global linkedin_password
linkedin_username = ""
linkedin_password = ""
global twitter_username
global twitter_password
twitter_username = ""
twitter_password = ""
global vkontakte_username
global vkontakte_password
vkontakte_username = "" # Can be mobile or email
vkontakte_password = ""
#Generate initial 5 character hex tracking code
global tracking_id
tracking_id = ''.join(random.choice('0123456789ABCDEF') for i in range(5))
startTime = datetime.now()
# person class to hold data
class Person(object):
first_name = ""
last_name = ""
full_name = ""
#profile link
facebook = ""
# connected request status: connected/rejected/pending/error/unknown etc
facebookstatus = ""
# Phish status: sent/error
facebookphish = ""
# 5 character hex tracking code
facebooktrackingcode = ""
# markov message that was generated
facebookmarkovmessage = ""
# final phishing message sent: default message or markov + phishing link
facebookfinalphishingmessage = ""
# log check: did user click?
facebookclicked = ""
# log check: what IP did user click from
facebookclickedip = ""
# log check: what time did user click
facebookclickedtime = ""
# log check: what was user agent from click
facebookclickeduseragent = ""
linkedin = ""
linkedinstatus = ""
linkedinphish = ""
linkedintrackingcode = ""
linkedinmarkovmessage = ""
linkedinfinalphishingmessage = ""
linkedinclicked = ""
linkedinclickedip = ""
linkedinclickedtime = ""
linkedinclickeduseragent = ""
twitter = ""
twitterstatus = ""
twitterphish = ""
twittertrackingcode = ""
twittermarkovmessage = ""
twitterfinalphishingmessage = ""
twitterclicked = ""
twitterclickedip = ""
twitterclickedtime = ""
twitterclickeduseragent = ""
vkontakte = ""
vkontaktestatus = ""
vkontaktephish = ""
vkontaktetrackingcode = ""
vkontaktemarkovmessage = ""
vkontaktefinalphishingmessage = ""
vkontakteclicked = ""
vkontakteclickedip = ""
vkontakteclickedtime = ""
vkontakteclickeduseragent = ""
def __init__(self, first_name, last_name, full_name):
self.first_name = first_name
self.last_name = last_name
self.full_name = full_name
def prepare_linkedin(company_url):
LinkedinphisherObject = linkedinphisher.Linkedinphisher(showbrowser)
LinkedinphisherObject.doLogin(linkedin_username,linkedin_password)
connection_list = LinkedinphisherObject.prepareLinkedinProfile(company_url,linkedin_username,linkedin_password)
try:
LinkedinphisherObject.kill()
except:
print("Error Killing LinkedIn Selenium instance")
return connection_list
# TODO Code to friend all Facebook targets
def add_facebook(peoplelist):
FacebookphisherObject = facebookphisher.Facebookphisher(showbrowser)
FacebookphisherObject.doLogin(facebook_username,facebook_password)
count=1
ammount=len(peoplelist)
for person in peoplelist:
#Testcode to mimic a session timeout
#if count == 3: print "triggered delete"
# FacebookphisherObject.testdeletecookies()
if person.facebook:
if args.vv == True:
print("Adding Facebook Friend %i/%i : %s" % (count,ammount,person.full_name))
else:
sys.stdout.write("\rAdding Facebook Friend %i/%i : %s " % (count,ammount,person.full_name))
sys.stdout.flush()
count = count + 1
try:
FacebookphisherObject.addFacebookProfile(person.facebook,facebook_username,facebook_password)
except:
continue
else:
continue
try:
FacebookphisherObject.kill()
except:
print("Error Killing Facebook Selenium instance")
# TODO Code to connect to all LinkedIn targets
def add_linkedin(peoplelist):
LinkedinphisherObject = linkedinphisher.Linkedinphisher(showbrowser)
LinkedinphisherObject.doLogin(linkedin_username,linkedin_password)
count=1
ammount=len(peoplelist)
for person in peoplelist:
#Testcode to mimic a session timeout
#if count == 3: print "triggered delete"
# LinkedinphisherObject.testdeletecookies()
if person.linkedin:
if args.vv == True:
print("Adding LinkedIn Connection %i/%i : %s" % (count,ammount,person.full_name))
else:
sys.stdout.write("\rAdding LinkedIn Connection %i/%i : %s " % (count,ammount,person.full_name))
sys.stdout.flush()
count = count + 1
try:
LinkedinphisherObject.addLinkedinProfile(person.linkedin,linkedin_username,linkedin_password)
except:
continue
else:
continue
try:
LinkedinphisherObject.kill()
except:
print("Error Killing LinkedIn Selenium instance")
#Follow on twitter
def add_twitter(peoplelist):
TwitterphisherObject = twitterphisher.Twitterphisher(showbrowser)
TwitterphisherObject.doLogin(twitter_username,twitter_password)
count=1
ammount=len(peoplelist)
for person in peoplelist:
#Testcode to mimic a session timeout
#if count == 3: print "triggered delete"
# TwitterphisherObject.testdeletecookies()
if person.twitter:
if args.vv == True:
print("Following Twitter target %i/%i : %s" % (count,ammount,person.full_name))
else:
sys.stdout.write("\rFollowing Twitter target %i/%i : %s " % (count,ammount,person.full_name))
sys.stdout.flush()
count = count + 1
try:
TwitterphisherObject.addTwitterProfile(person.twitter,twitter_username,twitter_password)
except:
continue
else:
continue
try:
TwitterphisherObject.kill()
except:
print("Error Killing Twitter Selenium instance")
def add_vkontakte(peoplelist):
VkontaktephisherObject = vkontaktephisher.Vkontaktephisher(showbrowser)
VkontaktephisherObject.doLogin(vkontakte_username,vkontakte_password)
count=1
ammount=len(peoplelist)
for person in peoplelist:
#Testcode to mimic a session timeout
#if count == 3: print "triggered delete"
# VkontaktephisherObject.testdeletecookies()
if person.vkontakte:
if args.vv == True:
print("Adding Vkontakte Connection %i/%i : %s" % (count,ammount,person.full_name))
else:
sys.stdout.write("\rAdding Vkontakte Connection %i/%i : %s " % (count,ammount,person.full_name))
sys.stdout.flush()
count = count + 1
try:
VkontaktephisherObject.addVkontakteProfile(person.vkontakte,vkontakte_username,vkontakte_password)
except:
continue
else:
continue
try:
VkontaktephisherObject.kill()
except:
print("Error Killing VKontakte Selenium instance")
# [MORE_SOCIAL_MEDIA_SITES_TAG]
# TODO Code to check if Facebook Target has accepted friend request
def check_facebook(peoplelist):
FacebookphisherObject = facebookphisher.Facebookphisher(showbrowser)
FacebookphisherObject.doLogin(facebook_username,facebook_password)
count=1
ammount=len(peoplelist)
for person in peoplelist:
#Testcode to mimic a session timeout
#if count == 3: print "triggered delete"
# FacebookphisherObject.testdeletecookies()
if person.facebook:
if args.vv == True:
print("Checking Facebook for Friend Request Status %i/%i : %s" % (count,ammount,person.full_name))
else:
sys.stdout.write("\rChecking Facebook for Friend Request Status %i/%i : %s " % (count,ammount,person.full_name))
sys.stdout.flush()
count = count + 1
try:
person.facebookstatus = FacebookphisherObject.checkFacebookProfile(person.facebook,facebook_username,facebook_password)
if args.vv == True:
print(person.facebook + " : " + person.facebookstatus)
sleep(3)
except:
continue
else:
continue
try:
FacebookphisherObject.kill()
except:
print("Error Killing Facebook Selenium instance")
return peoplelist
# If connected, set person.facebookstatus to Yes
# Output connected targets to csv + console
# TODO Code to check if LinkedIn Target has accepted connection request
def check_linkedin(peoplelist):
LinkedinphisherObject = linkedinphisher.Linkedinphisher(showbrowser)
LinkedinphisherObject.doLogin(linkedin_username,linkedin_password)
count=1
ammount=len(peoplelist)
for person in peoplelist:
#Testcode to mimic a session timeout
#if count == 3: print "triggered delete"
# LinkedinphisherObject.testdeletecookies()
if person.linkedin:
if args.vv == True:
print("Checking LinkedIn for Connection Status %i/%i : %s" % (count,ammount,person.full_name))
else:
sys.stdout.write("\rChecking LinkedIn for Connection Status %i/%i : %s " % (count,ammount,person.full_name))
sys.stdout.flush()
count = count + 1
try:
person.linkedinstatus = LinkedinphisherObject.checkLinkedinProfile(person.linkedin,linkedin_username,linkedin_password)
if args.vv == True:
print(person.linkedin + " : " + person.linkedinstatus)
sleep(3)
except:
continue
else:
continue
try:
LinkedinphisherObject.kill()
except:
print("Error Killing LinkedIn Selenium instance")
return peoplelist
# If connected, set person.linkedinstatus to Yes
# Output connected targets to csv + console
def check_twitter(peoplelist):
TwitterphisherObject = twitterphisher.Twitterphisher(showbrowser)
TwitterphisherObject.doLogin(twitter_username,twitter_password)
count=1
ammount=len(peoplelist)
for person in peoplelist:
#Testcode to mimic a session timeout
#if count == 3: print "triggered delete"
# TwitterphisherObject.testdeletecookies()
if person.twitter:
if args.vv == True:
print("Checking Twitter for Following Status %i/%i : %s" % (count,ammount,person.full_name))
else:
sys.stdout.write("\rChecking Twitter for Following Status %i/%i : %s " % (count,ammount,person.full_name))
sys.stdout.flush()
count = count + 1
try:
person.twitterstatus = TwitterphisherObject.checkTwitterProfile(person.twitter,twitter_username,twitter_password)
if args.vv == True:
print(person.twitter + " : " + person.twitterstatus)
sleep(3)
except:
continue
else:
continue
try:
TwitterphisherObject.kill()
except:
print("Error Killing Twitter Selenium instance")
return peoplelist
# If connected, set person.linkedinstatus to Yes
# Output connected targets to csv + console
# TODO Code to check if LinkedIn Target has accepted connection request
def check_vkontakte(peoplelist):
VkontaktephisherObject = vkontaktephisher.Vkontaktephisher(showbrowser)
VkontaktephisherObject.doLogin(vkontakte_username,vkontakte_password)
count=1
ammount=len(peoplelist)
for person in peoplelist:
#Testcode to mimic a session timeout
#if count == 3: print "triggered delete"
# VkontaktephisherObject.testdeletecookies()
if person.vkontakte:
if args.vv == True:
print("Checking Vkontakte for Connection Status %i/%i : %s" % (count,ammount,person.full_name))
else:
sys.stdout.write("\rChecking Vkontakte for Connection Status %i/%i : %s " % (count,ammount,person.full_name))
sys.stdout.flush()
count = count + 1
try:
person.vkontaktestatus = VkontaktephisherObject.checkVkontakteProfile(person.vkontakte,vkontakte_username,vkontakte_password)
if args.vv == True:
print(person.vkontakte + " : " + person.vkontaktestatus)
sleep(3)
except:
continue
else:
continue
try:
VkontaktephisherObject.kill()
except:
print("Error Killing VKontakte Selenium instance")
return peoplelist
# If connected, set person.vkontaktestatus to Yes
# Output connected targets to csv + console
# [MORE_SOCIAL_MEDIA_SITES_TAG]
def generate_markov_facebook(peoplelist):
FacebookphisherObject = facebookphisher.Facebookphisher(showbrowser)
FacebookphisherObject.doLogin(facebook_username,facebook_password)
count=1
ammount=len(peoplelist)
for person in peoplelist:
#Testcode to mimic a session timeout
#if count == 3: print "triggered delete"
# FacebookphisherObject.testdeletecookies()
if person.facebook:
if args.vv == True:
print("Generating Facebook Markov Message Phish %i/%i : %s" % (count,ammount,person.full_name))
else:
sys.stdout.write("\rGenerating Facebook Markov Message Phish %i/%i : %s " % (count,ammount,person.full_name))
sys.stdout.flush()
count = count + 1
try:
if args.markovlength:
person.facebookmarkovmessage = FacebookphisherObject.generateMarkovMessageForFacebookProfile(person.facebook,args.markovlength,facebook_username,facebook_password)
else:
person.facebookmarkovmessage = FacebookphisherObject.generateMarkovMessageForFacebookProfile(person.facebook,140,facebook_username,facebook_password)
sleep(3)
except:
continue
else:
traceback.print_exc()
continue
try:
FacebookphisherObject.kill()
except:
print("Error Killing Facebook Selenium instance")
return peoplelist
def generate_markov_linkedin(peoplelist):
LinkedinphisherObject = linkedinphisher.Linkedinphisher(showbrowser)
LinkedinphisherObject.doLogin(linkedin_username,linkedin_password)
count=1
ammount=len(peoplelist)
for person in peoplelist:
#Testcode to mimic a session timeout
#if count == 3: print "triggered delete"
# LinkedinphisherObject.testdeletecookies()
if person.linkedin:
if args.vv == True:
print("Generating Linkedin Markov Message Phish %i/%i : %s" % (count,ammount,person.full_name))
else:
sys.stdout.write("\rGenerating Linkedin Markov Message Phish %i/%i : %s " % (count,ammount,person.full_name))
sys.stdout.flush()
count = count + 1
try:
if args.markovlength:
person.linkedinmarkovmessage = LinkedinphisherObject.generateMarkovMessageForLinkedinProfile(person.linkedin,args.markovlength,linkedin_username,linkedin_password)
else:
person.linkedinmarkovmessage = LinkedinphisherObject.generateMarkovMessageForLinkedinProfile(person.linkedin,140,linkedin_username,linkedin_password)
sleep(3)
except:
continue
else:
traceback.print_exc()
continue
try:
LinkedinphisherObject.kill()
except:
print("Error Killing Linkedin Selenium instance")
return peoplelist
def generate_markov_twitter(peoplelist):
#Works by scraping posts in recent activity
#https://www.twitter.com/in/user-id/detail/recent-activity/
TwitterphisherObject = twitterphisher.Twitterphisher(showbrowser)
TwitterphisherObject.doLogin(twitter_username,twitter_password)
count=1
ammount=len(peoplelist)
for person in peoplelist:
#Testcode to mimic a session timeout
#if count == 3: print "triggered delete"
# FacebookphisherObject.testdeletecookies()
if person.twitter:
if args.vv == True:
print("Generating Twitter Markov Message Phish %i/%i : %s" % (count,ammount,person.full_name))
else:
sys.stdout.write("\rGenerating Twitter Markov Message Phish %i/%i : %s " % (count,ammount,person.full_name))
sys.stdout.flush()
count = count + 1
try:
if args.markovlength:
person.twittermarkovmessage = TwitterphisherObject.generateMarkovMessageForTwitterProfile(person.twitter,args.markovlength,twitter_username,twitter_password)
else:
person.twittermarkovmessage = TwitterphisherObject.generateMarkovMessageForTwitterProfile(person.twitter,140,twitter_username,twitter_password)
sleep(3)
except:
continue
else:
traceback.print_exc()
continue
try:
TwitterphisherObject.kill()
except:
print("Error Killing Twitter Selenium instance")
return peoplelist
def generate_markov_vkontakte(peoplelist):
#Works by scraping posts in recent activity
#https://www.vkontakte.com/in/user-id/detail/recent-activity/
VkontaktephisherObject = vkontaktephisher.Vkontaktephisher(showbrowser)
VkontaktephisherObject.doLogin(vkontakte_username,vkontakte_password)
count=1
ammount=len(peoplelist)
for person in peoplelist:
#Testcode to mimic a session timeout
#if count == 3: print "triggered delete"
# FacebookphisherObject.testdeletecookies()
if person.vkontakte:
if args.vv == True:
print("Generating Vkontakte Markov Message Phish %i/%i : %s" % (count,ammount,person.full_name))
else:
sys.stdout.write("\rGenerating Vkontakte Markov Message Phish %i/%i : %s " % (count,ammount,person.full_name))
sys.stdout.flush()
count = count + 1
try:
if args.markovlength:
person.vkontaktemarkovmessage = VkontaktephisherObject.generateMarkovMessageForVkontakteProfile(person.vkontakte,args.markovlength,vkontakte_username,vkontakte_password)
else:
person.vkontaktemarkovmessage = VkontaktephisherObject.generateMarkovMessageForVkontakteProfile(person.vkontakte,140,vkontakte_username,vkontakte_password)
sleep(3)
except:
continue
else:
traceback.print_exc()
continue
try:
VkontaktephisherObject.kill()
except:
print("Error Killing VKontakte Selenium instance")
return peoplelist
# [MORE_SOCIAL_MEDIA_SITES_TAG]
# TODO Code to check & phish if Facebook Target has accepted friend request
def checkphish_facebook(peoplelist):
FacebookphisherObject = facebookphisher.Facebookphisher(showbrowser)
FacebookphisherObject.doLogin(facebook_username,facebook_password)
count=1
ammount=len(peoplelist)
for person in peoplelist:
#Testcode to mimic a session timeout
#if count == 3: print "triggered delete"
# FacebookphisherObject.testdeletecookies()
if person.facebook:
if args.vv == True:
print("Sending Facebook Phish %i/%i : %s" % (count,ammount,person.full_name))
else:
sys.stdout.write("\rSending Facebook Phish %i/%i : %s " % (count,ammount,person.full_name))
sys.stdout.flush()
count = count + 1
try:
#Set unique tracking id, increment global tracking_id value
global tracking_id
person.facebooktrackingcode = tracking_id
tracking_id = numpy.base_repr((int(tracking_id, 36) + 1), 36).zfill(5)
# Need to sepparate these out, so that there is another function to generate markov messages
if args.markovmessage: # If markov message, check if blank message "Error-MarkovNone" or "Error", if so send message, else send markov message
if person.facebookmarkovmessage == "Error-MarkovGeneralCrash" or person.facebookmarkovmessage == "Error-MarkovNoData" or person.facebookmarkovmessage == "Error-MarkovifyCrash":
person.facebookfinalphishingmessage = args.message.replace('[TRACKING_ID]',person.facebooktrackingcode).replace('[FULL_NAME]',person.full_name).replace('[LAST_NAME]',person.last_name).replace('[FIRST_NAME]',person.first_name)
person.facebookphish = FacebookphisherObject.checkThenPhishFacebookProfile(person.facebook,person.facebookfinalphishingmessage,facebook_username,facebook_password)
else:
phishingurl = args.markovmessage.replace('[TRACKING_ID]',person.facebooktrackingcode).replace('[FULL_NAME]',person.full_name).replace('[LAST_NAME]',person.last_name).replace('[FIRST_NAME]',person.first_name)
# if markov message contains no links, add the end, else replace links with phishing link
if "http" not in person.facebookmarkovmessage and "https" not in person.facebookmarkovmessage:
person.facebookfinalphishingmessage = person.facebookmarkovmessage + " " + phishingurl
else:
final_message_array = person.facebookmarkovmessage.split()
temp_message = ""
for word in final_message_array:
if "http" not in word and "https" not in word:
temp_message = temp_message + word + " "
else:
temp_message = temp_message + phishingurl + " "
person.facebookfinalphishingmessage = temp_message[:-1]
person.facebookphish = FacebookphisherObject.checkThenPhishFacebookProfile(person.facebook,person.facebookfinalphishingmessage,facebook_username,facebook_password)
elif args.message: # If just message, replace variables then send
person.facebookfinalphishingmessage = args.message.replace('[TRACKING_ID]',person.facebooktrackingcode).replace('[FULL_NAME]',person.full_name).replace('[LAST_NAME]',person.last_name).replace('[FIRST_NAME]',person.first_name)
person.facebookphish = FacebookphisherObject.checkThenPhishFacebookProfile(person.facebook,person.facebookfinalphishingmessage,facebook_username,facebook_password)
else:
print("Error, No Phishing Message Provided")
sys.exit(0)
sleep(3)
except:
traceback.print_exc()
continue
else:
continue
try:
FacebookphisherObject.kill()
except:
print("Error Killing Facebook Selenium instance")
return peoplelist
# If connected, send phishing message(-m), or generate custom one with markov chains(-mm)
# Generate unique tracking codes before phishing
# Output phished users + profiles + tracking codes to csv + console
# TODO Code to check & phish if LinkedIn Target has accepted connection request
def checkphish_linkedin(peoplelist):
# If connected, send phishing message(-m), or generate custom one with markov chains(-mm)
# Generate unique tracking codes before phishing
# Output phished users + profiles + tracking codes to csv + console
LinkedinphisherObject = linkedinphisher.Linkedinphisher(showbrowser)
LinkedinphisherObject.doLogin(linkedin_username,linkedin_password)
count=1
ammount=len(peoplelist)
for person in peoplelist:
#Testcode to mimic a session timeout
#if count == 3: print "triggered delete"
# LinkedinphisherObject.testdeletecookies()
if person.linkedin:
if args.vv == True:
print("Sending LinkedIn Phish %i/%i : %s" % (count,ammount,person.full_name))
else:
sys.stdout.write("\rSending LinkedIn Phish %i/%i : %s " % (count,ammount,person.full_name))
sys.stdout.flush()
count = count + 1
try:
#Set unique tracking id, increment global tracking_id value
global tracking_id
person.linkedintrackingcode = tracking_id
tracking_id = numpy.base_repr((int(tracking_id, 36) + 1), 36).zfill(5)
# Need to sepparate these out, so that there is another function to generate markov messages
if args.markovmessage: # If markov message, check if blank message "Error-MarkovNone" or "Error", if so send message, else send markov message
if person.linkedinmarkovmessage == "Error-MarkovGeneralCrash" or person.linkedinmarkovmessage == "Error-MarkovNoData" or person.linkedinmarkovmessage == "Error-MarkovifyCrash":
person.linkedinfinalphishingmessage = args.message.replace('[TRACKING_ID]',person.linkedintrackingcode).replace('[FULL_NAME]',person.full_name).replace('[LAST_NAME]',person.last_name).replace('[FIRST_NAME]',person.first_name)
person.linkedinphish = LinkedinphisherObject.checkThenPhishLinkedinProfile(person.linkedin,person.linkedinfinalphishingmessage,linkedin_username,linkedin_password)
else:
phishingurl = args.markovmessage.replace('[TRACKING_ID]',person.linkedintrackingcode).replace('[FULL_NAME]',person.full_name).replace('[LAST_NAME]',person.last_name).replace('[FIRST_NAME]',person.first_name)
# if markov message contains no links, add the end, else replace links with phishing link
if "http" not in person.linkedinmarkovmessage and "https" not in person.linkedinmarkovmessage:
person.linkedinfinalphishingmessage = person.linkedinmarkovmessage + " " + phishingurl
else:
final_message_array = person.linkedinmarkovmessage.split()
temp_message = ""
for word in final_message_array:
if "http" not in word and "https" not in word:
temp_message = temp_message + word + " "
else:
temp_message = temp_message + phishingurl + " "
person.linkedinfinalphishingmessage = temp_message[:-1]
person.linkedinphish = LinkedinphisherObject.checkThenPhishLinkedinProfile(person.linkedin,person.linkedinfinalphishingmessage,linkedin_username,linkedin_password)
elif args.message: # If just message, replace variables then send
person.linkedinfinalphishingmessage = args.message.replace('[TRACKING_ID]',person.linkedintrackingcode).replace('[FULL_NAME]',person.full_name).replace('[LAST_NAME]',person.last_name).replace('[FIRST_NAME]',person.first_name)
person.linkedinphish = LinkedinphisherObject.checkThenPhishLinkedinProfile(person.linkedin,person.linkedinfinalphishingmessage,linkedin_username,linkedin_password)
else:
print("Error, No Phishing Message Provided")
sys.exit(0)
sleep(3)
except:
traceback.print_exc()
continue
else:
continue
try:
LinkedinphisherObject.kill()
except:
print("Error Killing LinkedIn Selenium instance")
return peoplelist
# If connected, send phishing message(-m), or generate custom one with markov chains(-mm)
# Generate unique tracking codes before phishing
# Output phished users + profiles + tracking codes to csv + console
# TODO Code to check & phish if LinkedIn Target has accepted connection request
def checkphish_twitter(peoplelist):
# If connected, send phishing message(-m), or generate custom one with markov chains(-mm)
# Generate unique tracking codes before phishing
# Output phished users + profiles + tracking codes to csv + console
TwitterphisherObject = twitterphisher.Twitterphisher(showbrowser)
TwitterphisherObject.doLogin(twitter_username,twitter_password)
count=1
ammount=len(peoplelist)
for person in peoplelist:
#Testcode to mimic a session timeout
#if count == 3: print "triggered delete"
# TwitterphisherObject.testdeletecookies()
if person.twitter:
if args.vv == True:
print("Sending Twitter Phish %i/%i : %s" % (count,ammount,person.full_name))
else:
sys.stdout.write("\rSending Twitter Phish %i/%i : %s " % (count,ammount,person.full_name))
sys.stdout.flush()
count = count + 1
try:
#Set unique tracking id, increment global tracking_id value
global tracking_id
person.twittertrackingcode = tracking_id
tracking_id = numpy.base_repr((int(tracking_id, 36) + 1), 36).zfill(5)
# Need to sepparate these out, so that there is another function to generate markov messages
if args.markovmessage: # If markov message, check if blank message "Error-MarkovNone" or "Error", if so send message, else send markov message
if person.twittermarkovmessage == "Error-MarkovGeneralCrash" or person.twittermarkovmessage == "Error-MarkovNoData" or person.twittermarkovmessage == "Error-MarkovifyCrash":
person.twitterfinalphishingmessage = args.message.replace('[TRACKING_ID]',person.twittertrackingcode).replace('[FULL_NAME]',person.full_name).replace('[LAST_NAME]',person.last_name).replace('[FIRST_NAME]',person.first_name)
person.twitterphish = TwitterphisherObject.checkThenPhishTwitterProfile(person.twitter,person.twitterfinalphishingmessage,twitter_username,twitter_password)
else:
phishingurl = args.markovmessage.replace('[TRACKING_ID]',person.twittertrackingcode).replace('[FULL_NAME]',person.full_name).replace('[LAST_NAME]',person.last_name).replace('[FIRST_NAME]',person.first_name)
# if markov message contains no links, add the end, else replace links with phishing link
if "http" not in person.twittermarkovmessage and "https" not in person.twittermarkovmessage:
person.twitterfinalphishingmessage = person.twittermarkovmessage + " " + phishingurl
else:
final_message_array = person.twittermarkovmessage.split()
temp_message = ""
for word in final_message_array:
if "http" not in word and "https" not in word:
temp_message = temp_message + word + " "
else:
temp_message = temp_message + phishingurl + " "
person.twitterfinalphishingmessage = temp_message[:-1]
person.twitterphish = TwitterphisherObject.checkThenPhishTwitterProfile(person.twitter,person.twitterfinalphishingmessage,twitter_username,twitter_password)
elif args.message: # If just message, replace variables then send
person.twitterfinalphishingmessage = args.message.replace('[TRACKING_ID]',person.twittertrackingcode).replace('[FULL_NAME]',person.full_name).replace('[LAST_NAME]',person.last_name).replace('[FIRST_NAME]',person.first_name)
person.twitterphish = TwitterphisherObject.checkThenPhishTwitterProfile(person.twitter,person.twitterfinalphishingmessage,twitter_username,twitter_password)
else:
print("Error, No Phishing Message Provided")
sys.exit(0)
sleep(3)
except:
traceback.print_exc()
continue
else:
continue
try:
TwitterphisherObject.kill()
except:
print("Error Killing Twitter Selenium instance")
return peoplelist
# If connected, send phishing message(-m), or generate custom one with markov chains(-mm)
# Generate unique tracking codes before phishing
# Output phished users + profiles + tracking codes to csv + console
# TODO Code to check & phish if LinkedIn Target has accepted connection request
def checkphish_vkontakte(peoplelist):
# If connected, send phishing message(-m), or generate custom one with markov chains(-mm)
# Generate unique tracking codes before phishing
# Output phished users + profiles + tracking codes to csv + console
VkontaktephisherObject = vkontaktephisher.Vkontaktephisher(showbrowser)
VkontaktephisherObject.doLogin(vkontakte_username,vkontakte_password)
count=1
ammount=len(peoplelist)
for person in peoplelist:
#Testcode to mimic a session timeout
#if count == 3: print "triggered delete"
# VkontaktephisherObject.testdeletecookies()
if person.vkontakte:
if args.vv == True:
print("Sending Vkontakte Phish %i/%i : %s" % (count,ammount,person.full_name))
else:
sys.stdout.write("\rSending Vkontakte Phish %i/%i : %s " % (count,ammount,person.full_name))
sys.stdout.flush()
count = count + 1
try:
#Set unique tracking id, increment global tracking_id value
global tracking_id
person.vkontaktetrackingcode = tracking_id
tracking_id = numpy.base_repr((int(tracking_id, 36) + 1), 36).zfill(5)
# Need to sepparate these out, so that there is another function to generate markov messages
if args.markovmessage: # If markov message, check if blank message "Error-MarkovNone" or "Error", if so send message, else send markov message
if person.vkontaktemarkovmessage == "Error-MarkovGeneralCrash" or person.vkontaktemarkovmessage == "Error-MarkovNoData" or person.vkontaktemarkovmessage == "Error-MarkovifyCrash":
person.vkontaktefinalphishingmessage = args.message.replace('[TRACKING_ID]',person.vkontaktetrackingcode).replace('[FULL_NAME]',person.full_name).replace('[LAST_NAME]',person.last_name).replace('[FIRST_NAME]',person.first_name)
person.vkontaktephish = VkontaktephisherObject.checkThenPhishVkontakteProfile(person.vkontakte,person.vkontaktefinalphishingmessage,vkontakte_username,vkontakte_password)
else:
phishingurl = args.markovmessage.replace('[TRACKING_ID]',person.vkontaktetrackingcode).replace('[FULL_NAME]',person.full_name).replace('[LAST_NAME]',person.last_name).replace('[FIRST_NAME]',person.first_name)
# if markov message contains no links, add the end, else replace links with phishing link
if "http" not in person.vkontaktemarkovmessage and "https" not in person.vkontaktemarkovmessage:
person.vkontaktefinalphishingmessage = person.vkontaktemarkovmessage + " " + phishingurl
else:
final_message_array = person.vkontaktemarkovmessage.split()
temp_message = ""
#If word in sentance is a link, replace it with phishing link
for word in final_message_array:
if "http" not in word and "https" not in word:
temp_message = temp_message + word + " "
else:
temp_message = temp_message + phishingurl + " "
person.vkontaktefinalphishingmessage = temp_message[:-1]
person.vkontaktephish = VkontaktephisherObject.checkThenPhishVkontakteProfile(person.vkontakte,person.vkontaktefinalphishingmessage,vkontakte_username,vkontakte_password)
elif args.message: # If just message, replace variables then send
person.vkontaktefinalphishingmessage = args.message.replace('[TRACKING_ID]',person.vkontaktetrackingcode).replace('[FULL_NAME]',person.full_name).replace('[LAST_NAME]',person.last_name).replace('[FIRST_NAME]',person.first_name)
person.vkontaktephish = VkontaktephisherObject.checkThenPhishVkontakteProfile(person.vkontakte,person.vkontaktefinalphishingmessage,vkontakte_username,vkontakte_password)
else:
print("Error, No Phishing Message Provided")
sys.exit(0)
sleep(3)
except:
traceback.print_exc()
continue
else:
continue
try:
VkontaktephisherObject.kill()
except:
print("Error Killing VKontakte Selenium instance")
return peoplelist
# If connected, send phishing message(-m), or generate custom one with markov chains(-mm)
# Generate unique tracking codes before phishing
# Output phished users + profiles + tracking codes to csv + console
# [MORE_SOCIAL_MEDIA_SITES_TAG]
# Code to check if each person has clicked by comparing unique tracking codes across web logs.
# Loops through the logs looking up each persons code, is "smart" and ignores the sites automated crawlers which poison the logs
def checkclicks(peoplelist,weblogs):
#linkedinclicked = ""
#linkedinclickedip = ""
#linkedinclickedtime = ""
#linkedinclickeduseragent = ""
file = open(weblogs, "r")
for person in peoplelist:
if person.facebookphish != "Sent":
person.facebookclicked = "Message Not Sent"
person.facebookclickedip = person.facebookphish
else:
person.facebookclicked = "Not Clicked"
if person.linkedinphish != "Sent":
person.linkedinclicked = "Message Not Sent"
person.linkedinclickedip = person.linkedinphish
else:
person.linkedinclicked = "Not Clicked"
if person.twitterphish != "Sent":
person.twitterclicked = "Message Not Sent"
person.twitterclickedip = person.twitterphish
else:
person.twitterclicked = "Not Clicked"
if person.vkontaktephish != "Sent":
person.vkontakteclicked = "Message Not Sent"
person.vkontakteclickedip = person.vkontaktephish
else:
person.vkontakteclicked = "Not Clicked"
for line in file:
if person.facebooktrackingcode != "":
if re.search(person.facebooktrackingcode, line):
# Only get first click by breaking after detection.
# Also disregard facebook cralwer user agents:
# Facebook crawler agents:
# User-Agent: facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)
if "facebookexternalhit" not in line and "+http://www.facebook.com/externalhit_uatext.php" not in line:
person.facebookclicked = "Link Clicked"
person.facebookclickedip = line.split(" - ")[0]
person.facebookclickedtime = line.split(" - ")[1]
person.facebookclickeduseragent = line.split(" - ")[2].replace(">",">").replace("<","<")
break
else:
person.facebookclicked = "Message Not Sent"
break
# After looping through the file, need to use .seek(0) to reset it to the start
file.seek(0)
for line in file:
if person.linkedintrackingcode != "":
if re.search(person.linkedintrackingcode, line):
# LinkedIn crawler agents:
# User-Agent: LinkedInBot/1.0 (compatible; Mozilla/5.0; Apache-HttpClient +http://www.linkedin.com)
if "LinkedInBot" not in line and "+http://www.linkedin.com" not in line:
person.linkedinclicked = "Link Clicked"
person.linkedinclickedip = line.split(" - ")[0]
person.linkedinclickedtime = line.split(" - ")[1]
person.linkedinclickeduseragent = line.split(" - ")[2].replace(">",">").replace("<","<")
break
else:
person.linkedinclicked = "Message Not Sent"
break
file.seek(0)
for line in file:
if person.twittertrackingcode != "":
if re.search(person.twittertrackingcode, line):
# Twitter crawler agents:
# User-Agent: Twitterbot/1.0
# User-Agent: Mozilla/5.0 (compatible; AhrefsBot/6.1; +http://ahrefs.com/robot/)
# User-Agent: Mozilla/5.0 (compatible; TrendsmapResolver/0.1)
if "Twitterbot" not in line and "AhrefsBot" not in line and "TrendsmapResolver" not in line and "Python-urllib" not in line and "+http://www.alexa.com" not in line:
if line.split(" - ")[2] != "":
person.twitterclicked = "Link Clicked"
person.twitterclickedip = line.split(" - ")[0]
person.twitterclickedtime = line.split(" - ")[1]
person.twitterclickeduseragent = line.split(" - ")[2].replace(">",">").replace("<","<")
break
else:
person.twitterclicked = "Message Not Sent"
break
file.seek(0)
for line in file:
if person.vkontaktetrackingcode != "":
if re.search(person.vkontaktetrackingcode, line):
# VKontakte crawler agents:
# User-Agent: Mozilla/5.0 (compatible; vkShare; +http://vk.com/dev/Share)
if "vkShare" not in line and "+http://vk.com/dev/Share" not in line:
person.vkontakteclicked = "Link Clicked"
person.vkontakteclickedip = line.split(" - ")[0]
person.vkontakteclickedtime = line.split(" - ")[1]
person.vkontakteclickeduseragent = line.split(" - ")[2].replace(">",">").replace("<","<")
break
else:
person.vkontakteclicked = "Message Not Sent"
break
file.seek(0)
# Non memory effiencent way, but better for HUGE log files
#if person.facebooktrackingcode in open(weblogs).read():
# person.facebookclicked = "Y"
#else:
# person.facebookclicked = "N"
return peoplelist
# Parse arguments, select which sites to use, then have:
# 3 options, either add and wait with given time (friendphish 2d) or just (add) or just (phish) or (check)
# this should mean you can
# 1) (add) everyone to friends/contacts
# 2) (check) and see who has accepted the request
# 3) (phish) send a message to everyone who has accepted
# 4) (addphish [X hours]) add everyone, wait X hours and then phish them
# option to add tracking code to links based off string in phishing message like [TRACKING_ID]
# 5) (checkclicks) takes the tracking ID csv + web server logs (Apache+IIS+pythonsimpleserver) and gives info on who has clicked the link
parser = argparse.ArgumentParser(
formatter_class=argparse.RawDescriptionHelpFormatter,
description='Social Attacker by Jacob Wilkin(Greenwolf)',
usage='%(prog)s -f <function> -i <inputCSV> <options>')
parser.add_argument('-v', '--version', action='version',
version='%(prog)s 0.1.0 : Social Attacker by Jacob Wilkin(Greenwolf)')
parser.add_argument('-vv', '--verbose', action='store_true',dest='vv',help='Verbose Mode')
parser.add_argument('-f', '--function',action='store', dest='function',required=True,choices=set(("prepare","add","check","generate","phish","addphish","checkclicks")),
help='Specify the function to perform \'add\'(everyone on list),\'check\'(who has accepted the request),\'generate\'(unique phish messages),\'phish\'(all that have accepted),\'addphish\'(Add & Phish everyone on list) or \'checkclicks\'(to see who has clicked the links)')
parser.add_argument('-i', '--input',action='store', dest='input',required=True,
help='The name of the csv file containing links to profiles, must include columns with header titled "Full Name","LinkedIn","Facebook","Twitter","Vkontakte" or the social attacker csv with tracking IDs if using the checklicks option')
parser.add_argument('-w', '--wait',action='store', dest='wait',required=False,
help='The number of hours to wait after adding targets on the list, before sending the phishing messages')
parser.add_argument('-m', '--message',action='store', dest='message',required=False,
help='The message that is sent to the targets: "[FULL_NAME]","[FIRST_NAME]","[LAST_NAME]" will be replaced with the targets name. "[TRACKING_ID]" will be replaced with a unique 6 character alphanumeric that will allow web logs to be loaded into social attacker to track clicks for each user. Example: "Hello [FIRSTNAME], Please click this link https://phishingdomain.com/macro_document.docx?t=[TRACKING_ID]".')
parser.add_argument('-mm', '--markovmessage',action='store', dest='markovmessage',required=False,
help='Use Markov Chains based on target history to generate a custom message. A link must be provided to add to the end of the message. "[TRACKING_ID]" will be replaced with a unique 6 character alphanumeric that will allow web logs to be loaded into social attacker to track clicks for each user. Example: "https://phishingdomain.com/macro_document.docx?t=[TRACKING_ID]". Note: If using this option you must also specify a backup message to use with -m or --message incase Markov generation fails.')
parser.add_argument('-ml', '--markovlength',action='store', dest='markovlength',required=False,
help='Set the max length in chars of the generated Markov Message, default is 140 if unset.')
parser.add_argument('-wl', '--weblogs',action='store', dest='weblogs',required=False,
help='A weblog containing requests to the site, to pull out tracking IDs and check for clicks')
parser.add_argument('-s', '--showbrowser',action='store_true',dest='showbrowser',help='If flag is set then browser will be visible')
parser.add_argument('-a', '--all',action='store_true',dest='a',help='Flag to check all supported social media sites')
parser.add_argument('-fb', '--facebook',action='store_true',dest='fb',help='Flag to check Facebook')
parser.add_argument('-li', '--linkedin',action='store_true',dest='li',help='Flag to check LinkedIn')
parser.add_argument('-tw', '--twitter',action='store_true',dest='tw',help='Flag to check Twitter')
parser.add_argument('-vk', '--vkontakte',action='store_true',dest='vk',help='Flag to check Vkontakte')
# [MORE_SOCIAL_MEDIA_SITES_TAG]
args = parser.parse_args()
if args.showbrowser:
showbrowser=True
else:
showbrowser=False
# A site needs to be specified
if not (args.a or args.fb or args.li or args.tw or args.vk) and args.function != "checkclicks":
parser.error('No sites specified, add -a for all, or a combination of the sites you want to check using a mix of -fb -li -tw -vk')
# adding and phishing at the same need needs a wait time
if args.function == "addphish" and not args.wait:
parser.error('Please supply a wait time for the \'addphish\' option with -w')
# tracking needs a weblog
if args.function == "checkclicks" and not args.weblogs:
parser.error('To use the \'checkclicks\' option, please provide an apache,iis or python simple server log file so tracking IDs can be extracted using -wl')
# A phish needs a message:
if ((args.function == "phish" or args.function == "addphish") and not args.message):
parser.error('If you wish to send a phishing message, please provide a message with -m, if you wish to use custom message generation with markov chains use -mm and provide a phishing link. Note you must always provide a -m message as a backup for if Markov generation fails. For more details see -h for help')
if (args.function == "prepare" and not args.li):
parser.error("The 'prepare' function only works if you specify LinkedIn (-li) and a company url as the input")
if (args.function == "add" or args.function == "check" or args.function == "generate" or args.function == "phish" or args.function == "addphish"):
# import social media profiles + names from social mapper CSV into person class from social mapper
# read csv into data using pandas, split up columns into a name,facebook and linkedin column
data = pandas.read_csv(args.input)
data.replace(numpy.nan,'', inplace=True)
try:
name_column = data['Full Name']
except:
print("No column called \"Full Name\" found in %s" % args.input)
sys.exit()
if (args.a or args.fb):
try:
facebook_column = data['Facebook']