Repository navigation
Expand file tree
/
Copy pathAddHashList.ps1
More file actions
59 lines (50 loc) · 1.69 KB
/
Copy pathAddHashList.ps1
File metadata and controls
59 lines (50 loc) · 1.69 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<#
.SYNOPSIS
Add hashes to an application capture
.DESCRIPTION
Add a list of hashes to an application capture. These hashes must already exist in the Airlock repository.
Loads API key and URL from a config file if it exists.
.PARAMETER File
The file to read the hashes from.
.PARAMETER AppCapture
The name of the application capture to add the hashes to.
.PARAMETER APIKey
Optional API key to use.
.PARAMETER AirlockURL
Optional URL to use.
.EXAMPLE
.\AddHashList.ps1 -File '.\NewHashes.txt' -AppCapture 'MyApp'
#>
[CmdletBinding()]
param
(
[Parameter(Mandatory = $true)]
[string]$File,
[Parameter(Mandatory = $true)]
[string]$AppCapture,
[Parameter()]
[string]$APIKey,
[Parameter()]
[string]$AirlockURL
)
Set-StrictMode -Version Latest
Import-Module -Name .\AirlockFunctions.psm1 -Force
Get-Config -APIKey $APIKey -AirlockURL $AirlockURL
$HashFileContent = Get-Content -Path $File | Where-Object { $_ -and $_.Trim() } | Where-Object {$_.Length -eq 64}
$AppCaptures = Get-AppCapturesFromAirlock
$AppCaptureID = $AppCaptures | Where-Object {$_.Name -eq $AppCapture} | Select-Object -First 1 -ExpandProperty ID
if (!$AppCaptureID) {
Write-Host -ForegroundColor Red "Application capture '$AppCapture' not found"
exit
}
Write-Host -ForegroundColor DarkGreen 'I found:'
Write-Host -ForegroundColor Green "$($HashFileContent.Count) hashes"
$title = ''
$question = 'Add them?'
$choices = '&Yes', '&No'
$decision = $Host.UI.PromptForChoice($title, $question, $choices, 1)
if ($decision -eq 1) {
exit
}
Add-HashesToApplicationCapture -ApplicationID $AppCaptureID -SHA256Hashes $HashFileContent
Write-Host -ForegroundColor Green 'Hashes added to AppCapture'