Skip to content

Commit

Permalink
fix: inputfile mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Arc-2023 committed Sep 25, 2024
1 parent 4cafcb9 commit e7d803a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
15 changes: 11 additions & 4 deletions core/fofaMain.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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"))
Expand All @@ -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__':
Expand Down
5 changes: 3 additions & 2 deletions fofa.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e7d803a

Please sign in to comment.