示例#1
0
 def _load_methods(self):
     self.methods = []
     if not os.path.exists(conf.getAuthLoadSettings()):
         self.logger.warning("Could not find auth loader file!")
         return
     # Read and parse plugin file
     data = open(conf.getAuthLoadSettings(), "r").read()
     data = [
         x.split(maxsplit=2) for x in data.splitlines()
         if not x.startswith("#") and x
     ]
     for x in [x for x in data if len(x) in [2, 3]]:
         try:
             x.extend([""] * (3 - len(x)))  # add empty args if none exist
             method, authType, args = x
             if authType.lower() not in [
                     "required",
                     "sufficient",
             ]:  # Skip if authType not known
                 continue
             # Create object
             args = {y.split("=")[0]: y.split("=")[1] for y in args.split()}
             i = importlib.import_module("lib.authenticationMethods.%s" %
                                         method)
             authMethod = getattr(i, method.split("/")[-1])(**args)
             # Add object to list
             self.methods.append((method, authType.lower(), authMethod))
             self.logger.info("Loaded Auth Method {}".format(x[0]))
         except Exception as e:
             self.logger.error(
                 "Failed to load Auth Method {}:  -> {}".format(x[0], e))
 def _load_methods(self):
   self.methods = []
   if not os.path.exists(conf.getAuthLoadSettings()):
       print("[!] Could not find auth loader file!")
       return
   # Read and parse plugin file
   data = open(conf.getAuthLoadSettings(), "r").read()
   data = [x.split(maxsplit=2) for x in data.splitlines() if not x.startswith("#") and x]
   for x in [x for x in data if len(x) in [2, 3]]:
     try:
       x.extend(['']*(3-len(x))) # add empty args if none exist
       method, authType, args = x
       if authType.lower() not in ["required", "sufficient"]: # Skip if authType not known
         continue
       # Create object
       args = {y.split("=")[0]: y.split("=")[1] for y in args.split()}
       i = importlib.import_module("lib.authenticationMethods.%s"%method)
       authMethod = getattr(i, method.split("/")[-1])(**args)
       # Add object to list
       self.methods.append((method, authType.lower(), authMethod))
       print("[+] Loaded Auth Method %s"%x[0])
     except Exception as e:
       print("[!] Failed to load Auth Method %s: "%x[0])
       print("[!]  -> %s"%e)