diff --git a/qark/decompiler/decompiler.py b/qark/decompiler/decompiler.py index b75f8448..8b3c49d5 100644 --- a/qark/decompiler/decompiler.py +++ b/qark/decompiler/decompiler.py @@ -26,9 +26,9 @@ DECOMPILERS_PATH = os.path.join(LIB_PATH, "decompilers") -APK_TOOL_COMMAND = ("java -Djava.awt.headless=true -jar {apktool_path}/apktool.jar " - "d {path_to_source} --no-src --force -m --output {build_directory}") -DEX2JAR_COMMAND = "{dex2jar_path} {path_to_dex} -o {build_apk}.jar" +APK_TOOL_COMMAND = ("java -Djava.awt.headless=true -jar '{apktool_path}/apktool.jar' " + "d '{path_to_source}' --no-src --force -m --output '{build_directory}'") +DEX2JAR_COMMAND = "'{dex2jar_path}' '{path_to_dex}' -o '{build_apk}.jar'" def escape_windows_path(path): @@ -117,7 +117,7 @@ def _decompiler_function(self, decompiler): build_directory=self.build_directory)) try: - retcode = subprocess.call(shlex.split(decompiler_command)) + retcode = subprocess.call(shlex.split(decompiler_command.decode(encoding="utf-8"))) except Exception: log.exception("%s failed to finish decompiling, continuing", decompiler.name) else: @@ -152,7 +152,7 @@ def run_apktool(self): log.debug("Calling APKTool with following command") log.debug(custom_apktool_command) try: - subprocess.call(shlex.split(custom_apktool_command)) + subprocess.call(shlex.split(custom_apktool_command.decode(encoding="utf-8"))) except Exception: log.exception("Failed to run APKTool with command: %s", custom_apktool_command) raise SystemExit("Failed to run APKTool") @@ -203,7 +203,7 @@ def _run_dex2jar(self): log.debug("Running dex2jar with command %s", dex2jar_command) try: - ret_code = subprocess.call(shlex.split(dex2jar_command)) + ret_code = subprocess.call(shlex.split(dex2jar_command.decode(encoding="utf-8"))) if ret_code != 0: log.critical("Error running dex2jar command: %s", dex2jar_command) raise SystemExit("Error running dex2jar") diff --git a/qark/decompiler/external_decompiler.py b/qark/decompiler/external_decompiler.py index 47d6a27f..984d42a4 100644 --- a/qark/decompiler/external_decompiler.py +++ b/qark/decompiler/external_decompiler.py @@ -19,7 +19,7 @@ def __init__(self): ExternalDecompiler.__init__(self, name="cfr", path_to_decompiler=os.path.join(PATH_TO_DECOMPILERS, "cfr_0_124.jar"), - command="java -jar {path_to_decompiler} {jar} --outputdir {build_directory}/cfr") + command="java -jar '{path_to_decompiler}' '{jar}' --outputdir '{build_directory}/cfr'") class Procyon(ExternalDecompiler): @@ -28,7 +28,7 @@ def __init__(self): name="procyon", path_to_decompiler=os.path.join(PATH_TO_DECOMPILERS, "procyon-decompiler-1.0.jar"), - command="java -jar {path_to_decompiler} {jar} -o {build_directory}/procyon") + command="java -jar '{path_to_decompiler}' '{jar}' -o '{build_directory}/procyon'") class Fernflower(ExternalDecompiler): @@ -37,7 +37,7 @@ def __init__(self): name="fernflower", path_to_decompiler=os.path.join(PATH_TO_DECOMPILERS, "fernflower.jar"), - command="java -jar {path_to_decompiler} -ren=1 {jar} {build_directory}/fernflower") + command="java -jar '{path_to_decompiler}' -ren=1 '{jar}' '{build_directory}/fernflower'") DECOMPILERS = (CFR(), Procyon(), Fernflower())