Skip to main content

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


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.4.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

ip2asn-1.4-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file ip2asn-1.4.tar.gz.

File metadata

  • Download URL: ip2asn-1.4.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.26.0

File hashes

Hashes for ip2asn-1.4.tar.gz
Algorithm Hash digest
SHA256 6ca3c137f07f74fdbb03d526659b43817b0988ed074c5e01453d4e78fa41a6f8
MD5 52be374e0fe91efee48a53a2dd3329be
BLAKE2b-256 eaf08a9eebe2f43ffedffa0b686c574ebc627fa4eb4999cf9cc0d0e7598ad1a5

See more details on using hashes here.

File details

Details for the file ip2asn-1.4-py3-none-any.whl.

File metadata

  • Download URL: ip2asn-1.4-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.26.0

File hashes

Hashes for ip2asn-1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 0988be7aeaeedb64291e78683ee577199b723f8aecb9213ff922f27c3649dcaa
MD5 6357f229cc22a65f05a7b25f3b415f17
BLAKE2b-256 86f56b548f31a4e092b1c193e0a91e41c7101b18b052f891a2f9fc04dee53b92

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page