Skip to content

Instantly share code, notes, and snippets.

@superducktoes
Created March 13, 2023 16:17
Show Gist options
  • Save superducktoes/772a4de826cea52ec21f8826ee814343 to your computer and use it in GitHub Desktop.
Save superducktoes/772a4de826cea52ec21f8826ee814343 to your computer and use it in GitHub Desktop.
from greynoise import GreyNoise
# change API key and query
api_key = "<GN_API_KEY>"
gn_query = "last_seen:1d classification:malicious spoofable:false"
# set up api client
api_client = GreyNoise(api_key=api_key)
ip_list = []
complete = False
scroll = ""
# query gn and iterate to get all IP's to save to ip_list
while not complete:
r = api_client.query(gn_query, scroll=scroll, size=10000)
for i in r["data"]:
ip_list.append(i["ip"])
complete = r["complete"]
scroll = r.get("scroll")
# write ip_list to txt file
f = open("./malicious_ips.txt", "a")
for i in ip_list:
f.write("{}\n".format(i))
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment