diff --git a/Public/Default-ExecutionLogger.psm1 b/Public/Default-ExecutionLogger.psm1 index 854337c..6591c54 100644 --- a/Public/Default-ExecutionLogger.psm1 +++ b/Public/Default-ExecutionLogger.psm1 @@ -6,7 +6,18 @@ function Write-ExecutionLog($startTime, $stopTime, $technique, $testNum, $testNa if (!(Test-Path $logPath)) { New-Item $logPath -Force -ItemType File | Out-Null } - + if ($isWindows){ + $ipAddress = (Get-NetIPAddress | Where-Object { $_.PrefixOrigin -ne "WellKnown"}).IPAddress + } + elseif ($IsMacOS) { + $ipAddress = ifconfig -l | xargs -n1 ipconfig getifaddr + } + elseif ($IsLinux) { + $ipAddress = ip -4 -br addr show |sed -n -e 's/^.*UP\s* //p' + } + else { + $ipAddress = '' + } $timeUTC = (Get-Date($startTime).toUniversalTime() -uformat "%Y-%m-%dT%H:%M:%SZ").ToString() $timeLocal = (Get-Date($startTime) -uformat "%Y-%m-%dT%H:%M:%SZ").ToString() $msg = [PSCustomObject][ordered]@{ @@ -16,6 +27,7 @@ function Write-ExecutionLog($startTime, $stopTime, $technique, $testNum, $testNa "Test Number" = $testNum "Test Name" = $testName "Hostname" = $targetHostname + "IP Address" = $ipAddress "Username" = $targetUser "GUID" = $testGuid "ProcessId" = $res.ProcessId diff --git a/Public/Syslog-ExecutionLogger.psm1 b/Public/Syslog-ExecutionLogger.psm1 index b680cb0..a7eb2f4 100644 --- a/Public/Syslog-ExecutionLogger.psm1 +++ b/Public/Syslog-ExecutionLogger.psm1 @@ -5,6 +5,19 @@ function Start-ExecutionLog($startTime, $logPath, $targetHostname, $targetUser, function Write-ExecutionLog($startTime, $stopTime, $technique, $testNum, $testName, $testGuid, $testExecutor, $testDescription, $command, $logPath, $targetHostname, $targetUser, $res, $isWindows) { $timeUTC = (Get-Date($startTime).toUniversalTime() -uformat "%Y-%m-%dT%H:%M:%SZ").ToString() $timeLocal = (Get-Date($startTime) -uformat "%Y-%m-%dT%H:%M:%SZ").ToString() + if ($isWindows){ + $ipAddress = (Get-NetIPAddress | Where-Object { $_.PrefixOrigin -ne "WellKnown"}).IPAddress + } + elseif ($IsMacOS) { + $ipAddress = ifconfig -l | xargs -n1 ipconfig getifaddr + } + elseif ($IsLinux) { + $ipAddress = ip -4 -br addr show |sed -n -e 's/^.*UP\s* //p' + } + else { + $ipAddress = '' + } + $msg = [PSCustomObject][ordered]@{ "Execution Time (UTC)" = $timeUTC "Execution Time (Local)" = $timeLocal @@ -12,6 +25,7 @@ function Write-ExecutionLog($startTime, $stopTime, $technique, $testNum, $testNa "Test Number" = $testNum "Test Name" = $testName "Hostname" = $targetHostname + "IP Address" = $ipAddress "Username" = $targetUser "GUID" = $testGuid "Tag" = "atomicrunner"