Better way to extract files from apk - java

I've used this method for extracting the Java and XML files from the apk file but my Java files have a lot of modifications which for sure wasn't there in the original code.
For example, in one class appears for several times access$902, access$902 ,string of digits like 2130903064. They appear in the place of other methods or variables and the project doesn't build because of them.
Can be there extracted the original files or is a solution for this problem? Thanks

No.
Because build process generate .class files, and reverse engineering nevers get to the original code (AFAIK).
If the .apk file was generated using the proguard, this will be less readable and more difficult to understand.
The best alternative is use the AndroChef java decompiler, that runs in windows. This tool can allow you to change the method / variable / class names to be more readable, including the generated files.
The original code only the developer / company owns. I hope you are not using this for something illegal.

Related

is it possible to set the java decompiler to very verbose

Is it possible to set the java decompiler to return everything it finds during the process? I have a game I have been working on for a little over a year, I am still pretty new to java and have been beating my head against the keyboard and api documentation to produce this game. I come home from a business trip and find that my house has been broken into and my workstation is gone. I still have my keystore because I keep it on a flashdrive for safety. I also keep my project files on a flashdrive, which I did not remove from my workstation before leaving on my trip. I have tried to use every .apk decompiler I can find to recover my source code. They all return some code but of course because of proguard almost all of it is unusable. I have a copy of my signed .apk on my phone for testing purposes and it is debuggable, is there anyway to recover all of my project files from this? Like setting the java decompiler to very verbose, or a different setting that will produce a 1:1 copy of each file reguardless of if the decompiler thinks it is relavent?
Edit: I have used dj java decompiler, androchef decompiler and the decompiler # www.decompileandroid.com which is just a script that is run on their server to use the standard tools included in eclipse adt package for developing android applications.
I used to deobfuscate Java applications for a hobby and have worked on several decompilers, so if you send it to me, I might be able to help.
That being said, there are some things that are simply impossible to fix. You're never going to get back anything that isn't present in the compiled apk because it's impossible to recover information that isn't there. Among other things, this includes comments, original source code formatting, and compile time annotations. The obfuscation step will also strip out class names, variable names, unused methods, etc.
One other thing to try is to see if there's any possible way that a non obfuscated version of apk survived. Did you ever upload your files anywhere else?

Is it possible to get non-random names for Cache Files from GWT Compile

When I try to load the war file for my project in the Lighthttp server, I get "filename too long" error from the server for the generated JS files such as this :
"733C57A6999C647D009A3EBA1F5CEF9C.cache.js"
When I compile I am using the collapse all property so only one JS file gets created
I wanted to know if there was something that I could do in the code itself or in the xml file to generate a shorter name before it compiles (I don't want to have to rename the file every time)
Any help would be really appreciated.
If you only have one generated permutation, and you want to ignore the cacheing and give the file your own name, you can use the single script linker - this will generate only one JS file with both the selection script and the compiled app. This only works with one permutation.
<add-linker name="sso" />
Unless you are using FAT16 or FAT32, the error lies most likely somewhere else. For most modern filesystems the maximum filename length is usually 255 bytes, so the filename produced by the GWT compiler (in this case 41 characters) should fit easily. Maybe the overall path to the file is too long? Maybe the URL itself?
AFAIK, the generated *.cache.js files contain md5 sums in their names, which is crucial during the bootstrap process, so it's rather unlikely that you can circumvent this. Even if - it'd be unwise to use it in production (for example, because of problems with caching).

Eclipse custom builder: Identifying and cleaning generated files

I am creating a plugin for Eclipse, which contains tools for creating a custom type of project. These projects have a custom nature and builder. My builder (implements IncrementalProjectBuilder) takes a single input file, and generates a few (usually between 3 and 5) output files. When I run Clean Project, I need to remove the files the builder has previously generated.
Problem 1: The names of the generated files are not known exactly, but I do know the sort of files I expect to find (e.g. I know the extensions, and partial file names).
Problem 2: The user may add their own files to the project, which should not be affected by my build / clean steps.
My initial attempt was naive: remove every file except from the input file. This works, but has obvious problems.
My second attempt was better: I came up with a list of possible file names that may be generated, see if any of them exist and remove them.
By only knowing partial file names and matching them, I may inadvertently delete a user's file. E.g. I know I will generate a file called *_file.py. If the file I generate is called abc_file.py and the user has added their own xyz_file.py, I want to clean (remove) abc_file.py but leave xyz_file.py untouched.
The program which generates the output files from the input is constantly changing, and I don't want to rely on a concrete list of files that would need constant maintenance.
So, my question comes down to this. What methods exist for identifying the files generated by my custom builder, so I can remove them during a clean?
I've spent a couple of days Googling this one with not much to show for it. I am vaguely aware of a file system watcher in Java (Java7 WatchService?), but I don't know if that's the best solution to this problem.
Any information, advice or ideas appreciated.
One brute force approach would be to compare the project before and after the other program is invoked to get the list of files that were created/generated. Of course, it would be ideal if that program could somehow tell you which files it created. Once you have that list, you could iterate over those files as IFile's as use the setDerived() method to mark them as not being source files. When it comes time to clean the directory, you could use the derived setting to decide which files can be deleted.

C++ or Java Library for automated code editing?

I am writing/planning to write a program that takes in a java file (or multiple java files), and edits and adds functions/classes/variables and then outputs a new java file (or multiple files).
Is there a C++ or Java library that
Can recognize and output names of classes/functions within a text file
Can recognize and output the names of the input arguments for said classes/functions
Can allow me to insert code at specific lines or within specific functions
Can search for a given variable name/value
Maintains original file formatting
I would prefer not having to manually code something to do the above, so any help would be appreciated.
Thank you in advance!
EDIT: I currently use Eclipse, and am unsure of how to proceed. So to further explain my question:
In eclipse, if I write a program that opens another .java file, How would I go about 'asking' eclipse to output, say, all the class names of the .java file I just opened?
Also I will explain the 'purpose' of this project to further clarify. I want to write a program that can take in any java file, and turn it into a class that can implemented remotely via RMI. To do this I will need to add an execute() function, have the file implement Task and Serializable and add a few variables, etc... Based on my knowledge, doing this in Eclipse would require manual editing of the program, but I would like to completely automate this process.
Thank you, again.
Much of what you need can be found in a modern IDE; and some very good IDEs are open source (eclipse and Intellij IDEA Community Edition for Java). You might look there to see if there are modules that suite your needs.
Looks like you are talking of a tool like eclipse. You might not be looking for a full fledged IDE, but the requirements that you have mentioned are fulfilled by any basic IDE.
If you wish to make one of your own, you can do that using eclipse rich client platform.
All that you would need from Java is the reflection API.

disable extraction from jar file in java

I want to make setup file for java swing application .
I am creating the setup by writing the script file and selecting the source file as jar and other necessary resources .
Now i want to make my jar disable to extraction .
Is there any way from which i make sure so that no can access the resources from my jar file either the class files or images etc.
thanks in advance
You can make it harder to get your resources, but you can't make it impossible. That's not a Java problem, by the way, but a general one of distributed software. In order to access your resources, your program (or in the case of Java the runtime environment) must be able to unpack them. Even when you encrypt them somehow, the program needs to include the decryption key and the decryption algorithms. A determined user can find these through reverse engineering, and use them to get your resources.
You could try obfuscating your codes.
This is the one I have used for obfuscate.
http://www.zelix.com/klassmaster/
You could find more tools for that.
You can use java webstart, your jars will be kept in cache so very its hard to access.
Java Web Start Guide

Categories

Resources