Skip to content

Commit 31b909b

Browse files
committed
Check if there is a history before saving
1 parent 5da577f commit 31b909b

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

nxc/modules/powershell_history.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def on_admin_login(self, context, connection):
5353

5454
# Check if export is enabled
5555
context.log.info(f"Export option is set to: {self.export}")
56-
if self.export:
56+
if self.export and history:
5757
host = connection.host # Assuming 'host' contains the target IP or hostname
5858
filename = f"{host}_powershell_history.txt"
5959
export_path = join(NXC_PATH, "modules", "powershell_history")
@@ -68,7 +68,6 @@ def on_admin_login(self, context, connection):
6868
context.log.highlight(f"PowerShell history written to: {path}")
6969
except Exception as e:
7070
context.log.fail(f"Failed to write history to {filename}: {e}")
71-
7271
except Exception as e:
7372
context.log.fail(f"UNEXPECTED ERROR: {e}")
7473
context.log.debug(traceback.format_exc())

0 commit comments

Comments
 (0)