Skip to content

Commit

Permalink
修复 shaodan api 调用错误,增加 fofa 接口
Browse files Browse the repository at this point in the history
  • Loading branch information
Becivells committed Nov 12, 2019
1 parent 1b12120 commit bbe46e0
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 11 deletions.
3 changes: 2 additions & 1 deletion pocsuite3/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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')
Expand Down
7 changes: 6 additions & 1 deletion pocsuite3/lib/core/option.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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'
Expand Down
3 changes: 2 additions & 1 deletion pocsuite3/lib/core/poc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions pocsuite3/lib/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
8 changes: 6 additions & 2 deletions pocsuite3/lib/parse/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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',
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions pocsuite3/modules/shodan/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit bbe46e0

Please sign in to comment.