A tool for doing differential analysis of pcap files
Project description
Objective
A python class to search ip2asn information for matches.
Installation
Using pip:
pip3 install ip2asn
Or manually:
git clone git@github.com:hardaker/ip2asn.git
cd ip2asn
python3 setup.py build
python3 setup.py install
Example Usage
setup
curl -o ip2asn-v4-u32.tsv.gz https://iptoasn.com/data/ip2asn-v4-u32.tsv.gz
gunzip ip2asn-v4-u32.tsv.gz
command line
Searching for an address
# ip2asn -f ip2asn-v4-u32.tsv 8.8.8.8
Address: 8.8.8.8
Numeric ip: 134744072
ASN: 15169
Owner: GOOGLE - Google LLC
Country: US
ip_range: [134744064, 134744319]
Searching for an ASN
# ip2asn -f ip2asn-v4-u32.tsv -a 15169
ASN: 15169
Owner: GOOGLE - Google LLC
Country: US
ip_range: [134743040, 134743295]
ASN: 15169
Owner: GOOGLE - Google LLC
Country: US
ip_range: [134744064, 134744319]
ASN: 15169
Owner: GOOGLE - Google LLC
...
(google has a lot of registrations)
Coding
Searching by IP address
import ip2asn
i2a = ip2asn.IP2ASN("ip2asn-v4-u32.tsv")
result = i2a.lookup_address("93.184.216.34")
import pprint
pprint.pprint(result)
Produces:
{'ASN': '15133',
'country': 'US',
'ip_numeric': 1572395042,
'ip_range': [1572394752, 1572396543],
'ip_text': '93.184.216.34',
'owner': 'EDGECAST - MCI Communications Services, Inc. d/b/a Verizon Business'}
Searching by ASN
import ip2asn
i2a = ip2asn.IP2ASN("ip2asn-v4-u32.tsv")
results = i2a.lookup_asn(15169, limit=2) # limit is optional
import pprint
pprint.pprint(results)
``**
**Produces:**
``` text
[{'ASN': '15169',
'country': 'US',
'ip_range': [134743040, 134743295],
'owner': 'GOOGLE - Google LLC'},
{'ASN': '15169',
'country': 'US',
'ip_range': [134744064, 134744319],
'owner': 'GOOGLE - Google LLC'}]
Author
Wes Hardaker, USC/ISI
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ip2asn-1.3.tar.gz
(7.6 kB
view details)
Built Distribution
ip2asn-1.3-py3-none-any.whl
(8.9 kB
view details)
File details
Details for the file ip2asn-1.3.tar.gz
.
File metadata
- Download URL: ip2asn-1.3.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.26.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 181e7ed23b9af2f36354ed626a47c31c5f7e1b9ffdd5a9a638d538e714bde42a |
|
MD5 | 3e23183971e4b8aa50782f005933ecae |
|
BLAKE2b-256 | ca101010f48485b04d5fee2f84d490657b87d81ab7c271ed56bf720d6ce12417 |
File details
Details for the file ip2asn-1.3-py3-none-any.whl
.
File metadata
- Download URL: ip2asn-1.3-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.26.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1eaad5b2bd7d1aef98ff613e7d59de49e7acdbde9d5d4abfbee074eb2c243e55 |
|
MD5 | 4c95a872d0f22f33127e2ab61a5d50a5 |
|
BLAKE2b-256 | 09d7339ab5607ec8c3dbab9476574423800ce5aa149cdbcf64b7fcbc4ef8444a |