From c73cf83e0fc92b9fa5fc8243019a99a3975ff2cc Mon Sep 17 00:00:00 2001 From: John Matherly Date: Wed, 25 Dec 2019 11:38:34 -0600 Subject: [PATCH] Add history and type parameters to Shodan.dns.domain_info() method and CLI command --- CHANGELOG.md | 4 ++++ setup.py | 2 +- shodan/__main__.py | 6 ++++-- shodan/client.py | 9 +++++++-- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5bd47a4..90c2059 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ CHANGELOG ========= +1.21.1 +------ +* Add ``history`` and ``type`` parameters to ``Shodan.dns.domain_info()`` method and CLI command + 1.21.0 ------ * New API methods ``api.search_facets()`` and ``api.search_filters()`` to get a list of available facets and filters. diff --git a/setup.py b/setup.py index 17337b4..2148480 100755 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ setup( name='shodan', - version='1.21.0', + version='1.21.1', description='Python library and command-line utility for Shodan (https://developer.shodan.io)', long_description=README, long_description_content_type='text/x-rst', diff --git a/shodan/__main__.py b/shodan/__main__.py index d4b7aa0..9678bbb 100644 --- a/shodan/__main__.py +++ b/shodan/__main__.py @@ -138,13 +138,15 @@ def convert(fields, input, format): @click.argument('domain', metavar='') @click.option('--details', '-D', help='Lookup host information for any IPs in the domain results', default=False, is_flag=True) @click.option('--save', '-S', help='Save the information in the a file named after the domain (append if file exists).', default=False, is_flag=True) -def domain_info(domain, details, save): +@click.option('--history', '-H', help='Include historical DNS data in the results', default=False, is_flag=True) +@click.option('--type', '-T', help='Only returns DNS records of the provided type', default=None) +def domain_info(domain, details, save, history, type): """View all available information for a domain""" key = get_api_key() api = shodan.Shodan(key) try: - info = api.dns.domain_info(domain) + info = api.dns.domain_info(domain, history=history, type=type) except shodan.APIError as e: raise click.ClickException(e.value) diff --git a/shodan/client.py b/shodan/client.py index 3ed5e66..a83ac20 100644 --- a/shodan/client.py +++ b/shodan/client.py @@ -69,10 +69,15 @@ class Dns: def __init__(self, parent): self.parent = parent - def domain_info(self, domain): + def domain_info(self, domain, history=False, type=None): """Grab the DNS information for a domain. """ - return self.parent._request('/dns/domain/{}'.format(domain), {}) + args = {} + if history: + args['history'] = history + if type: + args['type'] = type + return self.parent._request('/dns/domain/{}'.format(domain), args) class Notifier: