forked from kawaxi/Kali-Setup
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Start
376 lines (292 loc) · 11.3 KB
/
Start
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
#!/bin/bash
# bash Start -f --winkeys --keyboard es --timezone America/Mexico_City --openvas
# ---------- Intense Colors ---------- #
#--- Using an Apple/Macintosh keyboard (non VM)? [ --osx ]
keyboardApple=false
#--- Using a Windows Keyboard ? [ --winkeys ]
keyboardWin=false
#--- Set keyboard layout [ --keyboard es]
keyboardLayout=""
#--- Set timezone location [ --timezone America/Mexico_City ]
timezone=""
# ---------- Optional Steps ---------- #
#--- Configures Burp Suite (for Burp Pro users...) [ --burp ]
burpFree=false
#--- Set static & lock DNS name server [ --dns ]
hardenDNS=false
#--- Install & configure OpenVAS [ --openvas ]
openVAS=false
#---Install Metasploit?
msF=false
#--- Full install?
f=false
FULL=0
UPDATE=0
# ---------- Declaring ---------- #
#--- Colors, Functions, banners, Headings
source lib/visual
#--- Help Functions
source lib/help
#--- Update & Upgrade
source lib/update
#--- Configuring the Environment
source lib/config
#--- Express Install , only basic apps for daily use.
source lib/express
#--- Full Module, get ready for pentest.
source lib/full
#--- Cleaning the system after all the work is done.
source lib/clean
#--- Using our full width
M=${COLUMNS:-$(tput cols)}
#--- Where do we start?
STAGE=0
# ---------- Total stages for total ---------- #
#--- Number of STAGES in Config File
C=19
#--- Number of STAGES In Start File
S=4
#--- Number of STAGES In Update File
U=2
#--- Number of STAGES In Express File
X=17
#--- Number of STAGES In FUll File
F=58
# ---------- Arguments ---------- #
#--- Read command line arguments
if ((!$#)) ; then # No arguments?
banner--
heading--
shorth--
exit 1
else
#--- Take the argument
while [[ "${#}" -gt 0 && ."${1}" == .-* ]]; do
opt="${1}";
shift;
case "$(echo ${opt} | tr '[:upper:]' '[:lower:]')" in
-|-- ) break 2;;
-winkeys|--winkeys )
keyboardWin=true;;
-osx|--osx )
keyboardApple=true;;
-apple|--apple )
keyboardApple=true;;
-dns|--dns )
hardenDNS=true;;
-openvas|--openvas )
openVAS=true;;
-msf|--msf )
msF=true;;
-burp|--burp )
burpFree=true;;
-keyboard|--keyboard )
keyboardLayout="${1}"; shift;;
-keyboard=*|--keyboard=* )
keyboardLayout="${opt#*=}";;
-timezone|--timezone )
timezone="${1}"; shift;;
-timezone=*|--timezone=* )
timezone="${opt#*=}";;
-f=*|--f=* )
f=true;;
-h)
banner--
heading--
help--;;
-f)
banner--
heading--
TEXT=' Full Install selected, this will take a while, please wait patienly '
notice--
UPDATE=3
TOTAL=$((S + C + U + X + F))
FULL=3;;
-x)
TEXT='[*] Initiating express module with update !'
notice--
FULL=1
TOTAL=$((S + C + U + X ))
UPDATE=3;;
-xx)
banner--
TEXT="[*] Initiating express module with no update !"
notice--
FULL=1
TOTAL=$((S + C + X ))
UPDATE=1;;
*)
banner--
TEXT="¡¡¡¡ Please provide a valid argument for the script !!!!"
notice--
shorth--
exit 1;;
esac
done
fi
time=$(date +%s) #Used for time Stats
#--- Are we running as root ?
if [[ "${EUID}" -ne 0 ]]; then
echo -e ' '${RED}'[!]'${RESET}" This script must be ${RED}run as root${RESET}" 1>&2
echo -e ' '${RED}'[!]'${RESET}" Quitting..." 1>&2
exit 1
else
echo -e "${BLUE}[*]${RESET}${BOLD}Kali Linux rolling post-install script${RESET}"
fi
#--- Fix display output for GUI programs In case your Creating this VM remotely (SSH)
export DISPLAY=:0.0
export TERM=xterm
#--- Check user inputs
if [[ -n "${timezone}" && ! -f "/usr/share/zoneinfo/${timezone}" ]]; then
echo -e ' '${RED}'[!]'${RESET}" It Looks like the ${RED}timezone '${timezone}'${RESET} is incorrect/not supported (Example: ${BOLD}America/Mexico_City ${RESET})" 1>&2
echo -e ' '${RED}'[!]'${RESET}" Quitting..." 1>&2
exit 1
elif [[ -n "${keyboardLayout}" && -e /usr/share/X11/xkb/rules/xorg.lst ]]; then
if ! $(grep -q " ${keyboardLayout} " /usr/share/X11/xkb/rules/xorg.lst); then
echo -e ' '${RED}'[!]'${RESET}" It Looks like the ${RED}keyboard layout '${keyboardLayout}'${RESET} is incorrect/not supported (Example: ${BOLD}gb${RESET})" 1>&2
echo -e ' '${RED}'[!]'${RESET}" Quitting..." 1>&2
exit 1
fi
fi
# ---------- Update your system ---------- #
if [[ "${UPDATE}" -ge 3 ]]; then
TEXT="Initiating System's Update, this will take a while!"
notice--
update--
else
if [[ "${UPDATE}" -ge 1 ]]; then
heading--
TEXT="We won't update the system this time ....Skipping!"
notice--
fi
fi
# ---------- Defaults ---------- #
# ---------- Start ---------- #
#--- Sync time
apt -y -qq install ntp ntpdate \
|| echo -e ' '${RED}'[!] Issue with apt install'${RESET} 1>&2
#--- Update time
ntpdate -b -s -u pool.ntp.org
#--- Start service
systemctl restart ntp
#--- Remove from start up
systemctl disable ntp 2>/dev/null
#--- Only used for stats at the end
start_time=$(date +%s)
#--- So you can watch progress , another options is gsettings set org.gnome.desktop.lockdown disable-lock-screen true
gsettings set org.gnome.desktop.screensaver lock-enabled false
#---if using 32 bits Create /usr/local/bin , our Script uses it to install apps.
if [[ $(getconf LONG_BIT) = 32 ]]; then
(( STAGE++ )); echo -e "\n\n ${GREEN}[*]${RESET} (${STAGE}/${TOTAL}) ${GREEN} Creating /usr/local/bin Directory... ${RESET}"
mkdir /usr/local/bin
fi
#--- What modules are we Skipping?
if [ "${burpFree}" != "true" ]; then
echo -e "\n\n ${YELLOW}[i]${RESET} ${YELLOW}Skipping Burp Suite${RESET} (missing: '$0 ${BOLD}--burp${RESET}')..." 1>&2
fi
if [ "${openVAS}" != "true" ]; then
echo -e "\n\n ${YELLOW}[i]${RESET} ${YELLOW}Skipping OpenVas${RESET} (missing: '$0 ${BOLD}--openvas${RESET}')..." 1>&2
fi
if [ "${msF}" != "true" ]; then
echo -e "\n\n ${YELLOW}[i]${RESET} ${YELLOW}Skipping Metasploit${RESET} (missing: '$0 ${BOLD}--msf${RESET}')..." 1>&2
fi
#--- Check to see if Kali is in a VM. If so, install "Virtual Machine Addons/Tools" for a "better" virtual experiment
if (dmidecode | grep -iq vmware); then
#--- Install virtual machines tools ~ http://docs.kali.org/general-use/install-vmware-tools-kali-guest
(( STAGE++ )); echo -e "\n\n ${GREEN}[*]${RESET} (${STAGE}/${TOTAL}) ${GREEN} Installing VMware's (open) virtual machine tools${RESET}"
apt -y -qq install open-vm-tools-desktop fuse \
|| echo -e ' '${RED}'[!] Issue with apt install'${RESET} 1>&2
apt -y -qq install make \
|| echo -e ' '${RED}'[!] Issue with apt install'${RESET} 1>&2 # There's a nags afterwards
#--- Shared folders support for Open-VM-Tools (some odd bug)
file=/usr/local/sbin/mount-shared-folders; [ -e "${file}" ] && cp -n $file{,.bkup}
cat <<EOF > "${file}" \
|| echo -e ' '${RED}'[!] Issue with writing file'${RESET} 1>&2
#!/bin/bash
vmware-hgfsclient | while read folder; do
echo "[i] Mounting \${folder} (/mnt/hgfs/\${folder})"
mkdir -p "/mnt/hgfs/\${folder}"
umount -f "/mnt/hgfs/\${folder}" 2>/dev/null
vmhgfs-fuse -o allow_other -o auto_unmount ".host:/\${folder}" "/mnt/hgfs/\${folder}"
done
sleep 2s
EOF
chmod +x "${file}"
ln -sf "${file}" /root/Desktop/mount-shared-folders.sh
# Fixing Time Sync Problem by updating rc.d
# https://www.digitalocean.com/community/tutorials/how-to-configure-a-linux-service-to-start-automatically-after-a-crash-or-reboot-part-1-practical-examples#step-1-%E2%80%94-connecting-to-your-debian-6-droplet
#systemctl enable open-vm-tools.service <---- enable this if you have problems with vmtools
#update-rc.d open-vm-tools enable
#systemctl restart open-vm-tools.service <---- enable this if you have problems with vmtools
# If this doest fix the problem , add Restart=on-failure under Service ; /etc/systemd/system/multi-user.target.wants/open-vm-tools.service
#file=/etc/systemd/system/multi-user.target.wants/open-vm-tools.service
# file=/etc/systemd/system/multi-user.target.wants/open-vm-tools.service; [ -e "${file}" ] && cp -n $file{,.bkup}
# if [[ -f "${file}" ]]; then
# echo -e ' '${GREEN}'[!]'${RESET}" ${file} ${ORANGE} Modifying File " ${RESET} 1>&2
# cat <<EOF > "${file}" \
# || echo -e ' '${RED}'[!] Issue with writing file'${RESET} 1>&2
# [Unit]
# Description=Service for virtual machines hosted on VMware
# Documentation=http://open-vm-tools.sourceforge.net/about.php
# ConditionVirtualization=vmware
# [Service]
# ExecStart=/usr/bin/vmtoolsd
# TimeoutStopSec=5
# Restart=on-failure
# [Install]
# WantedBy=multi-user.target
# EOF
# chmod 777 $file
# else
# echo -e ' '${RED}'[!] Are you sure this file exists? '${RESET} 1>&2
# fi
# Reloading daemons and service to reflect changes
# systemctl daemon-reload
# systemctl restart open-vm-tools.service
#--- Installing VirtualBox Guest Additions. Note: Need VirtualBox 4.2.xx+ for the host (http://docs.kali.org/general-use/kali-linux-virtual-box-guest)
elif (dmidecode | grep -iq virtualbox); then
(( STAGE++ )); echo -e "\n\n ${GREEN}[*]${RESET} (${STAGE}/${TOTAL}) ${GREEN} Installing VirtualBox's guest additions${RESET}"
apt -y -qq install virtualbox-guest-x11 \
|| echo -e ' '${RED}'[!] Issue with apt install'${RESET} 1>&2
fi
# ---------- Configure your system ---------- #
TEXT=' We are configuring your System , go get a drink.'
heading--
configure--
TEXT="!! System's Configuration done!!"
notice--
# ---------- End of Configuration ---------- #
if [[ "${FULL}" -ge 3 ]]; then
TEXT='Initiating Express Module, Apps will be Installed'
notice--
express--
TEXT='Initiating Full Module, All the rest of the software will be installed'
notice--
full--
else
if [[ "${FULL}" -ge 1 ]]; then
heading--
TEXT='Initiating Express Module, Only Basic Apps will be installed'
notice--
express--
fi
fi
# ---------- Clean the system---------- #
TEXT='Cleaning initiated, please wait'
notice--
clean--
# ---------- Time taken ---------- #
finish_time=$(date +%s)
echo -e "\n\n ${YELLOW}[i]${RESET} Time (roughly) taken: ${YELLOW}$(( $(( finish_time - start_time )) / 60 )) minutes${RESET}"
# ---------- Done ---------- #
echo -e "\n ${YELLOW}[i]${RESET} Don't forget to:"
echo -e " ${YELLOW}[i]${RESET} + Check the above output (Did everything install? Any errors? (${RED}HINT: What's in RED${RESET}?)"
echo -e " ${YELLOW}[i]${RESET} + Manually install: Nessus, Nexpose, and/or Metasploit Community"
echo -e " ${YELLOW}[i]${RESET} + Agree/Accept to: Maltego, OWASP ZAP, w3af, etc"
echo -e " ${YELLOW}[i]${RESET} + Setup git: ${YELLOW}git config --global user.name <name>;git config --global user.email <email>${RESET}"
echo -e " ${YELLOW}[i]${RESET} + ${BOLD}Change default passwords${RESET}: PostgreSQL/MSF, MySQL, OpenVAS, BeEF XSS, etc"
echo -e " ${YELLOW}[i]${RESET} + ${YELLOW}Reboot${RESET}"
(dmidecode | grep -iq virtual) \
&& echo -e " ${YELLOW}[i]${RESET} + Take a snapshot (Virtual machine detected)"
echo -e '\n'${BLUE}'[*]'${RESET}' '${BOLD}'Done! Happy Hacking'${RESET}'\n\a'
exit 0