Skip to content
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

Add checks for placeholder in custom tool task #1201

Merged
merged 2 commits into from
Feb 21, 2024
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
16 changes: 11 additions & 5 deletions web/reNgine/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,14 +468,20 @@ def subdomain_discovery(
elif tool in custom_subdomain_tools:
tool_query = InstalledExternalTool.objects.filter(name__icontains=tool.lower())
if not tool_query.exists():
logger.error(f'Missing {{TARGET}} and {{OUTPUT}} placeholders in {tool} configuration. Skipping.')
logger.error(f'{tool} configuration does not exists. Skipping.')
continue
if '{TARGET}' not in cmd:
logger.error(f'Missing {{TARGET}} placeholders in {tool} configuration. Skipping.')
continue
if '{OUTPUT}' not in cmd:
logger.error(f'Missing {{OUTPUT}} placeholders in {tool} configuration. Skipping.')
continue

custom_tool = tool_query.first()
cmd = custom_tool.subdomain_gathering_command
if '{TARGET}' in cmd and '{OUTPUT}' in cmd:
cmd = cmd.replace('{TARGET}', host)
cmd = cmd.replace('{OUTPUT}', f'{self.results_dir}/subdomains_{tool}.txt')
cmd = cmd.replace('{PATH}', custom_tool.github_clone_path) if '{PATH}' in cmd else cmd
cmd = cmd.replace('{TARGET}', host)
cmd = cmd.replace('{OUTPUT}', f'{self.results_dir}/subdomains_{tool}.txt')
cmd = cmd.replace('{PATH}', custom_tool.github_clone_path) if '{PATH}' in cmd else cmd
else:
logger.warning(
f'Subdomain discovery tool "{tool}" is not supported by reNgine. Skipping.')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,11 @@ <h6 class="text-danger">Please note that this subdomain gathering tool must supp
<div class="">
<span class="font-16">
reNgine needs to know how this tool accepts target and output the subdomain results.<br>
<strong>Use the below syntax wherever required.</strong>
<strong>Use the below syntax wherever required, but remember that <code>{TARGET}</code> and <code>{OUTPUT}</code> <strong>are mandatory placeholders</strong>.</strong>
<ul>
<li><code>{TARGET}</code> (mandatory), Use this for the command-line arg that takes in domain as input target. Example. <code>subfinder -d {TARGET}</code></li>
<li><code>{OUTPUT}</code> (mandatory), Use this for the command-line arg that takes the output arg. Example. <code>subfinder -d {TARGET} -o {OUTPUT}</code></li>
<li><code>{PATH}</code>, Use this if your tool is github cloned. Example. <code>python3 {PATH}/subdomain.py</code></li>
<li><code>{TARGET}</code>, Use this for the command-line arg that takes in domain as input target. Example. <code>subfinder -d {TARGET}</code></li>
<li><code>{OUTPUT}</code>, Use this for the command-line arg that takes the output arg. Example. <code>subfinder -d {TARGET} -o {OUTPUT}</code></li>
<li><code>{PROXY}</code>, Use this if your tool supports proxy. Example. <code>tool_name -p {PROXY}</code></li>
</ul>
You can use the combinations of the above syntax and also you can use any other command-line argument that your tool supports.
Expand Down
Loading