2222 HELP_MSG_HASHES ,
2323 HELP_MSG_IOC ,
2424 HELP_MSG_LIST_MODULES ,
25+ HELP_MSG_LOAD_MODULE ,
2526 HELP_MSG_MODULE ,
2627 HELP_MSG_NONINTERACTIVE ,
2728 HELP_MSG_OUTPUT ,
3031 HELP_MSG_VERSION ,
3132)
3233from mvt .common .logo import logo
34+ from mvt .common .module_loader import CustomModuleLoadError , load_custom_modules
3335from mvt .common .updates import IndicatorsUpdates
3436from mvt .common .utils import init_logging , set_verbose_logging
3537
@@ -59,6 +61,13 @@ def _get_disable_flags(ctx):
5961 )
6062
6163
64+ def _load_custom_modules (load_module ):
65+ try :
66+ return load_custom_modules (load_module )
67+ except CustomModuleLoadError as exc :
68+ raise click .ClickException (str (exc )) from exc
69+
70+
6271# ==============================================================================
6372# Main
6473# ==============================================================================
@@ -119,11 +128,28 @@ def check_adb(ctx):
119128@click .option ("--output" , "-o" , type = click .Path (exists = False ), help = HELP_MSG_OUTPUT )
120129@click .option ("--list-modules" , "-l" , is_flag = True , help = HELP_MSG_LIST_MODULES )
121130@click .option ("--module" , "-m" , help = HELP_MSG_MODULE )
131+ @click .option (
132+ "--load-module" ,
133+ type = click .Path (exists = True ),
134+ multiple = True ,
135+ default = [],
136+ help = HELP_MSG_LOAD_MODULE ,
137+ )
122138@click .option ("--verbose" , "-v" , is_flag = True , help = HELP_MSG_VERBOSE )
123139@click .argument ("BUGREPORT_PATH" , type = click .Path (exists = True ))
124140@click .pass_context
125- def check_bugreport (ctx , iocs , output , list_modules , module , verbose , bugreport_path ):
141+ def check_bugreport (
142+ ctx ,
143+ iocs ,
144+ output ,
145+ list_modules ,
146+ module ,
147+ load_module ,
148+ verbose ,
149+ bugreport_path ,
150+ ):
126151 set_verbose_logging (verbose )
152+ custom_modules = _load_custom_modules (load_module )
127153 # Always generate hashes as bug reports are small.
128154 cmd = CmdAndroidCheckBugreport (
129155 target_path = bugreport_path ,
@@ -133,6 +159,7 @@ def check_bugreport(ctx, iocs, output, list_modules, module, verbose, bugreport_
133159 hashes = True ,
134160 disable_version_check = _get_disable_flags (ctx )[0 ],
135161 disable_indicator_check = _get_disable_flags (ctx )[1 ],
162+ custom_modules = custom_modules ,
136163 )
137164
138165 if list_modules :
@@ -164,6 +191,13 @@ def check_bugreport(ctx, iocs, output, list_modules, module, verbose, bugreport_
164191)
165192@click .option ("--output" , "-o" , type = click .Path (exists = False ), help = HELP_MSG_OUTPUT )
166193@click .option ("--list-modules" , "-l" , is_flag = True , help = HELP_MSG_LIST_MODULES )
194+ @click .option (
195+ "--load-module" ,
196+ type = click .Path (exists = True ),
197+ multiple = True ,
198+ default = [],
199+ help = HELP_MSG_LOAD_MODULE ,
200+ )
167201@click .option ("--non-interactive" , "-n" , is_flag = True , help = HELP_MSG_NONINTERACTIVE )
168202@click .option ("--backup-password" , "-p" , help = HELP_MSG_ANDROID_BACKUP_PASSWORD )
169203@click .option ("--verbose" , "-v" , is_flag = True , help = HELP_MSG_VERBOSE )
@@ -174,12 +208,14 @@ def check_backup(
174208 iocs ,
175209 output ,
176210 list_modules ,
211+ load_module ,
177212 non_interactive ,
178213 backup_password ,
179214 verbose ,
180215 backup_path ,
181216):
182217 set_verbose_logging (verbose )
218+ custom_modules = _load_custom_modules (load_module )
183219
184220 # Always generate hashes as backups are generally small.
185221 cmd = CmdAndroidCheckBackup (
@@ -193,6 +229,7 @@ def check_backup(
193229 },
194230 disable_version_check = _get_disable_flags (ctx )[0 ],
195231 disable_indicator_check = _get_disable_flags (ctx )[1 ],
232+ custom_modules = custom_modules ,
196233 )
197234
198235 if list_modules :
@@ -223,6 +260,13 @@ def check_backup(
223260@click .option ("--output" , "-o" , type = click .Path (exists = False ), help = HELP_MSG_OUTPUT )
224261@click .option ("--list-modules" , "-l" , is_flag = True , help = HELP_MSG_LIST_MODULES )
225262@click .option ("--module" , "-m" , help = HELP_MSG_MODULE )
263+ @click .option (
264+ "--load-module" ,
265+ type = click .Path (exists = True ),
266+ multiple = True ,
267+ default = [],
268+ help = HELP_MSG_LOAD_MODULE ,
269+ )
226270@click .option ("--hashes" , "-H" , is_flag = True , help = HELP_MSG_HASHES )
227271@click .option ("--non-interactive" , "-n" , is_flag = True , help = HELP_MSG_NONINTERACTIVE )
228272@click .option ("--backup-password" , "-p" , help = HELP_MSG_ANDROID_BACKUP_PASSWORD )
@@ -235,13 +279,15 @@ def check_androidqf(
235279 output ,
236280 list_modules ,
237281 module ,
282+ load_module ,
238283 hashes ,
239284 non_interactive ,
240285 backup_password ,
241286 verbose ,
242287 androidqf_path ,
243288):
244289 set_verbose_logging (verbose )
290+ custom_modules = _load_custom_modules (load_module )
245291
246292 cmd = CmdAndroidCheckAndroidQF (
247293 target_path = androidqf_path ,
@@ -255,6 +301,7 @@ def check_androidqf(
255301 },
256302 disable_version_check = _get_disable_flags (ctx )[0 ],
257303 disable_indicator_check = _get_disable_flags (ctx )[1 ],
304+ custom_modules = custom_modules ,
258305 )
259306
260307 if list_modules :
@@ -288,6 +335,13 @@ def check_androidqf(
288335@click .option ("--output" , "-o" , type = click .Path (exists = False ), help = HELP_MSG_OUTPUT )
289336@click .option ("--list-modules" , "-l" , is_flag = True , help = HELP_MSG_LIST_MODULES )
290337@click .option ("--module" , "-m" , help = HELP_MSG_MODULE )
338+ @click .option (
339+ "--load-module" ,
340+ type = click .Path (exists = True ),
341+ multiple = True ,
342+ default = [],
343+ help = HELP_MSG_LOAD_MODULE ,
344+ )
291345@click .option (
292346 "--timezone" ,
293347 "-t" ,
@@ -307,11 +361,13 @@ def check_intrusion_logs(
307361 output ,
308362 list_modules ,
309363 module ,
364+ load_module ,
310365 timezone ,
311366 verbose ,
312367 logs_path ,
313368):
314369 set_verbose_logging (verbose )
370+ custom_modules = _load_custom_modules (load_module )
315371
316372 module_options = {}
317373 if timezone :
@@ -325,6 +381,7 @@ def check_intrusion_logs(
325381 module_options = module_options if module_options else None ,
326382 disable_version_check = _get_disable_flags (ctx )[0 ],
327383 disable_indicator_check = _get_disable_flags (ctx )[1 ],
384+ custom_modules = custom_modules ,
328385 )
329386
330387 if list_modules :
@@ -352,15 +409,25 @@ def check_intrusion_logs(
352409)
353410@click .option ("--list-modules" , "-l" , is_flag = True , help = HELP_MSG_LIST_MODULES )
354411@click .option ("--module" , "-m" , help = HELP_MSG_MODULE )
412+ @click .option (
413+ "--load-module" ,
414+ type = click .Path (exists = True ),
415+ multiple = True ,
416+ default = [],
417+ help = HELP_MSG_LOAD_MODULE ,
418+ )
355419@click .argument ("FOLDER" , type = click .Path (exists = True ))
356420@click .pass_context
357- def check_iocs (ctx , iocs , list_modules , module , folder ):
421+ def check_iocs (ctx , iocs , list_modules , module , load_module , folder ):
422+ custom_modules = _load_custom_modules (load_module )
358423 cmd = CmdCheckIOCS (
359424 target_path = folder ,
360425 ioc_files = iocs ,
361426 module_name = module ,
362427 disable_version_check = _get_disable_flags (ctx )[0 ],
363428 disable_indicator_check = _get_disable_flags (ctx )[1 ],
429+ custom_modules = custom_modules ,
430+ platform = "android" ,
364431 )
365432 cmd .modules = (
366433 BACKUP_MODULES + BUGREPORT_MODULES + ANDROIDQF_MODULES + INTRUSION_LOGS_MODULES
0 commit comments