From a140c9479c0d36018950c3808710803a991d066a Mon Sep 17 00:00:00 2001 From: Deft_ Date: Tue, 15 Oct 2024 19:59:22 +0200 Subject: [PATCH 1/2] Minor code optimization Signed-off-by: Deft_ --- nxc/modules/recent_files.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nxc/modules/recent_files.py b/nxc/modules/recent_files.py index bee613af44..c8e01ea742 100644 --- a/nxc/modules/recent_files.py +++ b/nxc/modules/recent_files.py @@ -19,21 +19,21 @@ def options(self, context, module_options): def on_admin_login(self, context, connection): lnks = [] for directory in connection.conn.listPath("C$", "Users\\*"): - if directory.get_longname() not in self.false_positive and directory.is_directory() > 0: + if directory.get_longname() not in self.false_positive and directory.is_directory(): context.log.highlight(f"C:\\{directory.get_longname()}") recent_files_dir = f"Users\\{directory.get_longname()}\\AppData\\Roaming\\Microsoft\\Windows\\Recent\\" for file in connection.conn.listPath("C$", f"{recent_files_dir}\\*"): file_path = f"{recent_files_dir}{file.get_longname()}" - if file.get_longname() not in self.false_positive: + if file.get_longname() not in self.false_positive and not file.is_directory(): file_path = f"{recent_files_dir}{file.get_longname()}" try: buf = BytesIO() connection.conn.getFile("C$", file_path, buf.write) buf.seek(0) - lnk = pylnk3.parse(buf).path + lnk = pylnk3.parse(buf).path.strip() if lnk and lnk not in lnks: context.log.highlight(f"\t{lnk}") lnks.append(lnk) except Exception as e: - # needed because of hidden directories in the Recents directory + # Sometimes PyLnk3 can't parse the lnk file... context.log.debug(f"Couldn't open {file_path} because of {e}") From 0cdd60a60f9a5f16851239d1af923eb0e7992ccf Mon Sep 17 00:00:00 2001 From: Alexander Neff Date: Tue, 1 Apr 2025 19:21:05 -0400 Subject: [PATCH 2/2] Add no options text --- nxc/modules/recent_files.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nxc/modules/recent_files.py b/nxc/modules/recent_files.py index c8e01ea742..0a1059e069 100644 --- a/nxc/modules/recent_files.py +++ b/nxc/modules/recent_files.py @@ -14,7 +14,7 @@ class NXCModule: false_positive = [".", "..", "desktop.ini", "Public", "Default", "Default User", "All Users", ".NET v4.5", ".NET v4.5 Classic"] def options(self, context, module_options): - """""" + """No options""" def on_admin_login(self, context, connection): lnks = []