ASNinformer -- a lightweight tool that takes IPs or ASNs as input, looks up their ASN information, and groups results in a JSON file.
ASNinformer is a simple Python script that takes IP addresses or ASNs as input, queries their ASN (Autonomous System Number) information via ip2asn.ipinfo.app and asn.ipinfo.app, groups IPs by ASN, and saves the results as a JSON file.
It is designed to work with stdin (piping) or direct command-line arguments.
- Accepts input from:
- Standard input (
stdin) - Command-line arguments
- Standard input (
- IP to ASN lookup - Queries IP to ASN information via
ip2asn.ipinfo.app - ASN to details lookup - Queries ASN details (company name, IP ranges) via
asn.ipinfo.app - Automatically groups IPs by ASN
- Saves results in JSON format
- Optional proxy support
- Uses a simple regex-based IPv4 validator
- ASN input support (e.g.,
AS13335)
Clone the repository:
git clone https://github.com/NakuTenshi/ASNinformer.git
cd ASNinformerMake the script executable:
chmod +x ASNinformer.pythen install the script:
./installecho 1.1.1.1 | ASNinformercat ips.txt | ASNinformerExample ips.txt:
1.1.1.1
8.8.8.8
9.9.9.9
ASNinformer 1.1.1.1ASNinformer 1.1.1.1 8.8.8.8echo AS13335 | ASNinformercat ASNs.txt | ASNinformerASNinformer AS13335ASNinformer AS13335 AS15169Example ASNs.txt:
AS13335
AS15169
| Flag | Description |
|---|---|
-p, --proxy |
Use an HTTP/HTTPS proxy |
-o |
Output file name (default: ./asn-result.json) |
echo 8.8.8.8 | ASNinformer -o results.jsonecho 8.8.8.8 | ASNinformer -p http://127.0.0.1:8080echo AS13335 | ASNinformer -o asn-details.jsonThe script outputs a JSON file structured like this:
{
"AS15169": {
"company's name": "Google LLC",
"ASN": "AS15169",
"ASN url": "https://bgp.he.net/AS15169",
"Provided IP Ranges": [
"8.8.8.0/24"
],
"Provided IP": [
"8.8.8.8"
]
}
}Each ASN entry contains:
- ASN - ASN number
- ASN url - Link to BGP info (
bgp.he.net) - Provided IP Ranges - Announced CIDR ranges for the input IPs
- Company's Name - Organization name
- Provided IP - List of input IPs belonging to that ASN
When you provide an ASN as input, the output includes IP ranges:
{
"AS13335": {
"Company's Name": "Cloudflare, Inc.",
"ASN": "AS13335",
"ASN Url": "https://bgp.he.net/AS13335",
"IP Ranges": [
"1.1.1.0/24",
"1.0.0.0/24",
...
]
}
}Each ASN entry contains:
- Company's Name - Organization name
- ASN - ASN number
- ASN Url - Link to BGP info (
bgp.he.net) - IP Ranges - All announced IP ranges for that ASN
- Python 3.x
requestslibrarycertifi,charset-normalizer,idna,urllib3(dependencies of requests)
Install dependencies:
pip install -r requirements.txtcreated by: NakuTenshi