Last active
May 14, 2021 19:34
-
-
Save cfalta/757cf119397affa149f416a5f14b68e2 to your computer and use it in GitHub Desktop.
Powershell function to check an IP against the public API of Greynoise
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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