nexus5 Android7.1.2
查看cpu信息、内核版本
安装编译环境
sudo apt-get update
sudo apt-get install build-essential fakeroot dpkg-dev libcurl4-openssl-dev
sudo apt-get build-dep git
mkdir git-openssl && cd git-openssl
sudo apt-get source git
linageOs源码中的交叉编译链
配置linageOs源码中的交叉编译环境
sudo vim ~/.bashrc
export ARCH=arm &&
export PATH=/usr/local/Android7.1.2/prebuilts/gcc/linux-x86/arm/arm-eabi-4.8/bin:$PATH &&
export CROSS_COMPILE=arm-eabi- &&
export ARCH=arm &&
export PATH=/usr/local/Android7.1.2/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin:$PATH &&
export CROSS_COMPILE=arm-linux-androideabi- &&
export ARCH=arm64 &&
export PATH=/usr/local/Android7.1.2/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin:$PATH &&
export CROSS_COMPILE=aarch64-linux-android- &&
export ARCH=x86 &&
export PATH=/usr/local/Android7.1.2/prebuilts/gcc/linux-x86/x86/x86_64-linux-android-4.9/bin:$PATH &&
export CROSS_COMPILE=x86_64-linux-android- &&
source ~/.bashrc
nexus5(7.1.2) hammerhead内核源码下载
git clone https://github.com/LineageOS/android_kernel_lge_msm8974.git -b cm-14.1
定制内核
make menuconfig
内核配置项
CONFIG_MODULES=Y
CONFIG_STRICT_MEMORY_RWX=N / CONFIG_DEBUG_RODATA=N
CONFIG_DEVMEM=Y
CONFIG_DEVKMEM=Y
CONFIG_KALLSYMS=Y
CONFIG_KALLSYMS_ALL=Y
CONFIG_HAVE_KPROBES=Y
CONFIG_HAVE_KRETPROBES=Y
CONFIG_HAVE_FUNCTION_TRACER=Y
CONFIG_HAVE_FUNCTION_GRAPH_TRACER=Y
CONFIG_TRACING=Y
CONFIG_FTRACE=Y
内核编译
make -j4
Android8.1内核交叉编译环境配置
sudo vim ~/.bashrc
export ARCH=arm &&
export PATH=/usr/local/Android/LineageOS/Android8.1.0/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin:$PATH &&
export CROSS_COMPILE=arm-linux-androideabi- &&
export ARCH=arm64 &&
export PATH=/usr/local/Android/LineageOS/Android8.1.0/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin:$PATH &&
export CROSS_COMPILE=aarch64-linux-android- &&
export ARCH=x86 &&
export PATH=/usr/local/Android/LineageOS/Android8.1.0/prebuilts/gcc/linux-x86/x86/x86_64-linux-android-4.9/bin:$PATH &&
export CROSS_COMPILE=x86_64-linux-android- &&
source ~/.bashrc
make menuconfig
make -j4
重写系统调用表拦截内核调用
https://bbs.pediy.com/thread-267004.htm
https://github.com/zq9120/android_syscall_logger
https://github.com/FairEye/android-syscall-monitor-kmsg
https://github.com/invictus1306/Android-syscall-monitor
https://github.com/Katana-O/Android-Syscall-Logger
ndk配置内核交叉编译环境(1)
内核交叉编译配置定制和编译(2)
内核篇加载内核模块(Android10)
内核系统调用openat Hook