-
Notifications
You must be signed in to change notification settings - Fork 0
/
02_kali_tools_kex_installer.ps1
124 lines (97 loc) · 3.94 KB
/
02_kali_tools_kex_installer.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
# 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 "
_/ _/ _/ _/_/_/ _/ _/ _/_/_/ _/_/_/_/_/ _/_/_/
_/ _/ _/ _/ _/ _/ _/ _/ _/
_/ _/ _/ _/ _/_/ _/ _/ _/ _/ _/
_/ _/ _/ _/ _/ _/ _/ _/ _/ _/
_/_/_/_/ _/_/ _/_/_/ _/ _/_/_/ _/ _/_/_/
"
# Function to center text in the console
function Centered-Text {
param (
[string]$Text, # Text to be centered
[string]$Padding = "===" # Padding character
)
# 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
}
Write-Host
Write-Host
Start-Sleep -Seconds 1
# Welcome message
Centered-Text -Text "Kali Linux Tools and Kali-Win-KeX Installer: Script 02"
# Check if Kali Linux is installed
$kaliInstalled = wsl --list --quiet
if ($kaliInstalled -eq "kali-linux") {
Centered-Text -Text "Kali Linux is installed. Running the update and package installation..."
Write-Host "-[*] Approx 2.9GiB of packages needs to be downloaded"
Write-Host "-[*] Approx 11.3GiB disk space will be taken up by installed Kali packages on your system."
Write-Host "-[*] Enter the Kali Linux PASSWORD used earlier in setup process...."
Start-Sleep -Seconds 2
Write-Host
Write-Host
$selection = Read-Host "Install? [(Y)es/(N)o def=N]"
if ($selection -eq 'y' -or $selection -eq 'Y') {
# Run the update and package installation command inside Kali Linux
Centered-Text -Text "Installing the tools...."
$Command = "sudo apt update && sudo apt install kali-linux-default kali-win-kex -y"
wsl -d kali-linux -- bash -c $Command
# Check if the command ran successfully
if ($LASTEXITCODE -eq 0) {
Centered-Text -Text "Kali Linux updated and packages installed successfully."
Write-Host "Please enter Kali Linux PASSWORD again. Need to enable Systemd..."
Start-Sleep -Seconds 1
# Create the /etc/wsl.conf file to enable systemd
$systemdConfig = "[boot]`nsystemd=true"
$createFileCommand = "echo '$systemdConfig' | sudo tee /etc/wsl.conf > /dev/null"
wsl -d kali-linux -- bash -c $createFileCommand
Centered-Text -Text "Systemd enabled in Kali Linux."
Write-Host "© 2024 @adithyasunil04"
exit
} else {
Write-Host
Centered-Text -Text "Failed to update and install packages in Kali Linux."
}
} else {
Centered-Text -Text "Kali Linux Package install Aborted."
}
} else {
Centered-Text -Text "Kali Linux is not installed on WSL. Please install it first."
}