-
Notifications
You must be signed in to change notification settings - Fork 0
/
01_Kali_installer_wsl2.ps1
114 lines (87 loc) · 3.76 KB
/
01_Kali_installer_wsl2.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
# Copyright © 2024 @adithyasunil04
#Print ASCII
clear
Write-Host " &BGBB#& #B#&
&#GPGGB# BGG#
#GGGGB#BGGG#
#GGGGGGGGGG&
&BGGGGGGGGGGBBB###BB&
BGPPGG5J7!!7Y5PPPY7YB&
#G?~557^:....:^^~?PP5GG&
&B5!:^!^::......~?JYBBBGGG#
#G5~:::::......:5&@@@@@@@&##&
BGP!:::::......!B
#GG?:::::.....:J&
&GGP~::::.....!G
BGG5^::::...~5
#GGG5^:::...!#
#GGGGP~:::...P
&&#BGGGGGG7:::..^#
&&#BGY?!~~!7J5J:::..~&
&######BGPPP555PPJ^::.!&
#5!::~JG&
&GJ7JY55#
&&"
Write-Host "
_/ _/ _/ _/_/_/ _/ _/ _/_/_/ _/_/_/_/_/ _/_/_/
_/ _/ _/ _/ _/ _/ _/ _/ _/
_/ _/ _/ _/ _/_/ _/ _/ _/ _/ _/
_/ _/ _/ _/ _/ _/ _/ _/ _/ _/
_/_/_/_/ _/_/ _/_/_/ _/ _/_/_/ _/ _/_/_/
"
Write-Host
Write-Host
# Function to center text in the console
function Centered-Text {
param (
[string]$Text, # Text to be centered
[string]$Padding = "====" # Padding character, default is "===="
)
# Get the width of the terminal window
$windowWidth = [console]::WindowWidth
# Calculate the total length of the output line
$textLength = $Text.Length
$paddingLength = $Padding.Length
# Calculate the number of padding blocks needed on each side
$availableSpace = $windowWidth - $textLength
$padCount = [math]::Floor($availableSpace / (2 * $paddingLength))
# Build the line with padding and centered text
$line = ($Padding * $padCount) + " " + $Text + " " + ($Padding * $padCount)
# Print the result
Write-Output $line
Write-Host
Write-Host
Write-Host
}
Start-Sleep -Seconds 1
# Welcome message
Centered-Text -Text "Kali Linux WSL2 Installer: Script 01"
# Check if WSL2 is installed and enabled
$wslFeature = Get-WindowsOptionalFeature -Online -FeatureName 'Microsoft-Windows-Subsystem-Linux'
$vmFeature = Get-WindowsOptionalFeature -Online -FeatureName 'VirtualMachinePlatform'
# Check if WSL2 and VirtualMachinePlatform are enabled
if ($wslFeature.State -ne 'Enabled' -or $vmFeature.State -ne 'Enabled') {
Centered-Text -Text "WSL2 or VirtualMachinePlatform not enabled. Please enable it by running ""Script-00"" or maybe a restart."
exit
} else {
Centered-Text -Text "WSL2 and VirtualMachinePlatform are enabled. Proceeding with Kali Linux installation..."
}
Write-Host "The script will now proceed to download Kali Linux Image and will install it on your system."
Write-Host
Write-Host "-[*] Once downloaded, it will ask you to enter a new UNIX username and accompanying password."
Write-Host "-[*] This username and password is used to login to your kali machine on WSL"
Write-Host "-[*] If your not sure what to write as username, put your first/last/pet/crush's name or maybe "lugvitc" ;)"
Write-Host "-[*] Remember the PASSWORD that you are going to use for Kali Linux. You will need it later on to install tools or programs perhaps."
Write-Host
Write-Host "If you see the Kali Linux terminal, it means Kali Base Image Installed Successfully, type 'exit' command and then proceed to run the next install script."
Write-Host
Start-Sleep -Seconds 6
Centered-Text -Text "Installing Kali Linux..."
wsl --install -d kali-linux
# Check the exit code of the previous command
if ($LASTEXITCODE -ne 0) {
Centered-Text -Text "Couldn't install Kali Linux."
} else {
Centered-Text -Text "Kali Linux installation complete."
Write-Host "© 2024 @adithyasunil04"
}