[Q] decompiling java/ recompiling - Android Software/Hacking General [Developers Only]

I can take dex files and decompiling them to smali assembler and make changes there but it is much harder to read than java. I have been able to decompiling to sTraight java but then once I have made a change, I can't figure out how to compile just the single java back to a class without recreating the entire project in eclipse. Is there a way to just compile that single file I changed and insert it back in?
Sent from my Inspire '4g'.

How did you decompiled dex file?
You can't compile it back just like that, but you could use some workaround:
If you reference in Java some other classes from dex, then you will have to create Java stubs for these classes.
Compile your java class, linking to above stubs and android.jar file (javac).
dex resulting *.class files (dx tool).
baksmali resulting classes.dex.
baksmali original dex file.
replace smali files with new ones.
smali everything back to classes.dex form.
You could also read this: http://code.google.com/p/android-apktool/issues/detail?id=88

Related

[Q] Compiling services.jar from source?

I've got an idea for a mod I want to make. I know where to find the Java code in the AOSP. This afternoon I spent some time futzing around with framework-res.apk; I used apktool to uncompress/decompile it, made some goofy changes, rebuilt the .apk, then signed and pushed back to my phone successfully.
Now, I want to make programmatic changes. So I pulled services.jar, decompiled with apktool again, and got my .smali files. Unfortunately, I don't understand the format whatsoever. I'm trying to do something more complicated than simply changing colors/graphics.
I want to know whether I can download the Android source, make my modification to the Java file I need, and recreate a services.jar out of it all. Is that possible? If so, is there a tutorial somewhere?

building a JAR with internal JAR dependencies

Hope you guys can give me some much sought advice.
I've been attempting to build a JAR file that packages it's own JARs as internal class dependencies, but without exposing those inner JAR dependencies to the outside world. I'm guessing this needs to happen, otherwise the link process for building an Eclipse Android project would fail if not.
So my problem is such:
If I have an internal dependency on say dom4j-1.6.1.jar, I don't want to prevent someone from being able to add my JAR to an Eclipse Android project and including their own dom4j package dependency (possibly a different version). If the internal JAR dependency is exposed they will experience a duplicate resource conflict when attempting to build their project.
e.g. java.lang.IllegalArgumentException: already added: Lcom/google/gson/DefaultTypeAdapters$ByteTypeAdapter;
Here is what I tried to date:
So I have a regular Android project in Eclipse which adds in my packaged JAR as an dependency.
I refered to the Oracle docs, however there is a footnote about the inclusion of JAR files within JARs.
Note: The Class-Path header points to classes or JAR files on the local network, not JAR files within the JAR file or classes accessible over internet protocols. To load classes in JAR files within a JAR file into the class path, you must write custom code to load those classes. For example, if MyJar.jar contains another JAR file called MyUtils.jar, you cannot use the Class-Path header in MyJar.jar's manifest to load classes in MyUtils.jar into the class path.
So I decided to try the Fat Jar Eclipse Plug-In from SourceForge.
It's an Eclipse Plug-In for deploying a project into one "fat" executable jar file containing all referenced libraries. References are taken from the project settings, so no manual configuration is necessary.
I did manage to execute my build using this method, however did have to manually hack the packaged JAR file to remove the reference to the annotations package which was causing a conflict with my Android test project by being referenced twice.
So now I am left with a project that builds and executes, but exposes those inner JAR dependency packages to my Android project.
I would appreciate any advice you guys can provide. I hope my explanation is clear enough.

Android Reverse Toolkit

I want to share my Tool I made yesterday in a couple of hours. I was just sad about all the steps which have to be done until you have a proper codebase of an android app (apk) so I automated some processes.
You might think "this guy have only 1 post I can't trust him !!!" I would probably think the same but I'm here on xda actually pretty long but just read as anonymous user without an account and now I just wanted to give something back so I created an account.
My Tool includes following thirdparty software:
jad (decompile .class files)
dex2Jar (converts apk files into .class files)
apktool Decompile (is used for extracting resources and Smali code)
apktool build (is used to build the smali code into an apk again)
testsign.jar (is used to sign the build apk file)
Features:
Decompile assets
Decompile resources
Decompile smali files
Decompile java files
Build apk from smali source
Sign build apk
Nice gui with drag and drop
The application is written in java so it should probably work on all operating system (not sure because jad isnt written in java so I have to use os specific files)
Screenshot:
i.imgur.com/U85AU.png
Virustotal
virustotal.com/file/69601c98a25edf2fcb22b94fb58863848a4cd4a7ee0a39b4ad40de54c086f102/analysis/1358111315/
Download: ul.to/5hy2wf9x
Awesome tool! Tested it and works perfectly! Thank you!

[Q] Problem Modding APK

Hello guys,
I am modding an apk to bypass an update check.
I have this outdated APK that functions fine since the URL and query and site address remains same but whenever it checks for and update it crashes. The thing is the developer made it topnotch but since then left and his site was recently taken down so check update query crashes it totally. What I need to do is update just the one function where it brings up the GUI after start. Otherwise it keeps saying download update or crashes randomly at time of starting up.
Now I have been browsing for a day or two for all the tutorials and right now I`m hell lot of confused. I have downloaded many tools and dependencies but I dont know how to proceed. I will tell you guys what I have and what I need.
I have de-compiled the APK using "dex2jar", I had a .JAR file which I decomplied using JD-GUI-Windows now after saving source I have .ZIP file in which I made the necessary editing. Next I downlaoded APKTool.JAR and extracted resource files and XML files that can be read in text editor. Along with some .SMALI files.
Now I am not familier with SMALI language at all and editing in it seems rather complicated and on the other side I have the .JAR file that decomlied all the classes just fine.
MY QUESTION IS:
How do I recompile the files I have ? I have the main coding extraced using dex2jar so in java format and JD-Gui to in .ZIP files, and resources/XML files also decoded using APKTools. What do I do next to recompile the APK ?
In short I have plain text based java source code and plain text XML and other resource file. How do I recompile it ?

decompile and desugar java bytecode

i need to do pentesting for developer, but all my decompiling tools failed to show proper code, take a look at my issue on github, what issue i'm facing :
https://github.com/leibnitz27/cfr/issues/235
Is there option in some others java bytecode decompilers which can decompile and desugar lambda, so it displays proper code. I wasn't been able to do pentest because of this, i can't read code, not even try to exploit it at all.
The Java bytecode decompiler in IntelliJ IDEA is a built-in tool that allows you to read compiled bytecode as if it were human-readable Java code.
jwoegerbauer said:
The Java bytecode decompiler in IntelliJ IDEA is a built-in tool that allows you to read compiled bytecode as if it were human-readable Java code.
Click to expand...
Click to collapse
just checked (IntelliJ IDEA), and tried, still no luck, as i know it uses Fernlower, which i already tried. (i have problems, with improper decopmilaton/desugaring java bytecode, and it throws multiple .class files with $$Lambda$ extention)
and this is my first time to see this retrolambda, for which i never heard before.
i wish i could decompile it manually, but i can't as before 2 days i didn't knew what is retrolambda, let alone manually decompile it.
resources, how i can manually decompile and understand retrolambda, are welcome, i will check in their git repository if i can find anything, some instrutions.

Categories

Resources