forked from offensive-security/kali-nethunter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
androidmenu.sh
executable file
·1379 lines (1174 loc) · 48.2 KB
/
androidmenu.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
# Modified to include menu system
# Kernel Development requires Kali 64bit host
# Configure the build environment
DEBUG=0 # Valid values are 0 or 1, with 1 being enabled
LOCALGIT=0
FROZENKERNEL=0
######### Dependencies #######
# cd ~
# git clone https://github.com/offensive-security/kali-nethunter
# cd kali-nethunter
# sh build-deps.sh
########## Compiler ###########
# cd ~
# git clone https://github.com/offensive-security/gcc-arm-linux-gnueabihf-4.7.git
# export PATH=${PATH}:/root/gcc-arm-linux-gnueabihf-4.7/bin
######### Local git repos #######
# When testing multiple images, it is often faster to first checkout git repos and use them locally.
# To do this, you can :
# cd ~/kali-nethunter
#
# - Nexus 10
# git clone https://github.com/binkybear/kernel_samsung_manta.git -b thunderkat
# git clone https://github.com/binkybear/nexus10-5.git -b android-exynos-manta-3.4-lollipop-release
# - Nexus 9
# git clone https://github.com/binkybear/flounder.git -b android-tegra-flounder-3.10-lollipop-release nexus9-5
# - Nexus 7 (2012)
# git clone https://github.com/binkybear/kangaroo.git -b kangaroo
# git clone https://github.com/binkybear/Grouper-3.1.10.git -b lollipop nexus7_2012-5
# - Nexus 7 (2013)
# git clone https://github.com/binkybear/kernel_msm.git -b android-msm-flo-3.4-kitkat-mr2 flodeb
# git clone https://github.com/binkybear/flo.git -b ElementalX-3.00 nexus7_2013-5
# - Nexus 6
# git clone https://github.com/binkybear/kernel_msm.git -b android-msm-shamu-3.10-lollipop-release nexus6-5
# - Nexus 5
# git clone https://github.com/binkybear/furnace_kernel_lge_hammerhead.git -b android-4.4
# git clone https://github.com/binkybear/kernel_msm.git -b android-msm-hammerhead-3.4-lollipop-release nexus5-5
# - Nexus 4
# git clone https://github.com/binkybear/kernel_msm.git -b android-msm-mako-3.4-kitkat-mr2 mako
# git clone https://github.com/binkybear/kernel_msm.git -b android-msm-mako-3.4-lollipop-release nexus4-5
# - OnePlus One
# git clone https://github.com/binkybear/AK-OnePone.git -b cm-11.0-ak oneplus11
# git clone https://github.com/binkybear/AK-OnePone.git -b cm-12.1 oneplus12
# - Galaxy S5
# git clone https://github.com/binkybear/KTSGS5.git -b aosp4.4 galaxy_s5
# git clone https://github.com/binkybear/KTSGS5.git -b tw4.4 galaxy_s5_tw
# - Galaxy S4
# git clone https://github.com/binkybear/android_kernel_samsung_jf.git -b cm-11.0 galaxy_s4
# git clone https://github.com/binkybear/android_kernel_samsung_exynos5410.git -b cm-11.0 galaxy_s4_i9500
# - Toolchain
# git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7
# git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9 -b lollipop-release
######## Local Repo ##########
# to update : for directory in $(ls -l |grep "^d" | awk -F" " '{print $9}');do cd $directory && git pull && cd ..;done
# 0 = use remote git clone | 1 = local copies
######## Frozen Kernels ##########
# Save time from having to build kernels every time set FROZENKERNEL=1.
# This will use premade kernels in devices/frozen_kernels/{VERSION}/{BUILDNAME}
######### Devices ##########
# Build scripts for each kernel is located under devices/devicename
source devices/nexus10-manta
source devices/nexus9-volantis #aka flounder
source devices/nexus6-shamu
source devices/nexus7-grouper-tilapia
source devices/nexus7-flo-deb
source devices/nexus5-hammerhead
source devices/nexus4-mako
source devices/one-bacon
source devices/sony-sirius
source devices/sony-leo
######### Set paths and permissions #######
basepwd=`pwd`
rootfs=`pwd`/rootfs
basedir=`pwd`/android-$VERSION
build_dir=`pwd`/PLACE_ROM_HERE
wwork=`pwd`/PLACE_ROM_HERE/working_rom_folder
wram=`pwd`/PLACE_ROM_HERE/working_ramdisk_folder
bt=`pwd`/utils/boottools
architecture="armhf"
chmod +x utils/boottools/*
######### Build script start #######
printf '\033[8;33;100t'
d_clear(){
# Disable the 'clear' statements, if DEBUG mode is enabled
if [ ${DEBUG} == 1 ]; then
echo **DEBUG** : Not clearing the screen.
else
clear
fi
}
f_check_version(){
# Allow user input of version number/folder creation to make set up easier
echo "Checking for git updates in local folder..."
for directory in $(ls -l | grep "^d" | awk -F" " '{print $9}');do cd $directory && git pull && cd ..;done
d_clear
# need to exit back to basedir to establish root folder
cd ${basepwd}
echo ""
read -p "Create working folder. Enter version number: " VERSION
export basedir=`pwd`/android-$VERSION
if [ -d "${basedir}" ]; then
echo ""
echo "Working folder / version already exsists, use a different version number?"
echo ""
read -p "Do you wish to continue with same version number? (y/n)" CONT
if [ "$CONT" == "y" ]; then
f_interface
else
exit 1
fi
else
mkdir -p ${basedir}
cd ${basedir}
f_interface
fi
}
###Nightly build script version of check version.
f_check_version_noui(){
# Allow user input of version number/folder creation to make set up easier
for directory in $(ls -l | grep "^d" | awk -F" " '{print $9}');do cd $directory && git pull && cd ..;done
cd ${basepwd}
VERSION=$(date +%m%d%Y)
case $nightlytype in
rootfs) export basedir=`pwd`/rootfs-$VERSION;;
kernel) export basedir=`pwd`/kernel-$device-$VERSION;;
esac
mkdir -p ${basedir}
cd ${basedir}
}
f_interface(){
d_clear
echo -e " \e[1mKALI NETHUNTER BUILDER FOR ANDROID DEVICES\e[0m"
echo ""
echo " WORK PATH: ${basedir}"
echo ""
echo -e "\e[31m [1] Build for Nexus Devices \e[0m"
echo ""
echo -e "\e[31m [2] Build for Samsung Devices \e[0m"
echo ""
echo -e "\e[31m [3] Build for OnePlus One Devices \e[0m"
echo ""
echo -e "\e[31m [4] Build for Sony Devices \e[0m"
echo ""
if [ -f "${basedir}/flashkernel/kernel/kernel" ] && [ -d "${basedir}/flash" ]; then
echo " [77] Inject finished rootfs/kernel into ROM"
fi
echo " [88] Build a rootfs only - Basic kali chroot for any Android Device"
echo " [99] Unmount and Clean Work Folders (file dir removal currently disabled)"
echo ""
echo " [q] Exit"
echo ""
echo ""
# wait for character input
read -p "Choice: " menuchoice
case $menuchoice in
1) d_clear; f_interface_nexus ;;
2) d_clear; f_interface_samsung ;;
3) d_clear; f_interface_oneplus ;;
4) d_clear; f_interface_sony ;;
77) d_clear; f_rom_build; f_interface ;;
88) d_clear; f_rootfs ; f_flashzip; f_zip_save; f_interface ;;
99) f_cleanup; f_interface ;;
q) d_clear; exit 1 ;;
*) echo "Incorrect choice..." ;
esac
}
f_interface_nexus(){
d_clear
echo ""
echo -e "\e[31m ---- NEXUS 10 (2012) - MANTA --------------------------------------------------------\e[0m"
echo " [1] Build for Nexus 10 Kernel with wireless USB support (Android 4.4+)"
echo ""
echo -e "\e[31m ---- NEXUS 7 (2012) - GROUPER/NAKASI -----------------------------------------------\e[0m"
echo " [2] Build for Nexus 7 (2012) with wireless USB support (Android 4.4+)"
echo ""
echo -e "\e[31m ---- NEXUS 7 (2013) - DEB/FLO ------------------------------------------------------\e[0m"
echo " [3] Build for Nexus 7 (2013) with wireless USB support (Android 4.4+)"
echo ""
echo -e "\e[31m ---- NEXUS 4 (2012) - MAKO ---------------------------------------------------------\e[0m"
echo " [4] Build for Nexus 4 with wireless USB support (Android 4.4+)"
echo ""
echo -e "\e[31m ---- NEXUS 5 (2013) - HAMMERHEAD ---------------------------------------------------\e[0m"
echo " [5] Build for Nexus 5 with wireless USB support (Android 4.4+)"
echo ""
echo -e "\e[31m ---- NEXUS 6 (2014) - SHAMU --------------------------------------------------------\e[0m"
echo " [6] Build for Nexus 6 with wireless USB support (Android 5)"
echo ""
echo -e "\e[31m ---- NEXUS 9 (2014) - VOLANTIS ------------------------------------------------------\e[0m"
echo " [7] Build for Nexus 9 with wireless USB support (Android 5)"
echo ""
echo " [0] Exit to Main Menu"
echo ""
echo ""
read -p "Choice: " nexusmenuchoice
case $nexusmenuchoice in
1) d_clear; f_manta ;;
2) d_clear; f_grouper ;;
3) d_clear; f_deb ;;
4) d_clear; f_mako ;;
5) d_clear; f_hammerhead ;;
6) d_clear; f_shamu ;;
7) d_clear; f_flounder ;;
0) d_clear; f_interface ;;
*) echo "Incorrect choice..." ;
esac
}
f_interface_samsung(){
echo ""
echo -e "\e[31m ---- SAMSUNG GALAXY S5 - G900(F/I/M/T/DEV/W8) ---------------------------------------\e[0m"
echo " [1] Build for Samsung Glaxy S5 G900 with wireless USB support (Android 4.4+)"
echo ""
echo -e "\e[31m ---- SAMSUNG GALAXY S4 - I9500 ------------------------------------------------------\e[0m"
echo " [2] Build for Samsung Glaxy S4 with wireless USB support (Android 4.4+)"
echo ""
echo " [0] Exit to Main Menu"
echo ""
echo ""
read -p "Choice: " samsungmenuchoice
case $samsungmenuchoice in
1) d_clear; f_galaxyS5 ;;
2) d_clear; f_galaxyS4_I9500 ;;
0) d_clear; f_interface ;;
*) echo "Incorrect choice..." ;
esac
}
f_interface_oneplus(){
echo -e "\e[31m ------------------------- OnePlus One --------------------\e[0m"
echo ""
echo " [1] Build All - Kali rootfs and Kernel (Android 4.4+)"
echo " [2] Build Kernel Only (Android 4.4+)"
echo " [3] Build All - Kali rootfs and Kernel (Android 5)"
echo " [4] Build Kernel Only (Android 5)"
echo " [0] Exit to Main Menu"
echo ""
echo ""
# wait for character input
read -p "Choice: " grouper_menuchoice
case $grouper_menuchoice in
1) d_clear; f_rootfs ; f_flashzip ; f_oneplus_kernel ; f_zip_save ; f_zip_kernel_save ; f_rom_build ;;
2) d_clear; f_oneplus_kernel ; f_zip_kernel_save ;;
3) d_clear; f_rootfs ; f_flashzip ; f_oneplus_kernel5 ; f_zip_save ; f_zip_kernel_save ; f_rom_build ;;
4) d_clear; f_oneplus_kernel5 ; f_zip_kernel_save ;;
0) d_clear; f_interface ;;
*) echo "Incorrect choice... " ;
esac
}
f_interface_sony(){
echo -e "\e[31m ------------------------- Sony Xperia Z2 (sirius) --------------------\e[0m"
echo ""
echo " [1] Build All - Kali rootfs and Kernel (Android 5)"
echo " [2] Build Kernel Only (Android 5)"
echo -e "\e[31m ------------------------- Sony Xperia Z3 (leo) --------------------\e[0m"
echo ""
echo " [3] Build All - Kali rootfs and Kernel (Android 5)"
echo " [4] Build Kernel Only (Android 5)"
echo " [0] Exit to Main Menu"
echo ""
echo ""
# wait for character input
read -p "Choice: " sony_menuchoice
case $sony_menuchoice in
1) d_clear; f_rootfs ; f_flashzip ; f_sony_kernel_z2 ; f_zip_save ; f_zip_kernel_save ; f_rom_build ;;
2) d_clear; f_sony_kernel_z2 ; f_zip_kernel_save ;;
3) d_clear; f_rootfs ; f_flashzip ; f_sony_kernel_z3 ; f_zip_save ; f_zip_kernel_save ; f_rom_build ;;
4) d_clear; f_sony_kernel_z3 ; f_zip_kernel_save ;;
0) d_clear; f_interface ;;
*) echo "Incorrect choice... " ;
esac
}
f_manta(){
echo -e "\e[31m ------------------------- NEXUS 10 -----------------------\e[0m"
echo ""
echo " [1] Build All - Kali rootfs and Kernel (Android 4.4+)"
echo " [2] Build Kernel Only (Android 4.4+)"
echo " [3] Build All - Kali rootfs and Kernel (Android 5)"
echo " [4] Build Kernel Only (Android 5)"
echo " [0] Exit to Main Menu"
echo ""
echo ""
# wait for character input
read -p "Choice: " manta_menuchoice
case $manta_menuchoice in
1) d_clear; f_rootfs ; f_flashzip ; f_nexus10_kernel ; f_zip_save ; f_zip_kernel_save ; f_rom_build ;;
2) d_clear; f_nexus10_kernel ; f_zip_kernel_save ;;
3) d_clear; f_rootfs ; f_flashzip ; f_nexus10_kernel5 ; f_zip_save ; f_zip_kernel_save ; f_rom_build ;;
4) d_clear; f_nexus10_kernel5 ; f_zip_kernel_save ;;
0) d_clear; f_interface ;;
*) echo "Incorrect choice..." ;
esac
}
f_flounder(){
echo -e "\e[31m ------------------------- NEXUS 9 -----------------------\e[0m"
echo ""
echo " [1] Build All - Kali rootfs and Kernel (Android 9)"
echo " [2] Build Kernel Only (Android 9)"
echo " [0] Exit to Main Menu"
echo ""
echo ""
# wait for character input
read -p "Choice: " manta_menuchoice
case $manta_menuchoice in
1) d_clear; f_rootfs ; f_flashzip ; f_nexus9_kernel5 ; f_zip_save ; f_zip_kernel_save ; f_rom_build ;;
2) d_clear; f_nexus9_kernel5 ; f_zip_kernel_save ;;
0) d_clear; f_interface ;;
*) echo "Incorrect choice..." ;
esac
}
f_shamu(){
echo -e "\e[31m ------------------------- NEXUS 6 -----------------------\e[0m"
echo ""
echo " [1] Build All - Kali rootfs and Kernel (Android 5)"
echo " [2] Build Kernel Only (Android 5)"
echo " [0] Exit to Main Menu"
echo ""
echo ""
# wait for character input
read -p "Choice: " shamu_menuchoice
case $shamu_menuchoice in
1) d_clear; f_rootfs ; f_flashzip ; f_nexus6_kernel5 ; f_zip_save ; f_zip_kernel_save ; f_rom_build ;;
2) d_clear; f_nexus6_kernel5 ; f_zip_kernel_save ;;
0) d_clear; f_interface ;;
*) echo "Incorrect choice..." ;
esac
}
f_grouper(){
echo -e "\e[31m ------------------------- NEXUS 7 (2012) -----------------------\e[0m"
echo ""
echo " [1] Build All - Kali rootfs and Kernel (Android 4.4+)"
echo " [2] Build Kernel Only (Android 4.4+)"
echo " [3] Build All - Kali rootfs and Kernel (Android 5)"
echo " [4] Build Kernel Only (Android 5)"
echo " [0] Exit to Main Menu"
echo ""
echo ""
# wait for character input
read -p "Choice: " grouper_menuchoice
case $grouper_menuchoice in
1) d_clear; f_rootfs ; f_flashzip ; f_nexus7_grouper_kernel ; f_zip_save ; f_zip_kernel_save ; f_rom_build ;;
2) d_clear; f_nexus7_grouper_kernel ; f_zip_kernel_save ;;
3) d_clear; f_rootfs ; f_flashzip ; f_nexus7_grouper_kernel5 ; f_zip_save ; f_zip_kernel_save ; f_rom_build ;;
4) d_clear; f_nexus7_grouper_kernel5 ; f_zip_kernel_save ;;
0) d_clear; f_interface ;;
*) echo "Incorrect choice... " ;
esac
}
f_deb(){
echo -e "\e[31m ------------------------- NEXUS 7 (2013) -----------------------\e[0m"
echo ""
echo " [1] Build All - Kali rootfs and Kernel (AOSP/STOCK) (Android 4.4+)"
echo " [2] Build Kernel (AOSP/STOCK) Only"
echo " [3] Build All - Kali rootfs and Kernel (CyanogenMod) (Android 4.4+)"
echo " [4] Build Kernel (CyanogenMod) Only"
echo " [5] Build All - Kali rootfs and Kernel (AOSP/STOCK) (Android 5)"
echo " [6] Build Kernel (AOSP/STOCK) (Android 5) Only"
echo " [0] Exit to Main Menu"
echo ""
echo ""
# wait for character input
read -p "Choice: " deb_menuchoice
case $deb_menuchoice in
1) d_clear; f_rootfs ; f_flashzip ; f_deb_stock_kernel ; f_zip_save ; f_zip_kernel_save ; f_rom_build ;;
2) d_clear; f_deb_stock_kernel ; f_zip_kernel_save ;;
3) d_clear; f_rootfs ; f_flashzip ; f_deb_cyanogen_kernel ; f_zip_save ; f_zip_kernel_save ; f_rom_build ;;
4) d_clear; f_deb_cyanogen_kernel ; f_zip_kernel_save ;;
5) d_clear; f_rootfs ; f_flashzip ; f_deb_stock_kernel5 ; f_zip_save ; f_zip_kernel_save ; f_rom_build ;;
6) d_clear; f_deb_stock_kernel5 ; f_zip_kernel_save ;;
0) d_clear; f_interface ;;
*) echo "Incorrect choice... " ;
esac
}
f_hammerhead(){
echo -e "\e[31m ------------------------- NEXUS 5 -----------------------\e[0m"
echo ""
echo " [1] Build All - Kali rootfs and Kernel (AOSP/STOCK) (Android 4.4+)"
echo " [2] Build Kernel (AOSP/STOCK) Only"
echo " [3] Build All - Kali rootfs and Kernel (AOSP/STOCK) (Android 5)"
echo " [4] Build Kernel (AOSP/STOCK) (Android 5) Only"
echo " [0] Exit to Main Menu"
echo ""
echo ""
# wait for character input
read -p "Choice: " deb_menuchoice
case $deb_menuchoice in
1) d_clear; f_rootfs ; f_flashzip ; f_hammerhead_stock_kernel ; f_zip_save ; f_zip_kernel_save ; f_rom_build ;;
2) d_clear; f_hammerhead_stock_kernel ; f_zip_kernel_save ;;
3) d_clear; f_rootfs ; f_flashzip ; f_hammerhead_stock_kernel5 ; f_zip_save ; f_zip_kernel_save ; f_rom_build ;;
4) d_clear; f_hammerhead_stock_kernel5 ; f_zip_kernel_save ;;
0) d_clear; f_interface ;;
*) echo "Incorrect choice... " ;
esac
}
f_mako(){
echo -e "\e[31m ------------------------- NEXUS 4 -----------------------\e[0m"
echo ""
echo " [1] Build All - Kali rootfs and Kernel (AOSP/STOCK) (Android 4.4+)"
echo " [2] Build Kernel (AOSP/STOCK) Only"
echo " [3] Build All - Kali rootfs and Kernel (AOSP/STOCK) (Android 5)"
echo " [4] Build Kernel (AOSP/STOCK) (Android 5) Only"
echo " [0] Exit to Main Menu"
echo ""
echo ""
# wait for character input
read -p "Choice: " mako_menuchoice
case $mako_menuchoice in
1) d_clear; f_rootfs ; f_flashzip ; f_mako_stock_kernel ; f_zip_save ; f_zip_kernel_save ; f_rom_build ;;
2) d_clear; f_mako_stock_kernel ; f_zip_kernel_save ;;
3) d_clear; f_rootfs ; f_flashzip ; f_mako_stock_kernel5 ; f_zip_save ; f_zip_kernel_save ; f_rom_build ;;
4) d_clear; f_mako_stock_kernel5 ; f_zip_kernel_save ;;
0) d_clear; f_interface ;;
*) echo "Incorrect choice... " ;
esac
}
f_galaxyS5(){
echo -e "\e[31m -------------- SAMSUNG GALAXY S5 ----G900(F/I/M/T/DEV/W8) ---------\e[0m"
echo ""
echo " [1] Build All - Kali rootfs and Kernel (AOSP/STOCK) (Android 4.4+)"
echo " [2] Build All - Kali rootfs and Kernel (TOUCHWIZ) (Android 4.4+)"
echo " [3] Build Kernel (AOSP/STOCK) Only"
echo " [4] Build Kernel (TOUCHWIZ) Only"
echo " [0] Exit to Main Menu"
echo ""
echo ""
# wait for character input
read -p "Choice: " s5_menuchoice
case $s5_menuchoice in
1) d_clear; f_rootfs ; f_flashzip ; f_s5_stock_kernel ; f_zip_save ; f_zip_kernel_save ; f_rom_build ;;
2) d_clear; f_rootfs ; f_flashzip ; f_s5_tw_kernel ; f_zip_save ; f_zip_kernel_save ; f_rom_build ;;
3) d_clear; f_s5_kernel ; f_zip_kernel_save ;;
4) d_clear; f_s5_tw_kernel ; f_zip_kernel_save ;;
0) d_clear; f_interface ;;
*) echo "Incorrect choice... " ;
esac
}
f_galaxyS4_I9500(){
echo -e "\e[31m -------------- SAMSUNG GALAXY S4 ----------GT-I9500 ---------\e[0m"
echo ""
echo " [1] Build All - Kali rootfs and Kernel (CM + All Qualacom Devices) (Android 4.4+)"
echo " [2] Build All - Kali rootfs and Kernel (CM + I9500) (Android 4.4+)"
echo " [3] Build Kernel (CM + Qualacom) Only"
echo " [4] Build Kernel (CM + I9500) Only"
echo " [0] Exit to Main Menu"
echo ""
echo ""
# wait for character input
read -p "Choice: " s4_menuchoice
case $s4_menuchoice in
1) d_clear; f_rootfs ; f_flashzip ; f_s4_kernel ; f_zip_save ; f_zip_kernel_save ; f_rom_build ;;
2) d_clear; f_rootfs ; f_flashzip ; f_s4_i9500_kernel ; f_zip_save ; f_zip_kernel_save ; f_rom_build ;;
3) d_clear; f_s4_kernel ; f_zip_kernel_save ;;
4) d_clear; f_s4_i9500_kernel ; f_zip_kernel_save ;;
0) d_clear; f_interface ;;
*) echo "Incorrect choice... " ;
esac
}
f_check_crosscompile(){
# Make sure that the cross compiler can be found in the path before we do
# anything else, that way the builds don't fail half way through.
case $ccc in
1) export PATH=${PATH}:/root/gcc-arm-linux-gnueabihf-4.7/bin; unset CROSS_COMPILE;;
*)
export CROSS_COMPILE=arm-linux-gnueabihf-
if [ $(compgen -c $CROSS_COMPILE | wc -l) -eq 0 ] ; then
echo "Missing cross compiler for Android root filesystem."
echo "Set up PATH according to the README"
echo ""
read -p "Enter export path (probable path): " -e -i "export PATH=${PATH}:/root/gcc-arm-linux-gnueabihf-4.7/bin" EXPORT_PATH
$EXPORT_PATH
unset CROSS_COMPILE
else
echo "Found cross compiler - will continue"
unset CROSS_COMPILE
fi;;
esac
}
f_rootfs(){
# Conduct check to see if previous rootfs was built
if [ -d "${rootfs}/kali-$architecture" ]; then
d_clear
echo "Detected prebuilt rootfs."
echo ""
read -p "Would you like to create a new rootfs? (y/n): " -e -i "n" createrootfs
if [ "$createrootfs" == "y" ]; then
echo "Removing previous rootfs"
rm -rf ${rootfs}/kali-$architecture
f_rootfs_build
else
echo "Continue with current build"
fi
else
echo "Previous rootfs build not found. Starting build."
sleep 5
f_rootfs_build
fi
}
f_rootfs_noui(){
rm -rf ${rootfs}/kali-armhf
f_rootfs_build
}
f_rootfs_build(){
f_check_crosscompile
# Set working folder to rootfs
cd ${rootfs}
# Package installations for various sections.
arm="abootimg cgpt fake-hwclock ntpdate vboot-utils vboot-kernel-utils uboot-mkimage"
base="kali-menu kali-defaults initramfs-tools usbutils openjdk-7-jre mlocate google-nexus-tools"
desktop="kali-defaults kali-root-login desktop-base xfce4 xfce4-places-plugin xfce4-goodies"
tools="nmap metasploit tcpdump tshark wireshark burpsuite armitage sqlmap recon-ng wipe socat ettercap-text-only beef-xss set device-pharmer nishang"
wireless="wifite iw aircrack-ng gpsd kismet kismet-plugins giskismet dnsmasq dsniff sslstrip mdk3 mitmproxy"
services="autossh openssh-server tightvncserver apache2 postgresql openvpn php5"
extras="wpasupplicant zip macchanger dbd florence libffi-dev python-setuptools python-pip hostapd ptunnel tcptrace dnsutils p0f mitmf"
mana="python-twisted python-dnspython libnl1 libnl-dev libssl-dev sslsplit python-pcapy tinyproxy isc-dhcp-server rfkill mana-toolkit"
bdf="backdoor-factory bdfproxy"
spiderfoot="python-lxml python-m2crypto python-netaddr python-mako"
sdr="sox librtlsdr"
export packages="${arm} ${base} ${desktop} ${tools} ${wireless} ${services} ${extras} ${mana} ${spiderfoot} ${sdr} ${bdf}"
export architecture="armhf"
# create the rootfs - not much to modify here, except maybe the hostname.
debootstrap --foreign --arch $architecture kali kali-$architecture http://http.kali.org/kali
cp /usr/bin/qemu-arm-static kali-$architecture/usr/bin/
# SECOND STAGE CHROOT
LANG=C chroot kali-$architecture /debootstrap/debootstrap --second-stage
cat << EOF > kali-$architecture/etc/apt/sources.list
deb http://http.kali.org/kali kali main contrib non-free
deb http://security.kali.org/kali-security kali/updates main contrib non-free
EOF
#define hostname
echo "localhost" > kali-$architecture/etc/hostname
# fix for TUN symbolic link to enable programs like openvpn
# set terminal length to 80 because root destroy terminal length
# add fd to enable stdin/stdout/stderr
cat << EOF > kali-$architecture/root/.bash_profile
export TERM=xterm-256color
stty columns 80
# /usr/bin/firstrun # we can remove this with sed at the end of the firstrun script
cd /root/
if [ ! -d "/dev/net/" ]; then
mkdir -p /dev/net
ln -sf /dev/tun /dev/net/tun
fi
if [ ! -d "/dev/fd/" ]; then
ln -sf /proc/self/fd /dev/fd
ln -sf /dev/fd/0 /dev/stdin
ln -sf /dev/fd/1 /dev/stdout
ln -sf /dev/fd/2 /dev/stderr
fi
EOF
cat << EOF > kali-$architecture/etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
EOF
if [ $LOCALGIT == 1 ]; then
cp /etc/hosts kali-$architecture/etc/
fi
# Copy over helper files to chroot /usr/bin
# Install Local files
cp -rf ${basepwd}/utils/{s,start-*} kali-$architecture/usr/bin/
cp -rf ${basepwd}/utils/hid/* kali-$architecture/usr/bin/
cp -rf ${basepwd}/utils/msf/*.sh kali-$architecture/usr/bin/
# Copy all start/stop scripts to xbin
cp ${basepwd}/flash/system/xbin/* ${rootfs}/kali-$architecture/usr/bin/
cat << EOF > kali-$architecture/etc/network/interfaces
auto lo
iface lo inet loopback
EOF
cat << EOF > kali-$architecture/etc/resolv.conf
#opendns
nameserver 208.67.222.222
nameserver 208.67.220.220
#google dns
nameserver 8.8.8.8
nameserver 8.8.4.4
EOF
# THIRD STAGE CHROOT
export MALLOC_CHECK_=0 # workaround for LP: #520465
export LC_ALL=C
export DEBIAN_FRONTEND=noninteractive
mount -t proc proc kali-$architecture/proc
mount -o bind /dev/ kali-$architecture/dev/
mount -o bind /dev/pts kali-$architecture/dev/pts
cat << EOF > kali-$architecture/debconf.set
console-common console-data/keymap/policy select Select keymap from full list
console-common console-data/keymap/full select en-latin1-nodeadkeys
EOF
cp ${basepwd}/utils/safe-apt-get kali-$architecture/usr/bin/safe-apt-get
cat << EOF > kali-$architecture/third-stage
#!/bin/bash
dpkg-divert --add --local --divert /usr/sbin/invoke-rc.d.chroot --rename /usr/sbin/invoke-rc.d
cp /bin/true /usr/sbin/invoke-rc.d
echo -e "#!/bin/sh\nexit 101" > /usr/sbin/policy-rc.d
chmod +x /usr/sbin/policy-rc.d
safe-apt-get update
safe-apt-get install locales-all
debconf-set-selections /debconf.set
rm -f /debconf.set
safe-apt-get update
safe-apt-get -y install git-core binutils ca-certificates initramfs-tools uboot-mkimage
safe-apt-get -y install locales console-common less nano git
echo "root:toor" | chpasswd
sed -i -e 's/KERNEL\!=\"eth\*|/KERNEL\!=\"/' /lib/udev/rules.d/75-persistent-net-generator.rules
rm -f /etc/udev/rules.d/70-persistent-net.rules
safe-apt-get --yes --force-yes install $packages
rm -f /usr/sbin/policy-rc.d
rm -f /usr/sbin/invoke-rc.d
dpkg-divert --remove --rename /usr/sbin/invoke-rc.d
rm -f /third-stage
EOF
chmod +x kali-$architecture/third-stage
LANG=C chroot kali-$architecture /third-stage
# Modify kismet configuration to work with gpsd and socat
sed -i 's/\# logprefix=\/some\/path\/to\/logs/logprefix=\/captures\/kismet/g' ${rootfs}/kali-$architecture/etc/kismet/kismet.conf
sed -i 's/# ncsource=wlan0/ncsource=wlan1/g' ${rootfs}/kali-$architecture/etc/kismet/kismet.conf
sed -i 's/gpshost=localhost:2947/gpshost=127.0.0.1:2947/g' ${rootfs}/kali-$architecture/etc/kismet/kismet.conf
# Copy over our kali specific mana config files
cp -rf ${basepwd}/utils/manna/start-mana* ${rootfs}/kali-$architecture/usr/bin/
cp -rf ${basepwd}/utils/manna/stop-mana* ${rootfs}/kali-$architecture/usr/bin/
cp -rf ${basepwd}/utils/manna/*.sh ${rootfs}/kali-$architecture/usr/share/mana-toolkit/run-mana/
dos2unix ${rootfs}/kali-$architecture/usr/share/mana-toolkit/run-mana/*
dos2unix ${rootfs}/kali-$architecture/etc/mana-toolkit/*
chmod 755 ${rootfs}/kali-$architecture/usr/share/mana-toolkit/run-mana/*
chmod 755 ${rootfs}/kali-$architecture/usr/bin/*.sh
# Set up HID powersploit hosted payload
cp -rf ${basepwd}/utils/files/powersploit-payload kali-$architecture/var/www/payload
chmod 644 kali-$architecture/var/www/payload
# Install Rawr (https://bitbucket.org/al14s/rawr/wiki/Usage)
git clone https://bitbucket.org/al14s/rawr.git ${rootfs}/kali-$architecture/opt/rawr
chmod 755 ${rootfs}/kali-$architecture/opt/rawr/install.sh
# Install Dictionary for wifite
mkdir -p ${rootfs}/kali-$architecture/opt/dic
tar xvf ${basepwd}/utils/dic/89.tar.gz -C ${rootfs}/kali-$architecture/opt/dic
# Install Pingen which generates DLINK WPS pins for some routers
wget https://raw.githubusercontent.com/devttys0/wps/master/pingens/dlink/pingen.py -O ${rootfs}/kali-$architecture/usr/bin/pingen
chmod 755 ${rootfs}/kali-$architecture/usr/bin/pingen
# Install Spiderfoot
# Cherrypy is newer in pip then in repo so we need to use that instead. All other depend are fine.
LANG=C chroot kali-$architecture pip install cherrypy
cd ${rootfs}/kali-$architecture/opt/
wget https://github.com/smicallef/spiderfoot/archive/v2.2.0-final.tar.gz -O spiderfoot.tar.gz
tar xvf spiderfoot.tar.gz && rm spiderfoot.tar.gz && mv spiderfoot-2.2.0-final spiderfoot
cd ${rootfs}
# Modify Kismet log saving folder
sed -i 's/hs/\/captures/g' ${rootfs}/kali-$architecture/etc/kismet/kismet.conf
# Kali Menu (bash script) to quickly launch common Android Programs
cp -rf ${basepwd}/menu/kalimenu ${rootfs}/kali-$architecture/usr/bin/kalimenu
sleep 5
#Installs deADBolt
curl -o ${rootfs}/kali-$architecture/usr/bin/deadbolt https://raw.githubusercontent.com/photonicgeek/deADBolt/master/main.sh
LANG=C chroot kali-$architecture chmod 755 /usr/bin/deadbolt
#Installs APFucker.py
curl -o ${rootfs}/kali-$architecture/usr/bin/apfucker.py https://raw.githubusercontent.com/mattoufoutu/scripts/master/AP-Fucker.py
LANG=C chroot kali-$architecture chmod 755 /usr/bin/apfucker.py
#Install HID attack script and dictionaries
cp ${basepwd}/flash/system/xbin/hid-keyboard ${rootfs}/kali-$architecture/usr/bin/hid-keyboard
cp ${basepwd}/utils/dic/pinlist.txt ${rootfs}/kali-$architecture/opt/dic/pinlist.txt
cp ${basepwd}/utils/dic/wordlist.txt ${rootfs}/kali-$architecture/opt/dic/wordlist.txt
cp ${basepwd}/utils/hid/hid-dic.sh ${rootfs}/kali-$architecture/usr/bin/hid-dic
LANG=C chroot kali-$architecture chmod 755 /usr/bin/hid-keyboard
LANG=C chroot kali-$architecture chmod 755 /usr/bin/hid-dic
# Set permissions to executable on newly added scripts
LANG=C chroot kali-$architecture chmod 755 /usr/bin/kalimenu
# Sets the default for hostapd.conf to the mana karma version
sed -i 's#^DAEMON_CONF=.*#DAEMON_CONF=/etc/mana-toolkit/hostapd-karma.conf#' kali-$architecture/etc/init.d/hostapd
sed -i 's/wlan0/wlan1/g' kali-$architecture/etc/mana-toolkit/hostapd-karma.conf
# DNSMASQ Configuration options for optional access point
cat <<EOF > kali-$architecture/etc/dnsmasq.conf
log-facility=/var/log/dnsmasq.log
#address=/#/10.0.0.1
#address=/google.com/10.0.0.1
interface=wlan1
dhcp-range=10.0.0.10,10.0.0.250,12h
dhcp-option=3,10.0.0.1
dhcp-option=6,10.0.0.1
#no-resolv
log-queries
EOF
# Add missing folders to chroot needed
cap=kali-$architecture/captures
mkdir -p kali-$architecture/root/.ssh/
mkdir -p kali-$architecture/sdcard kali-$architecture/system
mkdir -p $cap/evilap $cap/ettercap $cap/kismet/db $cap/nmap $cap/sslstrip $cap/tshark $cap/wifite $cap/tcpdump $cap/urlsnarf $cap/dsniff $cap/honeyproxy $cap/mana/sslsplit
# In order for metasploit to work daemon,nginx,postgres must all be added to inet
# beef-xss creates user beef-xss. Openvpn server requires nobdy:nobody in order to work
echo "inet:x:3004:postgres,root,beef-xss,daemon,nginx" >> kali-$architecture/etc/group
echo "nobody:x:3004:nobody" >> kali-$architecture/etc/group
if [ ${DEBUG} == 0 ]; then
# CLEANUP STAGE
cat << EOF > kali-$architecture/cleanup
#!/bin/bash
rm -rf /root/.bash_history
apt-get update
apt-get clean
rm -f /0
rm -f /hs_err*
rm -f cleanup
rm -f /usr/bin/qemu*
EOF
chmod +x kali-$architecture/cleanup
LANG=C chroot kali-$architecture /cleanup
umount ${rootfs}/kali-$architecture/proc/sys/fs/binfmt_misc
umount ${rootfs}/kali-$architecture/dev/pts
umount ${rootfs}/kali-$architecture/dev/
umount ${rootfs}/kali-$architecture/proc
sleep 5
fi
}
f_flashzip(){
#####################################################
# Create flashable Android FS. Git repository holds necessary
# folders/scripts/files.
# Flashable zip will need follow structure:
#
# /busybox/busybox - for mounting data folders for kernel install
# /data/app/kalilauncher.apk - Launches into root or menu
# /data/local/kalifs.tar.bz2 - The filesystem
# /data/local/tmp_kali - shell scripts to unzip filesystem/boot chroot + config files
# /kernel/kernel - kernel (zImage or zImage-dtb)
# /META-INF/com/google/android/updater-binary - Binary file for edify script
# /META-INF/com/google/android/updater-script - Edify script to install Kali
# /system/bin/bootkali - Launches the Kali chroot
# /system/bin/killkali - Shutsdown Kali chroot (unmounts and stops services)
# /system/etc/ - Contains firmware for wireless devices and nano for text editing
# /system/xbin/nano - Nano binary
# /system/xbin/busybox - Busybox binary
#####################################################
# Create base flashable zip
cp -rf ${basepwd}/flash ${basedir}/
mkdir -p ${basedir}/flash/data/local/
mkdir -p ${basedir}/flash/system/lib/modules
# Copy configuration files needed by nethunter app (we could also move this folder to flash/sdcard/files)
mkdir -p ${basedir}/flash/sdcard/files/modules
cp -rf ${basepwd}/utils/files ${basedir}/flash/sdcard
# Get latest Rubber Ducky conversion script
echo "Downloading latest Ducky conversion script"
mkdir -p ${basedir}/flash/sdcard/files/modules
wget https://raw.githubusercontent.com/offensive-security/kali-nethunter/master/utils/files/modules/duckconvert.txt -O ${basedir}/flash/sdcard/files/modules/duckconvert.txt
wget https://raw.githubusercontent.com/byt3bl33d3r/duckhunter/master/duckhunter.py -O ${basedir}/flash/sdcard/files/modules/duckhunter.py
# Download/add Android applications that are useful to our chroot enviornment
# Required: Terminal application is required
wget -P ${basedir}/flash/data/app/ http://jackpal.github.com/Android-Terminal-Emulator/downloads/Term.apk
# Suggested: BlueNMEA to enable GPS logging in Kismet
wget -P ${basedir}/flash/data/app/ http://max.kellermann.name/download/blue-nmea/BlueNMEA-2.1.3.apk
# Suggested: Hackers Keyboard for easier typing in the terminal
wget -P ${basedir}/flash/data/app/ https://hackerskeyboard.googlecode.com/files/hackerskeyboard-v1037.apk
# Suggested: Android VNC Viewer
wget -P ${basedir}/flash/data/app/ https://android-vnc-viewer.googlecode.com/files/androidVNC_build20110327.apk
# Suggested: DriveDroid for CDROM emulation
wget -P ${basedir}/flash/data/app/ http://softwarebakery.com/apps/drivedroid/files/drivedroid-free-0.9.20.apk
# Keyboard HID app
wget -P ${basedir}/flash/data/app/ https://github.com/pelya/android-keyboard-gadget/raw/master/USB-Keyboard.apk
# Suggested: RFAnalyzer
wget -P ${basedir}/flash/data/app/ https://github.com/demantz/RFAnalyzer/raw/master/RFAnalyzer.apk
}
#####################################################
# Zip and save
#####################################################
f_zip_save(){
apt-get install -y zip
d_clear
# Compress filesystem and add to our flashable zip
cd ${rootfs}
# Achtung, ugly hack to clean up chrooted /dev before packaging.
#######################################
rm -rf kali-$architecture/dev/*
#######################################
echo "Compressing kali rootfs, please wait"
tar jcf kalifs.tar.bz2 kali-$architecture
mv kalifs.tar.bz2 ${basedir}/flash/data/local/
#tar jcvf ${basedir}/flash/data/local/kalifs.tar.bz2 ${basedir}/kali-$architecture
echo "Structure for flashable zip file is complete."
echo "Build a kernel next or select build flashable zip form the main menu."
cd ${basedir}/flash/
zip -r6 update-kali-$VERSION.zip *
mv update-kali-$VERSION.zip ${basedir}
cd ${basedir}
# Generate sha1sum
echo "Generating sha1sum for update-kali$1.zip"
sha1sum update-kali-$VERSION.zip > ${basedir}/update-kali-$VERSION.sha1sum
echo "Flashable Kali zip now located at ${basedir}/update-kali-$VERSION.zip"
echo "Transfer file to device and flash in recovery"
sleep 5
}
f_zip_kernel_save(){
apt-get install -y zip
d_clear
cd ${basedir}/flashkernel/
zip -r6 kernel-kali-$VERSION.zip *
mv kernel-kali-$VERSION.zip ${basedir}
cd ${basedir}
# Generate sha1sum
echo "Generating sha1sum for kernelkali$1.zip"
sha1sum kernel-kali-$VERSION.zip > ${basedir}/kernel-kali-$VERSION.sha1sum
echo "Kernel can be flashed seperatley if needed using kernel-kali-$VERSION.zip"
echo "Transfer file to device and flash in recovery"
sleep 5
}
f_cleanup(){
if [ ${DEBUG} == 0 ]; then
# Clean up all the temporary build stuff and remove the directories.
# This only runs if debug mode is disabled.
echo "Unmounting any previous mounted folders"
sleep 3
d_clear
umount ${rootfs}/kali-$architecture/proc/sys/fs/binfmt_misc
umount ${rootfs}/kali-$architecture/dev/pts
umount ${rootfs}/kali-$architecture/dev/
umount ${rootfs}/kali-$architecture/proc
echo "Removing temporary build files"
rm -rf ${basedir}/patches ${basedir}/kernel ${basedir}/flash ${basedir}/kali-$architecture ${basedir}/flashkernel
fi
}
##############################################################
# Attempt to build rom from an existing zip file in ROM folder
##############################################################
f_rom_build(){
d_clear
cd ${basepwd}
echo "If you plan to add to ROM please place zip file in:"
echo "${basepwd}/PLACE_ROM_HERE"
echo ""
read -p "Would you like to attach Kali build to ROM? (y/n): " buildrom
if [ "$buildrom" == "n" ]; then
echo "All done!"
sleep 3
f_interface
fi
f_rom_build_menu(){
prompt="Please select a file: "
options=( $(find ${build_dir} -maxdepth 1 -iname '*.zip' | xargs -0) )
PS3="$prompt "
select zipfile in "${options[@]}" "Quit" ; do
if (( REPLY == 1 + ${#options[@]} )) ; then
f_interface
elif (( REPLY > 0 && REPLY <= ${#options[@]} )) ; then
echo "$zipfile chosen"
break
else
echo "Invalid option. Try another one."
f_rom_build_menu
fi
done
}
f_rom_build_menu