· 6 years ago · Mar 17, 2020, 10:33 PM
1$blah = $null
2
3$tags = @("phishing","docusign")
4$otxkey = "YOUR API KEY"
5# Define export location.
6$exports = "C:\Exports"
7$next = "https://otx.alienvault.com/api/v1/pulses/subscribed/?limit=10&page=1"
8$regex = "[^a-zA-Z]"
9$results = @()
10do {
11 write-progress "Pulling all AlienVault indicators and exporting to CSVs. Processing page: $page"
12 $indicators = invoke-webrequest -URI $next -UseBasicParsing -Headers @{"X-OTX-API-KEY"="$otxkey"} -UseDefaultCredentials
13 # Convert JSON data received into powershell object.
14 $data = $indicators.Content | ConvertFrom-Json
15 # Populate the next page into $next variable.
16 $next = $data.next
17 $page = $next.split("&")[1].split("=")[1]
18 foreach ($indicator in $data.results) {
19 foreach ($tag in $tags) {
20 if ($indicator.tags | where {$_ -eq $tag}) {
21 $results += $data.results
22 }
23 }
24 }
25} while ($blah -ne $null)
26$results | Export-CSV C:\results.csv