-
Notifications
You must be signed in to change notification settings - Fork 337
/
finaltouchup.sh
96 lines (84 loc) · 1.79 KB
/
finaltouchup.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
#!/data/data/com.termux/files/usr/bin/bash
fix_profile() {
if [ -f ${DESTINATION}/root/.bash_profile ]; then
sed -i '/if/,/fi/d' "${DESTINATION}/root/.bash_profile"
fi
}
fix_sudo() {
chmod +s $DESTINATION/usr/bin/sudo
chmod +s $DESTINATION/usr/bin/su
echo "kali ALL=(ALL:ALL) ALL" > $DESTINATION/etc/sudoers.d/kali
echo "Set disable_coredump false" > $DESTINATION/etc/sudo.conf
}
fix_uid() {
GID=$(id -g)
startkali -r usermod -u $UID kali 2>/dev/null
startkali -r groupmod -g $GID kali 2>/dev/null
}
create_xsession_handler() {
if [ $SETARCH = "arm64" ]; then
LIBGCCPATH=/usr/lib/aarch64-linux-gnu
else
LIBGCCPATH=/usr/lib/arm-linux-gnueabihf
fi
VNC_WRAPPER=$DESTINATION/usr/bin/vnc
cat > $VNC_WRAPPER <<- EOF
#!/bin/bash
vnc_start() {
if [ ! -f ~/.vnc/passwd ]; then
vnc_passwd
fi
USR=\$(whoami)
if [ \$USR = "root" ]; then
SCR=:1
else
SCR=:2
fi
export USER=\$USR; LD_PRELOAD=$LIBGCCPATH/libgcc_s.so.1 nohup vncserver \$SCR >/dev/null 2>&1 </dev/null
}
vnc_stop() {
vncserver -kill :1
vncserver -kill :2
return \$?
}
vnc_passwd() {
vncpasswd
return \$?
}
vnc_status() {
session_list=\$(vncserver -list)
if [[ \$session_list == *"590"* ]]; then
echo "\$session_list"
else
echo "there is nothing to list :)"
echo "you can start a new session by << vnc start >>"
fi
}
vnc_kill() {
pkill Xtigervnc
return \$?
}
case "\$1" in
start)
vnc_start
;;
stop)
vnc_stop
;;
status)
vnc_status
;;
kill)
vnc_kill
;;
*)
echo "[!] invalid input"
esac
EOF
chmod +x $VNC_WRAPPER
}
## Main
fix_profile
fix_sudo
fix_uid
create_xsession_handler