Android内核溢出调试环境搭建

289 阅读1分钟

本文已参与「新人创作礼」活动,一起开启掘金创作之路。

1、系统环境

操作系统:Windows11

虚拟机VirtualBox6.1:Downloads – Oracle VM VirtualBox

Ubuntu18.04.6: releases.ubuntu.com/18.04/ubunt…

VirtualBox主机与虚拟机不能复制粘贴的解决办法,要开启两项:

第1项:安装增强功能

第2项:选中使用主机输(I/O)缓存

k1.png

k2.png

2、GDB8.2 带python功能

a@sys:~$ gdb GNU gdb (Ubuntu 8.1.1-0ubuntu1) 8.1.1 Copyright (C) 2018 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later gnu.org/licenses/gp… This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: www.gnu.org/software/gd…. Find the GDB manual and other documentation resources online at: www.gnu.org/software/gd…. For help, type "help". Type "apropos word" to search for commands related to "word". (gdb) python

import os import sys print(sys.version_info) end sys.version_info(major=3, minor=6, micro=9, releaselevel='final', serial=0) (gdb)

如果gdb本身没有带python,需要自己安装,过程中注意事项如下:

安装Python2.7出现如下错误:

The following packages have unmet dependencies: python2.7 : Depends: python2.7-minimal (= 2.7.15rc1-1) but it is not going to be installed Depends: libpython2.7-stdlib (= 2.7.15rc1-1) but 2.7.17-1~18.04ubuntu1.6 is to be installed E: Unable to correct problems, you have held broken packages.

则执行下面的安装命令:

sudo apt-get install aptitude

sudo aptitude install python2.7

其他辅助命令:查看进程的绝对路径

ll /proc/pid

sudo aptitude install gcc 输入 n y y

sudo apt-get install g++

sudo apt-get install python2.7-dev

sudo apt-get install texinfo

wget ftp.gnu.org/gnu/gdb/gdb…

tar zxf gdb-8.2.tar.gz

sudo aptitude install make

gdb-8.2$ ./configure --with-python='/usr/bin/python2.7'

3、安装Android Studio

安装sdk ndk avd

设置$PATH

a@sys:~$ cat ~/.bashrc

export PATH=/Android/Sdk/platform-tools:/Android/Sdk/emulator:$PATH 开启虚拟机CPU VT虚拟化,并赋予kvm权限:

sudo chown a -R /dev/kvm

4、下载安卓内核源代码

repo init --depth=1 -u android.googlesource.com/kernel/mani… -b q-goldfish-android-goldfish-4.14-dev

k3.png