2015/01/02

为反编译Android应用设置Linux环境

Linux environment setup

ubuntu 14.04 64-bit virtual machine on virtual box
1. shared folder:   in virtual box setting, create two shared folder “Documents”, “Downloads” on mac os, set full r/w rights and permanent. then in unbuntu’s mnt directory you will see “sf_Downloads” and “sf_Documents” ( with AdditionIn package installed ).
2. however, you may need to run “sudo adduser fanghui vboxsf” to add yourself to vboxsf group, and restart ubuntu guest.


android apktool
http://ibotpeaches.github.io/Apktool/install/
1. Check java 1.7 installed or not
       $java -version
       $sudo apt-get install default-jre  (or openjdk-7-jre)


2. Download Linux wrapper script (https://raw.githubusercontent.com/iBotPeaches/Apktool/master/scripts/linux/apktool,  Right click, Save Link As apktool)

3. Download apktool-2 (https://bitbucket.org/iBotPeaches/apktool/downloads, find newest here)

4. Make sure you have the 32bit libraries (ia32-libs) downloaded and installed by your linux package manager, if you are on a 64bit unix system.
(This helps provide support for the 32bit native binary aapt, which is required by apktool)

5. Rename downloaded jar to apktool.jar

6. Move both files (apktool.jar & apktool) to /usr/local/bin (root needed)
Make sure both files are executable (chmod +x)

7. Try running apktool via cli
   example:   $apktool d flappy-bird.apk
  will unzip the file structure
  find “Fake Flappy birds on Android” on http://androidmalwaredump.blogspot.sg/


dex2jar
   download dex2jar from http://sourceforge.net/projects/dex2jar/files/
   extract to a folder
        $unzip -x dex2jar-2.0.zip  -d /home/your_folder
   convert apk to jar file  ( you might need chmod +x d2j* )
        $sh /home/your_folder/dex2jar-2.0/d2j-dex2jar.sh  flappy_bird.apk


jd-gui
    download from jd.benow.ca
  it is a jar file “jd-gui-1.1.0.jar", so run with
     $java -jar jd-gui-1.1.0.jar
 a gui will pop up.

jad
jad is a decompiler tool similar to jd-gui, except command line.
download from http://varaneckas.com/jad/
somehow i cannot run jad 1.5.8e for linux on intel, so i choose jad 1.5.8e for linux (statically linked) instead.


boomerang (not mature)
download boomerang-linux-alpha-0.3 from http://boomerang.sourceforge.net/download.php
it requires libgc. when I try to run the program, I get this error:
./boomerang: error while loading shared libraries: libgc.so.1: cannot open shared object file: No such file or directory

You need to install libgc, something like

sudo apt-get install libgc1c2
sudo apt-get install libgc1c2:i386 
  (for 64-bit linux)

boomerang also requires libexpat1
sudo apt-get install libexpat1:i386

ok.

====
Note: run 32-bit executable on 64-bit linux

use “file file_name” to view exe type.

file-name: ELF 32-bit LSB  executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.8, not stripped


firstly install ia32-libs.
sudo apt-get install ia32-libs
or
sudo apt-get update
sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0

or
To run 32bit executable file in a 64 bit multi-arch Ubuntu system, you have to add i386 architecture and also you have to install libc6:i386,libncurses5:i386,libstdc++6:i386 these three library packages.
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386
sudo ./file-name

没有评论: