Created
July 23, 2014 17:55
-
-
Save axper/c8dddea6dc0730d0e0c9 to your computer and use it in GitHub Desktop.
Print whois info about given IP address
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
# Requirements: | |
# 1. Python 3 | |
# 2. pip3 install ipwhois | |
from ipwhois import IPWhois | |
from ipwhois.utils import get_countries | |
ip = input('IP Address:') | |
result = IPWhois(ip).lookup() | |
print('ASN (Autonomous System number):', result['asn']) | |
print('ASN Classless Inter-Domain Routing:', result['asn_cidr']) | |
print('ASN Country:', get_countries()[result['asn_country_code']]) | |
print('ASN Registry:', result['asn_registry']) | |
for net in result['nets']: | |
print('====', net['name'], '====') | |
print(net['description']) | |
print(' Created:', net['created']) | |
print(' Updated:', net['updated']) | |
print(' Classless Inter-Domain Routing:', net['cidr']) | |
print(' ==== Geographic Data ====') | |
print(' Country:', get_countries()[net['country']]) | |
print(' State:', net['state']) | |
print(' City:', net['city']) | |
print(' Address:') | |
print(' ' + net['address'].replace('\n', '\n ')) | |
print(' Postal Code:', net['postal_code']) | |
print(' ==== Emails ====') | |
print(' Abuse Email:', net['abuse_emails']) | |
print(' Tech Email:', net['tech_emails']) | |
print(' Misc Email:', net['misc_emails']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment