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

optimize generate_templist #1696

Merged
merged 2 commits into from
Aug 25, 2024
Merged
Changes from 1 commit
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
27 changes: 19 additions & 8 deletions bbot/modules/deadly/ffuf.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,18 +312,29 @@ async def execute_ffuf(

def generate_templist(self, prefix=None):
line_count = 0

virtual_file = []

if prefix:
prefix = prefix.strip().lower()

max_lines = self.config.get("lines")
banned_set = set(self.banned_characters)
Copy link
Collaborator

Choose a reason for hiding this comment

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

since these are global to the module can we move them into setup()

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

0e33cd9 Should be cleaner.

I didn't move it to setup(), because ffuf_shortnames overrides the ffuf setup() - keeping them as a class attribute is currently the least redundant way to define them.


for idx, val in enumerate(self.wordlist_lines):
if idx > self.config.get("lines"):
if idx > max_lines:
break
if len(val) > 0:
if val.strip().lower() in self.blacklist:
self.debug(f"Skipping adding [{val.strip()}] to wordlist because it was in the blacklist")
stripped_val = val.strip().lower()
if stripped_val:
# Check if the word is in the blacklist
if stripped_val in self.blacklist:
self.debug(f"Skipping adding [{stripped_val}] to wordlist because it was in the blacklist")
else:
if not prefix or val.strip().lower().startswith(prefix.strip().lower()):
if not any(char in val.strip().lower() for char in self.banned_characters):
# Check if it starts with the given prefix (if any)
if not prefix or stripped_val.startswith(prefix):
# Check if it contains any banned characters
if not any(char in banned_set for char in stripped_val):
line_count += 1
virtual_file.append(f"{val.strip().lower()}")
virtual_file.append(stripped_val)

virtual_file.append(self.canary)
return self.helpers.tempfile(virtual_file, pipe=False), line_count
Loading