Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import base64, httplib, string, urllib2
- username = "username"
- password = "password"
- domain = "home.domain.com"
- def getIPFromUrl(url):
- return urllib2.urlopen(url).read()
- def createAuthString(username, password):
- authString = base64.encodestring(username + ":" + password)
- authString = string.replace(authString, "\012", "")
- return authString
- def sendRequest(host, authString, updateParams):
- request = httplib.HTTPS(host)
- request.putrequest("GET", updateParams)
- request.putheader("HOST", host)
- request.putheader("USER-AGENT", "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)")
- request.putheader("AUTHORIZATION", "Basic " + authString)
- request.endheaders()
- return request
- def updateIP(ip, username, password, domain):
- host = "www.ovh.com"
- authString = createAuthString(username, password)
- updateParams = "/nic/update?system=dyndns&hostname=" + domain + "&myip=" + ip
- request = sendRequest(host, authString, updateParams)
- errcode, errmsg, headers = request.getreply()
- try:
- response = request.getfile().read()
- except:
- response = "No output from request."
- print "[*]http code = " + `errcode`
- print "[*]http msg = " + errmsg
- print "[*]http response = " + response
- def main():
- ip = getIPFromUrl("https://domain.com/ip.php")
- updateIP(ip, username, password, domain)
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement