-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodule.py
80 lines (64 loc) · 2.23 KB
/
module.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
import os
from console import print_info, print_ok
from setglobal import Global
# from jobs import Jobs, Job
class Module(object):
def __init__(self, information, options):
self._information = information
self.options = options
self.args = {}
self.update_global()
self.update_options()
self.init_args()
def update_global(self):
variables = Global.get_instance().get_variables()
for key, value in self.options.items():
try:
if variables[key]:
continue
except:
Global.get_instance().add_value(key, None)
def update_options(self):
variables = Global.get_instance().get_variables()
for key, value in self.options.items():
try:
value = variables[key]
if value:
self.options[key][0] = value
except:
pass
def get_information(self):
return self._information
def set_value(self, name, value):
self.args[name] = value
self.options[name][0] = value
if value:
msg = name + " >> " + value
print_info(msg)
def get_value(self, option):
return self.args[option]
def get_options_dict(self):
return self.options
def get_options_names(self):
return self.options.keys()
def init_args(self):
for key, opts in self.options.items():
self.args[key] = opts[0]
def run_module(self):
raise Exception("ERROR: run_module method must be implemented in the child class")
def run(self, t):
# only if it is called with super
# management threads
# job = Job(self._information,t)
# Jobs.get_instance().add_value(job)
print_ok("Done!")
def check_arguments(self):
for key, value in self.options.items():
if value[2] is True and str(value[0]) == "None":
return False
return True
def run_binary(self, binary, args=None):
payload = binary
if args:
payload += " " + " ".join(args)
os.system(payload)