@@ -101,6 +101,10 @@ def _sanitize_message(cls, message: str) -> str:
101101 - Known wpa-sec API key from Configuration.wpasec_api_key
102102 - Command-line API key arguments like "-k <value>" and "--key <value>"
103103 - MAC addresses in standard hex notation (aa:bb:cc:dd:ee:ff)
104+ - WPA/WEP keys from aircrack "KEY FOUND! [ <key> ]" output
105+ - Live passphrase progress "Current passphrase: <value>"
106+ - Hashcat cracked output "hash*bssid*station*essid:<password>"
107+ - Generic PSK/passphrase/password keyword-value pairs
104108 """
105109 try :
106110 # Import lazily to avoid circular imports during module initialization
@@ -121,10 +125,10 @@ def _sanitize_message(cls, message: str) -> str:
121125 # Never let sanitization break logging
122126 pass
123127
128+ import re
129+
124130 # Mask common CLI key patterns: "-k <value>" and "--key <value>"
125131 try :
126- import re
127-
128132 def _mask_cli_key (match ):
129133 flag = match .group (1 )
130134 return f"{ flag } ****"
@@ -136,8 +140,6 @@ def _mask_cli_key(match):
136140
137141 # Mask MAC addresses: aa:bb:cc:dd:ee:ff -> aa:bb:cc:**:**:**
138142 try :
139- import re
140-
141143 def _mask_mac (match ):
142144 full = match .group (0 )
143145 parts = full .split (":" )
@@ -149,6 +151,46 @@ def _mask_mac(match):
149151 except Exception :
150152 pass
151153
154+ # Mask aircrack "KEY FOUND! [ <key> ]" output
155+ try :
156+ sanitized = re .sub (r"(KEY FOUND!\s*\[)\s*\S.*?\s*(\])" , r"\1 **** \2" , sanitized )
157+ except Exception :
158+ pass
159+
160+ # Mask aircrack live progress "Current passphrase: <value>"
161+ try :
162+ sanitized = re .sub (
163+ r"(Current\s+passphrase\s*:)\s*\S.*" ,
164+ r"\1 ****" ,
165+ sanitized ,
166+ flags = re .IGNORECASE ,
167+ )
168+ except Exception :
169+ pass
170+
171+ # Mask hashcat cracked output: trailing :<password> after PMKID/hash lines
172+ # Format: hash*bssid*station*essid:password or hash:password
173+ try :
174+ sanitized = re .sub (
175+ r"([0-9a-fA-F\*]{20,}:[^:\n]{0,64}):[^\n]+$" ,
176+ r"\1:****" ,
177+ sanitized ,
178+ flags = re .MULTILINE ,
179+ )
180+ except Exception :
181+ pass
182+
183+ # Mask generic keyword-value pairs: password/passphrase/psk followed by
184+ # a delimiter (=, :, space) and a value
185+ try :
186+ sanitized = re .sub (
187+ r"(?i)(password|passphrase|psk|wpa_psk|wpa_passphrase)\s*[=:]\s*\S+" ,
188+ r"\1=****" ,
189+ sanitized ,
190+ )
191+ except Exception :
192+ pass
193+
152194 return sanitized
153195
154196 @classmethod
0 commit comments