Hide My A$$ Pro VPN OSX Script to Stop Networking on Disconnect

The HMA program for OSX is not as advance as the Windows version and lacks several features. My main complaint with the software is that you are unable to bind programs to the VPN connection. Since the whole point of using this service is to be anonymous, this would be defeated if the connection is lost for any reason.

The following script will bind all network activity to the VPN connection. Before using this script there are a few things that will need to be done. Please note that you will need root access to use this script.

  1. Determine your path to Perl:
  2. nDarkness:bin safety$ which perl

    (This may be different on your system.)

  3. Substitute this as the first line of the script below
  4. Delete all firewall rules if they exist:
  5. nDarkness:bin safety$ sudo ipfw f
    Are you sure? [yn] y
    Flushed all rules.
  6. Now create a file with the command below and paste the script below that:
  7. nDarkness:bin safety$ nano vpn_ipfw.pl
    #!/opt/local/bin/perl -w
    use strict;
    my $route = `netstat -r`;
    $route =~ m{(.*?)/32};
    my $address = "$1:443";
    system('ipfw add 01000 allow ip from any to any via tun0');
    system("ipfw add 01100 allow ip from any to $address");
    system('ipfw add 01200 deny ip from any to not me');
    system('ipfw add 65535 allow ip from any to any');
  8. After this is entered, press ctrl+x => y => enter
  9. Use the HMA software to connect to a VPN server and then run our script:
  10. nDarkness:bin safety$ sudo perl vpn_ipfw.pl

Now if we lose our connection to the VPN server all networking activity will completely stop. To reconnect networking again you will need to repeat step 3 above.

Tags: ,

One Response to “Hide My A$$ Pro VPN OSX Script to Stop Networking on Disconnect”

  1. justin July 21, 2011 at 2:39 pm #

    way easier way than this,simply open vuze’s preferences,type thekeyword “bind” and enter the local ip that you are currently connected to with that particular server that particular time of day. example if you connect to hma,and your new ip is 173.345.543.23,you would enter that ip into the local ip address slot and click save. that easy works flawlessly everytime.

Leave a Reply