Skip to content

Instantly share code, notes, and snippets.

@cfalta
Last active May 14, 2021 19:34
Show Gist options
  • Save cfalta/757cf119397affa149f416a5f14b68e2 to your computer and use it in GitHub Desktop.
Save cfalta/757cf119397affa149f416a5f14b68e2 to your computer and use it in GitHub Desktop.
Powershell function to check an IP against the public API of Greynoise
function Test-Greynoise
{
[CmdletBinding()]
Param (
[Parameter(Mandatory = $false, ValueFromPipeline = $true)]
[ValidatePattern({\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}})]
[String]
$IP)
if(-not $IP)
{
#Try to get IPs from clipboard
$c = Get-Clipboard
if($c)
{
$IPList = ($c | sls -Pattern "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}" -AllMatches).matches.value
$result = @()
foreach($i in $IPList)
{
$result += irm https://api.greynoise.io/v3/community/$($i)
}
$result | Format-Table
}
}
else {
irm https://api.greynoise.io/v3/community/$($IP)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment