ClaudiuGeorgiu / Obfuscapk

An automatic obfuscation tool for Android apps that works in a black-box fashion, supports advanced obfuscation features and has a modular architecture easily extensible with new techniques
MIT License
1.09k stars 285 forks source link

Obfuscate APK not Find In Linux and macOS #132

Closed Yunoon closed 9 months ago

Yunoon commented 2 years ago

my Command docker run -v "/root":"/workdir" claudiugeorgiu/obfuscapk -w /workdir/obfuscation_dir/ -o ConstStringEncryption -d /workdir/obfuscated.apk /workdir/base233.apk -p

but in /root, the obfuscated.apk not in the directory.

ClaudiuGeorgiu commented 2 years ago

Rebuild, NewAlignment and NewSignature obfuscators are always needed to complete an obfuscation operation, to build the final obfuscated apk. Add them after ConstStringEncryption and obfuscated.apk should be generated correctly.

Yunoon commented 2 years ago

Rebuild, NewAlignment and NewSignature obfuscators are always needed to complete an obfuscation operation, to build the final obfuscated apk. Add them after ConstStringEncryption and obfuscated.apk should be generated correctly.

Thanks for your reply. The obfuscated.apk already can generate, but if the size of input.apk is over 10M. It can't work, and give some error info.

[root@VM-0-15-centos ~]# docker run -v "/root":"/workdir" claudiugeorgiu/obfuscapk -w /workdir/obfuscation_dir/ -o ConstStringEncryption -o Rebuild -o NewAlignment -o NewSignature -o Nop -d /workdir/obfuscated.apk /workdir/base233.apk -p Encrypting constant strings: 100%|██████████|[00:07<00:00, 834.98file/s] bfuscator/s] Running obfuscators (Rebuild): 20%|██ |[00:13<00:52, 13.23s/obfuscator] 13/04/2022 02:07:47> [ERROR][obfuscapk.tool.Apktool][build()] Error during build command: I: Using Apktool 2.6.0 I: Smaling smali folder into classes.dex... I: Smaling smali_classes4 folder into classes4.dex... I: Smaling smali_classes2 folder into classes2.dex... I: Smaling smali_classes3 folder into classes3.dex... I: Building resources... brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [/tmp/brut_util_Jar_15959729868483470002394043931865133930.tmp, p, --forced-package-id, 127, --min-sdk-version, 31, --target-sdk-version, 32, --version-code, 1, --version-name, 1.0, --no-version-vectors, -F, /tmp/APKTOOL18373106872540519262.tmp, -e, /tmp/APKTOOL744005608164406140.tmp, -0, arsc, -I, /tmp/1.apk, -S, /workdir/obfuscation_dir/base233/res, -M, /workdir/obfuscation_dir/base233/AndroidManifest.xml] W: invalid resource directory name: /workdir/obfuscation_dir/base233/res navigation

13/04/2022 02:07:47> [ERROR][obfuscapk.obfuscation][build_obfuscated_apk()] Error during apk building: Command '['/usr/local/bin/apktool', '--frame-path', '/tmp', 'b', '--force-all', '/workdir/obfuscation_dir/base233', '-o', '/workdir/obfuscated.apk']' returned non-zero exit status 1. 13/04/2022 02:07:47> [ERROR][yapsy_loaded_plugin_Rebuild_1.rebuild.Rebuild][obfuscate()] Error during execution of "Rebuild" obfuscator: Command '['/usr/local/bin/apktool', '--frame-path', '/tmp', 'b', '--force-all', '/workdir/obfuscation_dir/base233', '-o', '/workdir/obfuscated.apk']' returned non-zero exit status 1. 13/04/2022 02:07:47> [CRITICAL][obfuscapk.main][perform_obfuscation()] Error during obfuscation: Command '['/usr/local/bin/apktool', '--frame-path', '/tmp', 'b', '--force-all', '/workdir/obfuscation_dir/base233', '-o', '/workdir/obfuscated.apk']' returned non-zero exit status 1. Traceback (most recent call last): File "/Obfuscapk/obfuscapk/main.py", line 153, in perform_obfuscation (obfuscator_name_to_function[obfuscator_name])(obfuscation) File "/Obfuscapk/obfuscapk/obfuscators/rebuild/rebuild.py", line 20, in obfuscate obfuscation_info.build_obfuscated_apk() File "/Obfuscapk/obfuscapk/obfuscation.py", line 555, in build_obfuscated_apk apktool.build(self._decoded_apk_path, self.obfuscated_apk_path) File "/Obfuscapk/obfuscapk/tool.py", line 166, in build output = subprocess.check_output( File "/usr/local/lib/python3.10/subprocess.py", line 420, in check_output return run(popenargs, stdout=PIPE, timeout=timeout, check=True, File "/usr/local/lib/python3.10/subprocess.py", line 524, in run raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '['/usr/local/bin/apktool', '--frame-path', '/tmp', 'b', '--force-all', '/workdir/obfuscation_dir/base233', '-o', '/workdir/obfuscated.apk']' returned non-zero exit status 1. Running obfuscators (Rebuild): 20%|██ |[00:26<01:47, 26.78s/obfuscator] Traceback (most recent call last): File "/usr/local/lib/python3.10/runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "/usr/local/lib/python3.10/runpy.py", line 86, in _run_code exec(code, run_globals) File "/Obfuscapk/obfuscapk/cli.py", line 189, in main() File "/Obfuscapk/obfuscapk/cli.py", line 171, in main perform_obfuscation( File "/Obfuscapk/obfuscapk/main.py", line 153, in perform_obfuscation (obfuscator_name_to_function[obfuscator_name])(obfuscation) File "/Obfuscapk/obfuscapk/obfuscators/rebuild/rebuild.py", line 20, in obfuscate obfuscation_info.build_obfuscated_apk() File "/Obfuscapk/obfuscapk/obfuscation.py", line 555, in build_obfuscated_apk apktool.build(self._decoded_apk_path, self.obfuscated_apk_path) File "/Obfuscapk/obfuscapk/tool.py", line 166, in build output = subprocess.check_output( File "/usr/local/lib/python3.10/subprocess.py", line 420, in check_output return run(popenargs, stdout=PIPE, timeout=timeout, check=True, File "/usr/local/lib/python3.10/subprocess.py", line 524, in run raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '['/usr/local/bin/apktool', '--frame-path', '/tmp', 'b', '--force-all', '/workdir/obfuscation_dir/base233', '-o', '/workdir/obfuscated.apk']' returned non-zero exit status 1.

Yunoon commented 2 years ago

I found that it might be a problem with my APK file. When I try to obfuscate an APK file from officially provided, I can obfuscate it. The APK file in question was compiled and generated by android studio.