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 XMLResponse.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). IPv6 support hasn't been added yet.
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:
- Domain names
- URLs by means of stripping the protocol and path
- "Defanged" URLs which are intentionally obfuscated for security reasons
- Emails - the parser will remove the prefix and @
- IP addresses (not IPv6 yet)
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
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
Built Distribution
File details
Details for the file uddr_client-0.2.0.tar.gz
.
File metadata
- Download URL: uddr_client-0.2.0.tar.gz
- Upload date:
- Size: 12.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0fac5d83d6c5994d1affb40ea150b2520f8c3c72a38494278d19bcbb601dc36 |
|
MD5 | 6376a268962e6d665414bcd46ae0cb25 |
|
BLAKE2b-256 | 6d5d740efbfeb24338cb411f46c87ba46321b50afca20794705b20c9d03684c2 |
File details
Details for the file uddr_client-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: uddr_client-0.2.0-py3-none-any.whl
- Upload date:
- Size: 13.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f4e22962509e7e7551f793bb9b1f810688c44ea0455eca6f2fd44e06caa3312 |
|
MD5 | a2656e420a73a3d46e2c7f97e392ccbf |
|
BLAKE2b-256 | 9cd3b8a8950e85d005a58f34055c8688c4d089ae25e0ad26857682985e9bf01c |