Neue SLA bei kostenlosen Dyndns Accounts mittels AutoLoginScript umgehen

Status
Für weitere Antworten geschlossen.

3x3cut0r

Benutzer
Mitglied seit
21. Mai 2011
Beiträge
507
Punkte für Reaktionen
15
Punkte
44
So ...
habs mir heute mal kurz angeschaut. Also erstmal war es nur ne Kleinigkeit die NoIP.com an Ihrer Seite geändert hat.
So hat das Script zwar "Login failed" ausgegeben, angemeldet hat es sich trotzdem richtig. Die Prüfung in der Funktion war nur falsch.

Zusätzlich hat Python2 in der DSM auch seinen Pfad geändert. Kam wohl mit DSM 6?!

Hier mal das neue angepasste script:
Rich (BBCode):
#!/bin/python2

import urllib
import urllib2
import cookielib
import getopt
import sys
import logging

def getHiddenRandHTMLResponse(response):
    target = "<input type=\"hidden\" name=\"_token\" value=\""
    targetresponse = "<div id=\"sign-up-wrap\""
    parsedres = response[response.find(targetresponse):len(response)]
    return parsedres[parsedres.find(target)+len(target):parsedres.find(target)+len(target)+40]

def checkLogin(response):
    target = "<title>  My No-IP"
    if response.find(target) == -1:
        return False
    return True

def usage():
    print "usage: ./noipAutoLogin [options]"
    print ""
    print "options:"
    print "-h, --help 	 show this help message and exit"
    print "-u, --username   set your NoIP login_username"
    print "-p, --password   set your NoIP login_password"
    print ""
    print "example:"
    print "./noipAutoLogin -u username -p password"

class HTMLSession:
    cj = None
    opener = None
    txHeaders = None
    
    def __init__(self, txHeaders):
        #The CookieJar will hold any cookies necessary throughout the login process.
        self.cj = cookielib.MozillaCookieJar()
        self.txHeaders = txHeaders
        self.opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cj))
        urllib2.install_opener(self.opener)

    def setHeaders(self, txheaders):
        self.txHeaders = txHeaders

    def getHeaders(self):
        return self.txHeaders

    def openURI(self, uri, txdata):
        try:
            req = urllib2.Request(uri, txdata, self.txHeaders)
            # create a request object

            handle = urllib2.urlopen(req)
            # and open it to return a handle on the url

        except IOError as e:
            print 'we failed to open "%s".' % uri

            if hasattr(e, 'code'):
                print 'We failed with error code - %s.' % e.code
                logging.error('We failed with error code - %s.' % e.code)
            elif hasattr(e, 'reason'):
                print "The error object has the following 'reason' attribute :"
                print e.reason
                print "This usually means the server doesn't exist,'"
                print "is down, or we don't have an internet connection."
                return None
        else:
            return handle.read()

def main(argv):
    username = "beispiel@gmail.com"
    password = "mein_passwort"
    logfile = "/volume1/logs/noipAutoLogin.log"
    hiddenval = ""
    theurl = "https://www.noip.com/login"
    thelogouturl = "https://www.noip.com/logout"
    txdata = None
    txheaders =  {'User-agent' : 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'}
    # fake a user agent, some websites (like google) don't like automated exploration
    logging.basicConfig(filename=logfile,level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s', datefmt='%Y/%m/%d %H:%M:%S')

    try:
        opts, args = getopt.getopt(argv, "hu:p:", ["help", "username=","password="])
    except getopt.GetoptError:
        usage()
        logging.warning('Manual login with incorrect parameters')
        exit(2)
    for opt, arg in opts:
        if opt in ("-h", "--help"):
            usage()
            exit(2)
        elif opt in ("-u", "--username"):
            username = arg
        elif opt in ("-p", "--password"):
            password = arg

    myhtmlsession = HTMLSession(txheaders)
    response = myhtmlsession.openURI(theurl, None)
    if response == None:
        sys.exit(0)

    hiddenval = getHiddenRandHTMLResponse(response)
    txdata = urllib.urlencode({'username':username, 'password':password, 'Login':"1", 'submit_login_page':"1", '_token':hiddenval, 'Login': "Sign In"})
    response = myhtmlsession.openURI(theurl, txdata)
    if response == None:
        sys.exit(0)
    
    #we should sleep here for about 10 seconds.
    if checkLogin(response):
        print 'We have succesfully logged into NoIP.'
        logging.info('We have succesfully logged into NoIP.')
    else:
        print 'Login failed'
        logging.info('Login failed')

    response = myhtmlsession.openURI(thelogouturl, None)
    if response == None:
        sys.exit(0)

if __name__ == "__main__":
    main(sys.argv[1:])

Gruß

PS: es kann nicht schaden euer logfile mal zu löschen. bei mir hatte er probleme es zu überschreiben.
 
Zuletzt bearbeitet:

mcmax

Benutzer
Mitglied seit
27. Sep 2014
Beiträge
2
Punkte für Reaktionen
0
Punkte
0
Top, vielen Dank, läuft. Da hätte ich ja auch mal selber drauf kommen können, hab aber erst jetzt verstanden wie das script checkt, daß es sich eingeloggt hat.
Nochmals vielen Dank!
 

fly-tox

Benutzer
Mitglied seit
26. Jun 2016
Beiträge
3
Punkte für Reaktionen
0
Punkte
0
Auch von mir ein großen Dank! Funktioniert wieder wie es sein soll.
 

3x3cut0r

Benutzer
Mitglied seit
21. Mai 2011
Beiträge
507
Punkte für Reaktionen
15
Punkte
44
Ich hab mittlerweile festgestellt, dass das Skript nun so wie es ist endgültig nutzlos geworden ist.
Ein einloggen bei noip.com reicht nicht mehr aus um seine eingetragenen Hosts am Leben zu halten.
Man muss jetzt diesen Confirm Button drücken.
Muss ich mir die Tage mal genauer anschauen ... :(
 

3x3cut0r

Benutzer
Mitglied seit
21. Mai 2011
Beiträge
507
Punkte für Reaktionen
15
Punkte
44
Kleines Status-Update:
Hab jetzt erstmal das Skript für python3 umgeschrieben. Wer möchte kann es gerne mal ausprobieren:

Rich (BBCode):
#!/bin/python3

import urllib
import urllib.request
import http.cookiejar
import getopt
import sys
import logging

def getHiddenRandHTMLResponse(response):
    target = "<input type=\"hidden\" name=\"_token\" value=\""
    targetresponse = "<div id=\"sign-up-wrap\""
    response = str(response)
    parsedres = response[response.find(targetresponse):len(response)]
    return parsedres[parsedres.find(target)+len(target):parsedres.find(target)+len(target)+40]

def checkLogin(response):
    target = "<title>  My No-IP"
    response = str(response)
    if response.find(target) == -1:
        return False
    return True

def usage():
    print("usage: ./noipAutoLogin [options]")
    print("")
    print("options:")
    print("-h, --help 	 show this help message and exit")
    print("-u, --username   set your NoIP login_username")
    print("-p, --password   set your NoIP login_password")
    print("")
    print("example:")
    print("./noipAutoLogin -u username -p password")

class HTMLSession:
    cj = None
    opener = None
    txHeaders = None
    
    def __init__(self, txHeaders):
        self.cj = http.cookiejar.MozillaCookieJar()
        self.txHeaders = txHeaders
        self.opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(self.cj))
        urllib.request.install_opener(self.opener)

    def setHeaders(self, txheaders):
        self.txHeaders = txHeaders

    def getHeaders(self):
        return self.txHeaders

    def openURI(self, uri, txdata):
        try:
            req = urllib.request.Request(uri, txdata, self.txHeaders)
            handle = urllib.request.urlopen(req)
            
        except IOError as e:
            print('we failed to open "%s".' % uri)
            if hasattr(e, 'code'):
                print('We failed with error code - %s.' % e.code)
                logging.error('We failed with error code - %s.' % e.code)
            elif hasattr(e, 'reason'):
                print("The error object has the following 'reason' attribute :")
                print(e.reason)
                print("This usually means the server doesn't exist,'")
                print("is down, or we don't have an internet connection.")
                return None
        else:
            return handle.read()

def main(argv):
    username = "meine-NoIP-eMail@beispiel.de"
    password = "mein-NoIP-Login-Passwort"
    logfile = "/var/logs/noipAutoLogin.py3.log"
    hiddenval = ""
    theurl = "https://www.noip.com/login"
    thehostconfirmurl = "https://my.noip.com/#!/dynamic-dns"
    thelogouturl = "https://www.noip.com/logout"
    txdata = None
    txheaders =  {'User-agent' : 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'}
    logging.basicConfig(filename=logfile,level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s', datefmt='%Y/%m/%d %H:%M:%S')

    try:
        opts, args = getopt.getopt(argv, "hu:p:", ["help", "username=","password="])
    except getopt.GetoptError:
        usage()
        logging.warning('Manual login with incorrect parameters')
        exit(2)
    for opt, arg in opts:
        if opt in ("-h", "--help"):
            usage()
            exit(2)
        elif opt in ("-u", "--username"):
            username = arg
        elif opt in ("-p", "--password"):
            password = arg

    myhtmlsession = HTMLSession(txheaders)
    response = myhtmlsession.openURI(theurl, None)
    if response == None:
        sys.exit(0)

    hiddenval = getHiddenRandHTMLResponse(response)
    txdata = urllib.parse.urlencode({'username':username, 'password':password, 'Login':"1", 'submit_login_page':"1", '_token':hiddenval, 'Login': "Sign In"})
    txdata = txdata.encode("utf8")
    response = myhtmlsession.openURI(theurl, txdata)
    if response == None:
        sys.exit(0)
    
    if checkLogin(response):
        print('We have succesfully logged into NoIP.')
        logging.info('We have succesfully logged into NoIP.')
    else:
        print('Login failed')
        logging.info('Login failed')

    response = myhtmlsession.openURI(thelogouturl, None)
    if response == None:
        sys.exit(0)

if __name__ == "__main__":
    main(sys.argv[1:])

Wegen dem Confirm bin ich noch am schauen ...
 
Status
Für weitere Antworten geschlossen.
 

Kaffeautomat

Wenn du das Forum hilfreich findest oder uns unterstützen möchtest, dann gib uns doch einfach einen Kaffee aus.

Als Dankeschön schalten wir deinen Account werbefrei.

:coffee:

Hier gehts zum Kaffeeautomat 

 
 
  AdBlocker gefunden!

Du bist nicht hier, um Support für Adblocker zu erhalten. Dein Adblocker funktioniert bereits ;-)

Klar machen Adblocker einen guten Job, aber sie blockieren auch nützliche Funktionen.

Das Forum wird mit hohem technischen, zeitlichen und finanziellen Aufwand kostenfrei zur Verfügung gestellt. Wir zeigen keine offensive Werbung und bemühen uns um eine dezente Integration.

Bitte unterstütze dieses Forum, in dem du deinen Adblocker für diese Seite deaktivierst.

Du kannst uns auch über unseren Kaffeautomat einen Kaffe ausgeben oder ein PUR Abo abschließen und das Forum so werbefrei nutzen.

Vielen Dank für Deine Unterstützung!