forked from Cl0udG0d/Fofa-hack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfofa.py
66 lines (59 loc) · 2.85 KB
/
fofa.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2022/9/14 22:20
# @Author : Cl0udG0d
# @File : fofa.py
# @Github: https://github.com/Cl0udG0d
import argparse
import time
from core.fofaC import FofaC
import platform
if platform.system() == 'Windows':
from core.fofaS import FofaS
from tookit import unit, config
from tookit.levelData import LevelData
from tookit.outputData import OutputData
from tookit.unit import clipKeyWord, setProxy, outputLogo
def main():
outputLogo()
parser = argparse.ArgumentParser(description='Fofa-hack v{} 使用说明'.format(config.VERSION_NUM))
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument('--keyword', '-k', help='fofa搜索关键字')
group.add_argument('--inputfile', '-i', help="指定文件,从文件中批量读取fofa语法")
parser.add_argument('--timesleep', '-t', help='爬取每一页等待秒数,防止IP被Ban,默认为3', default=3)
parser.add_argument('--timeout', '-to', help='爬取每一页的超时时间', default=10)
parser.add_argument('--endcount', '-e', help='爬取结束数量')
parser.add_argument('--level', '-l', help='爬取等级: 1-3 ,数字越大内容越详细,默认为 1')
parser.add_argument('--output', '-o', help='输出格式:txt、json,默认为txt')
parser.add_argument('--fuzz', '-f', help='关键字fuzz参数,增加内容获取粒度', action='store_true')
parser.add_argument('--proxy', help="指定代理,代理格式 --proxy '127.0.0.1:7890'")
parser.add_argument('--type', type=str, choices=["common", "selenium"], default="common",
help="运行类型,默认为普通方式")
args = parser.parse_args()
time_sleep = int(args.timesleep)
timeout = int(args.timeout)
search_key = clipKeyWord(args.keyword) if args.keyword else None
endcount = int(args.endcount) if args.endcount else 100
level = args.level if args.level else "1"
level_data = LevelData(level)
fuzz = args.fuzz
output = args.output if args.output else "txt"
if search_key:
filename = "{}_{}.{}".format(unit.md5(search_key), int(time.time()), output)
output_data = OutputData(filename, level, pattern=output)
else:
filename = "暂无"
output_data = None
is_proxy, proxy = setProxy(args.proxy)
type = args.type
inputfile = args.inputfile if args.inputfile else None
if type == "selenium" and platform.system() == 'Windows':
fofa = FofaS(search_key, inputfile, filename, time_sleep, endcount, level, level_data, output, output_data,
fuzz,
timeout, is_proxy, proxy)
else:
fofa = FofaC(search_key, inputfile, filename, time_sleep, endcount, level, level_data, output, output_data,
fuzz, timeout, is_proxy, proxy)
fofa.start()
if __name__ == '__main__':
main()