From e7d803a930523c4faaf48ef3a5284f1931ac5306 Mon Sep 17 00:00:00 2001 From: ui C Date: Mon, 23 Sep 2024 15:27:29 +0800 Subject: [PATCH 1/2] fix: inputfile mode --- core/fofaMain.py | 15 +++++++++++---- fofa.py | 5 +++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/core/fofaMain.py b/core/fofaMain.py index 303afad..e4f0eea 100644 --- a/core/fofaMain.py +++ b/core/fofaMain.py @@ -432,7 +432,6 @@ def fofaSpider(self, search_key, searchbs64, index): @return: """ # while len(self.host_set) < self.endcount and self.old_length !=len(self.host_set): - self.old_length = len(self.host_set) self.timestamp_list[index].clear() context = self.fofaSpiderOnePageData(search_key, searchbs64, index) @@ -461,6 +460,9 @@ def fofaSpider(self, search_key, searchbs64, index): self.fofaFuzzSpider(search_key, context, index) search_key_modify = self.modifySearchTimeUrl(search_key, index) + # 特判,如果destroy不exit的话就会出错 + if search_key_modify == 'end': + return # print(search_key_modify) searchbs64_modify = urllib.parse.quote(base64.b64encode(search_key_modify.encode("utf-8"))) # search_key = search_key_modify @@ -564,6 +566,8 @@ def modifySearchTimeUrl(self, search_key, index): if len(timestamp_list) == 0: print(colorize(_("似乎时间戳到了尽头."), "red")) self._destroy() + # 返回特定的值,特判 + return 'end' # print(timestamp_list) time_first = timestamp_list[0].split(' ')[0].strip('\n').strip() @@ -675,11 +679,12 @@ def start(self): print(colorize(_('[*] 开始运行'), "green")) if self.inputfile: with open(self.inputfile, 'r') as f: + # self.filename = "{}_{}.{}".format(unit.md5(self.search_key), int(time.time()), self.output) + # self.output_data = OutputData(self.filename, self.level, pattern=self.output) for line in f.readlines(): self.cleanInitParameters() self.search_key = clipKeyWord(line.strip()) - self.filename = "{}_{}.{}".format(unit.md5(self.search_key), int(time.time()), self.output) - self.output_data = OutputData(self.filename, self.level, pattern=self.output) + searchbs64, countnum = self.getFofaKeywordsCount(self.search_key) if str(countnum) == "0" and len(str(countnum)) == 1: print(colorize(_('无搜索结果,执行下一条'), "red")) @@ -706,7 +711,9 @@ def start(self): def _destroy(self): self.removeDuplicate() - sys.exit(0) + if not self.inputfile: + + sys.exit(0) if __name__ == '__main__': diff --git a/fofa.py b/fofa.py index b972ed1..dcecc75 100644 --- a/fofa.py +++ b/fofa.py @@ -140,8 +140,9 @@ def main(): # filename = "{}_{}.{}".format(unit.md5(search_key), int(time.time()), output) output_data = OutputData(filename, level, pattern=output) else: - filename = _("暂无") - output_data = None + # filename = _("暂无") + filename="{}.{}".format(outputname,output) + output_data = OutputData(filename, level, pattern=output) if args.proxy or args.proxy_url or args.proxy_file : config.IS_PROXY = True From bf61ced6ae952d00fb3252d7dc9a477f4133f74a Mon Sep 17 00:00:00 2001 From: ui C Date: Wed, 25 Sep 2024 20:42:08 +0800 Subject: [PATCH 2/2] up lxml to 5.3.0 in case of failing in build it --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 134eca9..fc857e1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -16,7 +16,7 @@ jaraco.context==5.3.0 jaraco.functools==4.0.1 jeepney==0.8.0 keyring==25.2.1 -lxml==4.9.2 +lxml==5.3.0 markdown-it-py==3.0.0 mdurl==0.1.2 mmh3==4.1.0