def main(): parser = get_parser() args = parser.parse_args() options = build_options(args) if not options.output.json: print(f"[+] APKiD {__version__} :: from RedNaga :: rednaga.io") rules = options.rules_manager.load() scanner = Scanner(rules, options) for input in args.input: scanner.scan(input)
def apkid_analysis(app_dir, apk_file, apk_name): """APKiD Analysis of DEX files""" apkid_res = {} if not settings.APKID_ENABLED: return apkid_res if not os.path.exists(apk_file): logger.error("APKiD - APK not found") return {'error': True} from apkid import __version__ as apkid_ver from apkid.apkid import Scanner, Options logger.info("Running APKiD") dest_dir = os.path.join(app_dir, "apkid") options = Options( timeout=30, verbose=None, json=True, output_dir=dest_dir, typing=None, entry_max_scan_size=100 * 1024 * 1024, scan_depth=2, recursive=True ) rules = options.rules_manager.load() scanner = Scanner(rules, options) scanner.scan(apk_file) file_name = filename_from_path(apk_file) report_file = file_name + "_apkid.json" report = os.path.join(dest_dir, report_file) with open(report, 'r') as flip: result = json.load(flip) for filep, res in result.items(): try: dex_file = filep.rsplit("!", 1)[1] except Exception: dex_file = apk_name apkid_res[dex_file] = res return apkid_res