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.11k stars 288 forks source link

Apk no start after obfuskate #3

Closed dfdfdfs closed 12 months ago

dfdfdfs commented 5 years ago

Hello

after the command

obfuscapk -o RandomManifest -o Rebuild -o NewSignature -o NewAlignment -p original.apk Apk work

after the command python3.7 -m obfuscapk.cli -o ConstStringEncryption -o RandomManifest -o Rebuild -o NewSignature -o NewAlignment -p sss.apk

Apk not work Android 6.0

See apk files

Obfuscate apk https://cloud.mail.ru/public/UtDg/4jLkoZbcn

Original apk https://trashbox.ru/files30/220305/sms-edit-v1.4.0.apk/

Please fix bug

ClaudiuGeorgiu commented 5 years ago

Hi, I tried installing the obfuscated app you provided on an Android 6 emulator and it starts and seems to work. Can you describe more in details what is the expected behavior and what doesn't work exactly?

dfdfdfs commented 5 years ago

Hello

Please look at this APK.

After comand python3.7 -m obfuscapk.cli -o MethodRename -o RandomManifest -o Rebuild -o NewSignature -o NewAlignment -p sss.apk APK crashes

See log

09-09 22:13:16.329 I/Timeline( 5819): Timeline: Activity_launch_request id:com.wooga.pearlsperil time:69821341 09-09 22:13:16.334 D/GameManagerService( 4557): identifyGamePackage. com.wooga.pearlsperil 09-09 22:13:16.334 D/MultiWindowPolicy( 4557): Gamemode - return 0, when calling identifyForegroundApp(com.wooga.pearlsperil) 09-09 22:13:16.334 V/WindowManager( 4557): addAppToken: AppWindowToken{83ab670 token=Token{80a70b3 ActivityRecord{9656e22 u0 com.wooga.pearlsperil/com.wooga.WoogaUnityPlayerActivity t1328}}} to stack=1 task=1328 at 0 09-09 22:13:16.339 D/ISSUE_DEBUG( 4557): InputChannelName : 4ae388 Starting com.wooga.pearlsperil 09-09 22:13:16.364 I/ActivityManager( 4557): Start proc 13458:com.wooga.pearlsperil/u0a1424 for activity com.wooga.pearlsperil/com.wooga.WoogaUnityPlayerActivity 09-09 22:13:16.369 W/SELinux (13458): SELinux: seapp_context_lookup: seinfo=default, level=s0:c512,c768, pkgname=com.wooga.pearlsperil 09-09 22:13:16.379 I/ActivityManager( 4557): DSS on for com.wooga.pearlsperil and scale is 0.75 09-09 22:13:16.409 V/WindowStateAnimator( 4557): Finishing drawing window Window{4ae388 u0 d0 Starting com.wooga.pearlsperil}: mDrawState=DRAW_PENDING 09-09 22:13:16.464 D/ActivityManager( 4557): Launching com.wooga.pearlsperil, updated priority 09-09 22:13:16.474 D/GameManagerService( 4557): NotifyRunnable. pkg: com.wooga.pearlsperil, type: 4, isMinimized: false, isTunableApp: false 09-09 22:13:16.514 D/GetAppListHook(13458): Set Size:4 pkg:com.wooga.pearlsperil 09-09 22:13:16.514 I/Xposed (13458): W:com.wooga.pearlsperil com.wooga.pearlsperil 09-09 22:13:16.549 D/FileOpenHook(13458): Set Size:4 pkg:com.wooga.pearlsperil 09-09 22:13:16.634 E/AndroidRuntime(13458): Process: com.wooga.pearlsperil, PID: 13458 09-09 22:13:16.639 W/ActivityManager( 4557): Force finishing activity com.wooga.pearlsperil/com.wooga.WoogaUnityPlayerActivity 09-09 22:13:16.664 V/WindowStateAnimator( 4557): Finishing drawing window Window{4ae388 u0 d0 Starting com.wooga.pearlsperil}: mDrawState=DRAW_PENDING 09-09 22:13:16.949 I/WindowManager( 4557): Screenshot max retries 4 of Token{80a70b3 ActivityRecord{9656e22 u0 com.wooga.pearlsperil/com.wooga.WoogaUnityPlayerActivity t1328 f}} appWin=Window{4ae388 u0 d0 Starting com.wooga.pearlsperil} drawState=3 09-09 22:13:16.964 D/ISSUE_DEBUG( 4557): InputChannelName : e5119df Application Error: com.wooga.pearlsperil 09-09 22:13:17.009 D/StatusBarManagerService( 4557): manageDisableList userId=0 what=0x0 pkg=Window{e5119df u0 d0 Application Error: com.wooga.pearlsperil} 09-09 22:13:17.044 I/FA (13458): adb shell setprop debug.firebase.analytics.app com.wooga.pearlsperil 09-09 22:13:17.049 V/WindowStateAnimator( 4557): Finishing drawing window Window{e5119df u0 d0 Application Error: com.wooga.pearlsperil}: mDrawState=DRAW_PENDING 09-09 22:13:17.064 I/WindowManager( 4557): Screen frozen for +681ms due to Window{e5119df u0 d0 Application Error: com.wooga.pearlsperil} 09-09 22:13:17.069 D/q_com.wooga.pearlsperil(13458): MD5 data: 09-09 22:13:17.069 I/Xposed (13458): [com.wooga.pearlsperil]MD5 data: 09-09 22:13:17.074 W/System.err(13458): java.io.FileNotFoundException: /sdcard/ydsec/com.wooga.pearlsperil.txt: open failed: EACCES (Permission denied) 09-09 22:13:17.074 D/q_com.wooga.pearlsperil(13458): MD5 result: 09-09 22:13:17.074 I/Xposed (13458): [com.wooga.pearlsperil]MD5 result: 09-09 22:13:17.074 W/System.err(13458): java.io.FileNotFoundException: /sdcard/ydsec/com.wooga.pearlsperil.txt: open failed: EACCES (Permission denied) 09-09 22:13:17.449 W/ActivityManager( 4557): Activity pause timeout for ActivityRecord{9656e22 u0 com.wooga.pearlsperil/com.wooga.WoogaUnityPlayerActivity t1328 f} 09-09 22:13:17.624 V/WindowStateAnimator( 4557): Finishing drawing window Window{e5119df u0 d0 Application Error: com.wooga.pearlsperil}: mDrawState=DRAW_PENDING 09-09 22:13:17.629 V/WindowStateAnimator( 4557): Finishing drawing window Window{4ae388 u0 d0 Starting com.wooga.pearlsperil EXITING}: mDrawState=DRAW_PENDING 09-09 22:13:17.639 V/WindowStateAnimator( 4557): Finishing drawing window Window{e5119df u0 d0 Application Error: com.wooga.pearlsperil}: mDrawState=HAS_DRAWN 09-09 22:13:17.639 D/StatusBarManagerService( 4557): manageDisableList userId=0 what=0x0 pkg=Window{e5119df u0 d0 Application Error: com.wooga.pearlsperil} 09-09 22:13:18.734 I/ActivityManager( 4557): Process com.wooga.pearlsperil (pid 13458)(adj 11) has died(93,985) 09-09 22:13:18.734 D/ActivityManager( 4557): isAutoRunBlockedApp:: com.wooga.pearlsperil, Auto Run ON

Apk file https://cloud.mail.ru/public/3HP3/5dsBr9Boj

Original https://cloud.mail.ru/public/5Eo2/285SJ7Xnn

dfdfdfs commented 5 years ago

After comand python3.7 -m obfuscapk.cli -o Nop -o RandomManifest -o Rebuild -o NewSignature -o NewAlignment -p sss.apk APK crashes

Apk https://cloud.mail.ru/public/4kDZ/3zioyyqkc

dfdfdfs commented 5 years ago

After comand python3.7 -m obfuscapk.cli -o Nop -o RandomManifest -o Rebuild -o NewSignature -o NewAlignment -p sss.apk APK crashes

Apk https://cloud.mail.ru/public/4kDZ/3zioyyqkc

See log https://cloud.mail.ru/public/5grN/3Z3Toat8U package name com.wooga.pearlsperil

09-10 19:25:54.626 D/AndroidRuntime(27782): Shutting down VM 09-10 19:25:54.626 E/AndroidRuntime(27782): FATAL EXCEPTION: main 09-10 19:25:54.626 E/AndroidRuntime(27782): Process: com.wooga.pearlsperil, PID: 27782 09-10 19:25:54.626 E/AndroidRuntime(27782): java.lang.VerifyError: Rejecting class com.google.firebase.FirebaseApp because it failed compile-time verification (declaration of 'com.google.firebase.FirebaseApp' appears in /data/app/com.wooga.pearlsperil-1/base.apk:classes2.dex) 09-10 19:25:54.626 E/AndroidRuntime(27782): at com.google.firebase.provider.FirebaseInitProvider.onCreate(com.google.firebase:firebase-common@@17.0.0:53) 09-10 19:25:54.626 E/AndroidRuntime(27782): at android.content.ContentProvider.attachInfo(ContentProvider.java:1789) 09-10 19:25:54.626 E/AndroidRuntime(27782): at android.content.ContentProvider.attachInfo(ContentProvider.java:1764) 09-10 19:25:54.626 E/AndroidRuntime(27782): at com.google.firebase.provider.FirebaseInitProvider.attachInfo(com.google.firebase:firebase-common@@17.0.0:47) 09-10 19:25:54.626 E/AndroidRuntime(27782): at android.app.ActivityThread.installProvider(ActivityThread.java:6763) 09-10 19:25:54.626 E/AndroidRuntime(27782): at android.app.ActivityThread.installContentProviders(ActivityThread.java:6358) 09-10 19:25:54.626 E/AndroidRuntime(27782): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6298) 09-10 19:25:54.626 E/AndroidRuntime(27782): at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method) 09-10 19:25:54.626 E/AndroidRuntime(27782): at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:751) 09-10 19:25:54.626 E/AndroidRuntime(27782): at android.app.ActivityThread.handleBindApplication() 09-10 19:25:54.626 E/AndroidRuntime(27782): at android.app.ActivityThread.access$1800(ActivityThread.java:221) 09-10 19:25:54.626 E/AndroidRuntime(27782): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1860) 09-10 19:25:54.626 E/AndroidRuntime(27782): at android.os.Handler.dispatchMessage(Handler.java:102) 09-10 19:25:54.626 E/AndroidRuntime(27782): at android.os.Looper.loop(Looper.java:158) 09-10 19:25:54.626 E/AndroidRuntime(27782): at android.app.ActivityThread.main(ActivityThread.java:7225) 09-10 19:25:54.626 E/AndroidRuntime(27782): at java.lang.reflect.Method.invoke(Native Method) 09-10 19:25:54.626 E/AndroidRuntime(27782): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 09-10 19:25:54.626 E/AndroidRuntime(27782): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 09-10 19:25:54.626 E/AndroidRuntime(27782): at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)

ClaudiuGeorgiu commented 5 years ago

Hi, try using only Rebuild, NewSignature and NewAlignment. Does it work? If not, then the app might have some anti-repackaging checks, therefore the obfuscation obviously won't work. Unfortunately the app uses arm libraries, so I cannot test it on the emulator.

dfdfdfs commented 5 years ago

Hi

1 after the command obfuscapk -o RandomManifest -o Rebuild -o NewSignature -o NewAlignment -p original.apk Apk work

2 After comand python3.7 -m obfuscapk.cli -o Nop -o RandomManifest -o Rebuild -o NewSignature -o NewAlignment -p sss.apk APK crashes

See video https://cloud.mail.ru/public/HP72/3kbLCUnu7

3 Protection signatures and verify Dex file no ( see video)

4 The emulator https://www.memuplay.com/ allows you to run APK with arm libraries

Apk crashes not only 6 android.

Apk crashes 5 and 6 and 7 and 8 android

See log

package name com.wooga.pearlsperil

09-10 19:25:54.626 D/AndroidRuntime(27782): Shutting down VM 09-10 19:25:54.626 E/AndroidRuntime(27782): FATAL EXCEPTION: main 09-10 19:25:54.626 E/AndroidRuntime(27782): Process: com.wooga.pearlsperil, PID: 27782 09-10 19:25:54.626 E/AndroidRuntime(27782): java.lang.VerifyError: Rejecting class com.google.firebase.FirebaseApp because it failed compile-time verification (declaration of 'com.google.firebase.FirebaseApp' appears in /data/app/com.wooga.pearlsperil-1/base.apk:classes2.dex) 09-10 19:25:54.626 E/AndroidRuntime(27782): at com.google.firebase.provider.FirebaseInitProvider.onCreate(com.google.firebase:firebase-common@@17.0.0:53) 09-10 19:25:54.626 E/AndroidRuntime(27782): at android.content.ContentProvider.attachInfo(ContentProvider.java:1789) 09-10 19:25:54.626 E/AndroidRuntime(27782): at android.content.ContentProvider.attachInfo(ContentProvider.java:1764) 09-10 19:25:54.626 E/AndroidRuntime(27782): at com.google.firebase.provider.FirebaseInitProvider.attachInfo(com.google.firebase:firebase-common@@17.0.0:47) 09-10 19:25:54.626 E/AndroidRuntime(27782): at android.app.ActivityThread.installProvider(ActivityThread.java:6763) 09-10 19:25:54.626 E/AndroidRuntime(27782): at android.app.ActivityThread.installContentProviders(ActivityThread.java:6358) 09-10 19:25:54.626 E/AndroidRuntime(27782): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6298) 09-10 19:25:54.626 E/AndroidRuntime(27782): at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method) 09-10 19:25:54.626 E/AndroidRuntime(27782): at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:751) 09-10 19:25:54.626 E/AndroidRuntime(27782): at android.app.ActivityThread.handleBindApplication() 09-10 19:25:54.626 E/AndroidRuntime(27782): at android.app.ActivityThread.access$1800(ActivityThread.java:221) 09-10 19:25:54.626 E/AndroidRuntime(27782): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1860) 09-10 19:25:54.626 E/AndroidRuntime(27782): at android.os.Handler.dispatchMessage(Handler.java:102) 09-10 19:25:54.626 E/AndroidRuntime(27782): at android.os.Looper.loop(Looper.java:158) 09-10 19:25:54.626 E/AndroidRuntime(27782): at android.app.ActivityThread.main(ActivityThread.java:7225) 09-10 19:25:54.626 E/AndroidRuntime(27782): at java.lang.reflect.Method.invoke(Native Method) 09-10 19:25:54.626 E/AndroidRuntime(27782): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 09-10 19:25:54.626 E/AndroidRuntime(27782): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 09-10 19:25:54.626 E/AndroidRuntime(27782): at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)

dfdfdfs commented 5 years ago

Here is another APK

See skreen https://cloud.mail.ru/public/3UJi/4aL37P3JK

After comand python3.7 -m obfuscapk.cli -o Nop -o Goto -o RandomManifest -o Rebuild -o NewSignature -o NewAlignment -p sss.apk Apk Work

After comand

python3.7 -m obfuscapk.cli -o MethodRename -o RandomManifest -o Rebuild -o NewSignature -o NewAlignment -p sss.apk Apk crashes

Orig apk https://cloud.mail.ru/public/bGkc/2QJXyR5dH

Obfus apk https://cloud.mail.ru/public/3DsN/3hfT6TemM

See video https://cloud.mail.ru/public/3PsM/dSMNVp9dN

Please download the APK and check for yourself.

dfdfdfs commented 5 years ago

Hello

Please help me.

dfdfdfs commented 5 years ago

Hello

Please help me.

ClaudiuGeorgiu commented 5 years ago

The issue is still open and we are aware that the tool is not perfect and does not always work. But this is a research project and is completely open source and free, so anyone can view the code and try to solve issues. In case of updates, this issue will be updated accordingly, but until then please stop sending "please help" messages (also to my email), since it's not useful but annoying. Thanks.

dfdfdfs commented 5 years ago

ok

MR-AMDEV commented 4 years ago

@dfdfdfs If your apk doesn't work then i have following suggestions for you: 1) First of all Use the basic command: python3.7 -m obfuscapk.cli -p -d /root/Desktop/obfuscated.apk -o Rebuild -o NewSignature -o NewAlignment /root/Desktop/input.apk

2) Now if the basic command works then try adding obfuscators One-by-One 3) For example instead of trying all these encryption obfuscators: -o ConstStringEncryption -o ResStringEncryption -o LibEncryption Try to use the first encryption -o ConstStringEncryption and then build your apk, if it works then add a new obfuscator along with the first one (such as -o ConstStringEncryption -o ResStringEncryption) and then so on... Doing this one-by-one helps you to understand that some applications are complex or their structure is different, it will also help you to build your working apk with your desired obfuscation.

You can look at all the obfuscators available in the readme file of this project.