Skip to content

Commit 0131505

Browse files
gunph1lddguido
authored andcommitted
Enhance PS1 script (trailofbits#510)
update docs Update README.md update readme
1 parent e6c8f19 commit 0131505

File tree

3 files changed

+50
-23
lines changed

3 files changed

+50
-23
lines changed

README.md

+5-20
Original file line numberDiff line numberDiff line change
@@ -102,31 +102,16 @@ No version of Android supports IKEv2. Install the [strongSwan VPN Client for And
102102

103103
### Windows
104104

105-
Windows clients have a more complicated setup than most others. Follow the steps below to set one up:
105+
#### Scripted installation
106106

107-
1. Copy the CA certificate (`cacert.pem`), user certificate (`$user.p12`), and the user PowerShell script (`windows_$user.ps1`) to the client computer.
108-
2. Import the CA certificate to the local machine Trusted Root certificate store.
109-
3. Open PowerShell as Administrator. Navigate to your copied files.
110-
4. If you haven't already, you will need to change the Execution Policy to allow unsigned scripts to run.
111-
112-
```powershell
113-
Set-ExecutionPolicy Unrestricted -Scope CurrentUser
107+
Copy your powershell script `windows_{username}.ps1` and p12 certificate `{username}.p12` to the Windows machine and run the following command as Administrator to configure the VPN connection.
114108
```
115-
116-
5. In the same PowerShell window, run the included PowerShell script to import the user certificate, set up a VPN connection, and activate stronger ciphers on it.
117-
6. After you execute the user script, set the Execution Policy back before you close the PowerShell window.
118-
119-
```powershell
120-
Set-ExecutionPolicy Restricted -Scope CurrentUser
109+
powershell -ExecutionPolicy ByPass -File windows_{username}.ps1 Add
121110
```
122111

123-
Your VPN is now installed and ready to use.
112+
#### Manual installation
124113

125-
If you want to perform these steps by hand, you will need to import the user certificate to the Personal certificate store, add an IKEv2 connection in the network settings, then activate stronger ciphers on it via the following PowerShell script:
126-
127-
```powershell
128-
Set-VpnConnectionIPsecConfiguration -ConnectionName "Algo" -AuthenticationTransformConstants GCMAES128 -CipherTransformConstants GCMAES128 -EncryptionMethod AES128 -IntegrityCheckMethod SHA384 -DHGroup ECP256 -PfsGroup ECP256
129-
```
114+
See the [Windows setup instructions](/docs/client-windows.md) for more a more detailed walkthrough.
130115

131116
### Linux Network Manager Clients (e.g., Ubuntu, Debian, or Fedora Desktop)
132117

docs/client-windows.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Windows client manual setup
2+
3+
Windows clients have a more complicated setup than most others. Follow the steps below to set one up:
4+
5+
1. Copy the CA certificate (`cacert.pem`), user certificate (`$user.p12`), and the user PowerShell script (`windows_$user.ps1`) to the client computer.
6+
2. Import the CA certificate to the local machine Trusted Root certificate store.
7+
3. Open PowerShell as Administrator. Navigate to your copied files.
8+
4. If you haven't already, you will need to change the Execution Policy to allow unsigned scripts to run.
9+
10+
```powershell
11+
Set-ExecutionPolicy Unrestricted -Scope CurrentUser
12+
```
13+
14+
5. In the same PowerShell window, run the included PowerShell script to import the user certificate, set up a VPN connection, and activate stronger ciphers on it.
15+
6. After you execute the user script, set the Execution Policy back before you close the PowerShell window.
16+
17+
```powershell
18+
Set-ExecutionPolicy Restricted -Scope CurrentUser
19+
```
20+
21+
Your VPN is now installed and ready to use.
22+
23+
If you want to perform these steps by hand, you will need to import the user certificate to the Personal certificate store, add an IKEv2 connection in the network settings, then activate stronger ciphers on it via the following PowerShell script:
24+
25+
```powershell
26+
Set-VpnConnectionIPsecConfiguration -ConnectionName "Algo" -AuthenticationTransformConstants GCMAES128 -CipherTransformConstants GCMAES128 -EncryptionMethod AES128 -IntegrityCheckMethod SHA384 -DHGroup ECP256 -PfsGroup ECP256
27+
```
+18-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1-
certutil -f -p {{ easyrsa_p12_export_password }} -importpfx .\{{ item }}.p12
2-
Add-VpnConnection -name "Algo VPN {{ IP_subject_alt_name }} IKEv2" -ServerAddress "{{ IP_subject_alt_name }}" -TunnelType IKEv2 -AuthenticationMethod MachineCertificate -EncryptionLevel Required
3-
Set-VpnConnectionIPsecConfiguration -ConnectionName "Algo VPN {{ IP_subject_alt_name }} IKEv2" -AuthenticationTransformConstants GCMAES128 -CipherTransformConstants GCMAES128 -EncryptionMethod AES128 -IntegrityCheckMethod SHA384 -DHGroup ECP256 -PfsGroup ECP256
1+
2+
function AddAlgoVPN {
3+
certutil -f -p {{ easyrsa_p12_export_password }} -importpfx .\{{ item }}.p12
4+
Add-VpnConnection -name "Algo VPN {{ IP_subject_alt_name }} IKEv2" -ServerAddress "{{ IP_subject_alt_name }}" -TunnelType IKEv2 -AuthenticationMethod MachineCertificate -EncryptionLevel Required
5+
Set-VpnConnectionIPsecConfiguration -ConnectionName "Algo VPN {{ IP_subject_alt_name }} IKEv2" -AuthenticationTransformConstants GCMAES128 -CipherTransformConstants GCMAES128 -EncryptionMethod AES128 -IntegrityCheckMethod SHA384 -DHGroup ECP256 -PfsGroup ECP256 -Force
6+
}
7+
8+
function RemoveAlgoVPN {
9+
Get-ChildItem cert:LocalMachine/Root | Where-Object { $_.Subject -match '^CN={{ IP_subject_alt_name }}$' -and $_.Issuer -match '^CN={{ IP_subject_alt_name }}$' } | Remove-Item
10+
Get-ChildItem cert:LocalMachine/My | Where-Object { $_.Subject -match '^CN={{ item }}$' -and $_.Issuer -match '^CN={{ IP_subject_alt_name }}$' } | Remove-Item
11+
Remove-VpnConnection -name "Algo VPN {{ IP_subject_alt_name }} IKEv2" -Force
12+
}
13+
14+
switch ($args[0]) {
15+
"Add" { AddAlgoVPN }
16+
"Remove" { RemoveAlgoVPN }
17+
default { Write-Host Usage: $MyInvocation.MyCommand.Name "(Add|Remove)" }
18+
}

0 commit comments

Comments
 (0)