Skip to content

Commit

Permalink
fix: mix bugfixes for stable release
Browse files Browse the repository at this point in the history
  • Loading branch information
ocervell committed Nov 10, 2024
1 parent e8e9a77 commit b743925
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 10 deletions.
3 changes: 2 additions & 1 deletion secator/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,9 @@ def run_command(self, results, name, targets, opts={}):
results = deduplicate(results, attr='_uuid')

# Get expanded targets
if not chunk:
if not chunk and results:
targets, opts = run_extractors(results, opts, targets)
debug('after extractors', obj={'targets': targets, 'opts': opts}, sub='celery.state')

try:
# Get task class
Expand Down
1 change: 0 additions & 1 deletion secator/configs/workflows/host_recon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ input_types:
tasks:
naabu:
description: Find open ports
ports: "-" # scan all ports
nmap:
description: Search for vulnerabilities on open ports
skip_host_discovery: True
Expand Down
20 changes: 15 additions & 5 deletions secator/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,23 +174,33 @@ def get_command_options(config):
if conf.get('required', False):
debug('OPT (skipped: opt is required and defined in config)', obj={'opt': opt}, sub=f'cli.{config.name}', verbose=True) # noqa: E501
continue
if opt_default is not None and opt_value_in_config != opt_default and opt_is_flag:
conf['reverse'] = True
conf['default'] = not conf['default']
mapped_value = cls.opt_value_map.get(opt)
if callable(mapped_value):
opt_value_in_config = mapped_value(opt_value_in_config)
elif mapped_value:
opt_value_in_config = mapped_value
if opt_value_in_config != opt_default:
if opt in opt_cache:
continue
if opt_is_flag:
conf['reverse'] = True
conf['default'] = not conf['default']
# print(f'{opt}: change default to {opt_value_in_config}')
conf['default'] = opt_value_in_config

# If opt is a flag but the default is True, add opposite flag
if opt_is_flag and opt_default is True:
conf['reverse'] = True

# Check if opt already processed before
opt = opt.replace('_', '-')
if opt in opt_cache:
# debug('OPT (skipped: opt is already in opt cache)', obj={'opt': opt}, sub=f'cli.{config.name}', verbose=True)
continue

# Build help
all_opts[opt] = conf
opt_cache.append(opt)
opt = opt.replace('_', '-')
all_opts[opt] = conf

# Debug
debug_conf = OrderedDict({'opt': opt, 'config_val': opt_value_in_config or 'N/A', **conf.copy()})
Expand Down
2 changes: 1 addition & 1 deletion secator/tasks/naabu.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class naabu(ReconPort):
file_flag = '-list'
json_flag = '-json'
opts = {
PORTS: {'type': str, 'short': 'p', 'help': 'Ports (default: nmap\'s top 100 ports'},
PORTS: {'type': str, 'short': 'p', 'help': 'Ports'},
TOP_PORTS: {'type': str, 'short': 'tp', 'help': 'Top ports'},
'scan_type': {'type': str, 'short': 'st', 'help': 'Scan type (SYN (s)/CONNECT(c))'},
# 'health_check': {'is_flag': True, 'short': 'hc', 'help': 'Health check'}
Expand Down
2 changes: 1 addition & 1 deletion secator/tasks/nmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class nmap(VulnMulti):
opt_prefix = '--'
output_types = [Port, Vulnerability, Exploit]
opts = {
PORTS: {'type': str, 'short': 'p', 'help': 'Ports to scan (default: most common 1000 ports for each protocol)'},
PORTS: {'type': str, 'short': 'p', 'default': 'top-1000', 'help': 'Ports to scan'},
TOP_PORTS: {'type': int, 'short': 'tp', 'help': 'Top ports to scan [full, 100, 1000]'},
SCRIPT: {'type': str, 'default': 'vulners', 'help': 'NSE scripts'},
'skip_host_discovery': {'is_flag': True, 'short': 'Pn', 'default': False, 'help': 'Skip host discovery (no ping)'},
Expand Down
2 changes: 2 additions & 0 deletions secator/tasks/searchsploit.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ def tags_extractor(item):

@staticmethod
def before_init(self):
if len(self.inputs) == 0:
return
_in = self.inputs[0]
self.matched_at = None
if '~' in _in:
Expand Down
2 changes: 1 addition & 1 deletion secator/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ def debug(msg, sub='', id='', obj=None, lazy=None, obj_after=True, obj_breakline
if isinstance(obj, dict):
obj_str += sep.join(f'[dim blue]{k}[/] [dim yellow]->[/] [dim green]{v}[/]' for k, v in obj.items() if v is not None)
elif isinstance(obj, list):
obj_str += f'[dim]{sep.join(obj)}[/]'
obj_str += f'[dim green]{sep.join(obj)}[/]'
if obj_str and not obj_after:
s = f'{s} {obj_str} '
s += f'[dim yellow]{msg}[/] '
Expand Down

0 comments on commit b743925

Please sign in to comment.