Skip to main content

A Python client for the UDDR API.

Project description

uddr_client

A Python SDK for UltraDDR

Installation

The package can be installed using pip

pip install uddr_client

Setup

For ease of use, you can store your API key and client ID in an environment file using the client's "setup" method.

import uddr_client
uddr_client.connect.setup()

Alternatively, you can pass the key or ID directly to the connection using keyword arguments.

c = uddr_client.connect('api_key=<your API key>, client_id=<your client ID>')

API Usage

import uddr_client

c = uddr_client.connect() # Instantiates a new instance of the client which, by default, uses the API key stored in your .env

resp = c.api().reports()        # Call an endpoint
print(resp)

Available methods

The API client currently supports the following endpoints:

  • aggregates()
  • bar()
  • histogram()
  • summary()
  • report()
  • reports()
  • histogram_artifact()
  • logs()
  • passthrough()

Use Python's help function for more in-depth documentation on each method.

help(c.api().logs)

Response parsing

Aside from the report() endpoint (which returns an application/pdf), all methods produce a Response object which handles different outputs.

  • Response.xml(): Outputs the response in XML
  • Response.csv(): Outputs the response in CSV

The default is JSON.

DoH Usage

The DNS over HTTPS (DoH) client provides an interface for directly querying the UDDR resolvers.

import uddr_client

c = uddr_client.connect() # Instantiates a new instance of the client
doh = c.doh('google.com') # Creates a DOHClient instance for google.com
print(doh)                # This will return the full json response

Record Types

The client stores the response for various DNS record types as properties. The following are supported.

doh.A      # For A records
doh.AAAA   # For AAAA records
doh.CNAME  # For CNAME records
doh.NS     # For NS records
doh.MX     # For MX records
doh.TXT    # For TXT records
doh.SOA    # For SOA records
doh.SRV    # For SRV records
doh.CAA    # For CAA records
doh.DS     # For DS records
doh.DNSKEY # For DNSKEY records

Reverse Lookups

If you pass an IP to the client, it will automatically perform a reverse lookup (PTR).

IoC Parsing

This concept is borrowed from Michael Smith's DDR-IOC-Checker.

Indicators of compromise passed to the DOHClient as a positional argument will be run through a parser. The parser accepts the following:

  1. Domain names
  2. URLs by means of stripping the protocol and path
  3. "Defanged" URLs which are intentionally obfuscated for security reasons
  4. Emails - the parser will remove the prefix and @
  5. IP addresses

Additional Methods

The following methods return information about the DoH query or specific parts of the response.

  • status() - Returns an object with information about the status of the response. DoH provides a numerical code, this expands with a message and description.
  • block_info() - Returns a string stating whether the domain is blocked (by checking if the A record resolves to the UDDR block page).
  • answer() - Returns the answer section of the response, if one exists.
  • authority() - Returns the authority section of the response, if one exists.

Dependencies

  • pandas
  • xmltodict
  • python-decouple
  • requests

License

This project is licensed under the terms of the MIT license. See LICENSE.md for more details.

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

uddr_client-0.2.5.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

uddr_client-0.2.5-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file uddr_client-0.2.5.tar.gz.

File metadata

  • Download URL: uddr_client-0.2.5.tar.gz
  • Upload date:
  • Size: 13.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for uddr_client-0.2.5.tar.gz
Algorithm Hash digest
SHA256 0cf6f08309c6521dd87faae5e7deca7cbcaef0e36fee6efea4a293d614892948
MD5 845dacc2660a88c4d3a6a386f360dc5d
BLAKE2b-256 c07f55d8a9bd8a2239a69204ec4f545f6fe9d53b967ffdcc05449eb09d08bca9

See more details on using hashes here.

File details

Details for the file uddr_client-0.2.5-py3-none-any.whl.

File metadata

  • Download URL: uddr_client-0.2.5-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for uddr_client-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 5303223a1a0706df20949d86304b69bafe9edf73200ab44bbd76a0843e9fcb41
MD5 c9575e69a4018f35c19274b1c116ee60
BLAKE2b-256 e338975188ae50586742f95a449585a81c0f12e7449fc206d00c40d9c325b70a

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