Created
September 27, 2015 22:31
-
-
Save shayas/11e3d7cca7602890508a to your computer and use it in GitHub Desktop.
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
''' | |
Date : 7/26/2011 | |
Authoer : Shay Ashkenazi | |
Edimax BR-6524n Broadband Router L2TP Reconnector | |
''' | |
import http.client | |
import time | |
# variables | |
HOST = "192.168.1.1" # router ip | |
USER_NAME = "" # insert username | |
PASS = "" # insert pass | |
MAC_1 = "0016E68574AF" # original mac address | |
MAC_2 = "000000000000" # new mac address | |
GATEWAY = "" # insert gateway | |
#opens connection with the router | |
conn1 = http.client.HTTPConnection(HOST) | |
print("Connected to the router") | |
#defines the router's http site's required headers | |
headers = {"Host": HOST, "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept-Language": "en-us,en;q=0.5", "Accept-Encoding": "gzip, deflate", "Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7", "Connection": "keep-alive", "Referer": "http://" + HOST + "/wanl2tp.asp", "Authorization": "Basic YWRtaW46MTIzNA==", "Content-Type": "application/x-www-form-urlencoded", "Content-Length": "257"} | |
#disconnects from the internet | |
params1 = ("L2TPIpMode=0&HostName=c" + GATEWAY + "&macAddrValue=" + MAC_1 + "&Mac=" + MAC_2 + "&DNSMode=0&L2TPUserName=" + USER_NAME + "%40015&L2TPPassword=" + PASS + "&L2TPGateway=" + GATEWAY + "&L2TPMTU=1392&L2TPConnectType=2&L2TPDisconnect=Disconnect&submit-url=%2Fwanl2tp.asp&wanMode=6") | |
conn1.request("POST", "/goform/formL2TPSetup", params1, headers) | |
res1 = conn1.getresponse() | |
print("Internet disconnection response:\t" + str(res1.status) + str(res1.reason)) | |
#connects to the internet | |
params2 = ("L2TPIpMode=0&HostName=" + GATEWAY + "&macAddrValue=" + MAC_1 + "&Mac=" + MAC_2 + "&DNSMode=0&L2TPUserName=" + USER_NAME + "%40015&L2TPPassword=" + PASS + "&L2TPGateway=" + GATEWAY + "&L2TPMTU=1392&L2TPConnectType=2&L2TPConnect=Connect&submit-url=%2Fwanl2tp.asp&wanMode=6") | |
conn1.request("POST", "/goform/formL2TPSetup", params2, headers) | |
res2 = conn1.getresponse() | |
print("Internet connection response:\t\t" + res2.status + res2.reason) | |
#closes the connection with the router | |
conn1.close() | |
print("Disconnected from the router") | |
print("Down in 5 seconds...") | |
time.sleep(5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment