Preface:This guide is by no means all inclusive or for experienced developers. Anyone with the capacity to read and learn can accomplish this. However you will need to know basic linux commands and syntax. I also did a few weeks of research on this topic, not just for Android development but linux in general.
Disclaimer:I am not responsible for any damage you may or may not do with your device. You will be compiling and flashing your own created kernel, you accept any risks. This can also be done with any device, not just the one that I will be listing, but use your common sense.
Sources:There are many sources that I used to learn this knowledge, and I recommend you reading through it all as well. it will give you a better understanding + good reads to increase your knowledge
maxters (maxters.net)
http://www.maxters.netthewadegeek (XDA-Developers):
http://forum-xda-developers.com/showthread.php?t=1748297nixCraft (cyberciti.biz)
http://www.cyberciti.biz/tips/compiling-linux-kernel-module.htmlhttp://www.cyberciti.biz/faq/add-remove-list-linux-kernel-modules/linuxtopia (linuxtopia.com)
http://www.linuxtopia.org/online_books/linux_kernel/kernel_configuration/ch08.htmlXDA University (xda-university.com)
http://xda-university.com/as-a-developer/getting-started-building-a-kernel-from-source (Droidzone)
http://xda-university.com/as-a-developer/adding-features-to-your-kernelKernel Modules and Device Drivers
www.intellimetrix.us/download/Abbott_Book_CH7.pdfGoogle (source.android.com)
http://source.android.com/source/building-kernels.htmlIntroduction:In order to get your Android Smartphone into a wireless pentesting device the easiest route would be to enable a USB OTG cable to work with your favorite wireless USB device. To accomplish this we need to compile and enable the driver in the kernel, and then flash your new kernel with the module of the compiled wireless drivers. For this demonstration I will be using a Verizon Variant Samsung Galaxy S4 with the Stock "TouchWiz" kernel. However instead of using the stock, I will be using a developed kernel that is already auto "loki'd" which is how it bypasses the locked bootloader. You can start with whichever kernel you would like.
Prerequisites:
- Kernel
- Android NDK (or a linux ARM toolchain, Linearo offers a good one)
- Linux Operating system (For this guide I will be using Ubuntu 12.04 LTS)
Ok so now you have your Operating system, your kernel and your toolchain, so now lets get everything you need to config and compile.
Dependencies (Ubuntu 12.04 LTS Specific):sudo add-apt-repository ppa:nilarimogard/webupd8
sudo apt-get update
sudo apt-get install git android-tools-adb android-tools-fastboot build-essential gnupg flex bison gperf zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev gcc-multilib libx11-dev:i386 libreadline6-dev:i386 libglapi-mesa:i386 libgl1-mesa-glx:i386 libgl1-mesa-dev libgl1-mesa-dri:i386 g++-multilib tofrodos libxml2-utils xsltproc zlib1g-dev:i386
sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
Congrats! Your build environment is now set up and you can work on adding the wireless driver to your kernel that you choose. In my case I will be doing ath9k.
Compiling Your Module:....to be continue