Commit ad15fdcd by César Galvis

feat: deleted all wireguard code

parent da3132d6
......@@ -32,9 +32,5 @@ Vagrant.configure("2") do |config|
config.vm.provision "shell", path: "src/scripts/ps/ChocolateyInstall.ps1"
## Install Chocolatey packages
config.vm.provision "shell", path: "src/scripts/ps/ChocolateyInstallPackages.ps1"
## Wireguard Install and setup
config.vm.provision "shell", path: "src/scripts/ps/WireguardInstall.ps1"
## Enable traffic forwarding
config.vm.provision "shell", path: "src/scripts/ps/EnableTrafficForwarding.ps1"
end
# === CONFIGURATION ===
# Name of the VPN interface (Fortinet client) and the WireGuard interface
$vpnInterfaceName = "Fortinet" # Change if different
$wgInterfaceName = "WireGuard"
# === HELPER FUNCTION ===
function Enable-ICS {
param (
[string]$SharedInterface,
[string]$TargetInterface
)
$networkListManager = New-Object -ComObject HNetCfg.HNetShare
$connections = $networkListManager.EnumEveryConnection()
foreach ($conn in $connections) {
$props = $networkListManager.NetConnectionProps($conn)
$config = $networkListManager.INetSharingConfigurationForINetConnection($conn)
if ($props.Name -eq $SharedInterface) {
# Enable sharing on the VPN interface
if (-not $config.SharingEnabled) {
Write-Host "→ Enabling ICS on '$SharedInterface'"
$config.EnableSharing(0) # 0 = outbound
}
}
if ($props.Name -eq $TargetInterface) {
# Check if sharing is already enabled on the target interface
if ($config.SharingEnabled) {
Write-Host "ICS is already enabled on '$TargetInterface'"
} else {
Write-Host "ICS does not need to be enabled on '$TargetInterface'"
}
}
}
}
# === VERIFY INTERFACES ===
$netAdapters = Get-NetAdapter
$vpnFound = $netAdapters | Where-Object { $_.InterfaceDescription -like "*$vpnInterfaceName*" }
$wgFound = $netAdapters | Where-Object { $_.InterfaceDescription -like "*$wgInterfaceName*" }
if (-not $vpnFound) {
Write-Host "Could not find VPN interface '$vpnInterfaceName'"
exit 1
}
if (-not $wgFound) {
Write-Host "Could not find WireGuard interface '$wgInterfaceName'"
exit 1
}
# === APPLY ICS ===
Enable-ICS -SharedInterface $vpnFound.Name -TargetInterface $wgFound.Name
Write-Host "ICS enabled: '$vpnInterfaceName' + '$wgInterfaceName'"
......@@ -30,20 +30,4 @@ Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\P
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize" -Name "SystemUsesLightTheme" -Value 0
## Restart explorer.exe
Stop-Process -Name explorer -Force
Start-Process explorer.exe
# Configure FQDN domain
Write-Host "Configure FQDN domain..."
$hostsPath = "$env:SystemRoot\System32\drivers\etc\hosts"
$fqdn = "windows-vpn.local"
$ip = "127.0.0.1"
$entry = "$ip`t$fqdn"
## Check if the entry already exists
$hostsContent = Get-Content $hostsPath
if ($hostsContent -notcontains $entry) {
Add-Content -Path $hostsPath -Value $entry
Write-Host "Added: $entry"
} else {
Write-Host "The entry already exists"
}
\ No newline at end of file
Start-Process explorer.exe
\ No newline at end of file
# Wireguard install
# Define download URL for WireGuard official MSI installer
$wgInstallerUrl = "https://download.wireguard.com/windows-client/wireguard-installer.exe"
$installerPath = "$env:TEMP\wireguard-installer.exe"
# Download the installer
Write-Host "Downloading WireGuard from official site..."
Invoke-WebRequest -Uri $wgInstallerUrl -OutFile $installerPath
# Run the installer silently
Write-Host "Installing WireGuard..."
Start-Process -FilePath $installerPath -ArgumentList "/install /quiet" -Wait
# Wait for the installation to complete
Start-Sleep -Seconds 10
# Set paths
$wgPath = "C:\Program Files\WireGuard"
$configPath = "$wgPath\Configurations"
$serverConfigFile = "$configPath\server.conf"
$outputPath = "C:\vagrant\files\WireGuard"
$clientConfigFile = "$outputPath\client.conf"
# Create configuration and output folders if it doesn't exist
New-Item -ItemType Directory -Force -Path $configPath
New-Item -ItemType Directory -Force -Path $outputPath
# Generate server key pair
$serverPrivateKey = & "$wgPath\wg.exe" genkey
$serverPublicKey = $serverPrivateKey | & "$wgPath\wg.exe" pubkey
# Generate client key pair (you can extract and use this later)
$clientPrivateKey = & "$wgPath\wg.exe" genkey
$clientPublicKey = $clientPrivateKey | & "$wgPath\wg.exe" pubkey
# Save the keys for later (optional)
$keysOutput = @"
{
"Server Private Key": "$serverPrivateKey",
"Server Public Key": "$serverPublicKey",
"Client Private Key": "$clientPrivateKey",
"Client Public Key": "$clientPublicKey"
}
"@
$keysOutput | Out-File "$outputPath\generated-keys.json"
# Create the WireGuard server configuration
@"
[Interface]
PrivateKey = $serverPrivateKey
Address = 10.10.0.1/24
ListenPort = 51820
[Peer]
PublicKey = $clientPublicKey
AllowedIPs = 10.10.0.2/32
"@ | Out-File $serverConfigFile -Encoding ascii
# Create the WireGuard client configuration
@"
[Interface]
PrivateKey = $clientPrivateKey
Address = 10.10.0.2/24
[Peer]
PublicKey = $serverPublicKey
Endpoint = windows-vpn.local:51820
AllowedIPs = 192.168.11.0/24
PersistentKeepalive = 25
"@ | Out-File $clientConfigFile -Encoding ascii
# Install the tunnel as a Windows service
& "$wgPath\wireguard.exe" /installtunnelservice $serverConfigFile
# Optionally open the UDP port in Windows Firewall
New-NetFirewallRule -DisplayName "WireGuard VPN" -Direction Inbound -Action Allow `
-Protocol UDP -LocalPort 51820
# Output server info
Write-Host "WireGuard server has been configured and started."
Write-Host "Keys saved to: $outputPath\generated-keys.json"
Write-Host "Client config saved to: $outputPath\client.conf"
# Add shortcuts
## Get the desktop path for the current user
$desktopPath = [Environment]::GetFolderPath("Desktop")
## PowerShell
### Create the shortcut path
$shortcutPath = Join-Path $desktopPath "WireGuard.lnk"
### Create the WScript.Shell COM object
$WshShell = New-Object -ComObject WScript.Shell
### Create the shortcut
$shortcut = $WshShell.CreateShortcut($shortcutPath)
### Set the target path to PowerShell
$shortcut.TargetPath = "C:\Program Files\WireGuard\wireguard.exe"
### Save the shortcut
$shortcut.Save()
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment