From bbe46e071f766d8add904e6c690d942c41a876d9 Mon Sep 17 00:00:00 2001 From: becivells Date: Tue, 12 Nov 2019 10:38:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20shaodan=20api=20=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E9=94=99=E8=AF=AF=EF=BC=8C=E5=A2=9E=E5=8A=A0=20fofa?= =?UTF-8?q?=20=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pocsuite3/api/__init__.py | 3 ++- pocsuite3/lib/core/option.py | 7 ++++++- pocsuite3/lib/core/poc.py | 3 ++- pocsuite3/lib/core/settings.py | 8 ++++---- pocsuite3/lib/parse/cmd.py | 8 ++++++-- pocsuite3/modules/shodan/__init__.py | 4 ++-- 6 files changed, 22 insertions(+), 11 deletions(-) diff --git a/pocsuite3/api/__init__.py b/pocsuite3/api/__init__.py index 835bdd91..7a386612 100644 --- a/pocsuite3/api/__init__.py +++ b/pocsuite3/api/__init__.py @@ -19,6 +19,7 @@ from pocsuite3.modules.seebug import Seebug from pocsuite3.modules.zoomeye import ZoomEye from pocsuite3.modules.shodan import Shodan +from pocsuite3.modules.fofa import Fofa from pocsuite3.modules.censys import Censys from pocsuite3.modules.spider import crawl from pocsuite3.modules.httpserver import PHTTPServer @@ -31,7 +32,7 @@ 'PLUGIN_TYPE', 'POCBase', 'Output', 'AttribDict', 'POC_CATEGORY', 'register_poc', 'conf', 'kb', 'logger', 'paths', 'DEFAULT_LISTENER_PORT', 'load_file_to_module', 'load_string_to_module', 'single_time_warn_message', 'CEye', 'Seebug', - 'ZoomEye', 'Shodan', 'PHTTPServer', 'REVERSE_PAYLOAD', 'get_listener_ip', 'get_listener_port', + 'ZoomEye', 'Shodan','Fofa','Censys', 'PHTTPServer', 'REVERSE_PAYLOAD', 'get_listener_ip', 'get_listener_port', 'get_results', 'init_pocsuite', 'start_pocsuite', 'get_poc_options', 'crawl', 'OSShellcodes', 'WebShell', 'OptDict', 'OptIP', 'OptPort', 'OptBool', 'OptInteger', 'OptFloat', 'OptString', \ 'OptItems', 'OptDict', 'get_middle_text', 'generate_shellcode_list', 'random_str') diff --git a/pocsuite3/lib/core/option.py b/pocsuite3/lib/core/option.py index c01e67ed..ad8fd99b 100644 --- a/pocsuite3/lib/core/option.py +++ b/pocsuite3/lib/core/option.py @@ -211,7 +211,7 @@ def _set_multiple_targets(): if conf.dork: # enable plugin 'target_from_zoomeye' by default - if 'target_from_shodan' not in conf.plugins: + if 'target_from_shodan' not in conf.plugins and 'target_from_fofa' not in conf.plugins: conf.plugins.append('target_from_zoomeye') if conf.dork_zoomeye: @@ -223,6 +223,8 @@ def _set_multiple_targets(): if conf.dork_censys: conf.plugins.append('target_from_censys') + if conf.dork_fofa: + conf.plugins.append('target_from_fofa') def _set_task_queue(): if kb.registered_pocs and kb.targets: @@ -485,11 +487,14 @@ def _set_conf_attributes(): conf.login_user = None conf.login_pass = None conf.shodan_token = None + conf.fofa_user = None + conf.fofa_token = None conf.censys_uid = None conf.censys_secret = None conf.dork = None conf.dork_zoomeye = None conf.dork_shodan = None + conf.dork_fofa = None conf.dork_censys = None conf.max_page = 1 conf.search_type = 'host' diff --git a/pocsuite3/lib/core/poc.py b/pocsuite3/lib/core/poc.py index f6cf13e2..90890f7a 100644 --- a/pocsuite3/lib/core/poc.py +++ b/pocsuite3/lib/core/poc.py @@ -219,7 +219,8 @@ def execute(self, target, headers=None, params=None, mode='verify', verbose=True except BaseException as e: self.expt = (ERROR_TYPE_ID.OTHER, e) logger.error("PoC has raised a exception") - logger.exception(e) + logger.error(str(e)) + # logger.exception(e) output = Output(self) return output diff --git a/pocsuite3/lib/core/settings.py b/pocsuite3/lib/core/settings.py index 85428404..4a2356dc 100644 --- a/pocsuite3/lib/core/settings.py +++ b/pocsuite3/lib/core/settings.py @@ -90,7 +90,7 @@ # Cmd line parse whitelist CMD_PARSE_WHITELIST = ['version', 'update', 'url', 'file', 'verify', 'attack', 'shell', 'cookie', 'host', 'referer', 'user-agent', 'random-agent', 'proxy', 'proxy-cred', 'timeout', 'retry', 'delay', 'headers', - 'login-user', 'login-pass', 'dork', 'max-page', 'search-type', - 'vul-keyword', 'ssv-id', 'lhost', 'lport', 'plugins', 'pocs-path', 'threads', 'batch', - 'requires', 'quiet', 'poc', 'verbose', 'mode', 'api', 'connect_back_host', 'connect_back_port', - 'ppt'] + 'login-user', 'login-pass', 'dork', 'dork-shodan', 'dork-censys', 'dork-zoomeye', 'dork-fofa', + 'max-page', 'search-type', 'shodan-token', 'fofa-user', 'fofa-token', 'vul-keyword', 'ssv-id', + 'lhost', 'lport', 'plugins', 'pocs-path', 'threads', 'batch', 'requires', 'quiet', 'poc', + 'verbose', 'mode', 'api', 'connect_back_host', 'connect_back_port', 'ppt'] diff --git a/pocsuite3/lib/parse/cmd.py b/pocsuite3/lib/parse/cmd.py index 88bffe59..9d070dee 100644 --- a/pocsuite3/lib/parse/cmd.py +++ b/pocsuite3/lib/parse/cmd.py @@ -68,6 +68,8 @@ def cmd_line_parser(argv=None): group.add_argument("--login-user", dest="login_user", help="Telnet404 login user") group.add_argument("--login-pass", dest="login_pass", help="Telnet404 login password") group.add_argument("--shodan-token", dest="shodan_token", help="Shodan token") + group.add_argument("--fofa-user", dest="fofa_user", help="fofa user") + group.add_argument("--fofa-token", dest="fofa_token", help="fofa token") group.add_argument("--censys-uid", dest="censys_uid", help="Censys uid") group.add_argument("--censys-secret", dest="censys_secret", help="Censys secret") # Modules options @@ -80,6 +82,8 @@ def cmd_line_parser(argv=None): help="Shodan dork used for search.") modules.add_argument("--dork-censys", dest="dork_censys", action="store", default=None, help="Censys dork used for search.") + modules.add_argument("--dork-fofa", dest="dork_fofa", action="store", default=None, + help="Fofa dork used for search.") modules.add_argument("--max-page", dest="max_page", type=int, default=1, help="Max page used in ZoomEye API(10 targets/Page).") modules.add_argument("--search-type", dest="search_type", action="store", default='host', @@ -122,8 +126,8 @@ def cmd_line_parser(argv=None): diy.add_argument(line) args = parser.parse_args() - if not any((args.url, args.url_file, args.update_all, args.plugins, args.dork, args.configFile, - args.show_version)): + if not any((args.url, args.url_file, args.update_all, args.plugins, args.dork, args.dork_shodan, args.dork_fofa, + args.dork_censys, args.dork_zoomeye, args.configFile, args.show_version)): err_msg = "missing a mandatory option (-u, --url-file, --update). " err_msg += "Use -h for basic and -hh for advanced help\n" parser.error(err_msg) diff --git a/pocsuite3/modules/shodan/__init__.py b/pocsuite3/modules/shodan/__init__.py index f1bb03d1..50975d3e 100644 --- a/pocsuite3/modules/shodan/__init__.py +++ b/pocsuite3/modules/shodan/__init__.py @@ -20,9 +20,9 @@ def __init__(self, conf_path=paths.POCSUITE_RC_PATH, token=None): except Exception: pass - self.token = token if token: - self.write_conf() + self.token = token + self.check_token() def token_is_available(self): if self.token: