diff --git a/nxc/protocols/smb/firefox.py b/nxc/protocols/smb/firefox.py index 01829962d..d3e41b087 100644 --- a/nxc/protocols/smb/firefox.py +++ b/nxc/protocols/smb/firefox.py @@ -4,6 +4,7 @@ import hmac import json import ntpath +import os import sqlite3 import tempfile from Cryptodome.Cipher import AES, DES3 @@ -121,7 +122,10 @@ def get_login_data(self, logins_data): ] def get_key(self, key4_data, master_password=b""): - fh = tempfile.NamedTemporaryFile() + # Instead of disabling "delete" and removing the file manually, + # in the future (py3.12) we could use "delete_on_close=False" as a cleaner solution + # Related issue: #134 + fh = tempfile.NamedTemporaryFile(delete=False) fh.write(key4_data) fh.seek(0) db = sqlite3.connect(fh.name) @@ -149,7 +153,9 @@ def get_key(self, key4_data, master_password=b""): self.logger.debug(e) fh.close() return b"" + db.close() fh.close() + os.remove(fh.name) def is_master_password_correct(self, key_data, master_password=b""): try: