Skip to content

Instantly share code, notes, and snippets.

@superducktoes
Last active May 22, 2023 19:22
Show Gist options
  • Save superducktoes/16872735a829a50d627e3f577575fabb to your computer and use it in GitHub Desktop.
Save superducktoes/16872735a829a50d627e3f577575fabb to your computer and use it in GitHub Desktop.
GreyNoise Write IP's To File
import requests
import json
GN_API_KEY = ""
GN_QUERY = 'tags:"SSH Bruteforcer" last_seen:1d spoofable:false'
file_name = "./greynoise_ips.txt"
GN_QUERY_URL = "https://api.greynoise.io/v2/experimental/gnql"
HEADERS = {
"accept": "application/json",
"key": GN_API_KEY
}
gn_ip_list = []
continue_loop = True
PARAMS = {
"query": GN_QUERY,
"size": "10000",
"scroll": ""
}
file = open(file_name, "a")
while continue_loop:
# make the request to GN
print("making request")
r = requests.get(GN_QUERY_URL, headers=HEADERS, params=PARAMS).json()
for i in r["data"]:
file.write("{}\n".format(i["ip"]))
# if there's more than 10,000 results add the scoll key to the params and keep requesting
if("scroll" in r):
PARAMS["scroll"] = r["scroll"]
else:
continue_loop = False
break
file.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment