def run(self): results = [] exceptions = [] # run all modules Log.info("Running all Android analysis modules") for module in self._analysis_modules: instance = module.Module() for option in self.options: if hasattr(self, option["name"]): setattr(instance, option["name"], getattr(self, option["name"])) try: Log.debug("Validating and Running: {}".format(instance.name())) instance.validate_options() run_result = instance.run() for key in run_result: if key.endswith("_result") and validate_analysis_result( run_result[key]) and run_result[key]["report"]: results += [run_result[key]] except Exception as e: exceptions += [{"module": instance.name(), "exception": e}] # setup output folders Log.info("Creating output folders") output_directory = "{}{}".format(self.output, self._output_directory) execute("mkdir -p {}".format(output_directory)) output_file = "{}/results.json".format(output_directory) # write results to json file Log.info("Writing results to file") with open(output_file, "w") as fp: fp.write(dumps(results)) return { "android_analysis": results, "exceptions": exceptions, "print": "The following issues were found:\n* {}".format("\n* ".join( [result["title"] for result in results])) }
def _print_result(self, result): from scrounger.core.module import validate_analysis_result if "exceptions" in result: for e in result["exceptions"]: print("[-] Exception: {}".format(e)) if "print" in result: print("[+] {}".format(result.pop("print"))) for key in result: if key.endswith("_result") and validate_analysis_result( result[key]): print("[+] Analysis result: {} (Severity: {})".format( result[key]["title"], result[key]["severity"])) print(" Should Be Reported: {}".format( "Yes" if result[key]["report"] else "No")) if "verbose" in self._global_options and \ self._global_options["verbose"].lower() == "true": print(" Details:\n{}".format(result[key]["details"]))
def _run_modules(modules, arguments, device): from scrounger.core.module import validate_analysis_result modules_instances = _module_parser(modules) options = _arguments_parser(arguments) if not device and "device" in options: device = options["device"] device = _device_parser(device, modules) options["device"] = device for index in modules_instances: print("Excuting Module {}".format(index)) instance = modules_instances[index] # set default options first for option in instance.options: setattr(instance, option["name"], option["default"]) # set options for option in options: setattr(instance, option, options[option]) result = instance.run() if "print" in result: print("[+] {}".format(result.pop("print"))) for key in result: if key.endswith("_result") and validate_analysis_result( result[key]): print("[+] Analysis result: {} (Severity: {})".format( result[key]["title"], result[key]["severity"])) print(" Should Be Reported: {}".format( "Yes" if result[key]["report"] else "No")) if _VERBOSE: print(" Details:\n{}".format(result[key]["details"]))
def _print_result(self, result): from scrounger.core.module import validate_analysis_result if "exceptions" in result: for e in result["exceptions"]: self._print_error("Exception: {}".format(e.message)) if "print" in result: self._print_status(result.pop("print")) for key in result: if key.endswith("_result") and validate_analysis_result( result[key]): print_result = "Analysis result: {} (Severity: {})".format( result[key]["title"], result[key]["severity"]) print_result = "{}\n Should Be Reported: {}".format( print_result, "Yes" if result[key]["report"] else "No") if "verbose" in self._session.global_options and \ self._session.global_options["verbose"].lower() == "true": print_result = "{}\n Details:\n{}".format( print_result, result[key]["details"]) self._print_status(print_result)