Skip to content

Conversation

@JustGuardian
Copy link

@JustGuardian JustGuardian commented Nov 4, 2025

This modification is a fix for #419 . That behavior happened because Wifite considers a handshake “captured” if any validator (tshark, cowpatty, or aircrack-ng) returns a positive result but I've noticed aircrack-ng every time reports a handshake as valid even when no real EAPOL exchange is present in the capture file. The fix introduces stricter validation, requiring at least one between tshark or cowpatty to confirm the handshake before it’s accepted.

Summary by Sourcery

Bug Fixes:

  • Prevent aircrack-ng alone from counting as a valid handshake to avoid false positives

@sourcery-ai
Copy link

sourcery-ai bot commented Nov 4, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Refine handshake validation by enforcing stricter checks: only accept captures validated by tshark or cowpatty and reject aircrack-only/hcxpcapngtool results to eliminate false positives.

Class diagram for updated handshake validation logic

classDiagram
    class Handshake {
        +has_handshake()
        +tshark_handshakes()
        +cowpatty_handshakes()
        +aircrack_handshakes()
        +hcxpcapngtool_handshakes()
    }
    Handshake : has_handshake() updated
    Handshake : Only returns True if tshark or cowpatty detects handshake
    Handshake : aircrack-only and hcxpcapngtool-only results are ignored
Loading

Flow diagram for new handshake validation decision process

flowchart TD
    A["Start handshake validation"] --> B["Check tshark_handshakes"]
    B -- "Found" --> E["Return True (valid handshake)"]
    B -- "Not found" --> C["Check cowpatty_handshakes"]
    C -- "Found" --> E
    C -- "Not found" --> D["Reject (Return False)"]
Loading

File-Level Changes

Change Details Files
Stricter handshake acceptance logic requiring tshark or cowpatty confirmations
  • Replaced OR-based combination of all validators with sequential checks for tshark then cowpatty
  • Removed aircrack_handshakes() and hcxpcapngtool_handshakes() from validation path
  • Updated inline comments to explain preference for strict validators and rationale
wifite/model/handshake.py

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `wifite/model/handshake.py:75-79` </location>
<code_context>
    def has_handshake(self):
        if not self.bssid or not self.essid:
            self.divine_bssid_and_essid()

        #return len(self.tshark_handshakes()) > 0
        # Prefer strict validators. Do NOT accept aircrack alone as proof.
        # Tshark requires the full 4-way (strict) — keep it.
        if len(self.tshark_handshakes()) > 0:
            return True

        # cowpatty can be reliable for 2&3 captures
        if len(self.cowpatty_handshakes()) > 0:
            return True

        # Do NOT treat aircrack-only as valid (aircrack is informative but not definitive)
        return False

</code_context>

<issue_to_address>
**suggestion (code-quality):** We've found these issues:

- Lift code into else after jump in control flow ([`reintroduce-else`](https://docs.sourcery.ai/Reference/Default-Rules/refactorings/reintroduce-else/))
- Replace if statement with if expression ([`assign-if-exp`](https://docs.sourcery.ai/Reference/Default-Rules/refactorings/assign-if-exp/))
- Simplify boolean if expression ([`boolean-if-exp-identity`](https://docs.sourcery.ai/Reference/Default-Rules/refactorings/boolean-if-exp-identity/))
- Remove unnecessary casts to int, str, float or bool ([`remove-unnecessary-cast`](https://docs.sourcery.ai/Reference/Default-Rules/refactorings/remove-unnecessary-cast/))

```suggestion
        return len(self.cowpatty_handshakes()) > 0
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@kimocoder kimocoder merged commit e6ab0e5 into kimocoder:master Nov 5, 2025
11 of 12 checks passed
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