Created
March 13, 2023 16:17
-
-
Save superducktoes/772a4de826cea52ec21f8826ee814343 to your computer and use it in GitHub Desktop.
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 characters
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