Skip to content

Commit

Permalink
Fixes #8: Decode errors handled
Browse files Browse the repository at this point in the history
  • Loading branch information
hojat sajadinia committed Aug 2, 2024
1 parent e1894a8 commit a566c18
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion AndRoPass.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def argument_catcher():

def main():
cp.pr('blue', DES)

use_system_apktool = argument_catcher().apktool
system_apktool_path = argument_catcher().apktool_path
apk_file_path = argument_catcher().apk
Expand Down
16 changes: 8 additions & 8 deletions utils/Compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,17 @@ def decompile(self):
stderr=PIPE)
stdout, stderr = process.communicate()
if stderr != b'':
cp.pr('error', f"[ERROR] {stderr.decode('utf-8')}")
decompile_with_res_status = self.check_for_exception(stdout.decode('utf-8'))
cp.pr('error', f"[ERROR] {stderr.decode('utf-8', errors='ignore')}")
decompile_with_res_status = self.check_for_exception(stdout.decode('utf-8', errors='ignore'))

# Decompile using APKTool without resource
process = Popen(self.apktool_command + [ 'd', '-r', '-f', self.apk_path, '-o' , decompile_out_path_without_resource ],
stdout=PIPE,
stderr=PIPE)
stdout, stderr = process.communicate()
if stderr != b'':
cp.pr('error', f"[ERROR] {stderr.decode('utf-8')}")
decompile_without_res_status = self.check_for_exception(stdout.decode('utf-8'))
cp.pr('error', f"[ERROR] {stderr.decode('utf-8', errors='ignore')}")
decompile_without_res_status = self.check_for_exception(stdout.decode('utf-8', errors='ignore'))

if (decompile_with_res_status or decompile_without_res_status) != True:
# TODO Try multiple apktool versions to fix decompilation errors
Expand Down Expand Up @@ -110,9 +110,9 @@ def compile(self):
stderr=PIPE)
stdout, stderr = process.communicate()
if stderr != b'':
cp.pr('error', f"[ERROR] {stderr.decode('utf-8')}")
cp.pr('error', f"[ERROR] {stderr.decode('utf-8', errors='ignore')}")
compile_with_res_status = False
compile_with_res_status = compile_with_res_status and self.check_for_exception(stdout.decode('utf-8'))
compile_with_res_status = compile_with_res_status and self.check_for_exception(stdout.decode('utf-8', errors='ignore'))

# APK compiling without resource
if self.decompile_out_path_without_resource != '':
Expand All @@ -121,9 +121,9 @@ def compile(self):
stderr=PIPE)
stdout, stderr = process.communicate()
if stderr != b'':
cp.pr('error', f"[ERROR] {stderr.decode('utf-8')}")
cp.pr('error', f"[ERROR] {stderr.decode('utf-8', errors='ignore')}")
compile_without_res_status = False
compile_without_res_status = compile_without_res_status and self.check_for_exception(stdout.decode('utf-8'))
compile_without_res_status = compile_without_res_status and self.check_for_exception(stdout.decode('utf-8', errors='ignore'))

if (compile_with_res_status or compile_without_res_status) != True:
# TODO Try multiple apktool versions to fix compilation errors
Expand Down

0 comments on commit a566c18

Please sign in to comment.