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

Custom wordlist functionality addition for scan modules #1026

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

pUrGe12
Copy link
Contributor

@pUrGe12 pUrGe12 commented Feb 24, 2025

Proposed change

As discussed in issue #1025, users cannot use their own wordlist through the command line (they will have to go and change the path in config.py). I have added a command line argument that allows users to enter a path to their wordlist. If they don't then the defaults are used.

Your PR description goes here.

Type of change

  • New core framework functionality
  • Bugfix (non-breaking change which fixes an issue)
  • Code refactoring without any functionality changes
  • New or existing module/payload change
  • Localization improvement
  • Dependency upgrade
  • Documentation improvement

Checklist

  • I've followed the contributing guidelines
  • I've run make pre-commit, it didn't generate any changes
  • I've run make test, all tests passed locally

@pUrGe12 pUrGe12 changed the title Custom wordlist functionality addition Custom wordlist functionality addition for scan modules Mar 3, 2025
@securestep9
Copy link
Collaborator

@pUrGe12 custom wordlist functionality existed in Nettacker for many years it is just not well documented . Some of the improvements in PR1026 are sill welcome (e.g. you are welcome to add the new '-W' argument to define the wordlist to make the feature easier to use)

Here is how to use the custom wordlist feature - add this to the command lie:

--modules-extra-args "read_from_file=/path/to/custom/wordlist.txt"

by default the relative path is assumed to be nettacker/lib/payloads/ so if you define:

--modules-extra-args "read_from_file=mydirs.txt"
then place your mydirs.txt custom wordlist in nettacker/lib/payloads/

Can you please update your PR (or submit a new one) which just sets the 'read_from_file' based on the '-W' argument. The rest of Nettacker (e.g. modules, fuzzer) do not need to be modified - the feature is already built-in!

@pUrGe12
Copy link
Contributor Author

pUrGe12 commented Mar 6, 2025

Updated based on the suggestion!

Copy link
Collaborator

@securestep9 securestep9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be simplified even further - please review/amend this PR

@@ -127,6 +127,7 @@ class DefaultSettings(ConfigBase):
scan_subdomains = False
selected_modules = None
url_base_path = None
user_wordlist = ""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not necessary

"--wordlist",
action="store",
dest="user_wordlist",
default=Config.settings.user_wordlist,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be 'read_from_file' nor user_wordlist - there is no value in creating unnecessary setting/variable

@@ -39,6 +39,9 @@ def __init__(
self.module_inputs[module_extra_args] = self.module_inputs["modules_extra_args"][
module_extra_args
]
if options.user_wordlist:
self.module_inputs["read_from_file"] = options.user_wordlist
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary copy - just use 'read_from_file' - no need to create an additional user_wordlist, only to copy it into 'read_from_file'

@@ -35,6 +35,7 @@ cannot_run_api_server: You can't run API Server through itself!
error_target: Cannot specify the target(s)
error_target_file: "Cannot specify the target(s), unable to open file: {0}"
error_username: "Cannot specify the username(s), unable to open file: {0}"
error_wordlist: "Unable to open wordlist file: {0}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not necessary

@pUrGe12
Copy link
Contributor Author

pUrGe12 commented Mar 6, 2025

have made the required changes.

"-W",
"--wordlist",
action="store",
dest="read_from_file",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you lost help and default here

Copy link
Contributor Author

@pUrGe12 pUrGe12 Mar 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I add a "read_from_file" variable in config and set that to none for default or just specify None here itself? I'll have to edit config to set default right?

@@ -39,6 +39,7 @@ def __init__(
self.module_inputs[module_extra_args] = self.module_inputs["modules_extra_args"][
module_extra_args
]

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary empty line here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants