-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCylance-Threats.ps1
37 lines (33 loc) · 1.04 KB
/
Cylance-Threats.ps1
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
$path = $ScriptDir = Split-Path $script:MyInvocation.MyCommand.Path
. $path"\Cylance-Const.ps1"
function Get-Threat {
param(
[Parameter(Mandatory=$true)][string] $sha256_id
)
$res = Invoke-WebRequest ($THREAT_URL+'/'+$sha256_id) `
-Headers $header -Method GET
return $res.Content
}
function Get-Threats {
param(
[Parameter(Mandatory=$false)][string] $query_string
)
$res = Invoke-WebRequest ($THREAT_URL+$query_string) `
-Headers $header -Method GET
return $res.Content | convertfrom-json
}
function Get-AllThreats {
param(
[Parameter(Mandatory=$false)][string] $query_string
)
$page_content = @()
$res = Get-Threats -query_string '?page_size=100'
$res.total_pages
$page_content += $res.page_items
for($page= 2; $page -le $res.total_pages; $page++){
Write-Host "Fetching page:"$page
$r = Get-Threats -query_string ('?page='+$page+'&page_size=100')
$page_content += $r.page_items
}
return $page_content
}