Small changes to wpa-sec.py

Signed-off-by: Jeroen Oudshoorn <oudshoorn.jeroen@gmail.com>
This commit is contained in:
Jeroen Oudshoorn
2024-12-20 08:55:08 +01:00
parent 35deab25f2
commit 7764e1dfdf

View File

@ -36,16 +36,15 @@ class WpaSec(plugins.Plugin):
"""
with open(path, 'rb') as file_to_upload:
cookie = {'key': self.options['api_key']}
payload = {'file': file_to_upload}
try:
result = requests.post(self.options['api_url'],
cookies=cookie,
files=payload,
files=file_to_upload,
timeout=timeout)
if result.status_code == 200:
if 'already submitted' in result.text:
logging.debug("%s was already submitted.", path)
if ' already submitted' in result.text:
logging.info("%s was already submitted.", path)
return False
return True
elif result.status_code != 200:
@ -108,7 +107,11 @@ class WpaSec(plugins.Plugin):
display = agent.view()
reported = self.report.data_field_or('reported', default=list())
handshake_dir = config['bettercap']['handshakes']
handshake_filenames = os.listdir(handshake_dir)
try:
handshake_filenames = os.listdir(handshake_dir)
except FileNotFoundError:
logging.info("WPA_SEC: Handshake directory doesn't exist.")
return
handshake_paths = [os.path.join(handshake_dir, filename) for filename in handshake_filenames if filename.endswith('.pcap')]
handshake_paths = remove_whitelisted(handshake_paths, config['main']['whitelist'])
handshake_new = set(handshake_paths) - set(reported) - set(self.skip)