-
Notifications
You must be signed in to change notification settings - Fork 0
/
kalinethunter
382 lines (320 loc) · 11.2 KB
/
kalinethunter
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
#!/data/data/com.termux/files/usr/bin/bash -e
# colors
red='\033[1;31m'
yellow='\033[1;33m'
blue='\033[1;34m'
reset='\033[0m'
# Clean up
pre_cleanup() {
#printf "\n${yellow} 正在清除之前的kali,请耐心等待\n"
find $HOME -name "kali*" -type d -exec rm -rf {} \; || :
}
post_cleanup() {
printf "\n${yellow} 正在清除kali安装包(kalifs*),请耐心等待"
find $HOME -name "kalifs*" -type f -exec rm -rf {} \; || :
}
# Utility function for Unknown Arch
#####################
# Decide Chroot #
#####################
setchroot() {
chroot=full
}
unknownarch() {
printf "$red"
echo "[*] Unknown Architecture :("
printf "$reset"
exit
}
# Utility function for detect system
checksysinfo() {
printf "$blue [*] Checking host architecture ..."
case $(getprop ro.product.cpu.abi) in
arm64-v8a)
SETARCH=arm64
;;
armeabi|armeabi-v7a)
SETARCH=armhf
;;
*)
unknownarch
;;
esac
}
# Check if required packages are present
checkdeps() {
printf "${blue}\n"
echo " [*] Updating apt cache..."
apt update -y &> /dev/null
echo " [*] Checking for all required tools..."
for i in proot tar axel; do
if [ -e $PREFIX/bin/$i ]; then
echo " • $i is OK"
else
echo "Installing ${i}..."
apt install -y $i || {
printf "$red"
echo " ERROR: check your internet connection or apt\n Exiting..."
printf "$reset"
exit
}
fi
done
apt upgrade -y
}
# URLs of all possibls architectures
seturl() {
URL="https://images.kali.org/nethunter/kalifs-${SETARCH}-${chroot}.tar.xz"
}
# Utility function to get tar file
gettarfile() {
printf "$blue [*] Getting tar file...$reset\n\n"
DESTINATION=$HOME/kali-${SETARCH}
seturl
cd $HOME
rootfs="kalifs-${SETARCH}-${chroot}.tar.xz"
if [ ! -f "$rootfs" ]; then
axel ${EXTRAARGS} --alternate "$URL"
else
printf "${red}[!] continuing with already downloaded image, if this image is corrupted or half downloaded then delete it manually to download a fresh image.$reset\n\n"
fi
}
# Utility function to get SHA
getsha() {
printf "\n${blue} [*] Getting SHA ... $reset\n\n"
if [ -f kalifs-${SETARCH}-${chroot}.sha512sum ]; then
rm kalifs-${SETARCH}-${chroot}.sha512sum
fi
axel ${EXTRAARGS} --alternate "https://images.kali.org/nethunter/kalifs-${SETARCH}-${chroot}.sha512sum" -o kalifs-${SETARCH}-${chroot}.sha512sum
}
# Utility function to check integrity
checkintegrity() {
#printf "\n${blue} [*] Checking integrity of file...\n"
echo " [*] The script will immediately terminate in case of integrity failure"
#printf ' '
sha512sum -c kalifs-${SETARCH}-${chroot}.sha512sum || {
#printf "$red Sorry :( to say your downloaded linux file was corrupted or half downloaded, but don't worry, just rerun my script\n${reset}"
printf "\n$blue Start to extract\n${reset}"
}
}
# Utility function to extract tar file
extract() {
printf "$blue [*] Extracting... $reset\n\n"
printf "$red [*] 这个过程会需要点时间\n\n"
printf "$red [*] 请确保给终端留有后台\n\n"
printf "$red [*] 请勿退出此界面,程序掉了得重来\n\n"
printf "$blue [*] Extracting... $reset\n\n"
proot --link2symlink tar -xf $rootfs -C $HOME 2> /dev/null || :
}
# Utility function for login file
createloginfile() {
bin=${PREFIX}/bin/startkali
cat > $bin <<- EOM
#!/data/data/com.termux/files/usr/bin/bash -e
red='\033[1;31m'
blue='\033[1;34m'
printf "\n\n$blue [!!!]注意\n\n"
printf "$red [!!!]自测开启中文字体时不能用谷歌拼音\n\n"
#printf "$red [!!!]kali内还没有实现播放声音\n\n"
printf "\n\n$blue [*]快捷命令\n\n"
printf "$blue [*]使用中文字体:AsChinese\n\n"
printf "$blue [*]使用英文字体:AsUS\n\n"
printf "$blue [*]安装谷歌拼音输入法:GetGooglePinyin\n\n"
printf "$blue [*]安装谷歌浏览器:GetChromium\n\n"
printf "$blue [*]修改~/.vimrc来配置vim:FixVim\n\n"
printf "$blue [*]清除VNC服务在/tmp生成的文件:CleanVNC\n\n"
printf "\n\n$blue [*]常用命令提示\n\n"
printf "$blue [*]检查更新:apt update\n\n"
printf "$blue [*]更新软件:apt upgrade\n\n"
printf "$blue [*]修改密码 sudo passwd\n\n"
printf "$blue [*]启动vnc服务:startvnc\n"
printf "$blue [*]关闭vnc服务:stopvnc\n"
printf "$blue [*]了解更多vnc服务命令"
printf "$blue tigervncserver --help\n\n"
printf "$red 养成不用就关掉的习惯,不然每次都要改vnc连接器的端口号,或者需要运行CleanVNC\n\n"
unset LD_PRELOAD
if [ ! -f $DESTINATION/root/.version ]; then
touch $DESTINATION/root/.version
fi
user=kali
home="/home/\$user"
LOGIN="sudo -u \$user /bin/bash"
if [[ ("\$#" != "0" && ("\$1" == "-r")) ]]; then
user=root
home=/\$user
LOGIN="/bin/bash --login"
shift
fi
cmd="proot \\
--link2symlink \\
-0 \\
-r ${DESTINATION} \\
-b /dev \\
-b /proc \\
-b $DESTINATION\$home:/dev/shm \\
-b /sdcard \\
-b $HOME \\
-w \$home \\
/usr/bin/env -i \\
HOME=\$home TERM="\$TERM" \\
LANG=\$LANG PATH=/bin:/usr/bin:/sbin:/usr/sbin \\
\$LOGIN"
args="\$@"
if [ "\$#" == 0 ]; then
exec \$cmd
else
\$cmd -c "\$args"
fi
EOM
chmod 700 $bin
}
printline() {
printf "${blue}\n"
echo " #---------------------------------#"
}
FixBetter(){
printf "\n${yellow} 解决update签名验证问题\n"
echo "Acquire::AllowInsecureRepositories true ; " >> "/data/data/com.termux/files/home/kali-arm64/etc/apt/apt.conf.d/70debconf"
printf "\n${yellow} 修复kali用户权限问题 ==>直接给root权限\n"
sed -i "s/kali:x:100000:100000/kali:x:0:0/g" "/data/data/com.termux/files/home/kali-arm64/etc/passwd"
printf "\n${yellow} 添加国内源 ==>默认中科大源\n"
}
createPersonCmd1() {
bin=/data/data/com.termux/files/home/kali-arm64/bin/GetGooglePinyin
cat > $bin <<- EOM
echo "正在安装谷歌拼音"&&echo "sudo apt update"&&sudo apt update&&echo "sudo apt install fcitx"&&sudo apt install fcitx&&echo "sudo apt install fcitx-googlepinyin"&&sudo apt install fcitx-googlepinyin
if [ -f "/usr/share/applications/fcitx.desktop" ];then
cp /usr/share/applications/fcitx.desktop /home/kali/.config/autostart/fcitx.desktop
echo "OnlyShowIn=XFCE" >> /home/kali/.config/autostart/fcitx.desktop
echo "StartupNotify=false" >> /home/kali/.config/autostart/fcitx.desktop
echo "Terminal=false" >> /home/kali/.config/autostart/fcitx.desktop
echo "Hidden=false" >> /home/kali/.config/autostart/fcitx.desktop
fi
EOM
chmod 700 $bin
}
createPersonCmd2() {
bin=/data/data/com.termux/files/home/kali-arm64/bin/startvnc
cat > $bin <<- EOM
echo "只允许localhost进行连接"&&echo "正在执行命令tigervncserver -xstartup /usr/bin/xfce4-session"echo "想允许其他用户连接请使用 startvnc0"&&tigervncserver -xstartup /usr/bin/xfce4-session
EOM
chmod 700 $bin
}
createPersonCmd3() {
bin=/data/data/com.termux/files/home/kali-arm64/bin/startvnc0
cat > $bin <<- EOM
echo "正在执行命令 tigervncserver -xstartup /usr/bin/xfce4-session -localhost 0"&&tigervncserver -xstartup /usr/bin/xfce4-session -localhost 0
EOM
chmod 700 $bin
}
#英文
createPersonCmd33() {
bin=/data/data/com.termux/files/home/kali-arm64/bin/stopvnc
cat > $bin <<- EOM
echo "正在执行命令 tigervncserver -kill"&&tigervncserver -kill&&echo "关闭指定vnc任务使用以下命令"&&echo "tigervncserver -kill :数字"
EOM
chmod 700 $bin
}
createPersonCmd4() {
bin=/data/data/com.termux/files/home/kali-arm64/bin/GetChromium
cat > $bin <<- EOM
echo "正在安装Chromium"&&sudo apt update&&sudo apt install chromium&&sed -i '/.*Exec=*/c\Exec=/usr/bin/chromium --no-sandbox' /usr/share/applications/chromium.desktop
EOM
chmod 700 $bin
}
#汉化
createPersonCmd5() {
bin=/data/data/com.termux/files/home/kali-arm64/bin/AsChinese
cat > $bin <<- EOM
if [ -d "/usr/share/doc/fonts-wqy-zenhei/" ];then
echo "正在启用中文字体"&&sed -i '/.*export LANG=*/c\' ~/.bashrc&&echo "export LANG=zh_CN.UTF-8" >> ~/.bashrc&&echo "需要重新启动kali,设置才能生效"&&exit
else
echo "正在启用中文字体"&&sudo apt update&&sudo apt-get install ttf-wqy-microhei ttf-wqy-zenhei xfonts-wqy&&sed -i '/.*export LANG=*/c\' ~/.bashrc&&echo "export LANG=zh_CN.UTF-8" >> ~/.bashrc&&echo "需要重新启动kali,设置才能生效"&&exit
fi
EOM
chmod 700 $bin
}
#英文
createPersonCmd6() {
bin=/data/data/com.termux/files/home/kali-arm64/bin/AsUS
cat > $bin <<- EOM
echo "正在启用英文字体"&&sed -i '/.*export LANG=*/c\' ~/.bashrc&&echo "export LANG=en_US.UTF-8" >> ~/.bashrc&&echo "需要重新启动kali,设置才能生效"&&exit
EOM
chmod 700 $bin
}
setsource() {
##添加国内源
echo -e "#中科大 \ndeb http://mirrors.ustc.edu.cn/kali kali-rolling main non-free contrib\ndeb-src http://mirrors.ustc.edu.cn/kali kali-rolling main non-free contrib" > "/data/data/com.termux/files/home/kali-arm64/etc/apt/sources.list"
echo -e "#阿里云\n#deb https://mirrors.aliyun.com/kali kali-rolling main non-free contrib\n#deb-src https://mirrors.aliyun.com/kali kali-rolling main non-free contrib" >> "/data/data/com.termux/files/home/kali-arm64/etc/apt/sources.list"
echo -e "#清华大学\n#deb http://mirrors.tuna.tsinghua.edu.cn/kali kali-rolling main contrib non-free\n#deb-src https://mirrors.tuna.tsinghua.edu.cn/kali kali-rolling main contrib non-free" >> "/data/data/com.termux/files/home/kali-arm64/etc/apt/sources.list"
echo -e "#官方源\n#deb http://http.kali.org/kali kali-rolling main non-free contrib\n#deb-src http://http.kali.org/kali kali-rolling main non-free contrib" >> "/data/data/com.termux/files/home/kali-arm64/etc/apt/sources.list"
}
createPersonCmd7() {
bin=/data/data/com.termux/files/home/kali-arm64/bin/FixVim
cat > $bin <<- EOM
echo "syntax on" >> ~/.vimrc&&echo "set smarttab" >> ~/.vimrc&&echo "set termguicolors" ~/.vimrc&&echo "set title" >> ~/.vimrc&&echo "set relativenumber" >> ~/.vimrc
EOM
chmod 700 $bin
}
createPersonCmd8() {
bin=/data/data/com.termux/files/home/kali-arm64/bin/CleanVNC
cat > $bin <<- EOM
find /tmp -name ".X*-lock" -exec rm -rf {} \; 2>/dev/null
find /tmp -name "*-lock0001*" -exec rm -rf {} \; 2>/dev/null
find /tmp -name "ssh-*" -exec rm -rf {} \; 2>/dev/null
find /tmp -name "pulse-*" -exec rm -rf {} \; 2>/dev/null
find /tmp -name ".xfsm-ICE-*" -exec rm -rf {} \; 2>/dev/null
find /tmp/.ICE-unix/ -name "*.*" -exec rm -rf {} \; 2>/dev/null
find /tmp/.X11-unix/ -name "*.*" -exec rm -rf {} \; 2>/dev/null
find /tmp -name "fcitx-socket-\:*" -exec rm -rf {} \; 2>/dev/null
#rm -rf /tmp/null
#echo "不用管find:报错"
echo "清理完成"
EOM
chmod 700 $bin
}
# Start
clear
EXTRAARGS=""
if [[ ! -z $1 ]]; then
EXTRAARGS=$1
if [[ $EXTRAARGS != "--insecure" ]]; then
EXTRAARGS=""
fi
fi
printf "\n${yellow} You are going to install Kali Nethunter In Termux Without Root ;) Cool\n\n"
pre_cleanup
checksysinfo
checkdeps
setchroot
gettarfile
getsha
checkintegrity
extract
createloginfile
post_cleanup
FixBetter
setsource
printf "$blue [*] Configuring Kali For You ..."
# Utility function for resolv.conf
resolvconf() {
#create resolv.conf file
printf "\nnameserver 8.8.8.8\nnameserver 8.8.4.4" > ${DESTINATION}/etc/resolv.conf
}
resolvconf
################
# finaltouchup #
################
finalwork() {
printf "$blue \n\n : )牢记开机命令:startkali\n\n"
}
createPersonCmd1
createPersonCmd2
createPersonCmd3
createPersonCmd33
createPersonCmd4
createPersonCmd5
createPersonCmd6
createPersonCmd7
createPersonCmd8
finalwork