mirror of
https://github.com/C24Be/AS_Network_List.git
synced 2026-01-24 23:26:38 +03:00
Add whois limit, actions, etc
This commit is contained in:
@@ -32,12 +32,18 @@ def whois_query(whois_server, query, get_field="netname"):
|
||||
return None
|
||||
|
||||
def get_data(json, file, attr, field, prefix=""):
|
||||
limit = args.limit
|
||||
count = 0
|
||||
with open(file, 'w') as f:
|
||||
for x in json['data']['resources'][attr]:
|
||||
count += 1
|
||||
x = prefix+x.strip()
|
||||
response = whois_query(whois_server, x, field)
|
||||
if count > limit:
|
||||
response = None
|
||||
else:
|
||||
response = whois_query(whois_server, x, field)
|
||||
if response is None:
|
||||
name = "None"
|
||||
name = "-no-description-"
|
||||
else:
|
||||
name = response.split(':')[1].strip()
|
||||
print(f"{x} {name}")
|
||||
@@ -48,6 +54,7 @@ parser.add_argument('--asn', action='store_true', help='Run the ASN query')
|
||||
parser.add_argument('--ipv4', action='store_true', help='Run the IPv4 query')
|
||||
parser.add_argument('--ipv6', action='store_true', help='Run the IPv6 query')
|
||||
parser.add_argument('--all', action='store_true', help='Run all queries')
|
||||
parser.add_argument('--limit', type=int, help='Limit the number of whois queries to prevent blacklisting from whois servers', default=2500)
|
||||
args = parser.parse_args()
|
||||
|
||||
if not (args.asn or args.ipv4 or args.ipv6 or args.all):
|
||||
|
||||
Reference in New Issue
Block a user