Skip to content
This repository has been archived by the owner on Apr 25, 2019. It is now read-only.

Commit

Permalink
First Push
Browse files Browse the repository at this point in the history
Needed to add .gitignore so i can commit the 'empty folders'
  • Loading branch information
jmingov committed Dec 26, 2015
1 parent ec581d8 commit 960570b
Show file tree
Hide file tree
Showing 9 changed files with 306 additions and 2 deletions.
63 changes: 61 additions & 2 deletions README.md
@@ -1,2 +1,61 @@
# Nethunter-LRT
Scripts to unlock && flash NEXUS stock images && TWRP + SuperSU + Kali Nethunter from Linux
# nethunter-LRT


The **Nethunter Linux Root Toolkit** is a little collection of scripts to do some common things needed to **install Kali Linux Nethunter from Linux**.


***Tools needed:***

- USB debugging enabled in the phone.
- `adb` installed and present in `$PATH`
- `fastboot` installed and present in `$PATH`

*Use google if you don't know how to install adb or fastboot, Android SDK is the best way imo.*

**Assumptions:** The device is normally booted, USB debugging enabled and plugged to the Linux machine via USB cable.

**How to make this work:**

1. Clone the repository.
2. Download the correct Factory Image for your device from [Google Nexus Images](https://developers.google.com/android/nexus/images?hl=en) and put it in the folder `/stockImage`
3. Download the correct TWRP image for your device from [TWRP WEB](https://twrp.me/Devices/) and put it in the folder `/twrpImage`
4. Download Latest SuperSu (BETA) from [XDA_Chainfire post](http://forum.xda-developers.com/showpost.php?p=64161125&postcount=3) and put it in the folder `/superSu`
5. Put the nethunter zip (Atm you need to build it see [Latest nethunter build instructions](https://github.com/offensive-security/kali-nethunter/tree/newinstaller-fj/AnyKernel2)) in the folder `/kaliNethunter`

Now you are ready ^^.

-----------------
OEM Unlock:
---------------
This script is cross device. (Nexus and OnePlus)

Unlock any nexus/OP device using the script `oemUnlock.sh`

Is the first thing you will need to do in any new device.

Skip this if your phone bootloader is already unlocked.

-----------------
Flash Stock:
---------------
(Only nexus)
The script `stockFlash.sh` will flash the google factory image in the device.

This way you will get a clean phone to install nethunter on it.

Skip this if your phone has a clean flash done/ or you are using other rom.

-----------------
Custom Recovery (TWRP) + SuperSU (root) + Kali Linux Nethunter
-------------------------------------

This script is cross device. (Nexus and OnePlus)

The script `twrpFlash.sh` will flash the custom recovery and push the needed files to the phone.

Once you are in the TWRP recovery you will need to flash both zips using the flash utility in TWRP.


-----------------
More info: Read the source ^^

23 changes: 23 additions & 0 deletions common.sh
@@ -0,0 +1,23 @@
#!/bin/sh


# HELP FUNCTIONS

isAdbInPath () {
command -v adb >/dev/null 2>&1 && echo "adb FOUND" || { echo >&2 "We require adb but it's not installed/in path.\nAborting."; exit 1; }
}

isFastbootInPath () {
command -v fastboot >/dev/null 2>&1 && echo "fastboot FOUND" || { echo >&2 "We require fastboot but it's not installed/in path.\nAborting."; exit 1; }
}

isEmpty () {
files=$1
if find $files -maxdepth 0 -empty | read v; then echo "Dir $1 is empty. Files are missing\nAborting."; exit 1; else echo "Dir $1 has files"; fi
}

isAdbConnected () {
adbGoodState="device"
adbState=$(adb get-state)
if [ "$adbState" = "$adbGoodState" ] ; then echo "ADB device detected."; else echo "ADB DEVICE NOT DETECTED!!!\nAborting."; exit 1; fi
}
4 changes: 4 additions & 0 deletions kaliNethunter/.gitignore
@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore
49 changes: 49 additions & 0 deletions oemUnlock.sh
@@ -0,0 +1,49 @@
#!/bin/sh

# require functions
. ./common.sh

# INIT
echo "NETHUNTER LINUX FLASH (OEM UNLOCK)\n"
echo "NOTE: THIS WILL FACTORY RESET THE DEVICE (15 secs to cancel using 'ctrl + c')\n"
sleep 15
echo "CHECKING PRE-REQUISITES\n"

echo "Checking if adb is installed"
isAdbInPath
echo "Checking if adb is installed DONE\n"

echo "Checking if fastboot is installed"
isFastbootInPath
echo "Checking if fastboot is installed DONE\n"

echo "Adb connection check"
isAdbConnected
echo "Adb connection check DONE\n"

echo "CHECKING PRE-REQUISITES DONE\n"
sleep 3

echo "Rebooting into bootloader"
adb reboot bootloader
sleep 5
echo "Rebooting into bootloader DONE\n"

echo "Starting OEM UNLOCK"
echo "This needs you interaction. Check phone screen."
fastboot oem unlock
echo "OEM UNLOCK DONE\n"

echo "Rebooting the phone"
fastboot continue
echo "Rebooting the phone DONE\n"




echo "It can take a bit to boot up, dont worry. ^^\n"
echo "You will need to enable developer options and USB debugging again.\n"

echo "You can flash a stock rom using stockFlash.sh (Not needed if you are in latest android version)"
echo "or continue flashing TWRP && superSU && Kali Nethunter using twrpFlash.sh script\n"
exit
66 changes: 66 additions & 0 deletions stockFlash.sh
@@ -0,0 +1,66 @@
#!/bin/sh

# CONSTANTS

stockImageDir=stockImage/
romExtractionDir=_extracted

# require functions
. ./common.sh

# INIT

echo "NETHUNTER LINUX FLASH (STOCK NEXUS GOOGLE IMAGES)\n"

echo "CHECKING PRE-REQUISITES\n"

echo "Checking if adb is installed"
isAdbInPath
echo "Checking if adb is installed DONE\n"

echo "Checking if fastboot is installed"
isFastbootInPath
echo "Checking if fastboot is installed DONE\n"

echo "Adb connection check"
isAdbConnected
echo "Adb connection check DONE\n"

echo "Checking stock image existence"
isEmpty $stockImageDir
echo "Checking stock rom existence DONE\n"

echo "CHECKING PRE-REQUISITES DONE\n"
sleep 3

echo "Creating tmp dir $romExtractionDir"
mkdir $romExtractionDir
echo "Creating tmp dir $romExtractionDir DONE\n"

echo "Extracting $(ls $stockImageDir*)"
tar -xvf $stockImageDir* -C _extracted
echo "EXTACTING $(ls $stockImageDir*) DONE\n"

echo "cd to $romExtractionDir"
cd _extracted/*
echo "cd to $romExtractionDir DONE\n"

echo "Rebooting into bootloader"
adb reboot bootloader
sleep 5
echo "Rebooting into bootloader DONE\n"

echo "Flasing Stock Rom\n!!!! DONT UNPLUG THE DEVICE !!!!"
./flash-all.sh
echo "Flasing Stock Rom DONE\n"

echo "Deleting tmp dir $romExtractionDir"
rm -rf ../../$romExtractionDir
echo "Deleting $romExtractionDir DONE\n"

# END

echo "The device should be rebooting, once it is booted,"
echo "do the initial setup, enable developer options and USB debugging again.\n"
echo "Next step is flashing TWRP && superSU && Kali Nethunter using twrpFlash.sh script\n"
exit
4 changes: 4 additions & 0 deletions stockImage/.gitignore
@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore
4 changes: 4 additions & 0 deletions superSu/.gitignore
@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore
91 changes: 91 additions & 0 deletions twrpFlash.sh
@@ -0,0 +1,91 @@
#!/bin/sh

# CONSTANTS

# TWRP
twrpImageDir=twrpImage/
twrpImage="$twrpImageDir"*

# SuperSU
superSuDir=superSu/
superSuZip="$superSuDir"*
sdSupersu="/sdcard/supersu.zip"

# Kali Nethunter
nhDir=kaliNethunter/
nhZip="$nhDir"*
sdnh="/sdcard/kaliNethunter.zip"


# require functions
. ./common.sh


# INIT

echo "NETHUNTER LINUX FLASH (TWRP, SuperSU and Kali Nethunter)\n"

echo "CHECKING PRE-REQUISITES\n"

echo "Checking if adb is installed"
isAdbInPath
echo "Checking if adb is installed DONE\n"

echo "Checking if fastboot is installed"
isFastbootInPath
echo "Checking if fastboot is installed DONE\n"

echo "Adb connection check"
isAdbConnected
echo "Adb connection check DONE\n"

echo "Checking TWRP image existence"
isEmpty $twrpImageDir
echo "Checking TWRP image existence DONE\n"

echo "Checking SuperSu existence"
isEmpty $superSuDir
echo "Checking SuperSu existence DONE\n"

echo "Checking Kali Nethunter zip existence"
isEmpty $nhDir
echo "Checking Kali Nethunter zip existence DONE\n"

echo "CHECKING PRE-REQUISITES DONE\n"
sleep 3

echo "Sending Kali Nethunter zip to the device"
adb push -p $nhZip $sdnh
sleep 3
echo "Sending Kali Nethunter zip to the device DONE\n"

echo "Sending SuperSu zip to the device"
adb push -p $superSuZip $sdSupersu
sleep 3
echo "Sending SuperSu zip to the device DONE\n"

echo "Rebooting into bootloader"
adb reboot bootloader
sleep 5
echo "Rebooting into bootloader DONE\n"

echo "Flashing TWRP image"
fastboot flash recovery $twrpImage
sleep 3
echo "Flashing TWRP image DONE\n"

echo "Booting into TWRP"
fastboot boot $twrpImage
echo "Booting into TWRP DONE\n"

echo "ALL FINE\n"
echo "TWRP will show up soon in the phone"


echo "SuperSu zip is in $sdSupersu, flash it via TWRP first."
echo "Kali Nethunter zip is in $sdnh, flash it via TWRP AFTER superSu"
echo "You can flash both at the same time but select superSu first in TWRP\n"

echo "!!!! If TWRP ask to root the device DONT DO IT. !!!!"
exit

4 changes: 4 additions & 0 deletions twrpImage/.gitignore
@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

0 comments on commit 960570b

Please sign in to comment.