じゅのぶろ

社内SEが自宅でSOC/CSIRTするために色々頑張っていきたいブログ 画像が見れない場合はjavascriptを有効にするかデスクトップからご覧下さい。

kali nethunter v3.0導入した?

nethunter v3.0の(marshmallow)をnexus9にいれたので作業メモ.
基本的にこのwiki通りに進めていけば問題ないはずですが...
途中でつまづきました.試される方は自己責任で.
github.com

準備

サポートデバイスnexus系とOnePlus)が上記サイトの1.0節に記載されているので確認してください.
私が使用した端末は以下の通りです.
端末:nexus9
AndroidOS: 6.0.1
security patch level: March 1, 2016

1.0 イメージのダウンロード

zipで提供されているKali Linux NetHunter imagesを以下からダウンロードします.
www.offensive-security.com

1.1 Nethunterのビルド

github.com
私はcloneするのにけっこう時間がかかりました.
ここについてはコマンド例もあるので省略します.
結局使いませんでした(おそらく)

1.2 nethunter-LRTのダウンロード

Maclinuxと共通)からnethunterをインストールしたのでnethunter-LRTを使いました.
windowsの人はまた別のtoolkitを使うようです.
github.com

2.0 インストール

KaliNethunter-LRTを使うのでこの流れに沿っていくだけです.
github.com

2.1 事前準備

1.2節で落としたnethunter-LRTフォルダに移動し,
[stockImage]フォルダにコードネームに合った.img, .zip, .shファイル(tarを解凍)
Nexus: Google Nexus Images
OnePlusOne: https://cyngn.com/support(デバイスのfastbootバージョンに合ったものを選ぶ)


[twrpImage]フォルダにtwrpのイメージ
[supersu]フォルダにsupersuのzipファイル
[kaliNethunter]フォルダに1.0節でダウンロードしたKali Linux NetHunter imagesのzipファイル
をそれぞれ配置します(リネームはしないようにとのこと).

2.2 OEM Unlock

Android 端末のデータが消えますのでバックアップが必要な方は先に済ませておいてください
tar, unzip, adb, fastbootが必要になるので私はbrewから入れました.

brew install android-platform-tools

これでadb, fastboot が使えるようになる.

開発者モードにしていない場合,端末側で
設定(Setting) -> タブレットについて(About tablet)
ビルド番号(Build number)を何回かタップすると開発者向けオプションが表示されます.

その後,設定(Setting) -> 開発者向けオプション(Developer options)に移動して,
USBでバッキングをオンにしてポップアップが出てきたらPCを常に信頼にチェックマークしておくと良いでしょう.
同様に開発者向けオプションにあるEnable OEM unlockもオンにしてください.

その後,nethunter/oemUnlock.shを実行します.
bootloderの画面が起動しUnlock bootloaderと聞かれるのでyesを選択します.
コマンド
以下,ログです(日本語は私が追加しています).

$./oemUnlock.sh
NETHUNTER LINUX FLASH (OEM UNLOCK)

NOTE: THIS WILL FACTORY RESET THE DEVICE (15 secs to cancel using 'ctrl + c')

CHECKING PRE-REQUISITES

Checking if adb is installed
adb FOUND
Checking if adb is installed DONE

Checking if fastboot is installed
fastboot FOUND
Checking if fastboot is installed DONE

Adb connection check
ADB device detected.
Adb connection check DONE

CHECKING PRE-REQUISITES DONE

Rebooting into bootloader
Rebooting into bootloader DONE

Starting OEM UNLOCK
This needs you interaction. Check phone screen.
...
(bootloader) ability is 1
(bootloader) RUU_frame_buffer_enable_flag=0
(bootloader) Start Verify: 0
(bootloader) [hboot query] query 24 is not implemented
(bootloader) [hboot query] query 24 is not implemented
(bootloader) Start Verify: 0
(bootloader) [hboot query] query 24 is not implemented
(bootloader) [hboot query] query 24 is not implemented
(bootloader) Unlock device successfully!
OKAY [ 78.858s]
finished. total time: 78.858s
OEM UNLOCK DONE

Rebooting the phone
< waiting for device >
ここで少し時間かかります->端末側はErasing...となります
resuming boot...
FAILED (remote: not allowed)
finished. total time: 0.000s
Rebooting the phone DONE

It can take a bit to boot up, dont worry. ^^

You will need to enable developer options and USB debugging again.

You can flash a stock rom using stockFlash.sh (Not needed if you are in latest android version)
or continue flashing TWRP && superSU && Kali Nethunter using twrpFlash.sh script

2.3 kali nethunterインストール

OEMロック解除後は,初期化されていますので再起動して再び開発者オプションを表示させUSBでバッキングをオンにしてください.

OEMは解除のままになっているはずです.

USBでバッキングをオンにするとadbで接続ができるのでtwrpFlash.shを実行します.
転送が始まるがなぜかインストールできない:(

~~~省略~~

Sending SuperSu zip to the device
Transferring: 4306785/4306785 (100%)
6648 KB/s (4306785 bytes in 0.632s)
Sending SuperSu zip to the device DONE

~~~省略~~

Installing SuperSU
error: device '(null)' not found
Installing SuperSU DONE!

Installing Kali Linux Nethunter
error: device '(null)' not found
Installing Kali Linux Nethunter DONE!
Rebooting into Kali Linux Nethunter
error: device '(null)' not found
Everything is installed. Phone should be booting up! Enjoy

2.4 端末からインストール

というわけで端末からインストールしてみることに(スクリプトみるとadbで完結しそうだったがうまく動かないので...)
recoveryモードで起動(メニューなければHboot->recoveryから)
No command.となるのでどうやらtwrpがインストールできていない
再びbootloaderを起動(adb reboot-bootloader or ボリュームボタン+電源ボタンで起動)して
下記コマンドをpcで実行

nethunter-LRT$fastboot flash recovery twrpImage/twrp-3.0.0-2-flounder.img 
target reported max download size of 518205818 bytes
sending 'recovery' (13214 KB)...
OKAY [  0.759s]
writing 'recovery'...
(bootloader) Device State : Unlocked
OKAY [  0.884s]
finished. total time: 1.643s

twrpがインストールされたのでrecoveryを起動するとtwrpが起動するようになる.
swipe to allow modificationなのでスワイプした.
Installボタンおして/sdcardにあるsupersu.zipを選択(zipがない場合はAndroid File Transferなどで転送しておく)
swipe to confirm Flashなのでスワイプして書き込み.
reboot systemで再起動(不要かも).

再びbootloaderからrecovery(twrp)を起動
インストールからkali.zip(1.0節でダウンロードしたもの)を選択
インストールが始まり
Checking for Kali Chroot in installer ... this can take a while
で10分くらい待たされて終了します.
プログレスバーが止まる場合はいくら待ってもだめそうです)
結局下記のようにエラーが出るので1.1節でbuildしたzipも/sdcardに移してみましたが,同様のエラーでした.

Error: opening '/data/local/nhsystem/kali-armhf/dev/loop

Kali NetHunter for the Galaxy S5 (3.1.0) - Pg. 4 | Samsung Galaxy S 5
上記エラーについてなにかご存知の方教えていただけると助かります...

何はともあれ起動はするのでnethunterアプリからアップデートやパッケージのインストールができます.
いまのところ不具合はありませんが文鎮化のリスクはあるかもしれません.

途中でやめたくなったらbootloader画面にしておき,nethunter-LRT/stockImage/flash-all.shを実行すれば元に戻るはずです.
fastboot -w update image-volantisg-mmb29v.zipで怒られる場合はzipを解凍してできたimgをbootloaderの.imgと同じ階層に配置して,
flash-all.shを以下のように書き換えたらできました(code_name, versionは自分のものと読み替えてください).

fastboot flash bootloader bootloader-<code_name>.<version>.img
fastboot reboot-bootloader
sleep 5
fastboot flash recovery recovery.img
fastboot reboot-bootloader
sleep 5
~~~省略~~~

fastboot flashでは第二引数以降 <書き込み領域> <イメージ>という感じです.
fastbootについてはより詳しく解説している方がたくさんいるのでそちらを参照ください.

nethunterの使い方などはまだわかっていないのでまた今度解説できれば..