Tuesday, April 29, 2014

Reverse Engineering : Convert class or jar to Java files

Reverse Engineering : Convert class or jar to Java files
Previously, we have seen how to extract contents of .img file and also how to convert dex files to classes/jar.
In this post, I'm going to show a method to covert class/classes/jar file to java file(s).
To do so, we are going to use a tool, JD-GUI. It is a Java Decompiler, which supports all versions of Java, including java-7.
Download the application from here, and extract it to a proper location.
Now, open the terminal (in case of Linux) and run the following command:
./jd-gui
It will open the GUI window of Java decompiler.

Reverse Engineering : Convert class or jar to Java files

Just drag-and-drop a class/jar file into this window. In the left panel, we can find the corresponding java files, arranged in proper package format.
To save a single file, select it and choose "Save Source" from the top menu. And to save entire package, choose "Save all sources".

Troubleshooting:
You may ran into one of these problems, while trying to open jd-gui. Install the packages specified accordingly.
Error 1:
./jd-gui: error while loading shared libraries: libgtk-x11-2.0.so.0: cannot open shared object file: No such file or directory
Solution:
sudo apt-get install libgtk2.0-0:i386
Error 2:
./jd-gui: error while loading shared libraries: libXxf86vm.so.1: cannot open shared object file: No such file or directory
Solution:
sudo apt-get install libxxf86vm1:i386
Error 3:
./jd-gui: error while loading shared libraries: libSM.so.6: cannot open shared object file: No such file or directory
Solution:
sudo apt-get install libsm6:i386
Error 4:
/jd-gui: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
Solution:
sudo apt-get install lib32stdc++6

Monday, April 28, 2014

Reverse Engineering : Android Dex files to Class files

Reverse Engineering : Android Dex files to Class files
In my previous post, we have seen how to extract the contents of img file.
After extraction, you will find that most of the files have ".dex" extension. These are Compiled Android application code files.
In order to convert them into executable format (.class or .jar), you can use dex2jar tool.
Extract it to a proper location and open the terminal to this location.
Now run the following command:
./d2j-dex2jar.sh <Path-to-dex_file>
It will bundle the dex files into a jar file, and stores it in the current directory.
dex2jar can also be used to convert dex files into variuos other formats.
For detailed info, click here.

Thursday, April 24, 2014

Reverse Engineering : Extract contents from .img file

Reverse Engineering : Extract .img files of Android
Unyaffs is a program to extract files from a YAFFS2 file system image. Currently it can only extract images created by mkyaffs2image.

Download the source from here.

Compiling:
Extract the contents into a suitable place and run the following command
make
Usage:
unyaffs [options] <image_file_name> [<extract_directory>]
Options: -d detection of flash layout, no extraction -b spare contains bad block information -c <chunk size> set chunk size in KByte (default: autodetect, max: 16) -s <spare size> set spare size in Byte (default: autodetect, max: 512) -t list image contents -v verbose output -V print version

Source: Official github repository

Friday, April 18, 2014

Ubuntu: Problem installing flash player

Problem installing flash player
Recently, I installed ubuntu updates and my browser asked me for flash player, which was previously installed. i tried to install using the regular command
sudo apt-get install flashplugin-installer
But, it says
flashplugin-installer is already the newest version
Finally, I found the workaround. Previous installation has to removed first (which anyway is not working)
Run the following commands :
sudo apt-get purge flashplugin-installer
sudo apt-get install flashplugin-installer
Viola!! It works now.

Friday, April 11, 2014

Android: Failure [INSTALL_FAILED_UID_CHANGED]

Failure [INSTALL_FAILED_UID_CHANGED]

Today, I tried to install an application from command line and I found this error:
Failure [INSTALL_FAILED_UID_CHANGED]
After Googling for a while, I found the reason.
This happens when there is application data from older version is still present. To resolve this, clear/delete the following directory:
/data/data/<PACKAGE_NAME>
To do this, open terminal and type the following commands:
adb shell
cd /data/data/
rm -r <PACKAGE_NAME>
exit
Now try to install the application.
Viola.