-
Notifications
You must be signed in to change notification settings - Fork 237
/
Copy pathmango.py
executable file
·111 lines (99 loc) · 3.65 KB
/
mango.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
#!/usr/bin/env python3
# Standard library imports
import logging
import os.path
import sys
# Local application/library specific imports
from colorama import Fore, Style, init
from libraries.libmango import *
from libraries.Questions import *
from libraries.libguava import *
from libraries.libadb import *
from libraries.logging_config import setup_logging
from shutil import which
logging.getLogger().handlers = []
setup_logging()
logger = logging.getLogger(__name__)
init(autoreset=True)
def check_cli_tools():
tools = ["adb", "jdb", "zipalign", "apksigner", "trufflehog"]
all_installed = True
logger.info("Checking required tools:")
for tool in tools:
if shutil.which(tool):
print(f"{Fore.GREEN}[✔] {tool}")
else:
print(f"{Fore.RED}[x] {tool}")
all_installed = False
if not all_installed:
logger.warning("Some tools are missing. Certain features may not work correctly.")
else:
logger.info("All tools are installed. You are good to go!")
def print_logo():
print(Style.BRIGHT + BLUE + """
Welcome to
888b d888
8888b d8888
88888b.d88888
888Y88888P888 8888b. 88888b. .d88b. .d88b.
888 Y888P 888 "88b 888 "88b d88P"88b d88""88b
888 Y8P 888 .d888888 888 888 888 888 888 888
888 " 888 888 888 888 888 Y88b 888 Y88..88P
888 888 "Y888888 888 888 "Y88888 "Y88P"
888
Y8b d88P
"Y88P" """ + Style.RESET_ALL + RESET)
def start_session(db_session, existing=False):
application_database = apk_db(db_session)
guava = Guava(application_database)
p = parser()
p.database = application_database
p.guava = guava
if existing:
p.continue_session(guava)
p.device = p.get_device()
p.cmdloop()
def interactive_menu():
menu = {
'1': "Start a new session",
'2': "Continue an existing session",
'3': "Exit"
}
while True:
print("-" * 50 + "\n[?] What do you want to do?\n" + "-" * 50)
for key, option in menu.items():
print(f"{key}. {option}")
selection = input("\n[?] Enter your selection: ").strip()
if selection == '1':
session = input("\n[?] Enter a session name: ").strip()
start_session(session)
break
elif selection == '2':
session = input("\n[?] Enter the full path to the session file: ").strip()
if os.path.exists(session):
start_session(session, existing=True)
else:
logger.error(f"Can't find session file: {session}")
break
elif selection == '3':
print("Exiting...")
sys.exit()
else:
logger.warning("Unknown option selected. Please try again.")
if __name__ == "__main__":
if len(sys.argv) > 1:
if sys.argv[1] == '-h':
print("Usage: mango [session file]\n\nOptions:\n [session file] Specify the path to an existing session file to continue.\n -h Show this help message and exit.")
sys.exit(0)
else:
print_logo()
check_cli_tools()
session = sys.argv[1]
if os.path.exists(session):
start_session(session, existing=True)
else:
logger.error(f"Session file not found: {session}")
sys.exit(1)
else:
print_logo()
interactive_menu()