-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathasadt.py
More file actions
203 lines (114 loc) · 6.19 KB
/
asadt.py
File metadata and controls
203 lines (114 loc) · 6.19 KB
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
#!/usr/bin/env python3
try:
# HOSTUTILS
import typer as TypeCLI
import time
import os
# TERM UTILS
from rich import print
from rich.console import Console as rcon
from rich.prompt import Prompt
## DBHS
from libasadt3.displayboxhandler import DisplayBoxHandler_Service
## MAINPROG
from libasadt3.mainprog import CnfEdit
from libasadt3.mainprog import TOML_Loader
from libasadt3.mainprog import ProgBanner
from libasadt3.mainprog import ProgUpdate
from libasadt3.mainprog import Verify_SUID
## MODULES
from libasadt3 import modules_main
# ENV VARS
cli_host = TypeCLI.Typer()
con_host = rcon()
# LOCAL VARS
local_config_dir = f'{os.getcwd()}/config'
local_config = TOML_Loader(local_config_dir)
# SERVICE HANDLES
ui_handler = DisplayBoxHandler_Service()
nanoeditor = CnfEdit(5) # Alter 'editor_type' If "nano" is not the prefered terminal editor.
except ImportError as ErrorID:
print(f'Python Import Error: {ErrorID}')
raise SystemExit(3)
## LOAD MAIN CONFIGURATION
main_config = local_config.loadfile('scriptinfo.toml')
if main_config.status_ok == False:
print(f'[red bold]\nTOML_Loader Error > Failed To Load Configuration File "{main_config.parser_cnffileid}"!\nReason > {main_config.status_data}\n[/red bold]')
raise SystemExit(4)
else:
program_banner = ProgBanner(main_config.dictionary['script_data']['script_version'])
## INIT CLI
@cli_host.command('run', help='Selects [TOOL_NAME] In [MODULE_NAME] For Execution And Display\n\n----[THE SCANTOOL MODULE]----\n\nrun scantool nmap --> NMAP\n\nrun scantool nikto --> NIKTO\n\n----[THE HACKTOOL MODULE]----\n\nrun hacktool msfpc --> MSFPC')
def asadtexec(module_name: str, tool_name: str, debugger: bool = False):
program_banner.display_banner(banner_type='short')
if module_name == 'scantool':
if tool_name in modules_main.ScanTool.submodules:
module_active = modules_main.ScanTool
else:
print(f'[red bold] [!] Module Error > ScanTool Does Not Have A Tool Named "{tool_name}"\n[blue bold] [?] Need Help? > Execute: ./asadt.py run --help')
raise SystemExit(3)
elif module_name == 'hacktool':
if tool_name in modules_main.HackTool.submodules:
module_active = modules_main.HackTool
else:
print(f'[red bold] [!] Module Error > HackTool Does Not Have A Tool Named "{tool_name}"\n[blue bold] [?] Need Help? > Execute: ./asadt.py run --help')
raise SystemExit(3)
else:
print(f'[red bold] [!] Module Error > The Module "{module_name}" Does Not Exist!\n[blue bold] [?] Need Help? > Execute: ./asadt.py run --help')
raise SystemExit(3)
with con_host.status(f'[red bold] Loading ASADT SuperScript {main_config.dictionary["script_data"]["script_version"]}...', spinner='arc', spinner_style='red') as loaderanim:
time.sleep(1.5)
if tool_name in module_active.submodules:
if tool_name in ui_handler.uimodel_parameter_launchlist:
loaderanim.update(f'[red bold] Loading Configuration... {module_name} <\> {tool_name}')
tool_exec_props = TOML_Loader(local_config_dir).loadfile(module_name + '/' + tool_name + '.toml')
time.sleep(1.5)
loaderanim.update(f'[red bold] Displaying UI... {module_name} <\> {tool_name}')
tool_exec_args = ui_handler.DISPLAY_UI_MODEL(tool_name)
time.sleep(1.5)
loaderanim.stop()
if tool_exec_props.status_ok:
if tool_exec_args.ui_request_exit:
print('[red bold] [!] Exiting Upon User Request!\n')
raise SystemExit(1)
if tool_exec_args.ui_request_editcnf:
nanoeditor.run_editor(local_config_dir + '/' + module_name + '/' + tool_name + '.toml')
else:
module_active(tool_name, tool_exec_props.dictionary, tool_exec_args.values, debugger).cmdgen()
else:
print(f'[red bold] [!] LOML_Loader Error > The Configuration File "{tool_exec_props.parser_cnffileid}" Failed To Load!\n[blue bold] [?] Reason > {tool_exec_props.status_data}')
raise SystemExit(3)
else:
print(f'[red bold] [!] Error > DBHS: No UIMODEL Exists For "{tool_name}"\n[blue bold] [?] The Requested Tool Does Not Have A Registered DisplayBoxID')
raise SystemExit(3)
else:
print(f'[red bold] [!] Module Error > "{tool_name}" Does Not Exist!\n[blue bold] [?] Need Help? > Execute: ./asadt.py run --help')
raise SystemExit(3)
@cli_host.command('version', help='Shows Program Banner & Version, Then Exits.')
def showv():
program_banner.display_banner()
raise SystemExit(0)
@cli_host.command('update', help='Update APT Dependencies Or Check For Newer Version Of The ASADT MK 3 Script')
def hostupdate(apt_dep_update: bool = False):
program_banner.display_banner('short')
if apt_dep_update == True:
updateobj = ProgUpdate.localdebupdate(modules_main.toolbox_main)
raise SystemExit(0)
updateobj = ProgUpdate(main_config.dictionary['script_data']['script_version'], main_config.dictionary['script_data']['script_master'])
updateobj.check_rfs(); updateobj.write_uf()
new_hsi = TOML_Loader(os.getcwd()).loadfile(updateobj.newversion_config)
updateobj.remove_uf()
if new_hsi.status_ok:
update_resp = updateobj.verify_update_requirements(new_hsi.dictionary['script_data']['script_version'])
if update_resp == True:
update_ask = Prompt.ask('\n[yellow bold] [?] Answer? (Y/N)')
if update_ask == 'Y' or update_ask == 'y':
updateobj.new_release_download(main_config.dictionary['script_data']['script_repo'], str(new_hsi.dictionary['script_data']['script_version']).lower())
else:
print('[red bold]\n [!] Exiting Upon Users Request!\n')
raise SystemExit(1)
else:
raise SystemExit(0)
if __name__ == '__main__':
Verify_SUID()
cli_host()