-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild.sh
executable file
·561 lines (444 loc) · 20.4 KB
/
build.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
#!/bin/bash
# Rev: 0.2 - Minor changes + new package added in choices
# Rev: 0.3 - Changes to desktop environment.. XFCE -> LXDE
# Rev: 0.4 - Add support for Blackarch container deployment
# Rev: 0.5 - Added PowerShell script to support windows container deployement
# Rev: 0.6 - Added Parrotsec Linux build option
#### COLORS ####
RED="\e[0;91m"
GREEN="\e[1;92m"
BLUE="\e[1;94m"
YELLOW="\e[1;33m"
CYAN="\e[0;36m"
PURPLE="\e[0;35m"
WHITE="\e[0;97m"
RESET="\e[0m"
#### ASCII ####
ASCII="
${RED} _____ ${RESET}${PURPLE} ____ _ ${RESET}
${RED}| _ |___ ___${RESET}${PURPLE}| \ ___ ___| |_ ${RESET}
${RED}| __| -_| ${RESET}${PURPLE}| | | . | _| '_|${RESET}
${RED}|__| |___|_|_${RESET}${PURPLE}|____/|___|___|_,_|${RESET}
v0.6
"
DOCKER="`which docker`"
VNCPASSWD="`which vncpasswd`"
BLACKARCH_FOLDER="`pwd`/blackarch"
KALI_FOLDER="`pwd`/kali"
PARROT_FOLDER="`pwd`/parrotsec"
printf "${ASCII}\n"
printf "\nThis script will install ${BLUE}Kali Linux${RESET}, ${RED}Blackarch${RESET} or ${CYAN}Parrotsec${RESET}
in Docker and provide GUI access via X2GO or VNC...\n
More information about the program can be found here:
https://wiki.x2go.org/doku.php
\n
${RED}!${RESET}${YELLOW}[WARNING]${RESET}${RED}!${RESET}
You will be asked for your sudo password.
That's so Docker can execute the commands
the script will use.\n
Press enter key to continue\n"
read # Just wait for user input... :)
sleep 0.5
# Check if docker exists on system
if [[ -z ${DOCKER} ]]; then
printf "${RED}[-]${RESET} Docker is not installed !\n"
exit 1
else
printf "${GREEN}[+]${RESET} Docker is installed !\n"
fi
sleep 0.5
###############################################
# Delete created [{kali,barch}.mod2] files ####
###############################################
function del_mod2files {
printf "${YELLOW}[!]${RESET} Deleting unecessary files after build..\n"
printf "${BLUE}[*]${RESET} Files:\n"
printf "============================\n"
printf "Dockerfile.barch.mod2\n"
printf "Dockerfile.kali.mod2\n"
printf "Dockerfile.parrot.mod2\n"
printf "============================\n"
`which rm` -rf ${BLACKARCH_FOLDER}/Dockerfile.barch.mod2
`which rm` -rf ${KALI_FOLDER}/Dockerfile.kali.mod2
`which rm` -rf ${PARROT_FOLDER}/Dockerfile.parrotsec.mod2
}
#### ATTENTION ####
# It seems that due to the use of HTTPS in APT sources list
# some domains are returning a 404 for certain packages which is an issue
# so at the moment it will be only with the main tools package
# very frustrating so i dont recommend using Parrotsec
###################
##############################################
# Start building Parrotsec Linux container ###
##############################################
function build_parrotsec {
printf "${GREEN}[+]${RESET} Starting ${CYAN}Parrotsec Linux${RESET} Docker build !\n"
sleep 1
printf "${YELLOW}[!]${RESET} SSH key is needed to use the GUI access to ${CYAN}Parrotsec Linux${RESET} due to X2GO requirements.\n"
printf "${BLUE}[*]${RESET} Do you want to generate an SSH key ? [Y/n]: "
read SSHGEN_CHOICE
if [[ ( ${SSHGEN_CHOICE} = "" ) || ( ${SSHGEN_CHOICE} = "y" ) || ( ${SSHGEN_CHOICE} = "Y" ) || ( ${SSHGEN_CHOICE} = "Yes" ) || ( ${SSHGEN_CHOICE} = "yes" ) ]]; then
printf "${BLUE}[*]${RESET} What to name the SSH key ? "
read SSHF_NAME
if [[ ${SSHF_NAME} == "" ]]; then
printf "${RED}[-]${RESET} SSH key name can't be empty !\n"
exit 1
else
`which ssh-keygen` -f ${PARROT_FOLDER}/${SSHF_NAME}
# Place the public key into "Dockerfile" for Parrotsec Linux
`which cat` ${PARROT_FOLDER}/Dockerfile.parrotsec.mod | `which sed` "s|SSH_PUBKEY|$(cat ${PARROT_FOLDER}/${SSHF_NAME}.pub)|g" > ${PARROT_FOLDER}/Dockerfile.parrotsec.mod2
fi
elif [[ ( ${SSHGEN_CHOICE} = "n" ) || ( ${SSHGEN_CHOICE} = 'N' ) || ( ${SSHGEN_CHOICE} = "no" ) || ( ${SSHGEN_CHOICE} = "No" ) ]]; then
printf "\n
${YELLOW}[!]${RESET} NOTE:
You will have to generate your SSH key and
add it to the ${CYAN}Parrotsec Linux${RESET} Dockerfile to enable SSH and GUI
to the Parrotsec docker container. Then rerun docker build command
manually. Otherwise, you will have to use an alternative method.
Press enter key to continue\n
"
read
else
printf "${RED}[-]${RESET} Invalid choice !\n"
exit 1
fi
sleep 1
printf "\n${BLUE}[*]${RESET} Which package of ${CYAN}Parrotsec Linux${RESET} tools would you like to install ?\n
1. parrot-meta-all ${CYAN}(Takes up to TBC)${RESET}
2. parrot-tools ${CYAN}(Takes up to ~6.5Gb)${RESET}
3. parrot-tools-common ${CYAN}(Takes up to TBC)${RESET}
4. parrot-pico ${CYAN}(Takes up to TBC)${RESET}
Enter choice as number. i.e 1\n
Choice: "
read PACKAGE_CHOICE
if [[ ${PACKAGE_CHOICE} -eq 1 ]]; then
printf "${YELLOW}[!]${RESET} Going to install just the parrot-meta-all meta-package of ${CYAN}Parrotsec Linux${RESET}...\n"
`which cat` ${PARROT_FOLDER}/Dockerfile.parrotsec.mod2 | `which sed` 's/META_PACKAGE/parrot-meta-all/g' >> ${PARROT_FOLDER}/Dockerfile
elif [[ ${PACKAGE_CHOICE} -eq 2 ]]; then
printf "${YELLOW}[!]${RESET} Going to install just the tools meta-package of ${CYAN}Parrotsec Linux${RESET}...\n"
`which cat` ${PARROT_FOLDER}/Dockerfile.parrotsec.mod2 | `which sed` 's/META_PACKAGE/parrot-tools/g' >> ${PARROT_FOLDER}/Dockerfile
elif [[ ${PACKAGE_CHOICE} -eq 3 ]]; then
printf "${YELLOW}[!]${RESET} Going to install just the mini tools meta-package of ${CYAN}Parrotsec Linux${RESET}...\n"
`which cat` ${PARROT_FOLDER}/Dockerfile.parrotsec.mod2 | `which sed` 's/META_PACKAGE/parrot-tools-common/g' >> ${PARROT_FOLDER}/Dockerfile
elif [[ ${PACKAGE_CHOICE} -eq 4 ]]; then
printf "${YELLOW}[!]${RESET} Going to install just the pico tools meta-package of ${CYAN}Parrotsec Linux${RESET}...\n"
`which cat` ${PARROT_FOLDER}/Dockerfile.parrotsec.mod2 | `which sed` 's/META_PACKAGE/parrot-pico/g' >> ${PARROT_FOLDER}/Dockerfile
# MORE OPTIONS TO COME SOON...
else
printf "${RED}[-]${RESET} Choice doesn't exist, try again.\n"
exit 1
fi
# Choose the name of the parrot container
printf "${BLUE}[*]${RESET} How would you like to name the container image ?: "
read CI_NAME
if [[ ${CI_NAME} == "" ]]; then
printf "${RED}[-]${RESET} Container image name can't be empty !\n"
exit 1
else
# Install the Parrotsec Linux container from the file 'Dockerfile'
`which sudo` `which docker` build -t ${CI_NAME} ${PARROT_FOLDER}/.
fi
sleep 1
printf "\n${BLUE}[*]${RESET} Do you want to start the container ? [Y/n]: "
read START_CHOICE
if [[ ( ${START_CHOICE} = "") || ( ${START_CHOICE} = "y" ) || ( ${START_CHOICE} = "Y" ) || ( ${START_CHOICE} = "Yes" ) || ( ${START_CHOICE} = "yes" ) ]]; then
printf "${BLUE}[*]${RESET} Would you like to add any shared directories ? [Y/n]: "
read SHARED_DIRS_CHOICE
if [[ ( ${SHARED_DIRS_CHOICE} = "") || ( ${SHARED_DIRS_CHOICE} = "y" ) || ( ${SHARED_DIRS_CHOICE} = "Y" ) || ( ${SHARED_DIRS_CHOICE} = "Yes" ) || ( ${SHARED_DIRS_CHOICE} = "yes" ) ]]; then
printf "${YELLOW}What directories would you like to share ?${RESET}\n"
printf "Example: /home/user1/Desktop:/shared\n"
printf "Input: "
read SHARED_DIRS
if [[ ${SHARED_DIRS} == "" ]]; then
printf "${YELLOW}[!]${RESET} No shared directories chosen !\n"
else
DIRS_TO_SHARE="-v ${SHARED_DIRS}"
fi
elif [[ ( ${SHARED_DIRS_CHOICE} = "n" ) || ( ${SHARED_DIRS_CHOICE} = 'N' ) || ( ${SHARED_DIRS_CHOICE} = "no" ) || ( ${SHARED_DIRS_CHOICE} = "No" ) ]]; then
printf "${YELLOW}[!]${RESET} No shared directories will be added !\n"
fi
printf "${BLUE}[*]${RESET} What would you like to name your container ?: "
read CONTAINER_NAME
if [[ ${CONTAINER_NAME} == "" ]]; then
printf "${RED}[-]${RESET} Container name can't be empty !\n"
printf "You will have to start the container manually or\n"
printf "run the script again with the same choices.\n"
exit 1
else
`which sudo` `which docker` run -t -d ${DIRS_TO_SHARE} \
--name ${CONTAINER_NAME} \
-p 127.0.0.1:2224:22/tcp \
${CI_NAME}
printf "${GREEN}[+]${RESET} ${CYAN}Parrotsec Linux${RESET} container has been started. You can SSH on port 2224 localhost.\n"
del_mod2files
exit 0
fi
elif [[ ( ${START_CHOICE} = "n" ) || ( ${START_CHOICE} = 'N' ) || ( ${START_CHOICE} = "no" ) || ( ${START_CHOICE} = "No" ) ]]; then
printf "${YELLOW}[!]${RESET} All should be good now, hopefully. Start the ${CYAN}Parrotsec Linux${RESET} container manually.\n"
del_mod2files
exit 0
else
printf "${RED}[-]${RESET} Invalid choice !\n"
exit 1
fi
}
#########################################
# Start building Blackarch container ####
#########################################
function build_blackarch {
printf "${GREEN}[+]${RESET} Starting ${RED}Blackarch${RESET} Linux Docker build !\n"
sleep 1
printf "${YELLOW}[!]${RESET} SSH key is needed to access the container !\n"
printf "${BLUE}[*]${RESET} Do you want to generate an SSH key ? [Y/n]: "
read SSHGEN_CHOICE
if [[ ( ${SSHGEN_CHOICE} = "" ) || ( ${SSHGEN_CHOICE} = "y" ) || ( ${SSHGEN_CHOICE} = "Y" ) || ( ${SSHGEN_CHOICE} = "Yes" ) || ( ${SSHGEN_CHOICE} = "yes" ) ]]; then
printf "${BLUE}[*]${RESET} What to name the SSH key ? "
read SSHF_NAME
if [[ ${SSHF_NAME} == "" ]]; then
printf "${RED}[-]${RESET} SSH key name can't be empty !\n"
exit 1
else
`which ssh-keygen` -f ${BLACKARCH_FOLDER}/${SSHF_NAME}
# Place the public key into "Dockerfile" for Blackarch container
`which cat` ${BLACKARCH_FOLDER}/Dockerfile.barch.mod | `which sed` "s|SSH_PUBKEY|$(cat ${BLACKARCH_FOLDER}/${SSHF_NAME}.pub)|g" > ${BLACKARCH_FOLDER}/Dockerfile.barch.mod2
fi
elif [[ ( ${SSHGEN_CHOICE} = "n" ) || ( ${SSHGEN_CHOICE} = 'N' ) || ( ${SSHGEN_CHOICE} = "no" ) || ( ${SSHGEN_CHOICE} = "No" ) ]]; then
printf "\n
${YELLOW}[!]${RESET} NOTE:
You will have to generate your SSH key and
add it to the ${RED}Blackarch${RESET} Dockerfile to enable SSH and GUI
to the Kali docker container. Then rerun docker build command
manually. Otherwise, you will have to use an alternative method.
Press enter key to continue\n
"
read
else
printf "${RED}[-]${RESET} Invalid choice !\n"
exit 1
fi
sleep 1
printf "\n${BLUE}[*]${RESET} Which package of ${RED}Blackarch${RESET} tools would you like to install ?\n
1. blackarch-core ${CYAN}(Takes up to ~1.67GB)${RESET}\n
Enter choice as number. i.e 1\n
Choice: "
read PACKAGE_CHOICE
if [[ ${PACKAGE_CHOICE} -eq 1 ]]; then
printf "${YELLOW}[!]${RESET} Going to install just the core package of ${RED}Blackarch${RESET}...\n"
`which cat` ${BLACKARCH_FOLDER}/Dockerfile.barch.mod2 | `which sed` 's/META_PACKAGE//g' >> ${BLACKARCH_FOLDER}/Dockerfile
else
printf "${RED}[-]${RESET} Choice doesn't exist, try again.\n"
exit 1
fi
# Check if vncpasswd exists on system
# Needed for Xvnc and passwd file generation for Blackarch
printf "${YELLOW}[!]${RESET} Checking if 'vncpasswd' exists !\n"
sleep 0.5
if [[ -z ${VNCPASSWD} ]]; then
printf "${RED}[-]${RESET} Couldn't find 'vncpasswd' !\n"
sleep 0.5
else
printf "${GREEN}[+]${RESET} Found 'vncpasswd' !\n"
printf "${BLUE}[*]${RESET} Do you want to generate a VNC passwd file ? [Y/n]: "
read VNC_CHOICE
if [[ ( ${VNC_CHOICE} = "") || ( ${VNC_CHOICE} = "y" ) || ( ${VNC_CHOICE} = "Y" ) || ( ${VNC_CHOICE} = "Yes" ) || ( ${VNC_CHOICE} = "yes" ) ]]; then
`which vncpasswd`
`which cp` ~/.vnc/passwd ${BLACKARCH_FOLDER}
printf "${GREEN}[+]${RESET} VNC passwd file generated !\n"
printf "${GREEN}[+]${RESET} VNC passwd file will be added to the ${RED}Blackarch${RESET} container !\n"
`echo "ADD 'passwd' '/root/.vnc/passwd'" >> ${BLACKARCH_FOLDER}/Dockerfile`
elif [[ ( ${VNC_CHOICE} = "n" ) || ( ${VNC_CHOICE} = 'N' ) || ( ${VNC_CHOICE} = "no" ) || ( ${VNC_CHOICE} = "No" ) ]]; then
printf "${YELLOW}[!]${RESET} VNC passwd file will not be generated !\n"
else
printf "${RED}[-]${RESET} Invalid choice !\n"
exit 1
fi
fi
# Choose the name of the Blackarch container
printf "${BLUE}[*]${RESET} How would you like to name the container image ?: "
read CI_NAME
if [[ ${CI_NAME} == "" ]]; then
printf "${RED}[-]${RESET} Container image name can't be empty !\n"
exit 1
else
# Install the kali container from the file 'Dockerfile'
`which sudo` `which docker` build -t ${CI_NAME} ${BLACKARCH_FOLDER}/.
fi
sleep 1
printf "\n${BLUE}[*]${RESET} Do you want to start the container ? [Y/n]: "
read START_CHOICE
if [[ ( ${START_CHOICE} = "") || ( ${START_CHOICE} = "y" ) || ( ${START_CHOICE} = "Y" ) || ( ${START_CHOICE} = "Yes" ) || ( ${START_CHOICE} = "yes" ) ]]; then
printf "${BLUE}[*]${RESET} Would you like to add any shared directories ? [Y/n]: "
read SHARED_DIRS_CHOICE
if [[ ( ${SHARED_DIRS_CHOICE} = "") || ( ${SHARED_DIRS_CHOICE} = "y" ) || ( ${SHARED_DIRS_CHOICE} = "Y" ) || ( ${SHARED_DIRS_CHOICE} = "Yes" ) || ( ${SHARED_DIRS_CHOICE} = "yes" ) ]]; then
printf "${YELLOW}What directories would you like to share ?${RESET}\n"
printf "Example: /home/user1/Desktop:/shared\n"
printf "Input: "
read SHARED_DIRS
if [[ ${SHARED_DIRS} == "" ]]; then
printf "${YELLOW}[!]${RESET} No shared directories chosen !\n"
else
DIRS_TO_SHARE="-v ${SHARED_DIRS}"
fi
elif [[ ( ${SHARED_DIRS_CHOICE} = "n" ) || ( ${SHARED_DIRS_CHOICE} = 'N' ) || ( ${SHARED_DIRS_CHOICE} = "no" ) || ( ${SHARED_DIRS_CHOICE} = "No" ) ]]; then
printf "${YELLOW}[!]${RESET} No shared directories will be added !\n"
fi
printf "${BLUE}[*]${RESET} What would you like to name your container ?: "
read CONTAINER_NAME
if [[ ${CONTAINER_NAME} == "" ]]; then
printf "${RED}[-]${RESET} Container name can't be empty !\n"
printf "You will have to start the container manually or\n"
printf "run the script again with the same choices.\n"
exit 1
else # For Blackarch listen on 2223 and VNC on 5900
`which sudo` `which docker` run -t -d ${DIRS_TO_SHARE} \
--name ${CONTAINER_NAME} \
-p 127.0.0.1:2223:22/tcp \
-p 127.0.0.1:5900:5900/tcp \
${CI_NAME}
printf "${GREEN}[+]${RESET} ${RED}Blackarch${RESET} container has been started. You can SSH on port 2223 localhost.\n"
printf "${GREEN}[+]${RESET} For VNC access, log in to the container over SSH, run 'vncpasswd' then type 'nohup startx &'"
del_mod2files
exit 0
fi
elif [[ ( ${START_CHOICE} = "n" ) || ( ${START_CHOICE} = 'N' ) || ( ${START_CHOICE} = "no" ) || ( ${START_CHOICE} = "No" ) ]]; then
printf "${YELLOW}[!]${RESET} All should be good now, hopefully. Start the ${CYAN}Blackarch${RESET} container manually.\n"
del_mod2files
exit 0
else
printf "${RED}[-]${RESET} Invalid choice !\n"
exit 1
fi
}
#########################################
# Start building Kali Linux container ###
#########################################
function build_kali {
printf "${GREEN}[+]${RESET} Starting ${BLUE}Kali Linux${RESET} Docker build !\n"
sleep 1
printf "${YELLOW}[!]${RESET} SSH key is needed to use the GUI access to ${BLUE}Kali Linux${RESET} due to X2GO requirements.\n"
printf "${BLUE}[*]${RESET} Do you want to generate an SSH key ? [Y/n]: "
read SSHGEN_CHOICE
if [[ ( ${SSHGEN_CHOICE} = "" ) || ( ${SSHGEN_CHOICE} = "y" ) || ( ${SSHGEN_CHOICE} = "Y" ) || ( ${SSHGEN_CHOICE} = "Yes" ) || ( ${SSHGEN_CHOICE} = "yes" ) ]]; then
printf "${BLUE}[*]${RESET} What to name the SSH key ? "
read SSHF_NAME
if [[ ${SSHF_NAME} == "" ]]; then
printf "${RED}[-]${RESET} SSH key name can't be empty !\n"
exit 1
else
`which ssh-keygen` -f ${KALI_FOLDER}/${SSHF_NAME}
# Place the public key into "Dockerfile" for Kali Linux
`which cat` ${KALI_FOLDER}/Dockerfile.kali.mod | `which sed` "s|SSH_PUBKEY|$(cat ${KALI_FOLDER}/${SSHF_NAME}.pub)|g" > ${KALI_FOLDER}/Dockerfile.kali.mod2
fi
elif [[ ( ${SSHGEN_CHOICE} = "n" ) || ( ${SSHGEN_CHOICE} = 'N' ) || ( ${SSHGEN_CHOICE} = "no" ) || ( ${SSHGEN_CHOICE} = "No" ) ]]; then
printf "\n
${YELLOW}[!]${RESET} NOTE:
You will have to generate your SSH key and
add it to the ${BLUE}Kali Linux${RESET} Dockerfile to enable SSH and GUI
to the Kali docker container. Then rerun docker build command
manually. Otherwise, you will have to use an alternative method.
Press enter key to continue\n
"
read
else
printf "${RED}[-]${RESET} Invalid choice !\n"
exit 1
fi
sleep 1
printf "\n${BLUE}[*]${RESET} Which package of ${BLUE}Kali Linux${RESET} tools would you like to install ?\n
1. kali-linux-core ${CYAN}(Takes up to ~2.2Gb)${RESET}
2. kali-linux-default ${CYAN}(Takes up to ~8.5GB)${RESET}
3. kali-linux-large ${CYAN}(Takes up to ~12GB)${RESET}
4. kali-linux-everything ${CYAN}(Takes up to ~19.5GB)${RESET}\n
Enter choice as number. i.e 1\n
Choice: "
read PACKAGE_CHOICE
if [[ ${PACKAGE_CHOICE} -eq 1 ]]; then
printf "${YELLOW}[!]${RESET} Going to install just the core package of ${BLUE}Kali Linux${RESET}...\n"
`which cat` ${KALI_FOLDER}/Dockerfile.kali.mod2 | `which sed` 's/META_PACKAGE/kali-linux-core/g' >> ${KALI_FOLDER}/Dockerfile
elif [[ ${PACKAGE_CHOICE} -eq 2 ]]; then
printf "${YELLOW}[!]${RESET} Going to install 'kali-linux-default'\n"
`which cat` ${KALI_FOLDER}/Dockerfile.kali.mod2 | `which sed` 's/META_PACKAGE/kali-linux-default/g' >> ${KALI_FOLDER}/Dockerfile
elif [[ ${PACKAGE_CHOICE} -eq 3 ]]; then
printf "${YELLOW}[!]${RESET} Going to install 'kali-linux-large'\n"
`which cat` ${KALI_FOLDER}/Dockerfile.kali.mod2 | `which sed` 's/META_PACKAGE/kali-linux-large/g' >> ${KALI_FOLDER}/Dockerfile
elif [[ ${PACKAGE_CHOICE} -eq 4 ]]; then
printf "${YELLOW}[!]${RESET} Going to install 'kali-linux-everything'\n"
`which cat` ${KALI_FOLDER}/Dockerfile.kali.mod2 | `which sed` 's/META_PACKAGE/kali-linux-everything/g' >> ${KALI_FOLDER}/Dockerfile
else
printf "${RED}[-]${RESET} Choice doesn't exist, try again.\n"
exit 1
fi
# Choose the name of the kali container
printf "${BLUE}[*]${RESET} How would you like to name the container image ?: "
read CI_NAME
if [[ ${CI_NAME} == "" ]]; then
printf "${RED}[-]${RESET} Container image name can't be empty !\n"
exit 1
else
# Install the Kali Linux container from the file 'Dockerfile'
`which sudo` `which docker` build -t ${CI_NAME} ${KALI_FOLDER}/.
fi
sleep 1
printf "\n${BLUE}[*]${RESET} Do you want to start the container ? [Y/n]: "
read START_CHOICE
if [[ ( ${START_CHOICE} = "") || ( ${START_CHOICE} = "y" ) || ( ${START_CHOICE} = "Y" ) || ( ${START_CHOICE} = "Yes" ) || ( ${START_CHOICE} = "yes" ) ]]; then
printf "${BLUE}[*]${RESET} Would you like to add any shared directories ? [Y/n]: "
read SHARED_DIRS_CHOICE
if [[ ( ${SHARED_DIRS_CHOICE} = "") || ( ${SHARED_DIRS_CHOICE} = "y" ) || ( ${SHARED_DIRS_CHOICE} = "Y" ) || ( ${SHARED_DIRS_CHOICE} = "Yes" ) || ( ${SHARED_DIRS_CHOICE} = "yes" ) ]]; then
printf "${YELLOW}What directories would you like to share ?${RESET}\n"
printf "Example: /home/user1/Desktop:/shared\n"
printf "Input: "
read SHARED_DIRS
if [[ ${SHARED_DIRS} == "" ]]; then
printf "${YELLOW}[!]${RESET} No shared directories chosen !\n"
else
DIRS_TO_SHARE="-v ${SHARED_DIRS}"
fi
elif [[ ( ${SHARED_DIRS_CHOICE} = "n" ) || ( ${SHARED_DIRS_CHOICE} = 'N' ) || ( ${SHARED_DIRS_CHOICE} = "no" ) || ( ${SHARED_DIRS_CHOICE} = "No" ) ]]; then
printf "${YELLOW}[!]${RESET} No shared directories will be added !\n"
fi
printf "${BLUE}[*]${RESET} What would you like to name your container ?: "
read CONTAINER_NAME
if [[ ${CONTAINER_NAME} == "" ]]; then
printf "${RED}[-]${RESET} Container name can't be empty !\n"
printf "You will have to start the container manually or\n"
printf "run the script again with the same choices.\n"
exit 1
else
`which sudo` `which docker` run -t -d ${DIRS_TO_SHARE} \
--name ${CONTAINER_NAME} \
-p 127.0.0.1:2222:22/tcp \
${CI_NAME}
printf "${GREEN}[+]${RESET} ${BLUE}Kali Linux${RESET} container has been started. You can SSH on port 2222 localhost.\n"
del_mod2files
exit 0
fi
elif [[ ( ${START_CHOICE} = "n" ) || ( ${START_CHOICE} = 'N' ) || ( ${START_CHOICE} = "no" ) || ( ${START_CHOICE} = "No" ) ]]; then
printf "${YELLOW}[!]${RESET} All should be good now, hopefully. Start the ${BLUE}Kali Linux${RESET} container manually.\n"
del_mod2files
exit 0
else
printf "${RED}[-]${RESET} Invalid choice !\n"
exit 1
fi
}
function main {
printf "\n${BLUE}[*]${RESET} Which distribution to build ?\n
1. ${BLUE}Kali Linux${RESET}
2. ${RED}Blackarch${RESET}
3. ${CYAN}Parrotsec${RESET}\n
Enter choice as number. i.e 1\n
Choice: "
read DISTRO_CHOICE
if [[ ${DISTRO_CHOICE} -eq 1 ]]; then
build_kali
elif [[ ${DISTRO_CHOICE} -eq 2 ]]; then
build_blackarch
elif [[ ${DISTRO_CHOICE} -eq 3 ]]; then
build_parrotsec
else
printf "${RED}[-]${RESET} Choice doesn't exist, try again.\n"
exit 1
fi
}
main