In previous posts we went through installation process of rootless and rooted NetHunter on OnePlus 7 device, using already pre-compiled image from Kali website. Since the OnePlus 7 is a preferred high-end device by NetHunter, its image is already compiled and ready to download and install without any additional builds. With these images, NetHunter supports all 89 Android models; however, offers to download only up to 32 precompiled images. Because of that, for 57 devices, users must manually build an installation image. And that is what we will cover in this blogpost.
At the time of writing this blog, this is the list of Android models that support NetHunter with a custom kernel:
- Asus Zenfone 2 Laser
- Galaxy J7Prime for One UI Roms
- Galaxy J7Pro for One UI Roms
- Gemini PDA
- Google Pixel 3
- Google Pixel 3
- Google Pixel 3 XL
- Google Pixel 3 XL
- Google Pixel 4A
- Google Pixel 4A 5G
- Google Pixel C
- HTC 10
- HTC One M7
- HTC One M8
- Huawei Honor 5x
- Huawei P9 Plus
- Jiayu S3 Advanced
- LeEco Le 2
- Lenovo K8 Note
- LG G5 International
- LG G5 T-Mobile
- LG V20 International
- LG V20 T-Online
- LG V20 US Version
- Moto X2
- Motorola Moto G
- Motorola Moto G5
- Motorola Moto G5 Plus
- Motorola Moto X4
- Nexus 10
- Nexus 4
- Nexus 5
- Nexus 5X
- Nexus 6
- Nexus 6P
- Nexus 7 (2012)
- Nexus 7 [2013]
- Nexus 9
- Nokia 3.1
- Nokia 6.1
- Nokia 6.1 Plus
- nVidea Shield Tablet
- OnePlus 3 / 3T
- OnePlus 5 / 5T
- OnePlus 6 / 6T
- OnePlus 7 / 7 Pro / 7T / 7T Pro
- OnePlus 7 / 7 Pro / 7T / 7T Pro
- OnePlus 8 / 8T / 8 Pro
- OnePlus Nord
- OnePlus X
- OnePus 2
- OnePus One
- POCO X3 Pro
- Realme 5 Pro
- Realme 5/5i/5s
- Redmi 1S
- Samsung Galaxy A5 (2015)
- Samsung Galaxy A5 (2016)
- Samsung Galaxy A7 (2016)
- Samsung Galaxy Note 3
- Samsung Galaxy Note 7
- Samsung Galaxy S20 FE 5G (Snapdragon)
- Samsung Galaxy S4
- Samsung Galaxy S5
- Samsung Galaxy S5 Mini
- Samsung Galaxy S6
- Samsung Galaxy S6 Edge
- Samsung Galaxy S7
- Samsung Galaxy S7 Edge
- Samsung Galaxy Tab S4 LTE
- Samsung Galaxy Tab S4 WiFi
- Sony Xperia Z
- Sony Xperia Z1
- Sony Xperia Z5 Compact
- Sony Xperia ZR
- TicWatch Pro / Pro 4G/LTE / Pro 2020
- Xiaomi Mi 3 / Mi 4
- Xiaomi Mi 9T
- Xiaomi Mi A3
- Xiaomi MiPad 1
- Xiaomi Pocophone F1
- Xiaomi Redmi 3 / 3 Pro
- Xiaomi Redmi 4 Prime
- Xiaomi Redmi 4/4X
- Xiaomi Redmi 4X
- Xiaomi Redmi 4X
- Xiaomi Redmi 6 Pro
- Yu Yunique
- ZTE Axon 7
- Xiaomi Redmi 4X
- Xiaomi Redmi 6 Pro
- Yu Yunique
- ZTE Axon 7
From the list above, users can download NetHunter images with a custom kernel for 38 devices. These images must be installed over the particular Android version mentioned in parenthesis:
- Gemini PDA (Nougat)
- LG V20 International (Nougat)
- Nexus 10 (Lollipop)
- Nexus 5 (Marshmallow)
- Nexus 5 (Nougat)
- Nexus 5X (Oreo)
- Nexus 6 (LineageOS 16.0)
- Nexus 6 (Nougat)
- Nexus 6P (LineageOS 17.1)
- Nexus 6P (Oreo)
- Nexus 7 [2013] (LineageOS 13.0)
- Nexus 7 [2013] (Marshmallow)
- Nexus 9 (Nougat)
- Nokia 3.1 (Pie)
- Nokia 6.1 (LineageOS 18.1)
- Nokia 6.1 Plus (LineageOS 18.1)
- OnePlus 2 (LineageOS 14.1)
- OnePlus 2 (LineageOS 16.0)
- OnePlus 3 / 3T (Pie)
- OnePlus 3 / 3T (Ten)
- OnePlus 6 / 6T (OxygenOS Eleven)
- OnePlus 6 / 6T (OxygenOS Twelve)
- OnePlus 7 / 7 Pro / 7T / 7T Pro (Eleven)
- OnePlus 7 / 7 Pro / 7T / 7T Pro (Ten)
- OnePlus 8 / 8T / 8 Pro (Eleven)
- OnePlus 8 / 8T / 8 Pro (Twelve)
- OnePlus Nord (Eleven)
- OnePlus One (LineageOS 18.1)
- Samsung Galaxy S6 (Nougat)
- Samsung Galaxy Tab S4 LTE (Oreo)
- Samsung Galaxy Tab S4 WiFi (Oreo)
- Sony Xperia Z1 (Marshmallow)
- Sony Xperia Z1 (Pie)
- TicWatch Pro / Pro 4G/LTE / Pro 2020 (Wear OS)
- Xiaomi Mi 9T MIUI 11 (Ten)
- Xiaomi Mi A3 (LineageOS 18.1)
- Xiaomi Pocophone F1 (Eleven)
- ZTE Axon 7 (Marshmallow)
For devices mentioned in the first list and not in the second, mobile hackers must build NetHunter images from the source. The code is available on GitLab. If you are one of them, you don’t have to worry, it is not that difficult and we will go through the whole process from cloning NetHunter code repository, building it and flashing it to our device.
Prepare environment
When I was trying to build a NetHunter image or just a kernel on Windows 10 machine, it all went without any building errors. However, the final build seemed to be corrupted because TWRP was not able to flash it correctly. When I built and image in Kali Linux, everything went as it should. Because of that, the process of building the image will be done in Kali that is running in a virtual machine.
If your Kali is prepared, install the ADB tools and fastboot using the commands below. Both, ADB and fastboot, will then be then used to flash our images. This step is only necessary if you will flash built images from Kali VM machine directly and not from host machine.
apt-get install android-tools-adb
apt-get install android-tools-fastboot
Build NetHunter image
As a first, we will clone the NetHunter repository from GitLab using Git command:
git clone https://gitlab.com/kalilinux/nethunter/build-scripts/kali-nethunter-project
This will download all necessary files such as a chroot builder, pre-compiled kernels with modules and installation scripts.
Change to the installer directory of the NetHunter project:
cd kali-nethunter-project/nethunter-installer/
And run bootstraps script that will based on your choosing either download NetHunter images for all devices or just update devices directory with recently added images. This will take some time.
./bootstrap.sh
In the same directory is also located a python script build.py
that we will use for building our image.
From the help message, as you can see in Figure 3, we can see a list of supported device codenames (--devices
), various Android system versions, option to build only kernel (--kernel
) and option to build with various chroot size (--rootfs
).
For better understanding, here are commands to build various NetHunter images. To build an image with full chroot that will be installed on our OnePlus 7 running stock Android 10, we will use:
python3 build.py -d oneplus7-oos --ten --rootfs full
If you don’t want to bundle chroot, only build app with custom kernel, you can use command bellow. However, afterwards you must either download or copy the chroot to your device before using it.
python3 build.py -d oneplus7-oos --ten
To build only kernel image without the whole NetHunter image use --kernel
instead of --rootfs
option:
python3 build.py -d oneplus7-oos --ten --kernel
As a result, for all of these commands is a .zip file stored in the same directory as the build script. This build installer then needs to be flashed in recovery mode (TWRP). For instructions on how to flash NetHunter image, feel free to follow steps from my previous blogpost.
Conclusion
If your device is not in the list of 38 devices with a precompiled image, then you have two options. Either do a research if someone has already compiled and tested an image file – I advise to search on XDA forum, or you have build it yourself.
Even though I demonstrated building the NetHunter image for OnePlus 7, the same scenario applies for any other supported device where you will replace the device model and version of Android you have installed on your smartphone. You can find the list of backed devices in the help menu of the build script.
If your device is not even in the list of NetHunter supported 85 devices, then you have to find device kernel sources, compile them with NetHunter provided AnyKernel, and port them to your new device.
Tutorial for OnePlus Nord ce 2 lite 5g.
Thx 4 the tutorial brother ❤️🩹
Oneplus 8 pro.. kernal and image..is it the same way just changing the model number ?
I have the official kernel for my phone, is it possible to use it here or the image needs the custom kernel?
You have hit the mark. Thought excellent, it agree with you.
Hello, my dear friend. I have a Mi 9T phone. I rooted the device and downloaded NetHunter. I need how to use it correctly. Thank you.