· 6 years ago · Sep 17, 2019, 05:00 PM
1# greynoise.io api helper shell function
2# cc0 / kopime: x0 <https://pastebin.com/u/xero
3# _ ___ ______ _ ______ _ _______ _ _______
4# _\\\ \/ /_\\\ _ /_ _\\\_ \_\\\ _ \
5# \ _/ / \_/ \ / __/ / \
6# / \ \__ \ \ \__ / /
7# /_____/\ /__________/____\ /________/
8# \_____/ \____/x0^b7^imp
9# required:
10# export GREY_TOKEN="your_api_token_here"
11# usage:
12# greynoise 104.236.227.188
13# greynoise 0w.nz
14# dig +short xero.nu | greynoise
15
16function greynoise() {
17 IP="${1:-/dev/stdin}"
18 [[ "$IP" =~ "stdin" ]] && read IP < "$IP"
19 [[ "$IP" =~ "([0-9]{1,3}[\.]){3}[0-9]{1,3}" ]] || IP=`dig +short ${IP}`
20 curl -sX GET "https://api.greynoise.io/v2/noise/context/${IP}" -H "Accept: application/json" -H "key: ${GREY_TOKEN}"
21}