-
Notifications
You must be signed in to change notification settings - Fork 166
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
Implement ignore feature #322
Conversation
Reviewer's Guide by SourceryThis pull request implements an "ignore" feature for wifite2, allowing users to ignore targets on the fly during scanning and attacks. The changes include modifications to handle ignored targets, display them, and provide user options to ignore targets during attacks. Sequence diagram for ignoring a target during an attacksequenceDiagram
actor User
participant AttackAll
participant CrackResult
User->>AttackAll: Initiate attack
AttackAll->>User: Prompt for action
User->>AttackAll: Choose 'Ignore'
AttackAll->>CrackResult: ignore_target(target)
CrackResult->>CrackResultIgnored: Create ignored target
CrackResultIgnored->>CrackResultIgnored: Save ignored target
CrackResultIgnored-->>CrackResult: Return to AttackAll
CrackResult-->>AttackAll: Return to User
AttackAll-->>User: Continue with next target
Class diagram for the new ignore featureclassDiagram
class CrackResult {
+save()
+display(result_type)
+load_all()
+load_ignored_bssids(ignore_cracked)
+load(json)
+ignore_target(target)
}
class CrackResultIgnored {
+bssid
+essid
+result_type
+dump()
+print_single_line(longest_essid)
+to_dict()
}
CrackResult <|-- CrackResultIgnored
class Answer {
<<enumeration>>
+Skip
+ExitOrReturn
+Continue
+Ignore
}
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @mendelgusmao - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider refactoring the
CrackResult
class to separate concerns. The class is taking on too many responsibilities with the new ignore feature. - Improve consistency in naming conventions and code style, particularly for the new
Answer
enum and throughout the newignored_result.py
file. - Enhance error handling and consider performance optimizations, especially in the
ignore_target
andload_ignored_bssids
methods.
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟡 Complexity: 1 issue found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
def __init__(self, bssid, essid): | ||
self.result_type = 'IGN' | ||
self.bssid = bssid | ||
self.essid = essid | ||
super(CrackResultIgnored, self).__init__() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Consider adding validation for bssid and essid parameters in the constructor
It might be beneficial to add some basic validation for the bssid
and essid
parameters in the constructor. This could include checking for correct format of BSSID and ensuring that ESSID is not empty or too long.
def __init__(self, bssid, essid):
if not self._is_valid_bssid(bssid):
raise ValueError("Invalid BSSID format")
if not essid or len(essid) > 32:
raise ValueError("ESSID must not be empty and not exceed 32 characters")
self.result_type = 'IGN'
self.bssid = bssid
self.essid = essid
super(CrackResultIgnored, self).__init__()
% (name, len(saved_results))) | ||
|
||
@classmethod | ||
def display(cls): | ||
""" Show cracked targets from cracked file """ | ||
def display(cls, result_type): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (complexity): Consider refactoring the 'display' method into smaller, more focused methods.
The display
method has indeed become more complex with the addition of the result_type
parameter and conditional logic. To improve readability and maintainability, consider refactoring this method into smaller, more focused methods:
- Extract the loading and filtering logic into a separate method:
def get_filtered_results(cls, result_type):
targets = cls.load_all()
if result_type == 'cracked':
return [item for item in targets if item.get('type') != 'IGN']
else:
return [item for item in targets if item.get('type') == 'IGN']
- Simplify the
display
method by using the newget_filtered_results
method:
@classmethod
def display(cls, result_type):
name = cls.cracked_file
if not os.path.exists(name):
Color.pl('{!} {O}file {C}%s{O} not found{W}' % name)
return
filtered_results = cls.get_filtered_results(result_type)
if len(filtered_results) == 0:
Color.pl('{!} {R}no results found in {O}%s{W}' % name)
return
Color.pl('\n{+} Displaying {G}%d{W} %s target(s) from {C}%s{W}\n' % (
len(filtered_results), 'cracked' if result_type == 'cracked' else 'ignored', cls.cracked_file))
results = sorted([cls.load(item) for item in filtered_results], key=lambda x: x.date, reverse=True)
cls.print_results_table(results, result_type == 'cracked')
- Create a new method for printing the results table:
@classmethod
def print_results_table(cls, results, show_key):
longest_essid = max(len(result.essid or 'ESSID') for result in results)
cls.print_table_header(longest_essid, show_key)
for result in results:
result.print_single_line(longest_essid)
Color.pl('')
@classmethod
def print_table_header(cls, longest_essid, show_key):
# ... (existing header printing code) ...
These changes separate concerns, making each method more focused and easier to understand. The display
method now orchestrates the overall process, while smaller methods handle specific tasks. This approach improves readability and makes future modifications easier.
You have a conflict, resolve this first and I'll merge 🥇 |
d02d7da
to
1ec5fe6
Compare
Just a small contribution for wifite2: option to ignore targets on the fly.
Summary by Sourcery
Implement an 'ignore' feature to allow users to skip specific targets during attacks and manage ignored targets. Enhance the display functionality to show both cracked and ignored targets, improving user control and visibility over attack results.
New Features:
Enhancements: