mirror of
https://github.com/C24Be/AS_Network_List.git
synced 2026-01-25 07:26:59 +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
|
break
|
||||||
else:
|
else:
|
||||||
if re.match(r'^AS.*', line[0]):
|
if re.match(r'^AS.*', line[0]):
|
||||||
response = whois_query(line[0], "as-name")
|
response = whois_query(line[0], "as-name", True)
|
||||||
else:
|
else:
|
||||||
response = whois_query(line[0], "netname")
|
response = whois_query(line[0], "netname", True)
|
||||||
if response is None:
|
if response is None:
|
||||||
name = "-not-found-"
|
name = "-not-found-"
|
||||||
else:
|
else:
|
||||||
name = response.split(':')[1].strip()
|
name = response.strip()
|
||||||
print(line[0] + " " + name)
|
print(line[0] + " " + name)
|
||||||
lines[i]=str(line[0] + " " + name + "\n")
|
lines[i]=str(line[0] + " " + name + "\n")
|
||||||
with open(filename, 'w') as f:
|
with open(filename, 'w') as f:
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import requests
|
|||||||
import argparse
|
import argparse
|
||||||
import re
|
import re
|
||||||
from cymruwhois import Client
|
from cymruwhois import Client
|
||||||
|
from pylib.whois import whois_query
|
||||||
|
|
||||||
def get_as_prefixes(asn):
|
def get_as_prefixes(asn):
|
||||||
url = f"https://stat.ripe.net/data/announced-prefixes/data.json?resource={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)
|
line = re.sub(r'[^AS0-9]', '', asn)
|
||||||
if not args.quiet:
|
if not args.quiet:
|
||||||
print(f"# Networks announced by {line}")
|
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)
|
prefixes = get_as_prefixes(line)
|
||||||
for prefix in prefixes:
|
for prefix in prefixes:
|
||||||
print(prefix)
|
print(prefix)
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ def extract_netname(filename_or_url):
|
|||||||
if response is not None:
|
if response is not None:
|
||||||
if not args.quiet:
|
if not args.quiet:
|
||||||
print(f"# Network name: {netname}")
|
print(f"# Network name: {netname}")
|
||||||
ip_range = response.split(':')[1].strip()
|
ip_range = response.strip()
|
||||||
cidrs = convert_to_cidr(ip_range)
|
cidrs = convert_to_cidr(ip_range)
|
||||||
for cidr in cidrs:
|
for cidr in cidrs:
|
||||||
print(cidr)
|
print(cidr)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import socket
|
import socket
|
||||||
|
|
||||||
def whois_query(query, get_field="netname"):
|
def whois_query(query, get_field="netname", get_org=False):
|
||||||
|
|
||||||
whois_server = "whois.ripe.net"
|
whois_server = "whois.ripe.net"
|
||||||
|
|
||||||
@@ -21,8 +21,15 @@ def whois_query(query, get_field="netname"):
|
|||||||
break
|
break
|
||||||
s.close()
|
s.close()
|
||||||
|
|
||||||
|
org_name = None
|
||||||
|
basic_name = None
|
||||||
for line in response.split('\n'):
|
for line in response.split('\n'):
|
||||||
|
if line.startswith('org-name' + ':'):
|
||||||
|
org_name = line.split(':')[1].strip()
|
||||||
if line.startswith(get_field + ':'):
|
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