I found this while looking on the web for a vpn kill switch, can someone who is versed in scripting languages take a peek.
vpn script for a killswitch ;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace InternetKillSwitch
{
public partial class Form1 : Form
{
IPHostEntry host;
string localIP = "?";
bool vpnON = false;
int timerCount = 0;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
button2.Enabled = true;
button1.Enabled = false;
textBox1.Enabled = false;
timer1.Start();
}
private void button2_Click(object sender, EventArgs e)
{
button2.Enabled = false;
button1.Enabled = true;
textBox1.Enabled = true;
}
private void button3_Click(object sender, EventArgs e)
{
foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
{
string value = nic.Name;
Process.Start("cmd.exe", "/c netsh interface set interface \"" + value + "\" ENABLED"); //This should enable the interfaces again but for some reason doesnt work.
}
MessageBox.Show("All network adapters have been re-enabled. InternetKillSwitch is OFF.");
}
private void checkVPN()
{
vpnON = false;
if (textBox1.Text != "")
{
IPHostEntry host;
string localIP = "?";
host = Dns.GetHostEntry(Dns.GetHostName()); //This gets what your current IP Address is
foreach (IPAddress ip in host.AddressList)
{
if (ip.AddressFamily.ToString() == "InterNetwork")
{
localIP = ip.ToString();
if (ip.ToString() == textBox1.Text) //Returns true if the VPN Address typed matches the IP from the system
{
vpnON = true;
timer1.Start(); //Restart the timer since the check was good
}
}
}
if (vpnON == false)
{
//Kill all internet adapters
foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
{
string value = nic.Name;
Process.Start("cmd.exe", "/c netsh interface set interface \"" + value + "\" DISABLED");
}
MessageBox.Show("WARNING: VPN Address was NOT found. All Network Adapters have been disabled!");
timer1.Stop();
button2.Enabled = false;
button1.Enabled = true;
textBox1.Enabled = true;
}
}
}
private void timer1_Tick(object sender, EventArgs e) //This is the function to continuously check for VPN Connectivity, default check is every 5 seconds
{
timerCount = timerCount + 1;
if (timerCount > 5)
{
timer1.Stop();
checkVPN();
timerCount = 0;
}
}
}
}
this is from http://www.codeproject.com/Tips/834749/VPN-Kill-Switch
The Code Project Open License (CPOL
a vpn kill switch script and Windows application
-
- Posts: 19
- Joined: Wed Nov 12, 2014 7:41 pm
Re: a vpn kill switch script and Windows application
@OP
I'm not familiar enough with Windows to tell you if the code is effective or not, but what I can say is that it certainly isn't a scripting language. It's C#, written for the .NET platform. It needs to be compiled before it can run.
I'm not familiar enough with Windows to tell you if the code is effective or not, but what I can say is that it certainly isn't a scripting language. It's C#, written for the .NET platform. It needs to be compiled before it can run.
- marzametal
- Posts: 434
- Joined: Mon Aug 05, 2013 11:39 am
Re: a vpn kill switch script and Windows application
Spotshot put me onto one that he has been using for a while now... depends on your definition of killswitch...
http://vpnetmon.webs.com/
http://vpnetmon.webs.com/
-
- Posts: 19
- Joined: Wed Nov 12, 2014 7:41 pm
Re: a vpn kill switch script and Windows application
Black vpn is trying to sell the idea if yo go with them and have the modified router that you can change your servers remotely from the router. They are pushing dd-wrt firmware , you can buy a router through them or flash routers. I asked cyberghost vpn for a copy of the firmware update and software ( my wife seen a deal for a year for 5 devices premium vpn 23.00 us.) They don't want to give a copy of the special software so I will get a list of all servers, the router setups, Mac,nix,android,ect. I have been looking for a kill switch and dns leak fix as well as a way to combine the ovpn into a. Menu you can change remotely safety.