Skip to main content

criminalip.ctidb reader

Project description

Description

This is a Python module for reading CTI DB files.

CTI DB is a binary file format that stores data indexed by IP address subnets (IPv4 only).

Installation

To install ctidb, simply:

$ pip install ctidb

Usage

To use this module, you must first download or create a CTI DB file.

After you have obtained a database and imported the module, call CCtiReader with a path, to the database as the first argument. Optionally, you may pass a mode as the second argument. The modes are exported from ctidb. Valid modes are:

  • MODE_MEMORY - load database into memory. Pure Python.

  • MODE_AUTO - Default.

NOTE: To look up an IP address, use the get method on this object. The method will return the corresponding values for the IP address from the database (e.g., a dictionary for GeoIP2/GeoLite2 databases). If the database does not contain a record for that IP address, the method will return None.

Example

>>> import ctidb
>>>
>>> with ctidb.CCtiReader('criminalip.ctidb') as reader:
>>>
>>>     reader.get('223.26.31.75')
{'country': ... }

Exceptions

The module will return an InvalidDatabaseError if the database is corrupt or otherwise invalid. A ValueError will be thrown if you look up an invalid IP address or an IPv6 address in an IPv4 database.

Requirements

This code requires Python 3.7+. Older versions are not supported.

Versioning

Support

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

ctidb-0.0.14.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

ctidb-0.0.14-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file ctidb-0.0.14.tar.gz.

File metadata

  • Download URL: ctidb-0.0.14.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for ctidb-0.0.14.tar.gz
Algorithm Hash digest
SHA256 5fe12c5fc1a5c9c614d7a5eec851a77e3fc2c7b59bf34ad67df44536c523fa99
MD5 27b0ae672d1a71529c3c2a7d28fa71c5
BLAKE2b-256 e7c55fb313fd446d93245230ed025e6740f5fe4574e66b1ee48201782ea2a30a

See more details on using hashes here.

File details

Details for the file ctidb-0.0.14-py3-none-any.whl.

File metadata

  • Download URL: ctidb-0.0.14-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for ctidb-0.0.14-py3-none-any.whl
Algorithm Hash digest
SHA256 78bcfa43f0610656d940960887235ca0b3fddfea02ed7b809419723cbc2a4822
MD5 0f7be3d57b6491d99707310ce1c8567d
BLAKE2b-256 524df06f81631b8265de0921300959c518bc0e5914ceaae4123580de27261706

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