8000 fix: header parsing by ocervell · Pull Request #629 · freelabz/secator · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: header parsing #629

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions secator/output_types/url.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,8 @@ def __repr__(self):
s += rf' \[[magenta]{cl}[/]]'
if self.screenshot_path:
s += rf' \[[magenta]{_s(self.screenshot_path)}[/]]'
if self.headers:
for k, v in self.headers.items():
if k != 'User-Agent':
s += rf' \[[gold3]{k}: {v}[/]]'
return rich_to_ansi(s)
2 changes: 1 addition & 1 deletion secator/tasks/_categories.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@


OPTS = {
HEADER: {'type': str, 'help': 'Custom header to add to each request in the form "KEY1:VALUE1; KEY2:VALUE2"', 'default': 'User-Agent: ' + USER_AGENTS['chrome_134.0_win10']}, # noqa: E501
HEADER: {'type': str, 'help': 'Custom header to add to each request in the form "KEY1:VALUE1;; KEY2:VALUE2"', 'default': 'User-Agent: ' + USER_AGENTS['chrome_134.0_win10']}, # noqa: E501
DELAY: {'type': float, 'short': 'd', 'help': 'Delay to add between each requests'},
DEPTH: {'type': int, 'help': 'Scan depth'},
FILTER_CODES: {'type': str, 'short': 'fc', 'help': 'Filter out responses with HTTP codes'},
Expand Down
11 changes: 11 additions & 0 deletions secator/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ def extract_domain_info(input, domain_only=False):

Args:
input (str): An URL or FQDN.
domain_only (bool): Return only the registered domain name.

Returns:
tldextract.ExtractResult: Extracted info.
Expand Down Expand Up @@ -815,3 +816,13 @@ def convert_functions_to_strings(data):
return json.dumps(data.__name__) # or use inspect.getsource(data) if you want the actual function code
else:
return data


def headers_to_dict(header_opt):
headers = {}
for header in header_opt.split(';;'):
split = header.strip().split(':')
key = split[0].strip()
val = ':'.join(split[1:]).strip()
headers[key] = val
return headers
0