1 download ndk
export NDK=~/Downloads/android-ndk-r10e
2 Set cross-compiler for x86 (emulator)
mac:
export NDK_TOOLCHAIN=${NDK}/toolchains/x86-4.8/prebuilt/darwin-x86_64/bin/i686-linux-android-
export NDK_SYSROOT=${NDK}/platforms/android-19/arch-x86
Set cros-compiler for arm (device)
export NDK_TOOLCHAIN=${NDK}/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-
export NDK_SYSROOT=${NDK}/platforms/android-19/arch-arm
3 compile
// hello-world.c
#include <stdio.h>
int main(void)
{
printf("Hello world cross compiled on Android!\n");
return 0;
}
make CC=${NDK_TOOLCHAIN}gcc CFLAGS=--sysroot=${NDK_SYSROOT} hello-world
4 push to test
$ adb push hello-world /data/
$ adb shell
# /data/hello-world
Hello world cross compiled on Android!
reference:
https://yaapb.wordpress.com/2012/09/27/cross-compiling-a-c-application-using-the-android-ndk/
2015/10/26
2015/01/13
一些用来加固应用的.so库
libsecexe.so 梆梆加固
libAPKProtect.so APKProtect加固,
libprotectClass.so 360加固,
libNSaferOnly.so 通付盾加固,
libnqshield.so 网秦加固,
libshell.so 腾讯加固,
ijiami.dat 爱加密加固,
libddog.so 娜迦加固,
libmobisec.so 阿里加固,
libbaiduprotect.so 百度加固
2015/01/08
Virtualization on Android OS
Virtualisation on Android OS:
- OKL4 Microvisor from Open Kernel Labs. VMM runs on highest privilege, virtualising: processor(instructions,registers), memory, I/O. The other applications run on light-weight lower level.
- VLX from VirtualLogix.
- Mobile visor platform (MVP) from VMware, offering a hypervisor on smart mobile phones
Linux Container.
major difference between hypervisor and V-OS:
hypervisor lies between OS and hardware, while V-OS lies above OS level. so the security of V-OS actually heavily depends on protection/obfuscation on application code.
major difference btw. security method of V-OS and app-wrapping:
Problems: the purpose of security is not very clear. what does V-OS want to protect?
algorithm/implementation or sensitive data. code obfuscation can only improve the difficulty of reverse engineering (sometimes it is sufficient). if it is sensitive data, no absolute secure solution without hardware isolation support. the best effort may be to provide multiple layer securities.
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
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
订阅:
博文 (Atom)