-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.ps1
693 lines (515 loc) · 23.4 KB
/
build.ps1
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
# Creator: Kr0ff
# Print the ascii and warning message #
function Print_Ascii {
[string]$ascii = "
_____ ____ _
| _ |___ ___| \ ___ ___| |_
| __| -_| | | | . | _| '_|
|__| |___|_|_|____/|___|___|_,_|
v0.6"
Write-Output $ascii
[string]$warning_msg = "
This script will install Kali Linux or Blackarch
in Docker and provide GUI access via X2GO or VNC...
More information about the program can be found here:
https://wiki.x2go.org/doku.php
![WARNING]!
You will be asked for your sudo password.
That's so Docker can execute the commands
the script will use.
Press any key to continue"
Write-Output $warning_msg
Pause
}
# Below function obtained from: #
# https://devtipscurator.wordpress.com/2017/02/01/quick-tip-how-to-wait-for-user-keypress-in-powershell/ #
Function Pause ($Message = "") {
<#
.SYNOPSIS
Pause the script
.DESCRIPTION
This function just pauses the script and waits for user input
.PARAMETER Message
What message should be presented upon a pause
.EXAMPLE
EMPTY
.NOTES
EMPTY
#>
# Check if running in PowerShell ISE
If ($psISE) {
# "ReadKey" not supported in PowerShell ISE.
# Show MessageBox UI
$Shell = New-Object -ComObject "WScript.Shell"
$Button = $Shell.Popup("Click OK to continue.", 0, "Hello", 0)
Return
}
$Ignore =
16, # Shift (left or right)
17, # Ctrl (left or right)
18, # Alt (left or right)
20, # Caps lock
91, # Windows key (left)
92, # Windows key (right)
93, # Menu key
144, # Num lock
145, # Scroll lock
166, # Back
167, # Forward
168, # Refresh
169, # Stop
170, # Search
171, # Favorites
172, # Start/Home
173, # Mute
174, # Volume Down
175, # Volume Up
176, # Next Track
177, # Previous Track
178, # Stop Media
179, # Play
180, # Mail
181, # Select Media
182, # Application 1
183 # Application
Write-Host -NoNewline $Message
While ($KeyInfo.VirtualKeyCode -Eq $null -Or $Ignore -Contains $KeyInfo.VirtualKeyCode) {
$KeyInfo = $Host.UI.RawUI.ReadKey("NoEcho, IncludeKeyDown")
}
}
# Check if a program (Docker Desktop) is installed #
function Check_Program_Installed( $programName ) {
<#
.SYNOPSIS
Check if Docker Desktop is installed
.DESCRIPTION
Simple function to check if Docker Desktop is installed on the host machine
.PARAMETER programName
This takes an argument of what program to check for
That's set to Docker Desktop
.EXAMPLE
EMPTY
.NOTES
EMPTY
#>
$docker_installation_check = (Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Where { $_.DisplayName -eq $programName }) -ne $null
if ( $docker_installation_check -eq "True" ) {
Write-Output "[+] Docker is installed on host"
} else {
Write-Output "[-] Docker isn't installed, please install and re-run the script"
Exit(0)
}
return $docker_installation_check;
}
# Delete the generated *.mod2 Dockerfiles #
function del_mod2files {
<#
.SYNOPSIS
Delete used *.mod2 files
.DESCRIPTION
This function simply deletes the *.mod2 generated by the script since they wont be needed anymore
.EXAMPLE
EMPTY
.NOTES
EMPTY
#>
Write-Output "[!] Deleting unnecessary files after build"
Write-Output "[*] Files:"
Write-Output "============================"
Write-Output "Dockerfile.barch.mod2"
Write-Output "Dockerfile.kali.mod2"
Write-Output "Dockerfile.parrotsec.mod2"
Write-Output "============================"
# We don't need the error msg when file isn't found
Remove-Item ".\blackarch\Dockerfile.barch.mod2" 2>$null
Remove-Item ".\kali\Dockerfile.kali.mod2" 2>$null
Remove-Item ".\parrotsec\Dockerfile.parrotsec.mod2" 2>$null
Write-Host "[+] Files should be deleted"
Exit(0)
}
#### 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
###################
function build_parrotsec {
<#
.SYNOPSIS
Parrotsec linux container building function
.DESCRIPTION
This function will build a docker container based on Parrotsec linux and install a meta-package
of the user's choice.
Packages at the moment are as follows:
1. parrot-meta-all (Takes up to TBC)
2. parrot-tools (Takes up to ~6.5Gb)
3. parrot-tools-common (Takes up to TBC)
4. parrot-pico (Takes up to TBC)
.EXAMPLE
EMPTY
.NOTES
EMPTY
#>
Write-Output "[+] Starting Parrotsec Linux Docker build"
Start-Sleep -Seconds 1
Write-Output "[!] SSH key is needed to access the container !"
[string]$SSH_GEN_CHOICE = Read-Host "[?] Do you want to generate an SSH key ? [Y/n]"
if ( $SSH_GEN_CHOICE -eq '' -or $SSH_GEN_CHOICE -eq "Y" -or $SSH_GEN_CHOICE -eq "y" -or $SSH_GEN_CHOICE -eq "Yes" ) {
Write-Output "[+] Generating SSH key for Parrotsec linux container"
Start-Sleep -Seconds 1
[string]$SSH_KEY_NAME = Read-Host "[?] What should be the SSH key name"
if ( $SSH_KEY_NAME -eq '' ) {
Write-Output "[-] SSH key name cannot be empty"
Exit(1)
}
Start-Process "ssh-keygen" -ArgumentList "-f .\parrotsec\$SSH_KEY_NAME" -Wait
$SSH_PUBKEY = Get-Content ".\parrotsec\$SSH_KEY_NAME.pub"
(Get-Content -Path ".\parrotsec\Dockerfile.parrotsec.mod") -replace "SSH_PUBKEY","$SSH_PUBKEY" | Set-Content -Path ".\parrotsec\Dockerfile.parrotsec.mod2"
} elseif ( $SSH_GEN_CHOICE -eq "N" -or $SSH_GEN_CHOICE -eq "n" -or $SSH_GEN_CHOICE -eq "no" -or $SSH_GEN_CHOICE -eq "No" ) {
Write-Output "[!] No SSH key will be generated"
Write-Output "
[!] NOTE:
You will have to generate your SSH key and
add it to the Parrotsec linux Dockerfile to enable SSH and GUI
to the Parrotsec docker container. Then re-run docker build command
manually. Otherwise, you will have to use an alternative method.
Press any key to continue
"
Pause
} else {
Write-Output "[-] Unknown choice"
Exit(0)
}
Start-Sleep -Seconds 1
Write-Output "
[*] Which meta-package of Kali linux would you like to install ?
1. parrot-meta-all (Takes up to TBC)
2. parrot-tools (Takes up to ~6.5Gb)
3. parrot-tools-common (Takes up to TBC)
4. parrot-pico (Takes up to TBC)
Enter choice as number. i.e 1"
[int]$PACKAGE_CHOICE = Read-Host "Choice"
if ( $PACKAGE_CHOICE -eq 1 ) {
Write-Output "[+] Installing the parrot-meta-all meta-package of Parrotsec linux"
(Get-Content -Path ".\parrotsec\Dockerfile.parrotsec.mod2") -replace "META_PACKAGE","parrot-meta-all" | Set-Content -Path ".\parrotsec\Dockerfile"
} elseif ( $PACKAGE_CHOICE -eq 2 ) {
Write-Output "[+] Installing the tools meta-package of Parrotsec linux"
(Get-Content -Path ".\parrotsec\Dockerfile.parrotsec.mod2") -replace "META_PACKAGE","parrot-tools" | Set-Content -Path ".\parrotsec\Dockerfile"
} elseif ( $PACKAGE_CHOICE -eq 3 ) {
Write-Output "[+] Installing the mini tools meta-package of Parrotsec linux"
(Get-Content -Path ".\parrotsec\Dockerfile.parrotsec.mod2") -replace "META_PACKAGE","parrot-tools-common" | Set-Content -Path ".\parrotsec\Dockerfile"
} elseif ( $PACKAGE_CHOICE -eq 4 ) {
Write-Output "[+] Installing the pico tools meta-package of Parrotsec linux"
(Get-Content -Path ".\parrotsec\Dockerfile.parrotsec.mod2") -replace "META_PACKAGE","parrot-pico" | Set-Content -Path ".\parrotsec\Dockerfile"
} else {
Write-Output "[-] Unknown choice"
Exit(0)
}
[string]$CI_NAME = Read-Host "[?] What should be the name of the docker image"
if ( $CI_NAME -eq "" ) {
Write-Output "[!] Container image name cannot be empty"
Exit(0)
} else {
# Start-Process doesn't seem to work properly...
# TODO: Test powershell native options
cmd /c docker build -t $CI_NAME .\parrotsec\.
}
Start-Sleep -Seconds 0.5
[string]$STARTC_CHOICE = Read-Host "[?] Do you want to start the container [Y/n]"
if ( $STARTC_CHOICE -eq "" -or $STARTC_CHOICE -eq "Y" -or $STARTC_CHOICE -eq "y" -or $STARTC_CHOICE -eq "Yes" ) {
[string]$SHARED_DIRS_CHOICE = Read-Host "[?] Do you want to share directories [y/N]"
if ( $SHARED_DIRS_CHOICE -eq "Y" -or $SHARED_DIRS_CHOICE -eq "Y" -or $SHARED_DIRS_CHOICE -eq "Yes" ) {
Write-Output "[?] What directories to share with the container"
# User should get a notification from windows about the shared directory
# Has to be a full path including - C:/
Write-Output "Example: C:/Users/superuser/Desktop/secretfolder:/secretfolder"
[string]$SHARED_DIRS = Read-Host "Choice"
} elseif ( $SHARED_DIRS_CHOICE -eq "" -or $SHARED_DIRS_CHOICE -eq "n" -or $SHARED_DIRS_CHOICE -eq "N" -or $SHARED_DIRS_CHOICE -eq "no" -or $SHARED_DIRS_CHOICE -eq "No" ) {
Write-Output "[!] Container will have no shared directories"
} else {
Write-Output "[-] Unknown choice"
Exit(0)
}
[string]$CONTAINER_NAME = Read-Host "[?] What should be the container name"
if ( $CONTAINER_NAME -eq "" ) {
Write-Output "[-] Container name can't be empty !"
Write-Output "You will have to start the container manually or"
Write-Output "run the script again with the same choices."
Exit(0)
} else {
if ( $SHARED_DIRS ){
Start-Process "docker" -ArgumentList "run -t -v $SHARED_DIRS -d --name $CONTAINER_NAME -p 127.0.0.1:2224:22/tcp $CI_NAME" -Wait
} else {
Start-Process "docker" -ArgumentList "run -t -d --name $CONTAINER_NAME -p 127.0.0.1:2224:22/tcp $CI_NAME" -Wait
}
Write-Output "[+] Parrotsec linux container has been started. You can SSH on port 2222 localhost."
del_mod2files
Exit(0)
}
} elseif ( $STARTC_CHOICE -eq "n" -or $STARTC_CHOICE -eq "N" -or $STARTC_CHOICE -eq "no" -or $STARTC_CHOICE -eq "No" ) {
Write-Output "[+] Parrotsec linux container should be ready now"
del_mod2files
Exit(0)
} else {
Write-Output "[-] Unknown choice"
Exit(0)
}
}
function build_blackarch {
<#
.SYNOPSIS
Blackarch container building function
.DESCRIPTION
This function will build a docker container based on Blackarch linux and install the basic core meta-package
.EXAMPLE
EMPTY
.NOTES
EMPTY
#>
Write-Output "[+] Starting Blackarch Linux Docker build"
Start-Sleep -Seconds 1
Write-Output "[!] SSH key is needed to access the container !"
[string]$SSH_GEN_CHOICE = Read-Host "[?] Do you want to generate an SSH key ? [Y/n]"
if ( $SSH_GEN_CHOICE -eq '' -or $SSH_GEN_CHOICE -eq "Y" -or $SSH_GEN_CHOICE -eq "y" -or $SSH_GEN_CHOICE -eq "Yes" ) {
Write-Output "[+] Generating SSH key for Blackarch container"
Start-Sleep -Seconds 1
[string]$SSH_KEY_NAME = Read-Host "[?] What should be the SSH key name"
if ( $SSH_KEY_NAME -eq '' ) {
Write-Output "[-] SSH key name cannot be empty"
Exit(1)
}
Start-Process "ssh-keygen" -ArgumentList "-f .\blackarch\$SSH_KEY_NAME" -Wait
$SSH_PUBKEY = Get-Content ".\blackarch\$SSH_KEY_NAME.pub"
(Get-Content -Path ".\blackarch\Dockerfile.barch.mod") -replace "SSH_PUBKEY","$SSH_PUBKEY" | Set-Content -Path ".\blackarch\Dockerfile.barch.mod2"
} elseif ( $SSH_GEN_CHOICE -eq "N" -or $SSH_GEN_CHOICE -eq "n" -or $SSH_GEN_CHOICE -eq "no" -or $SSH_GEN_CHOICE -eq "No" ) {
Write-Output "[!] No SSH key will be generated"
Write-Output "
[!] NOTE:
You will have to generate your SSH key and
add it to the Blackarch Dockerfile to enable SSH and GUI
to the Blackarch docker container. Then rerun docker build command
manually. Otherwise, you will have to use an alternative method.
Press any key to continue
"
Pause
} else {
Write-Output "[-] Unknown choice"
Exit(0)
}
Start-Sleep -Seconds 1
Write-Output "
[*] Which package of Blackarch tools would you like to install ?
1. blackarch-core (Takes up to ~1.67GB)
Enter choice as number. i.e 1"
[int]$PACKAGE_CHOICE = Read-Host "Choice"
if ( $PACKAGE_CHOICE -eq 1 ) {
Write-Output "[+] Installing the core of Blackarch"
(Get-Content -Path ".\blackarch\Dockerfile.barch.mod2") -replace "META_PACKAGE","" | Set-Content -Path ".\blackarch\Dockerfile"
} else {
Write-Output "[-] Unknown choice"
Exit(0)
}
[string]$CI_NAME = Read-Host "[?] What should be the name of the docker image"
if ( $CI_NAME -eq "" ) {
Write-Output "[!] Container image name cannot be empty"
Exit(0)
} else {
# Start-Process doesn't seem to work properly...
# TODO: Test powershell native options
cmd /c docker build -t $CI_NAME .\blackarch\.
}
Start-Sleep -Seconds 0.5
[string]$STARTC_CHOICE = Read-Host "[?] Do you want to start the container [Y/n]"
if ( $STARTC_CHOICE -eq "" -or $STARTC_CHOICE -eq "Y" -or $STARTC_CHOICE -eq "y" -or $STARTC_CHOICE -eq "Yes" ) {
[string]$SHARED_DIRS_CHOICE = Read-Host "[?] Do you want to share directories [y/N]"
if ( $SHARED_DIRS_CHOICE -eq "Y" -or $SHARED_DIRS_CHOICE -eq "Y" -or $SHARED_DIRS_CHOICE -eq "Yes" ) {
Write-Output "[?] What directories to share with the container"
# Has to be a full path including - C:/
# User should get a notification from windows about the shared directory
Write-Output "Example: C:/Users/superuser/Desktop/secretfolder:/secretfolder"
[string]$SHARED_DIRS = Read-Host "Choice"
} elseif ( $SHARED_DIRS_CHOICE -eq "" -or $SHARED_DIRS_CHOICE -eq "n" -or $SHARED_DIRS_CHOICE -eq "N" -or $SHARED_DIRS_CHOICE -eq "no" -or $SHARED_DIRS_CHOICE -eq "No" ) {
Write-Output "[!] Container will have no shared directories"
} else {
Write-Output "[-] Unknown choice"
Exit(0)
}
[string]$CONTAINER_NAME = Read-Host "[?] What should be the container name"
if ( $CONTAINER_NAME -eq "" ) {
Write-Output "[-] Container name can't be empty !"
Write-Output "You will have to start the container manually or"
Write-Output "run the script again with the same choices."
Exit(0)
} else {
if ( $SHARED_DIRS ){
Start-Process "docker" -ArgumentList "run -t -d -v $SHARED_DIRS --name $CONTAINER_NAME -p 127.0.0.1:2223:22/tcp -p 127.0.0.1:5900:5900/tcp $CI_NAME" -Wait
} else {
Start-Process "docker" -ArgumentList "run -t -d --name $CONTAINER_NAME -p 127.0.0.1:2223:22/tcp -p 127.0.0.1:5900:5900/tcp $CI_NAME" -Wait
}
Write-Output "[+] Blackarch container has been started. You can SSH on port 2223 localhost."
Write-Output "[+] For VNC access, log in to the container over SSH, run 'vncpasswd' then type 'nohup startx &'"
del_mod2files
Exit(0)
}
} elseif ( $STARTC_CHOICE -eq "n" -or $STARTC_CHOICE -eq "N" -or $STARTC_CHOICE -eq "no" -or $STARTC_CHOICE -eq "No" ) {
Write-Output "[+] Blackarch container should be ready now"
del_mod2files
Exit(0)
} else {
Write-Output "[-] Unknown choice"
Exit(0)
}
}
function build_kali {
<#
.SYNOPSIS
Kali linux container building function
.DESCRIPTION
This function will build a docker container based on Kali linux and install a meta-package
of the user's choice.
Packages at the moment are as follows:
1. kali-linux-core (Takes up to ~2.2Gb)
2. kali-linux-default (Takes up to ~8.5GB)
3. kali-linux-large (Takes up to ~12GB)
4. kali-linux-everything (Takes up to ~19.5GB)
.EXAMPLE
EMPTY
.NOTES
EMPTY
#>
Write-Output "[+] Starting Kali Linux Docker build"
Start-Sleep -Seconds 1
Write-Output "[!] SSH key is needed to access the container !"
[string]$SSH_GEN_CHOICE = Read-Host "[?] Do you want to generate an SSH key ? [Y/n]"
if ( $SSH_GEN_CHOICE -eq '' -or $SSH_GEN_CHOICE -eq "Y" -or $SSH_GEN_CHOICE -eq "y" -or $SSH_GEN_CHOICE -eq "Yes" ) {
Write-Output "[+] Generating SSH key for Kali linux container"
Start-Sleep -Seconds 1
[string]$SSH_KEY_NAME = Read-Host "[?] What should be the SSH key name"
if ( $SSH_KEY_NAME -eq '' ) {
Write-Output "[-] SSH key name cannot be empty"
Exit(1)
}
Start-Process "ssh-keygen" -ArgumentList "-f .\kali\$SSH_KEY_NAME" -Wait
$SSH_PUBKEY = Get-Content ".\kali\$SSH_KEY_NAME.pub"
(Get-Content -Path ".\kali\Dockerfile.kali.mod") -replace "SSH_PUBKEY","$SSH_PUBKEY" | Set-Content -Path ".\kali\Dockerfile.kali.mod2"
} elseif ( $SSH_GEN_CHOICE -eq "N" -or $SSH_GEN_CHOICE -eq "n" -or $SSH_GEN_CHOICE -eq "no" -or $SSH_GEN_CHOICE -eq "No" ) {
Write-Output "[!] No SSH key will be generated"
Write-Output "
[!] NOTE:
You will have to generate your SSH key and
add it to the Kali linux Dockerfile to enable SSH and GUI
to the Kali docker container. Then re-run docker build command
manually. Otherwise, you will have to use an alternative method.
Press any key to continue
"
Pause
} else {
Write-Output "[-] Unknown choice"
Exit(0)
}
Start-Sleep -Seconds 1
Write-Output "
[*] Which meta-package of Kali linux would you like to install ?
1. kali-linux-core (Takes up to ~2.2Gb)
2. kali-linux-default (Takes up to ~8.5GB)
3. kali-linux-large (Takes up to ~12GB)
4. kali-linux-everything (Takes up to ~19.5GB)
Enter choice as number. i.e 1"
[int]$PACKAGE_CHOICE = Read-Host "Choice"
if ( $PACKAGE_CHOICE -eq 1 ) {
Write-Output "[+] Installing the core of Kali linux"
(Get-Content -Path ".\kali\Dockerfile.kali.mod2") -replace "META_PACKAGE","kali-linux-core" | Set-Content -Path ".\kali\Dockerfile"
} elseif ( $PACKAGE_CHOICE -eq 2 ) {
Write-Output "[+] Installing the default meta-package of Kali linux"
(Get-Content -Path ".\kali\Dockerfile.kali.mod2") -replace "META_PACKAGE","kali-linux-default" | Set-Content -Path ".\kali\Dockerfile"
} elseif ( $PACKAGE_CHOICE -eq 3 ) {
Write-Output "[+] Installing the large meta-package of Kali linux"
(Get-Content -Path ".\kali\Dockerfile.kali.mod2") -replace "META_PACKAGE","kali-linux-large" | Set-Content -Path ".\kali\Dockerfile"
} elseif ( $PACKAGE_CHOICE -eq 4 ) {
Write-Output "[+] Installing everything in Kali linux"
(Get-Content -Path ".\kali\Dockerfile.kali.mod2") -replace "META_PACKAGE","kali-linux-everything" | Set-Content -Path ".\kali\Dockerfile"
} else {
Write-Output "[-] Unknown choice"
Exit(0)
}
[string]$CI_NAME = Read-Host "[?] What should be the name of the docker image"
if ( $CI_NAME -eq "" ) {
Write-Output "[!] Container image name cannot be empty"
Exit(0)
} else {
# Start-Process doesn't seem to work properly...
# TODO: Test powershell native options
cmd /c docker build -t $CI_NAME .\kali\.
}
Start-Sleep -Seconds 0.5
[string]$STARTC_CHOICE = Read-Host "[?] Do you want to start the container [Y/n]"
if ( $STARTC_CHOICE -eq "" -or $STARTC_CHOICE -eq "Y" -or $STARTC_CHOICE -eq "y" -or $STARTC_CHOICE -eq "Yes" ) {
[string]$SHARED_DIRS_CHOICE = Read-Host "[?] Do you want to share directories [y/N]"
if ( $SHARED_DIRS_CHOICE -eq "Y" -or $SHARED_DIRS_CHOICE -eq "Y" -or $SHARED_DIRS_CHOICE -eq "Yes" ) {
Write-Output "[?] What directories to share with the container"
# User should get a notification from windows about the shared directory
# Has to be a full path including - C:/
Write-Output "Example: C:/Users/superuser/Desktop/secretfolder:/secretfolder"
[string]$SHARED_DIRS = Read-Host "Choice"
} elseif ( $SHARED_DIRS_CHOICE -eq "" -or $SHARED_DIRS_CHOICE -eq "n" -or $SHARED_DIRS_CHOICE -eq "N" -or $SHARED_DIRS_CHOICE -eq "no" -or $SHARED_DIRS_CHOICE -eq "No" ) {
Write-Output "[!] Container will have no shared directories"
} else {
Write-Output "[-] Unknown choice"
Exit(0)
}
[string]$CONTAINER_NAME = Read-Host "[?] What should be the container name"
if ( $CONTAINER_NAME -eq "" ) {
Write-Output "[-] Container name can't be empty !"
Write-Output "You will have to start the container manually or"
Write-Output "run the script again with the same choices."
Exit(0)
} else {
if ( $SHARED_DIRS ){
Start-Process "docker" -ArgumentList "run -t -v $SHARED_DIRS -d --name $CONTAINER_NAME -p 127.0.0.1:2222:22/tcp $CI_NAME" -Wait
} else {
Start-Process "docker" -ArgumentList "run -t -d --name $CONTAINER_NAME -p 127.0.0.1:2222:22/tcp $CI_NAME" -Wait
}
Write-Output "[+] Kali linux container has been started. You can SSH on port 2222 localhost."
del_mod2files
Exit(0)
}
} elseif ( $STARTC_CHOICE -eq "n" -or $STARTC_CHOICE -eq "N" -or $STARTC_CHOICE -eq "no" -or $STARTC_CHOICE -eq "No" ) {
Write-Output "[+] Kali linux container should be ready now"
del_mod2files
Exit(0)
} else {
Write-Output "[-] Unknown choice"
Exit(0)
}
}
function main {
<#
.SYNOPSIS
Main function
.DESCRIPTION
This is the main function of the script which will just prompt for which distro
to build as a container
.EXAMPLE
EMPTY
.NOTES
EMPTY
#>
Print_Ascii
Start-Sleep -Seconds 1
Write-Output "[*] Which distribution to build ?"
Write-Output "1. Kali Linux"
Write-Output "2. Blackarch"
Write-Output "Enter choice as number. i.e 1"
[int]$DISTRO_CHOICE = Read-Host "Choice"
if ( $DISTRO_CHOICE -eq 1 ) {
build_kali
} elseif ( $DISTRO_CHOICE -eq 2 ) {
build_blackarch
} elseif ( $DISTRO_CHOICE -eq 3 ) {
build_parrotsec
} else {
Write-Output "[-] Unknown choice"
Exit(0)
}
}
main