From cb44d09df795e48c032a3a05d97181e1cefe736f Mon Sep 17 00:00:00 2001 From: mpgn Date: Tue, 17 Dec 2024 21:08:00 +0100 Subject: [PATCH] fix ruff --- nxc/modules/notepad++.py | 2 +- nxc/modules/powershell_history.py | 10 +++------- nxc/modules/shadowrdp.py | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/nxc/modules/notepad++.py b/nxc/modules/notepad++.py index 54f19faf..9450e2bc 100644 --- a/nxc/modules/notepad++.py +++ b/nxc/modules/notepad++.py @@ -20,7 +20,7 @@ class NXCModule: def on_admin_login(self, context, connection): found = 0 - for directory in connection.conn.listPath("C$", "Users\\*"): + for directory in connection.conn.listPath("C$", "Users\\*"): if directory.get_longname() not in self.false_positive and directory.is_directory(): try: notepad_backup_dir = f"Users\\{directory.get_longname()}\\AppData\\Roaming\\Notepad++\\backup\\" diff --git a/nxc/modules/powershell_history.py b/nxc/modules/powershell_history.py index c410d3b1..3e531dc3 100644 --- a/nxc/modules/powershell_history.py +++ b/nxc/modules/powershell_history.py @@ -25,7 +25,7 @@ class NXCModule: self.export = bool(module_options.get("EXPORT", False)) def on_admin_login(self, context, connection): - for directory in connection.conn.listPath("C$", "Users\\*"): + for directory in connection.conn.listPath("C$", "Users\\*"): if directory.get_longname() not in self.false_positive and directory.is_directory(): try: powershell_history_dir = f"Users\\{directory.get_longname()}\\AppData\\Roaming\\Microsoft\\Windows\\PowerShell\\PSReadLine\\" @@ -37,12 +37,8 @@ class NXCModule: connection.conn.getFile("C$", file_path, buf.write) buf.seek(0) file_content = buf.read().decode("utf-8", errors="ignore").lower() - keywords = [] - for keyword in self.sensitive_keywords: - if keyword in file_content: - keywords.append(keyword.upper()) - - if keyword: + keywords = [keyword.upper() for keyword in self.sensitive_keywords if keyword in file_content] + if len(keywords): context.log.highlight(f"C:\\{file_path} [ {' '.join(keywords)} ]") else: context.log.highlight(f"C:\\{file_path}") diff --git a/nxc/modules/shadowrdp.py b/nxc/modules/shadowrdp.py index 040cb645..40ad8120 100644 --- a/nxc/modules/shadowrdp.py +++ b/nxc/modules/shadowrdp.py @@ -38,7 +38,7 @@ class NXCModule: remoteOps._RemoteOperations__rrp, regHandle, "Software\\Policies\\Microsoft\\Windows NT\\Terminal Services\\" - )['phkResult'] + )["phkResult"] # Checks if the key already exists or not try: