-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.ps1
More file actions
executable file
·259 lines (227 loc) · 8.07 KB
/
setup.ps1
File metadata and controls
executable file
·259 lines (227 loc) · 8.07 KB
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
#!/usr/bin/env pwsh
# Kali Linux MCP Server - Windows PowerShell Installation Script
param(
[switch]$SkipConfirmation,
[switch]$Force
)
# Set strict mode
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
# Color output functions
function Write-Success {
param([string]$Message)
Write-Host "✅ $Message" -ForegroundColor Green
}
function Write-Info {
param([string]$Message)
Write-Host "ℹ️ $Message" -ForegroundColor Cyan
}
function Write-Warning {
param([string]$Message)
Write-Host "⚠️ $Message" -ForegroundColor Yellow
}
function Write-Error {
param([string]$Message)
Write-Host "❌ $Message" -ForegroundColor Red
}
function Write-Step {
param([string]$Message)
Write-Host "🔧 $Message" -ForegroundColor Blue
}
# Main installation function
function Install-KaliMCPServer {
Write-Host ""
Write-Host "🐧 Kali Linux MCP Server - Windows Installation" -ForegroundColor Magenta
Write-Host "===============================================" -ForegroundColor Magenta
Write-Host ""
# Check prerequisites
Write-Step "Checking prerequisites..."
# Check Docker Desktop
try {
$dockerVersion = docker --version 2>$null
if ($dockerVersion) {
Write-Success "Docker Desktop is installed: $dockerVersion"
}
}
catch {
Write-Error "Docker Desktop is not installed or not running"
Write-Info "Please install Docker Desktop from: https://www.docker.com/products/docker-desktop"
Write-Info "Make sure Docker Desktop is running and has MCP Toolkit support"
exit 1
}
# Check Docker Desktop is running
try {
docker info | Out-Null
Write-Success "Docker Desktop is running"
}
catch {
Write-Error "Docker Desktop is not running"
Write-Info "Please start Docker Desktop and try again"
exit 1
}
# Check Docker Compose
try {
$composeVersion = docker-compose --version 2>$null
if ($composeVersion) {
Write-Success "Docker Compose is available: $composeVersion"
}
}
catch {
Write-Error "Docker Compose is not available"
Write-Info "Docker Compose should be included with Docker Desktop"
exit 1
}
# Check disk space (at least 20GB free)
try {
$disk = Get-WmiObject -Class Win32_LogicalDisk | Where-Object { $_.DeviceID -eq "C:" }
$freeSpaceGB = [math]::Round($disk.FreeSpace / 1GB, 2)
if ($freeSpaceGB -lt 20) {
Write-Warning "Low disk space: ${freeSpaceGB}GB free (minimum 20GB recommended)"
if (-not $Force) {
$continue = Read-Host "Continue anyway? (y/N)"
if ($continue -notmatch '^[Yy]') {
exit 1
}
}
} else {
Write-Success "Sufficient disk space: ${freeSpaceGB}GB free"
}
}
catch {
Write-Warning "Could not check disk space"
}
Write-Host ""
# Check if we're in the right directory
if (-not (Test-Path "docker-compose.yaml") -or -not (Test-Path "Dockerfile")) {
Write-Error "Please run this script from the kali-mcp-docker-desktop directory"
Write-Info "This directory should contain docker-compose.yaml and Dockerfile"
exit 1
}
if (-not $SkipConfirmation) {
Write-Host ""
Write-Warning "This will:"
Write-Host " • Download Kali Linux Docker image (~1GB)"
Write-Host " • Install kali-linux-everything package (~15GB)"
Write-Host " • Use ~15-20GB of disk space"
Write-Host " • Take 1-2 hours on first run"
Write-Host ""
$continue = Read-Host "Continue with installation? (y/N)"
if ($continue -notmatch '^[Yy]') {
Write-Info "Installation cancelled"
exit 0
}
}
Write-Host ""
# Build Docker images
Write-Step "Building Docker images..."
try {
docker-compose build
Write-Success "Docker images built successfully"
}
catch {
Write-Error "Failed to build Docker images"
Write-Info "Please check the error message above and try again"
exit 1
}
# Start services
Write-Step "Starting Kali MCP server..."
try {
docker-compose up -d
Write-Success "Kali MCP server started"
}
catch {
Write-Error "Failed to start services"
Write-Info "Please check the error message above and try again"
exit 1
}
# Wait for containers to be ready
Write-Step "Waiting for containers to start..."
Start-Sleep -Seconds 10
# Check if containers are running
try {
$containers = docker ps --filter "name=kali" --format "{{.Names}}"
if ($containers -match "kali-mcp-server" -and $containers -match "kali-tools-container") {
Write-Success "All containers are running"
} else {
Write-Warning "Some containers may not be running properly"
Write-Info "Run 'docker-compose ps' to check status"
}
}
catch {
Write-Warning "Could not verify container status"
}
# Create custom catalog
Write-Step "Creating custom catalog in Docker Desktop..."
try {
docker mcp catalog create my-security-tools 2>$null
Write-Success "Custom catalog created"
}
catch {
Write-Info "Catalog may already exist or command not available"
}
# Add server to catalog
Write-Step "Adding Kali server to catalog..."
try {
docker mcp catalog add my-security-tools kali-linux-tools ./kali-catalog.yaml
Write-Success "Kali server added to catalog"
}
catch {
Write-Warning "Could not add server to catalog"
Write-Info "You may need to add it manually in Docker Desktop"
}
# Enable server
Write-Step "Enabling Kali server..."
try {
docker mcp server enable kali-linux-tools
Write-Success "Kali server enabled"
}
catch {
Write-Warning "Could not enable server automatically"
Write-Info "You may need to enable it manually in Docker Desktop"
}
Write-Host ""
Write-Host "🎉 Installation Complete!" -ForegroundColor Green
Write-Host "=========================" -ForegroundColor Green
Write-Host ""
Write-Success "What was installed:"
Write-Host " ✅ Kali MCP server container"
Write-Host " ✅ Kali Linux tools container"
Write-Host " ✅ Custom catalog 'my-security-tools'"
Write-Host " ✅ Server enabled in Docker Desktop"
Write-Host ""
Write-Info "Next Steps:"
Write-Host " 1. Open Docker Desktop"
Write-Host " 2. Go to 'MCP Toolkit' in sidebar"
Write-Host " 3. Look for 'Kali Linux Security Tools' under 'my-security-tools'"
Write-Host " 4. Server should be enabled and ready to use"
Write-Host ""
Write-Warning "Important Notes:"
Write-Host " • First tool installation takes 1-2 hours"
Write-Host " • Requires ~15-20GB disk space total"
Write-Host " • Monitor progress with: docker-compose logs -f"
Write-Host " • Only use on systems you own or have permission to test"
Write-Host ""
Write-Info "Useful Commands:"
Write-Host " • View logs: docker-compose logs -f"
Write-Host " • Check status: docker-compose ps"
Write-Host " • Restart: docker-compose restart"
Write-Host " • Stop: docker-compose down"
Write-Host " • Uninstall: .\uninstall.ps1"
Write-Host ""
Write-Success "Installation completed successfully!"
}
# Check if running with admin rights (optional but recommended)
if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Write-Warning "Not running as Administrator"
Write-Info "Some Docker commands may work better with elevated privileges"
Write-Host ""
}
# Run installation
try {
Install-KaliMCPServer
}
catch {
Write-Error "Installation failed: $($_.Exception.Message)"
Write-Info "Please check the error message above and try again"
exit 1
}