-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Invoke-ATHRemoteFXvGPUDisablementCommand
- Loading branch information
1 parent
f734b9d
commit 2f65db8
Showing
4 changed files
with
391 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
...Harnesses/T1218_SignedBinaryProxyExecution/InvokeRemoteFXvGPUDisablementCommand.Tests.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
Set-StrictMode -Version Latest | ||
|
||
$TestScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent | ||
$ModuleRoot = Resolve-Path "$TestScriptRoot\..\..\" | ||
$ModuleManifest = "$ModuleRoot\AtomicTestHarnesses.psd1" | ||
|
||
Remove-Module [A]tomicTestHarnesses | ||
Import-Module $ModuleManifest -Force -ErrorAction Stop | ||
|
||
Describe 'Invoke-ATHRemoteFXvGPUDisablementCommand' { | ||
BeforeAll { | ||
$Help = Get-Help -Name Invoke-ATHRemoteFXvGPUDisablementCommand -Full | ||
|
||
$ExpectedTechniqueID = $null | ||
|
||
if ($Help.Synopsis.Split("`r`n")[-1] -match '^(?-i:Technique ID: )(?<TechniqueID>\S+) (?<TechniqueDescription>\(.+\))$') { | ||
$ExpectedTechniqueID = $Matches['TechniqueID'] | ||
} | ||
|
||
$FixedTestGuid = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' | ||
} | ||
|
||
Context 'Validating error conditions' -Tag 'Unit', 'T1218' { | ||
It 'should not execute an EXE that is not RemoteFXvGPUDisablement.exe' -Tag 'Unit', 'T1218' { | ||
{ Invoke-ATHRemoteFXvGPUDisablementCommand -RemoteFXvGPUDisablementFilePath "$Env:windir\System32\notepad.exe" -ErrorAction Stop } | Should -Throw | ||
} | ||
} | ||
|
||
Context 'Expected artifacts and behaviors when exercising the attack technique' -Tag 'Technique', 'T1218' { | ||
It 'should execute using default options' -Tag 'Technique', 'T1218' { | ||
$Result = Invoke-ATHRemoteFXvGPUDisablementCommand -TestGuid $FixedTestGuid | ||
|
||
$Result | Should -Not -BeNullOrEmpty | ||
|
||
$Result.TechniqueID | Should -BeExactly $ExpectedTechniqueID | ||
$Result.TestSuccess | Should -BeTrue | ||
$Result.TestGuid | Should -BeExactly $FixedTestGuid | ||
$Result.ModulePath | Should -Not -BeNullOrEmpty | ||
$Result.ModuleContents | Should -Not -BeNullOrEmpty | ||
$Result.ModuleFileHash | Should -Not -BeNullOrEmpty | ||
$Result.RunnerFilePath | Should -Match '\\System32\\RemoteFXvGPUDisablement.exe$' | ||
$Result.RunnerProcessId | Should -Not -BeNullOrEmpty | ||
$Result.RunnerCommandLine | Should -Match '\\System32\\RemoteFXvGPUDisablement.exe" Disable$' | ||
$Result.RunnerChildProcessId | Should -Not -BeNullOrEmpty | ||
$Result.RunnerChildProcessCommandLine | Should -MatchExactly "$($FixedTestGuid)`$" | ||
} | ||
|
||
It 'should execute from a non-standard path' -Tag 'Technique', 'T1218' { | ||
$AlternatePath = "$env:windir\Temp\notepad.exe" | ||
|
||
Copy-Item -Path "$Env:windir\System32\RemoteFXvGPUDisablement.exe" -Destination $AlternatePath -ErrorAction Stop | ||
|
||
$Result = Invoke-ATHRemoteFXvGPUDisablementCommand -RemoteFXvGPUDisablementFilePath $AlternatePath -TestGuid $FixedTestGuid | ||
|
||
$Result | Should -Not -BeNullOrEmpty | ||
|
||
$Result.TechniqueID | Should -BeExactly $ExpectedTechniqueID | ||
$Result.TestSuccess | Should -BeTrue | ||
$Result.TestGuid | Should -BeExactly $FixedTestGuid | ||
$Result.ModulePath | Should -Not -BeNullOrEmpty | ||
$Result.ModuleContents | Should -Not -BeNullOrEmpty | ||
$Result.ModuleFileHash | Should -Not -BeNullOrEmpty | ||
$Result.RunnerFilePath | Should -BeExactly "$AlternatePath" | ||
$Result.RunnerProcessId | Should -Not -BeNullOrEmpty | ||
$Result.RunnerCommandLine | Should -BeExactly "`"$AlternatePath`" Disable" | ||
$Result.RunnerChildProcessId | Should -Not -BeNullOrEmpty | ||
$Result.RunnerChildProcessCommandLine | Should -MatchExactly "$($FixedTestGuid)`$" | ||
|
||
Remove-Item -Path $AlternatePath -Force -ErrorAction SilentlyContinue | ||
} | ||
|
||
It 'should execute using a module path that is not specified in %PSModulePath%' -Tag 'Technique', 'T1218' { | ||
$Result = Invoke-ATHRemoteFXvGPUDisablementCommand -ModulePath $Env:TEMP -TestGuid $FixedTestGuid | ||
|
||
$Result | Should -Not -BeNullOrEmpty | ||
|
||
$Result.TechniqueID | Should -BeExactly $ExpectedTechniqueID | ||
$Result.TestSuccess | Should -BeTrue | ||
$Result.TestGuid | Should -BeExactly $FixedTestGuid | ||
$Result.ModulePath.StartsWith("$Env:TEMP") | Should -BeTrue | ||
$Result.ModuleContents | Should -Not -BeNullOrEmpty | ||
$Result.ModuleFileHash | Should -Not -BeNullOrEmpty | ||
$Result.RunnerFilePath | Should -Match '\\System32\\RemoteFXvGPUDisablement.exe$' | ||
$Result.RunnerProcessId | Should -Not -BeNullOrEmpty | ||
$Result.RunnerCommandLine | Should -Match '\\System32\\RemoteFXvGPUDisablement.exe" Disable$' | ||
$Result.RunnerChildProcessId | Should -Not -BeNullOrEmpty | ||
$Result.RunnerChildProcessCommandLine | Should -MatchExactly "$($FixedTestGuid)`$" | ||
} | ||
} | ||
} |
Oops, something went wrong.