Last active
February 25, 2021 11:09
-
-
Save n0x08/7ffeeb3d59ebc8aab2942e361905c12d to your computer and use it in GitHub Desktop.
Revisions
-
n0x08 revised this gist
Oct 11, 2018 . 1 changed file with 7 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -19,6 +19,13 @@ asn = sys.argv[1] print("Looking up "+ str(asn)) asrankraw = requests.get('http://as-rank.caida.org/api/v1/asns/' + asn.split('AS')[1]) asrank = asrankraw.json() print("Finding infection stats for " + asrank['data']['org']['name']) asnraw = requests.get('https://research.api.greynoise.io/v2/infections/asn/' + asn, headers = headers) #V2 IP API lookup asndata = asnraw.json() -
n0x08 revised this gist
Oct 11, 2018 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -31,4 +31,5 @@ sorted_tags.sort(key=lambda x: x[1]) sorted_tags.reverse() pprint(sorted_tags) print("Total infected hosts in " + str(asn) + ": " + str(sum(n for _, n in sorted_tags))) -
n0x08 created this gist
Oct 11, 2018 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ # !/usr/bin/env python # gnMonthlyInfected.py # # Report statistics on monthly infections # in a specified Autonomous System as seen # by Greynoise.io # # Requires: Greynoise API key # # Example: python3 gnMonthlyInfected.py AS12345 # import sys import json import requests from collections import Counter, defaultdict from pprint import pprint headers = {'key': 'GREYNOISE API KEY GOES HERE'} asn = sys.argv[1] asnraw = requests.get('https://research.api.greynoise.io/v2/infections/asn/' + asn, headers = headers) #V2 IP API lookup asndata = asnraw.json() tagstats = defaultdict(int) for i in asndata: tagstats[str(i['tag_name'])] += 1 sorted_tags = [x for x in tagstats.items()] sorted_tags.sort(key=lambda x: x[1]) sorted_tags.reverse() pprint(sorted_tags)