Feuerwasser
Benutzer
- Mitglied seit
- 28. Aug 2012
- Beiträge
- 245
- Punkte für Reaktionen
- 0
- Punkte
- 22
Mediaserver:~# sh /etc/noipAutoLogin
/etc/noipAutoLogin: line 3: import: not found
/etc/noipAutoLogin: line 4: import: not found
/etc/noipAutoLogin: line 5: import: not found
/etc/noipAutoLogin: line 6: import: not found
/etc/noipAutoLogin: line 7: import: not found
/etc/noipAutoLogin: line 8: import: not found
/etc/noipAutoLogin: line 10: syntax error: unexpected "("
#!/usr/local/packages/@appstore/Python/usr/local/bin/python
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>No-IP Members Portal: Your No-IP</title>"
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 = ""
password = ""
logfile = ""
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:])
2014/10/11 14:29:25 - INFO - We have succesfully logged into NoIP.
Mediaserver:~# /etc/noipAutoLogin
-ash: /etc/noipAutoLogin: Permission denied
Mediaserver:~# su /etc/noipAutoLogin
su: unknown user /etc/noipAutoLogin
Mediaserver:~# sudo /etc/noipAutoLogin
-ash: sudo: not found
thx! keine Ahnung warum es plötzlich mit veränderten Rechten geht, der root müsste doch auch ohne 755 was machen können oder?Mediaserver:~# chmod 755 /etc/noipAutoLogin
Mediaserver:~# /etc/noipAutoLogin
We have succesfully logged into NoIP.
DiskStation> /volume1/install/scripts/ddnsAutoLogin
-sh: /volume1/install/scripts/ddnsAutoLogin: not found
DiskStation> sh /volume1/install/scripts/ddnsAutoLogin
: not foundstall/scripts/ddnsAutoLogin: line 2:
/volume1/install/scripts/ddnsAutoLogin: line 3: import: not found
/volume1/install/scripts/ddnsAutoLogin: line 4: import: not found
/volume1/install/scripts/ddnsAutoLogin: line 5: import: not found
/volume1/install/scripts/ddnsAutoLogin: line 6: import: not found
/volume1/install/scripts/ddnsAutoLogin: line 7: import: not found
/volume1/install/scripts/ddnsAutoLogin: line 8: import: not found
: not foundstall/scripts/ddnsAutoLogin: line 9:
/volume1/install/scripts/ddnsAutoLogin: line 10: syntax error: unexpected "("
#!/volume1/@appstore/PythonModule/usr/lib/python2.7
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>No-IP Members Portal: Your No-IP</title>"
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 = ""
password = ""
logfile = "/volume1/install/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:])
Das kannst Du ja gar nicht mit#!/volume1/@appstore/PythonModule/usr/lib/python2.7
aufrufen, da es kein Shellscript sondern ein Python Script ist. -> Ruf das Script auf mit:sh /volume1/install/scripts/ddnsAutoLogin
oder/volume1/@appstore/PythonModule/usr/lib/python2.7 /volume1/install/scripts/ddnsAutoLogin
python /volume1/install/scripts/ddnsAutoLogin
Ausgeführt werden, allerdings weder über den Aufgabenplaner noch überpython /volume1/install/scripts/ddnsAutoLogin
Stimmt also der Ordner noch nicht?/volume1/@appstore/PythonModule/usr/lib/python2.7 /volume1/install/scripts/ddnsAutoLogin
Bin wohl zu wenig in der Materie drin um das zu wissen, da es im Wiki ohne dass "python" steht.python /volume1/install/scripts/ddnsAutoLogin
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.