def load_plugin(self, addr, port, session): url = 'http://' + addr + ':' + str(port) # try to connect routers try: r = HttpHelper.connect(session, url, 1) except Exception: raise ErrorTimeout if 'server' in r.headers: self.server = r.headers['server'] if 'www-authenticate' in r.headers: self.realm = r.headers['www-authenticate'] fingerprint_str = self.server + self.realm + r.content # match vendor for vendor_re in self.VENDOR_RES: vendor_pattern = re.compile(vendor_re[1], re.I) vendor_match = vendor_pattern.search(fingerprint_str) if vendor_match: # match module module_re_list = self.MODULE_RES[vendor_re[0]] for module_re in module_re_list: module_pattern = re.compile(module_re[0], re.S | re.I) vendor_match = module_pattern.search(fingerprint_str) if vendor_match: return module_re, self.server, self.realm, vendor_re[0] return '', self.server, self.realm, vendor_re[0] return '', self.server, self.realm, ''
def connect(self, url, times): r = HttpHelper.connect(self.session, url, times) return r