-
-
Notifications
You must be signed in to change notification settings - Fork 38
/
mmsf.py
executable file
·97 lines (85 loc) · 3.13 KB
/
mmsf.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
#!/usr/bin/python3
import os
import pkgutil
import readline
import shlex
from signal import signal, SIGINT
from Classes.MassiveMobileSecurityFramework import MassiveMobileSecurityFramework
from Classes.utils import listmodules, print_help, search, unknown_cmd
from colorama import Fore
def handler(signal_received, frame):
# Handle any cleanup here
print('SIGINT or CTRL-C detected. Type \'exit\' to exit')
def init_modules():
print("""
* * ( (
( ` ( ` )\ ) )\ )
)\))( )\))( (()/((()/(
((_)()\ ((_)()\ /(_))/(_))
(_()((_)(_()((_)(_)) (_))_|
| \/ || \/ |/ __|| |_
| |\/| || |\/| |\__ \| __|
|_| |_||_| |_||___/|_|
""")
print(Fore.GREEN + '... Initiating modules ...' + Fore.RESET)
modules = []
__path__ = [os.path.dirname(os.path.abspath(__file__)) + '/modules']
for importer, modname, ispkg in pkgutil.walk_packages(path=__path__):
p = __import__("modules." + modname)
m = getattr(p, modname)
c = getattr(m, modname)
instance = c()
modules.append(instance)
return modules
def main():
"""
modules: the modules instances
details_: list of tuples for (name, description) for listmodules
modules_dict: dict {name: instance} to perfom commands based on received name
"""
modules = init_modules()
details_ = [(x.name, x.description) for x in modules]
modules_dict = {}
for module in modules:
modules_dict[module.name] = module
modules_names, descriptions = zip(*details_)
mmsf = MassiveMobileSecurityFramework()
initial_commands = ["usemodule", "exit", "listmodules", "search"]
readline.parse_and_bind("tab: complete")
while True:
def init_completer(text, state):
options = [i for i in initial_commands if i.startswith(text)]
if state < len(options):
return options[state]
else:
return None
readline.set_completer(init_completer)
input_val = shlex.split(input('mmsf> '))
if len(input_val) < 1:
continue
if len(input_val) > 2:
unknown_cmd()
elif input_val[0].lower() == "exit":
quit()
elif input_val[0].lower() == "listmodules":
# if mmsf._device_type == 'iOS':
# listiosonlymodules
listmodules(list(modules_names), list(descriptions))
elif input_val[0].lower() == "usemodule":
if len(input_val) == 2:
action = input_val[1].lower()
if action not in modules_names:
unknown_cmd()
else:
modules_dict[action].execute(mmsf)
else:
print(Fore.RED + '[-] Usage: usemodule modulename' + Fore.RESET)
elif input_val[0].lower() == "search":
if len(input_val) == 2:
action = input_val[1].lower()
search(action, modules_dict)
elif input_val[0].lower() == "help" or input_val[0] == "?":
print_help()
if __name__ == "__main__":
signal(SIGINT, handler)
main()