Skip to content

Commit

Permalink
Merge pull request #201 from 13ph03nix/master
Browse files Browse the repository at this point in the history
feat(): add init target from poc dork function
  • Loading branch information
pokejeff authored Jul 28, 2021
2 parents 4e8bebc + 1bc1cdf commit 80020af
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
24 changes: 24 additions & 0 deletions pocsuite3/lib/core/option.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import re
import socket
import socks
import importlib
from queue import Queue
from urllib.parse import urlsplit

Expand Down Expand Up @@ -673,6 +674,28 @@ def _init_kb_comparison():
kb.comparison = StatisticsComparison()


def _init_target_from_poc_dork():
if len(kb.targets) > 0:
return

for poc_module, poc_class in kb.registered_pocs.items():
if not hasattr(poc_class, 'dork'):
continue
# find a available target source
target_source = ''
for i in ["zoomeye", "fofa", "shodan", "quake", "censys"]:
if i in poc_class.dork.keys():
target_source = i
break
# fetch target from target source, add it to kb.targets
conf.dork = poc_class.dork[target_source]
plugin_name = f'target_from_{target_source}'
importlib.import_module(f'pocsuite3.plugins.{plugin_name}')
for _, plugin in kb.plugins.targets.items():
if target_source in plugin.__class__.__name__.lower():
plugin.init()


def init():
"""
Set attributes into both configuration and knowledge base singletons
Expand All @@ -692,6 +715,7 @@ def init():
_set_plugins()
_init_targets_plugins()
_init_pocs_plugins()
_init_target_from_poc_dork()
_set_task_queue()
_init_results_plugins()

Expand Down
6 changes: 0 additions & 6 deletions pocsuite3/lib/parse/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,6 @@ 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.dork_shodan, args.dork_fofa, args.dork_quake,
args.dork_censys, args.dork_zoomeye, args.configFile, args.show_version)) and not args.rule and not args.rule_req:
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)

return args

except SystemExit:
Expand Down

0 comments on commit 80020af

Please sign in to comment.