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JCQk8L2gxPgoJCQk8L2Rpdj4gPHNwYW4gY2xhc3M9ImxhYmVsIGxhYmVsLXByaW1hcnkiPueUn+aIkOaXtumXtO+8mnt7cmVwb3J0VGltZX19PC9zcGFuPgogICAgICAgICAgICA8L2JyPjwvYnI+CgkJCTx0YWJsZSBjbGFzcz0idGFibGUiPgoJCQkJPHRoZWFkPgoJCQkJCTx0cj4KICAgIDx0aD4jPC90aD4KICAgIDx0aD5Vcmw8L3RoPgogICAgPHRoPlRpdGxlPC90aD4KICAgIDx0aD5BcHBsaWNhdGlvbjwvdGg+CiAgICA8dGg+U2VydmVyPC90aD4KICAgPHRoPkxhbmd1YWdlPC90aD4KICAgIDx0aD5TdGF0dXM8L3RoPgogICAgICAgICAgICAgICAgICAgICAgICAgICAgPC90cj4KCQkJCTwvdGhlYWQ+CiAgICAgICAgICAgICAgICAKCQkJCTx0Ym9keT4KICAgICAgICAgICAgICAgICAgICB7e2NvbnRlbnR9fQoJCQkJPC90Ym9keT4KCQkJPC90YWJsZT4KCQk8L2Rpdj4KCTwvZGl2Pgo8L2Rpdj4KICA8L2JvZHk+CjwvaHRtbD4=" html = base64.b64decode(html).decode('utf-8') html = html.replace("{{reportTime}}", reportTime) html = html.replace("{{version}}", Version) for key, value in Webinfo.result.items(): num = num + 1 url = key title = value['title'] application = value['App_Info']['Application'] status = value['status'] language = value['App_Info']['Language'] server = value['App_Info']['Server'] tr = "<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td><td>{6}</td></tr>".format( num, url, title, application, server, language, status) trs.append(tr) html = html.replace("{{content}}", ''.join(trs)) with open(self.path_html, 'w', encoding='utf-8') as f: f.write(html) print() successMsg = "结果文件输出路径为:{0}".format(self.path_html) logging.success(successMsg)
def __init__(self): self.urls = Urls.url self.name = [] filepath = os.path.join(path.library, 'end.json') with open(filepath, 'r', encoding='utf-8') as file: obj = json.load(file) # 初始化指纹库 for line in obj: if line['name'] not in self.name: self.name.append(line) self._prepare_app(line) Msg = "成功加载{0}指纹库,共加载指纹{1}".format(filepath, len(self.name)) logging.success(Msg) Msg = "是否开启了MD5指纹识别:{0}".format(config.checkmd5) logging.success(Msg) self.fingers = obj self.req = Request() self.md5 = config.checkmd5
def search(self): logging.success("正从数据库:{0}中查询信息".format(self.Dbpath)) sql = 'select * from datas where {0} like "%{1}%"'.format( Db.type, Db.key) self.cur.execute(sql) datas = self.cur.fetchall() for data in datas: Webinfo.result[data[1]] = { "title": data[2], "Application": data[3], "status": data[7], "Server": data[4], "System": data[6], "Language": data[5] } Msg = "{0} {1} {2} {4} {3}".format(color.green(data[3]), color.blue(data[4]), data[2], color.yellow(data[7]), data[1]) logging.info(Msg) logging.info("共查询到{0}条数据".format(len(Webinfo.result)))
def outXls(self): with xlsxwriter.Workbook(self.path_xls) as workbook: worksheet = workbook.add_worksheet('Finger scan') bold = workbook.add_format({"bold": True}) worksheet.set_column('A:A', 30) worksheet.set_column('B:B', 30) worksheet.set_column('C:C', 30) worksheet.set_column('D:D', 30) worksheet.set_column('E:E', 30) worksheet.set_column('F:F', 30) worksheet.set_column('G:G', 30) worksheet.write('A1', 'Url', bold) worksheet.write('B1', 'Title', bold) worksheet.write('C1', 'Application', bold) worksheet.write('D1', 'Server', bold) worksheet.write('E1', 'Language', bold) worksheet.write('F1', 'System', bold) worksheet.write('G1', 'Status', bold) row = 1 col = 0 for key, value in Webinfo.result.items(): url = key title = value['title'] application = value['Application'] status = value['status'] language = value['Language'] server = value['Server'] system = value['System'] worksheet.write(row, col, url) worksheet.write(row, col + 1, title) worksheet.write(row, col + 2, application) worksheet.write(row, col + 3, server) worksheet.write(row, col + 4, language) worksheet.write(row, col + 5, system) worksheet.write(row, col + 6, status) row = row + 1 print() successMsg = "结果文件输出路径为:{0}".format(self.path_xls) logging.success(successMsg)
def response(self, url, response): response_content = response.content html = response_content.decode( encoding=chardet.detect(response_content)['encoding']) title = self.get_title(html).strip().replace('\r', '').replace('\n', '') status = response.status_code size = len(response.text) soup = BeautifulSoup(html, 'html.parser') scripts = [ script['src'] for script in soup.findAll('script', src=True) ] meta = { meta['name'].lower(): meta['content'] for meta in soup.findAll('meta', attrs=dict(name=True, content=True)) } app_info = self.Wappalyzer.run(response.url, html, response.headers, scripts, meta) Webinfo.result[url] = { "title": title, "status": status, "size": size, "App_Info": app_info } for name, value in app_info.items(): if name == "Application": self.app = value break else: self.app = None msg = "{0} {4} {1} {2} {3}".format(color.green(str(self.app)), color.yellow(status), url, color.cyan(title), color.blue(app_info['Server'])) logging.success(msg)
def outJson(self): with open(self.path_json, 'w') as file: file.write(json.dumps(Webinfo.result)) print() successMsg = "结果文件输出路径为:{0}".format(self.path_json) logging.success(successMsg)