Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Invoke-AtomicTest.ps1 #182

Merged
merged 1 commit into from
Dec 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions Public/Invoke-AtomicTest.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function Invoke-AtomicTest {
function Invoke-AtomicTest {
[CmdletBinding(DefaultParameterSetName = 'technique',
SupportsShouldProcess = $true,
PositionalBinding = $false,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Comment on lines -196 to -213
Copy link
Collaborator Author

@cyberbuff cyberbuff Dec 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code for converting short form to TestNumbers lies within the isLoggingModuleSet condition. This should happen regardless of whether LoggingModule has been defined.

$commandLine = "Invoke-AtomicTest $AtomicTechnique"

Expand Down Expand Up @@ -526,4 +526,4 @@

} # End of PROCESS block
END { } # Intentionally left blank and can be removed
}
}
Loading