将TaintDroid编译进Android 2.3
2013-04-17 13:41
281 查看
将TaintDroid编译进Android 2.3
本文编译环境:Ubuntu10.04,32-bit
JDK SE 6
Bash Shell
在32-bit系统上编译Android时需要修改以下几个文件:
build/core/main.mk
change
ifneq (64,$(findstring 64,$(build_arch)))
to
ifneq (i686,$(findstring i686,$(build_arch)))
$(warning ************************************************************)
$(warning You are attempting to build on a 32-bit system.)
$(warning Only 64-bit build environments are supported beyond froyo/2.2.)
$(warning ************************************************************)
$(error stop)
endif
external/clearsilver/cgi/Android.mk,
external/clearsilver/java-jni/Android.mk,
external/clearsilver/util/Android.mk,
external/clearsilver/cs/Android.mk
change
LOCAL_CFLAGS += -m64
LOCAL_LDFLAGS += -m64
to
LOCAL_CFLAGS += -m32
LOCAL_LDFLAGS += -m32
step 1: 获取Android源代码
$ mkdir ~/tdroid-2.3.4
$ cd ~/tdroid-2.3.4
$ repo init -u https://android.googlesource.com/platform/manifest -b android-2.3.4_r1
$ repo sync
(根据网速不同,需要等待一段时间)
先尝试编译以下内核,防止当加入TaintDroid代码时出现问题。详细编译Android教程见Android源码发布网站,狂点这里。
$ . ./build/envsetup.sh
$ lunch 1
$ make -j4
等待。。。
$ emulator
如果编译正常会出现Android模拟器界面。
编译过程已经将一些环境变量加入到bash中,因此当重新启动一个shell时,将无法重现,此时需要将前一个bash shell中的环境变量提取出来。
我的做法是,在编译的shell中,使用env命令将所有环境变量导入到一个文本文件中,然后再将普通shell的环境变量导入到一个文本文件中,然后对比差异即可得出所需环境变量,然后将差异加入到普通shell中,即可正常启动emulator。
最近发现可以直接通过命令运行emulator:
进入主目录:
$ . build/envsetup.sh
$ lunch 1
$ emulator
这样也可以直接运行emulator,而且比我以前的方法方便许多。同时可以启用其他一些工具,例如adb等这些工具。
step 2: 获取TaintDroid源码
将以下内容复制粘贴到~/tdroid-2.3.4/.repo中,文件名为:local_manifest.xml。
<manifest>
<remote name="github" fetch="git://github.com" />
<remove-project name="platform/dalvik"/>
<project path="dalvik" remote="github" name="dbaeumges/android_platform_dalvik" revision="taintdroid-2.3_emulator" />
<remove-project name="platform/libcore"/>
<project path="libcore" remote="github" name="TaintDroid/android_platform_libcore" revision="taintdroid-2.3.4_r1" />
<remove-project name="platform/frameworks/base"/>
<project path="frameworks/base" remote="github" name="TaintDroid/android_platform_frameworks_base" revision="taintdroid-2.3.4_r1" />
<remove-project name="platform/system/vold"/>
<project path="system/vold" remote="github" name="TaintDroid/android_platform_system_vold" revision="taintdroid-2.3.4_r1" />
</manifest>
然后,执行以下命令:
$ cd ~/tdroid-2.3.4
$ repo sync
$ cd dalvik
$ git branch --track tdroid-2.3.4 github/taintdroid-2.3_emulator
$ git checkout tdroid-2.3.4
$ git pull
$ cd ../libcore
$ git branch --track tdroid-2.3.4 github/taintdorid-2.3.4_r1
$ git checkout tdroid-2.3.4
$ git pull
$ cd ../frameworks/base
$ git branch --track tdroid-2.3.4 github/taintdorid-2.3.4_r1
$ git checkout tdroid-2.3.4
$ git pull
$ cd ../..
$ cd system/vold
$ git branch --track tdroid-2.3.4 github/taintdorid-2.3.4_r1
$ git checkout tdroid-2.3.4
$ git pull
step 3: 编译Linux内核支持xattr SDcard
$ cd ~/tdroid-2.3.4
$ git clone http://android.googlesource.com/kernel/goldfish.git
$ cd goldfish
$ git branch --track android-goldfish-2.6.29 origin/android-goldfish-2.6.29
$ git checkout android-2.6.29
$ git pull
由于此时下载的内核无法支持yaffs文件格式,因此需要使用补丁文件,狂点这里下载。
$ cd ~/tdroid-2.3.4/goldfish
$ patch -p1 < ~/yaffs_xattr.patch
编译内核:
$ cd ~/tdroid-2.3.4
$ . ./build/envsetup.sh
$ lunch 1
$ cd goldfish
$ export ARCH=arm
$ export SUBARCH=arm
$ export CROSS_COMPILE=arm-eabi-
$ make goldfish_defconfig
$ make oldconfig
$ make menuconfig
(保证YAFFS和EXT2支持XATTR和SECURITY选项)
$ make -j4
$ cp arch/arm/boot/zImage ~/
打开.config文件检查是否以配置好:
...
#
# File systems
#
CONFIG_EXT2_FS=y
CONFIG_EXT2_FS_XATTR=y
CONFIG_EXT2_FS_POSIX_ACL=y
CONFIG_EXT2_FS_SECURITY=y
CONFIG_EXT2_FS_XIP=y
...
CONFIG_YAFFS_FS=y
CONFIG_YAFFS_YAFFS1=y
CONFIG_YAFFS_XATTR=y
CONFIG_YAFFS_SECURITY=y
# CONFIG_YAFFS_9BYTE_TAGS is not set
# CONFIG_YAFFS_DOES_ECC is not set
CONFIG_YAFFS_YAFFS2=y
CONFIG_YAFFS_AUTO_YAFFS2=y
# CONFIG_YAFFS_DISABLE_LAZY_LOAD is not set
# CONFIG_YAFFS_DISABLE_WIDE_TNODES is not set
# CONFIG_YAFFS_ALWAYS_CHECK_CHUNK_ERASED is not set
CONFIG_YAFFS_SHORT_NAMES_IN_RAM=y
...
step 4:编译TaintDroid
在根目录下建立一个文件名为:buildspec.mk,内容为:
# Enable core taint tracking logic (always add this)
WITH_TAINT_TRACKING := true
# Enable taint tracking for ODEX files (always add this)
WITH_TAINT_ODEX := true
# Enable taint tracking in the "fast" (aka ASM) interpreter (recommended)
WITH_TAINT_FAST := true
# Enable addition output for tracking JNI usage (not recommended)
#TAINT_JNI_LOG := true
然后编译TaintDroid:
$ . ./build/envsetup.sh
$ lunch 1
$ make clean
$ make -j4
step 5: 设置SD card
$ mksdcard 1024M sdcard.img
$ sudo mke2fs sdcard.img
step 6: 使用TaintDroid
$ emulator -kernel ~/zImage -sysdir ~/Desktop/samples/ -sdcard ~/Desktop/samples/sdcard.img -memory 512 -skindir ~/Desktop/samples/skins/ -skin HVGA -data ~/Desktop/samples/userdata-qemu.img -partition-size 1024 -qemu -android-hw ~/Desktop/samples/hardware-qemu.ini &
(sample目录为我将所有的img文件都放于一处的目录,此外&符号意为后台执行,输入上述命令后,还有输入以下命令改变执行模式)
$ adb shell setprop dalvik.vm.execution-mode int:portable
当模拟器启动后,可以安装TaintDroidNotify软件,测试TaintDroid是否已经安装。也可通过查看编译产生的目录out/target/product/generic/中文件install-files.txt来查找是否还有ftaint来判断是否安装成功。
TaintDroidNotify软件可以狂点这里下载。
Reference:
https://sites.google.com/site/taintdroid23/source http://appanalysis.org/download.html http://blog.csdn.net/zhenyongyuan123/article/details/6079717
相关文章推荐
- TaintDroid下载预编译(五):TaintDroid(Android)系统编译虚拟机和真机测试
- TaintDroid下载预编译(五):TaintDroid(Android)系统编译虚拟机和真机測试
- 编译Android 2.3源码错误总结
- ubuntu 32 bit系统下编译android 2.3
- 编译android 2.3, 出现`GLIBC_2.11' not found
- android 2.3 编译选项
- ubuntu 12.04 编译android 2.3遇到的问题
- Ubuntu 10.10(64位)编译Android 2.3
- ubuntu9.04编译android2.3失败
- Ubuntu 10.10(64位)编译Android 2.3
- 32位Ubuntu10.04上编译Android2.3
- Android2.3 编译出错:No rule to make InterpAsm-x86.S
- 编译android2.3过程中出现问题的解决
- Ubuntu10.04系统 32位机上安装编译Android2.3源码
- TaintDroid Build Instructions for Android 4.1 (updated Dec 6, 2012)
- 在32位Ubuntu 10.04上编译Android 2.3
- 虚拟机VMWARE和Ubuntu下搭建了一个android2.3/android4.2/android4.1/android4.0编译环境的操作过程
- TaintDroid下载与编译(六):(常出现的error)
- android2.3编译的两个问题
- Android2.3 SDK编译出现Multiple substitutions specified in non-positional format的分析