1
+ Set-StrictMode - Version Latest
2
+
3
+ $TestScriptRoot = Split-Path $MyInvocation.MyCommand.Path - Parent
4
+ $ModuleRoot = Resolve-Path " $TestScriptRoot \..\..\"
5
+ $ModuleManifest = " $ModuleRoot \AtomicTestHarnesses.psd1"
6
+
7
+ Remove-Module [A ]tomicTestHarnesses
8
+ Import-Module $ModuleManifest - Force - ErrorAction Stop
9
+
10
+ Describe ' Invoke-ATHRemoteFXvGPUDisablementCommand' {
11
+ BeforeAll {
12
+ $Help = Get-Help - Name Invoke-ATHRemoteFXvGPUDisablementCommand - Full
13
+
14
+ $ExpectedTechniqueID = $null
15
+
16
+ if ($Help.Synopsis.Split (" `r`n " )[-1 ] -match ' ^(?-i:Technique ID: )(?<TechniqueID>\S+) (?<TechniqueDescription>\(.+\))$' ) {
17
+ $ExpectedTechniqueID = $Matches [' TechniqueID' ]
18
+ }
19
+
20
+ $FixedTestGuid = ' aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
21
+ }
22
+
23
+ Context ' Validating error conditions' - Tag ' Unit' , ' T1218' {
24
+ It ' should not execute an EXE that is not RemoteFXvGPUDisablement.exe' - Tag ' Unit' , ' T1218' {
25
+ { Invoke-ATHRemoteFXvGPUDisablementCommand - RemoteFXvGPUDisablementFilePath " $Env: windir \System32\notepad.exe" - ErrorAction Stop } | Should - Throw
26
+ }
27
+ }
28
+
29
+ Context ' Expected artifacts and behaviors when exercising the attack technique' - Tag ' Technique' , ' T1218' {
30
+ It ' should execute using default options' - Tag ' Technique' , ' T1218' {
31
+ $Result = Invoke-ATHRemoteFXvGPUDisablementCommand - TestGuid $FixedTestGuid
32
+
33
+ $Result | Should -Not - BeNullOrEmpty
34
+
35
+ $Result.TechniqueID | Should - BeExactly $ExpectedTechniqueID
36
+ $Result.TestSuccess | Should - BeTrue
37
+ $Result.TestGuid | Should - BeExactly $FixedTestGuid
38
+ $Result.ModulePath | Should -Not - BeNullOrEmpty
39
+ $Result.ModuleContents | Should -Not - BeNullOrEmpty
40
+ $Result.ModuleFileHash | Should -Not - BeNullOrEmpty
41
+ $Result.RunnerFilePath | Should -Match ' \\System32\\RemoteFXvGPUDisablement.exe$'
42
+ $Result.RunnerProcessId | Should -Not - BeNullOrEmpty
43
+ $Result.RunnerCommandLine | Should -Match ' \\System32\\RemoteFXvGPUDisablement.exe" Disable$'
44
+ $Result.RunnerChildProcessId | Should -Not - BeNullOrEmpty
45
+ $Result.RunnerChildProcessCommandLine | Should - MatchExactly " $ ( $FixedTestGuid ) `$ "
46
+ }
47
+
48
+ It ' should execute from a non-standard path' - Tag ' Technique' , ' T1218' {
49
+ $AlternatePath = " $env: windir \Temp\notepad.exe"
50
+
51
+ Copy-Item - Path " $Env: windir \System32\RemoteFXvGPUDisablement.exe" - Destination $AlternatePath - ErrorAction Stop
52
+
53
+ $Result = Invoke-ATHRemoteFXvGPUDisablementCommand - RemoteFXvGPUDisablementFilePath $AlternatePath - TestGuid $FixedTestGuid
54
+
55
+ $Result | Should -Not - BeNullOrEmpty
56
+
57
+ $Result.TechniqueID | Should - BeExactly $ExpectedTechniqueID
58
+ $Result.TestSuccess | Should - BeTrue
59
+ $Result.TestGuid | Should - BeExactly $FixedTestGuid
60
+ $Result.ModulePath | Should -Not - BeNullOrEmpty
61
+ $Result.ModuleContents | Should -Not - BeNullOrEmpty
62
+ $Result.ModuleFileHash | Should -Not - BeNullOrEmpty
63
+ $Result.RunnerFilePath | Should - BeExactly " $AlternatePath "
64
+ $Result.RunnerProcessId | Should -Not - BeNullOrEmpty
65
+ $Result.RunnerCommandLine | Should - BeExactly " `" $AlternatePath `" Disable"
66
+ $Result.RunnerChildProcessId | Should -Not - BeNullOrEmpty
67
+ $Result.RunnerChildProcessCommandLine | Should - MatchExactly " $ ( $FixedTestGuid ) `$ "
68
+
69
+ Remove-Item - Path $AlternatePath - Force - ErrorAction SilentlyContinue
70
+ }
71
+
72
+ It ' should execute using a module path that is not specified in %PSModulePath%' - Tag ' Technique' , ' T1218' {
73
+ $Result = Invoke-ATHRemoteFXvGPUDisablementCommand - ModulePath $Env: TEMP - TestGuid $FixedTestGuid
74
+
75
+ $Result | Should -Not - BeNullOrEmpty
76
+
77
+ $Result.TechniqueID | Should - BeExactly $ExpectedTechniqueID
78
+ $Result.TestSuccess | Should - BeTrue
79
+ $Result.TestGuid | Should - BeExactly $FixedTestGuid
80
+ $Result.ModulePath.StartsWith (" $Env: TEMP " ) | Should - BeTrue
81
+ $Result.ModuleContents | Should -Not - BeNullOrEmpty
82
+ $Result.ModuleFileHash | Should -Not - BeNullOrEmpty
83
+ $Result.RunnerFilePath | Should -Match ' \\System32\\RemoteFXvGPUDisablement.exe$'
84
+ $Result.RunnerProcessId | Should -Not - BeNullOrEmpty
85
+ $Result.RunnerCommandLine | Should -Match ' \\System32\\RemoteFXvGPUDisablement.exe" Disable$'
86
+ $Result.RunnerChildProcessId | Should -Not - BeNullOrEmpty
87
+ $Result.RunnerChildProcessCommandLine | Should - MatchExactly " $ ( $FixedTestGuid ) `$ "
88
+ }
89
+ }
90
+ }
0 commit comments