I have a new project I’m working on which creates a threat-hunting dashboard. I’ve run in to an early problem where a function New-OTXIPv4Lookup
is not working in one of my inputs, but a second function New-DNSLookup
is working just find in the column before it.
Any help would be appreciated. I’m receiving the message ‘Object Reference not set to an instance of an object’ when I try to execute submit the input. When I run the function in the CLI, it works just fine.
They seem to be created in the same sort of way but one works and the other doesn’t, I have no idea why.
. ./keys.ps1
function New-DNSLookup {
param($dns_query)
Resolve-DnsName -Name $dns_query
}
function New-OTXIPv4Lookup { #THIS IS THE ONE WHICH DOESN'T WORK
param($otx_ip)
$headers = @{ "X-OTX-API-KEY" = $OTX_api}
$Response = Invoke-RestMethod -URI "https://otx.alienvault.com/api/v1/indicators/IPv4/$otx_ip/reputation" -Headers $headers
If (-not $Response.reputation) { #Just handling empty strings here
$Response.reputation = "No malicious activity known"
}
If (-not $Response) {
$Response = "asdf"
}
return $Response
}
$Endpoints = New-UDEndpointInitialization -Function @("New-DNSLookup","New-OTXIPv4Lookup")
$HomePage = New-UDPage -Name "Threat Intel" -icon signal -Content {
New-UDRow -Endpoint {
New-UDColumn -Size 4 -Content {
New-UDInput -Title "Enter DNS Name" -Endpoint {
param($dns_lookup)
$x = New-DNSLookup -dns_query $dns_lookup
Set-UDElement -id "dns_result" -Content {$x.IPAddress}
}
}
New-UDColumn -Size 8 -Content {
New-UDCard -Content {
New-UDElement -tag div -id "dns_result" -Content {"Response will show up here"}
}
}
}
New-UDRow -Endpoint {
New-UDColumn -size 4 -Content {
New-UDInput -Title "OTX IP Indicator Lookup" -Endpoint { #THIS IS THE ONE WHICH DOESN'T WORK
param($otx_ip_lookup)
$y = New-OTXIPv4Lookup -otx_ip $otx_ip_lookup
Set-UDElement -id "OTX_ip_response" -Content {$y}
}
}
New-UDColumn -Size 8 -Content {
New-UDCard -Content {
New-UDElement -tag div -id "OTX_ip_response" -Content {"Response will show up here"}
}
}
}
}
$mydashboard = New-UDDashboard -Pages $HomePage -EndpointInitialization $Endpoints
Start-UDDashboard -Port 1000 -Dashboard $MyDashboard
One returns as an array and the other as a pscustomobject. Though I’ve also tried having the pscustomobject return as a string by just calling the attribute with no luck.