-
Notifications
You must be signed in to change notification settings - Fork 6
/
ipinfo
executable file
·45 lines (40 loc) · 1.38 KB
/
ipinfo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
# basic cli netaddress enrichment with greynoise, virustotal & ipinfo
if [ -z "$1" ]; then
echo "usage: ipinfo <ip>"
exit 1
fi
if [[ ! $1 =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "usage: ipinfo <ip>"
exit 1
fi
response=$(curl -s "https://onionoo.torproject.org/details?search=$1")
relaydata=$(echo "$response" | jq -r '.relays')
bridgedata=$(echo "$response" | jq -r '.bridges')
if [ "$relaydata" = "[]" ] && [ "$bridgedata" = "[]" ]; then
echo
else
echo "this is an advertised Tor node"
echo "https://metrics.torproject.org/rs.html#search/$1"
# https://check.torproject.org/torbulkexitlist
echo
fi
curl -s ipinfo.io/${1} -H "User-Agent: curl/7.54" \
| jq -r 'del(.readme, .region, .ip, .city, .org) | to_entries | map("\(.key) \(.value)") | .[]' \
| column -t
if [ -f ~/.virustotal ]; then
VTKEY=$(cat ~/.virustotal)
curl -s https://www.virustotal.com/api/v3/ip_addresses/$1 \
--header "x-apikey: $VTKEY" \
| jq -r '.data.attributes.last_analysis_stats | to_entries | map("\(.key) \(.value)") | .[]' \
| column -t
echo
curl -s https://www.virustotal.com/api/v3/ip_addresses/$1/resolutions \
--header "x-apikey: $VTKEY" \
| jq -r '.data[].attributes.host_name' \
| column -t
echo
fi
curl -s https://api.greynoise.io/v3/community/$1 \
| jq -r 'del(.message, .ip, .name) | to_entries | map("\(.key) \(.value)") | .[]' \
| column -t