diff --git a/snxconnect.py b/snxconnect.py index 66e99b3..d6f3068 100644 --- a/snxconnect.py +++ b/snxconnect.py @@ -203,14 +203,23 @@ def login (self) : self.open (data = urlencode (d)) self.debug (self.purl) self.debug (self.info) - while 'MultiChallenge' in self.purl : - d = self.parse_pw_response () - otp = getpass ('One-time Password: ') - d ['password'] = enc.encrypt (otp) - self.debug ("nextfile: %s" % self.nextfile) + + if self.args.multi_challenge : + while 'MultiChallenge' in self.purl : + d = self.parse_pw_response () + otp = getpass ('One-time Password: ') + d ['password'] = enc.encrypt (otp) + self.debug ("nextfile: %s" % self.nextfile) + self.debug ("purl: %s" % self.purl) + self.open (data = urlencode (d)) + self.debug ("info: %s" % self.info) + + if self.purl.endswith ('Login/ActivateLogin') : + if self.args.save_cookies : + self.jar.save (self.args.cookiefile, ignore_discard = True) self.debug ("purl: %s" % self.purl) - self.open (data = urlencode (d)) - self.debug ("info: %s" % self.info) + self.open('sslvpn/Login/ActivateLogin?ActivateLogin=activate&LangSelect=en_US&submit=Continue&HeightData=') + if self.purl.endswith ('Portal/Main') : if self.args.save_cookies : self.jar.save (self.args.cookiefile, ignore_discard = True) @@ -222,7 +231,7 @@ def login (self) : self.generate_snx_info () return True else : - print ("Unexpected response, looking for MultiChallenge or Portal") + print ("Unexpected response, try again.") self.debug ("purl: %s" % self.purl) return # end def login @@ -405,7 +414,7 @@ def main () : except (OSError, IOError) : pass cfg = {} - boolopts = ['debug', 'save_cookies'] + boolopts = ['debug', 'save_cookies', 'multi_challenge'] if cfgf : for line in cfgf : line = line.strip ().decode ('utf-8') @@ -455,6 +464,11 @@ def main () : , help = 'Login type, default="%(default)s"' , default = cfg.get ('login_type', 'Standard') ) + cmd.add_argument \ + ( '-MC', '--multi-challenge' + , help = 'MultiChallenge, default="%(default)s"' + , default = cfg.get ('multi_challenge', False) + ) cmd.add_argument \ ( '-P', '--password' , help = 'Login password, not a good idea to specify on commandline'