diff --git a/Public/Invoke-AtomicTest.ps1 b/Public/Invoke-AtomicTest.ps1 index 0df73dc..a567507 100644 --- a/Public/Invoke-AtomicTest.ps1 +++ b/Public/Invoke-AtomicTest.ps1 @@ -1,4 +1,4 @@ -function Invoke-AtomicTest { +function Invoke-AtomicTest { [CmdletBinding(DefaultParameterSetName = 'technique', SupportsShouldProcess = $true, PositionalBinding = $false, @@ -135,6 +135,24 @@ $executionPlatform, $isElevated, $tmpDir, $executionHostname, $executionUser = Get-TargetInfo $Session $PathToPayloads = if ($Session) { "$tmpDir`AtomicRedTeam" } else { $PathToAtomicsFolder } + # Since there might a comma(T1559-1,2,3) Powershell takes it as array. + # So converting it back to string. + if ($AtomicTechnique -is [array]) { + $AtomicTechnique = $AtomicTechnique -join "," + } + + # Splitting Atomic Technique short form into technique and test numbers. + $AtomicTechniqueParams = ($AtomicTechnique -split '-') + $AtomicTechnique = $AtomicTechniqueParams[0] + + if ($AtomicTechniqueParams.Length -gt 1) { + $ShortTestNumbers = $AtomicTechniqueParams[-1] + } + + if ($null -eq $TestNumbers -and $null -ne $ShortTestNumbers) { + $TestNumbers = $ShortTestNumbers -split ',' + } + $isLoggingModuleSet = $false if (-not $NoExecutionLog) { $isLoggingModuleSet = $true @@ -193,24 +211,6 @@ return } - # Since there might a comma(T1559-1,2,3) Powershell takes it as array. - # So converting it back to string. - if ($AtomicTechnique -is [array]) { - $AtomicTechnique = $AtomicTechnique -join "," - } - - # Splitting Atomic Technique short form into technique and test numbers. - $AtomicTechniqueParams = ($AtomicTechnique -split '-') - $AtomicTechnique = $AtomicTechniqueParams[0] - - if ($AtomicTechniqueParams.Length -gt 1) { - $ShortTestNumbers = $AtomicTechniqueParams[-1] - } - - if ($null -eq $TestNumbers -and $null -ne $ShortTestNumbers) { - $TestNumbers = $ShortTestNumbers -split ',' - } - # Here we're rebuilding an equivalent command line to put in the logs $commandLine = "Invoke-AtomicTest $AtomicTechnique" @@ -526,4 +526,4 @@ } # End of PROCESS block END { } # Intentionally left blank and can be removed -} \ No newline at end of file +}