Last active
August 29, 2015 14:14
-
-
Save Palakis/daadcd052095316d5a2d to your computer and use it in GitHub Desktop.
OpenVPN autokill
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
import time | |
import telnetlib | |
if len(sys.argv) < 3: | |
print "Usage : "+__file__+" <host> <port> <client to kill>" | |
exit() | |
host = sys.argv[1] | |
port = sys.argv[2] | |
target = sys.argv[3] | |
try: | |
print "Opening connection to " + host + ":" + port + "..." | |
mgmt = telnetlib.Telnet(host, port, 20) | |
print "Autokill running" | |
while True: | |
mgmt.write("kill " + target + " \r\n") | |
time.sleep(1) | |
except (KeyboardInterrupt, SystemExit): | |
print "\rClosing connection" | |
mgmt.write("exit\r\n") | |
print "Goodbye!" | |
exit() | |
except: | |
raise |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment