mirror of
https://github.com/C24Be/AS_Network_List.git
synced 2026-01-24 23:26:38 +03:00
whois resolve details
This commit is contained in:
11612
auto/all-ru-asn.txt
11612
auto/all-ru-asn.txt
File diff suppressed because it is too large
Load Diff
12000
auto/all-ru-ipv4.txt
12000
auto/all-ru-ipv4.txt
File diff suppressed because it is too large
Load Diff
4866
auto/all-ru-ipv6.txt
4866
auto/all-ru-ipv6.txt
File diff suppressed because it is too large
Load Diff
@@ -18,13 +18,13 @@ def resolve(filename):
|
||||
break
|
||||
else:
|
||||
if re.match(r'^AS.*', line[0]):
|
||||
response = whois_query(line[0], "as-name")
|
||||
response = whois_query(line[0], "as-name", True)
|
||||
else:
|
||||
response = whois_query(line[0], "netname")
|
||||
response = whois_query(line[0], "netname", True)
|
||||
if response is None:
|
||||
name = "-not-found-"
|
||||
else:
|
||||
name = response.split(':')[1].strip()
|
||||
name = response.strip()
|
||||
print(line[0] + " " + name)
|
||||
lines[i]=str(line[0] + " " + name + "\n")
|
||||
with open(filename, 'w') as f:
|
||||
|
||||
@@ -4,6 +4,7 @@ import requests
|
||||
import argparse
|
||||
import re
|
||||
from cymruwhois import Client
|
||||
from pylib.whois import whois_query
|
||||
|
||||
def get_as_prefixes(asn):
|
||||
url = f"https://stat.ripe.net/data/announced-prefixes/data.json?resource={asn}"
|
||||
@@ -22,6 +23,10 @@ def print_prefixes(asn):
|
||||
line = re.sub(r'[^AS0-9]', '', asn)
|
||||
if not args.quiet:
|
||||
print(f"# Networks announced by {line}")
|
||||
response = whois_query(line, "as-name", True)
|
||||
if response is not None:
|
||||
info = response.strip()
|
||||
print(f"# AS-Name (ORG): {info}")
|
||||
prefixes = get_as_prefixes(line)
|
||||
for prefix in prefixes:
|
||||
print(prefix)
|
||||
|
||||
@@ -33,7 +33,7 @@ def extract_netname(filename_or_url):
|
||||
if response is not None:
|
||||
if not args.quiet:
|
||||
print(f"# Network name: {netname}")
|
||||
ip_range = response.split(':')[1].strip()
|
||||
ip_range = response.strip()
|
||||
cidrs = convert_to_cidr(ip_range)
|
||||
for cidr in cidrs:
|
||||
print(cidr)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import socket
|
||||
|
||||
def whois_query(query, get_field="netname"):
|
||||
def whois_query(query, get_field="netname", get_org=False):
|
||||
|
||||
whois_server = "whois.ripe.net"
|
||||
|
||||
@@ -21,8 +21,15 @@ def whois_query(query, get_field="netname"):
|
||||
break
|
||||
s.close()
|
||||
|
||||
org_name = None
|
||||
basic_name = None
|
||||
for line in response.split('\n'):
|
||||
if line.startswith('org-name' + ':'):
|
||||
org_name = line.split(':')[1].strip()
|
||||
if line.startswith(get_field + ':'):
|
||||
return line.strip()
|
||||
basic_name = line.split(':')[1].strip()
|
||||
|
||||
return None
|
||||
if get_org is True:
|
||||
return basic_name + ' (' + org_name + ')'
|
||||
else:
|
||||
return basic_name
|
||||
|
||||
Reference in New Issue
Block a user