Repository navigation
Expand file tree
/
Copy pathtest_cli_syntax.ps1
More file actions
37 lines (37 loc) · 1.79 KB
/
Copy pathtest_cli_syntax.ps1
File metadata and controls
37 lines (37 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
param([Parameter(Mandatory)][string]$BinaryPath)
$ErrorActionPreference = 'Stop'
$cases = @(
@{ Args=@('--cli','--help'); Exit=0; Match='Observe' },
@{ Args=@('--cli','/help'); Exit=0; Match='Observe' },
@{ Args=@('--cli','run','--help'); Exit=0; Match='Observe' },
@{ Args=@('/version'); Exit=0; Match='SPOOK' },
@{ Args=@('--cli','--api'); Exit=2; Match='requires a hook' },
@{ Args=@('--cli','/api'); Exit=2; Match='requires a hook' },
@{ Args=@('--cli','--loader','bad'); Exit=2; Match='unknown loader' },
@{ Args=@('--cli','/loader:bad'); Exit=2; Match='unknown loader' },
@{ Args=@('--cli','--unknown'); Exit=2; Match='unknown option' }
)
# A deliberately missing target exercises parsing without executing a target.
foreach ($switches in @(
@('--api','NtQueryInformationProcess','--stack'),
@('/stack','/api:NtQueryInformationProcess'),
@('/api','NtQueryInformationProcess','/registers'),
@('--quiet','--api','NtQueryInformationProcess'),
@('--deny','--api','NtQueryInformationProcess'),
@('--group','memory'), @('/group:memory'),
@('--lhook','NtQueryInformationProcess','--stack-trace'),
@('--loader','standard','--api','NtQueryInformationProcess')
)) {
$cases += @{ Args=@('--cli','run') + $switches + @('--','Z:\skugga-missing-cli-fixture.exe','/target-option'); Exit=2; Match='missing target: Z:' }
}
foreach ($case in $cases) {
$arguments = $case.Args
$output = (& $BinaryPath @arguments 2>&1) -join "`n"
if ($LASTEXITCODE -ne $case.Exit -or $output -notmatch $case.Match) {
throw "CLI case failed: $($arguments -join ' ')`n$output"
}
if ($output -match 'WATCH IT UNFOLD|SKUGGA - owned-process user-mode sensor runner') {
throw 'Obsolete banner found'
}
}
Write-Output "$($cases.Count) CLI syntax cases passed"