Parsing raw standard output
... or how to integrate tools that prints to stdout and do not support JSON lines.
If your tool does not output JSON lines / JSON files, it's requires a bit more effort to integrate it with secator.
Depending on how you want to parse the output, read:
Using regular expressions
Steps:
Use the
RegexSerializeritem loader.Use the
on_regex_loadedhook to yieldsecatoroutput types.
Example:
Assume mytool outputs on stdout like:
mytool -u mytarget.com
[INF] This is an info message
[ERR] This is an error message
[FOUND] https://mytarget.com/api [type=url] [status=200] [content_type=application/json] [title=MyAwesomeWebPage]
[FOUND] https://mytarget.com/api/metrics [type=url] [status=403]
[FOUND] A3TBABCD1234EFGH5678 [type=aws_api_key] [matched_at=https://mytarget/api/.aws_key.json]
[FOUND] <-- an HTML comment --> [type=aws_api_key] [matched_at=https://mytarget/api/.aws_key.json]
[FOUND] CVE-2021-44228 [type=vulnerability] [matched_at=https://mytarget/api/sensitive_api_path]First we need to find a regular expression that will match the items marked with [FOUND] and get the individual values using a named regex (you can use Pythex for this).
Here is the one we came up with:
An integration of mytool with secator would look like:
Run it with secator:
Writing a custom item loader
Steps:
Override the
item_loaderstatic method to parse the standard output with custom code.
Example:
Assume mytool outputs on stdout like:
Run it with secator:
Last updated
Was this helpful?