Skip to content

Commit a1a1be6

Browse files
committed
Refactor output file path construction in SMB protocol
- Updated the output file template to use os.path.join for improved OS compatibility. - Enhanced readability by separating base log directory and filename pattern construction.
1 parent 024ff0a commit a1a1be6

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

nxc/protocols/smb.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,10 @@ def enum_host_info(self):
287287
self.logger.debug(e)
288288

289289
self.os_arch = self.get_os_arch()
290-
self.output_file_template = os.path.expanduser(f"{NXC_PATH}/logs/{{output_folder}}/{self.hostname}_{self.host}_{datetime.now().strftime('%Y-%m-%d_%H%M%S')}".replace(":", "-"))
290+
# Construct the output file template using os.path.join for OS compatibility
291+
base_log_dir = os.path.join(os.path.expanduser(NXC_PATH), "logs")
292+
filename_pattern = f"{self.hostname}_{self.host}_{datetime.now().strftime('%Y-%m-%d_%H%M%S')}".replace(":", "-")
293+
self.output_file_template = os.path.join(base_log_dir, "{output_folder}", filename_pattern)
291294

292295
try:
293296
# DCs seem to want us to logoff first, windows workstations sometimes reset the connection

0 commit comments

Comments
 (0)