module documentation

Shodan CLI Note: Always run "shodan init <api key>" before trying to execute any other command! A simple interface to search Shodan, download data and parse compressed JSON files. The following commands are currently supported: alert convert count data download honeyscore host info init myip parse radar scan search stats stream

Function convert Convert the given input data file into a different format. The following file formats are supported:
Function count Returns the number of results for a search
Function domain_info View all available information for a domain
Function download Download search results and save them in a compressed JSON file.
Function honeyscore Check whether the IP is a honeypot or not.
Function host View all available information for an IP address
Function info Shows general information about your account
Function init Initialize the Shodan command-line
Function main Undocumented
Function myip Print your external IP address
Function parse Extract information out of compressed JSON files.
Function radar Real-Time Map of some results as Shodan finds them.
Function search Search the Shodan database
Function stats Provide summary information about a search query
Function stream Stream data in real-time.
Function version Print version of this tool.
Constant CONTEXT_SETTINGS Undocumented
Constant CONVERTERS Undocumented
@main.command()
@click.option('--fields', help='List of properties to output.', default=None)
@click.argument('input', metavar='<input file>')
@click.argument('format', metavar='<output format>', type=click.Choice(CONVERTERS.keys()))
def convert(fields, input, format): (source)

Convert the given input data file into a different format. The following file formats are supported: kml, csv, geo.json, images, xlsx Example: shodan convert data.json.gz kml

@main.command()
@click.argument('query', metavar='<search query>', nargs=-1)
def count(query): (source)

Returns the number of results for a search

@main.command(name='domain')
@click.argument('domain', metavar='<domain>')
@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)
@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): (source)

View all available information for a domain

@main.command()
@click.option('--limit', help='The number of results you want to download. -1 to download all the data possible.', default=1000, type=int)
@click.argument('filename', metavar='<filename>')
@click.argument('query', metavar='<search query>', nargs=-1)
def download(limit, filename, query): (source)

Download search results and save them in a compressed JSON file.

@main.command()
@click.argument('ip', metavar='<IP address>')
def honeyscore(ip): (source)

Check whether the IP is a honeypot or not.

@main.command()
@click.option('--format', help='The output format for the host information. Possible values are: pretty, tsv.', default='pretty', type=click.Choice(['pretty', 'tsv']))
@click.option('--history', help='Show the complete history of the host.', default=False, is_flag=True)
@click.option('--filename', '-O', help='Save the host information in the given file (append if file exists).', default=None)
@click.option('--save', '-S', help='Save the host information in the a file named after the IP (append if file exists).', default=False, is_flag=True)
@click.argument('ip', metavar='<ip address>')
def host(format, history, filename, save, ip): (source)

View all available information for an IP address

@main.command()
def info(): (source)

Shows general information about your account

@main.command()
@click.argument('key', metavar='<api key>')
def init(key): (source)

Initialize the Shodan command-line

@with_plugins(iter_entry_points('shodan.cli.plugins'))
@click.group(context_settings=CONTEXT_SETTINGS)
def main(): (source)

Undocumented

@main.command()
@click.option('--ipv6', '-6', is_flag=True, default=False, help='Try to use IPv6 instead of IPv4')
def myip(ipv6): (source)

Print your external IP address

@main.command()
@click.option('--color/--no-color', default=True)
@click.option('--fields', help='List of properties to output.', default='ip_str,port,hostnames,data')
@click.option('--filters', '-f', help='Filter the results for specific values using key:value pairs.', multiple=True)
@click.option('--filename', '-O', help='Save the filtered results in the given file (append if file exists).')
@click.option('--separator', help='The separator between the properties of the search results.', default='\t')
@click.argument('filenames', metavar='<filenames>', type=click.Path(exists=True), nargs=-1)
def parse(color, fields, filters, filename, separator, filenames): (source)

Extract information out of compressed JSON files.

@main.command()
def radar(): (source)

Real-Time Map of some results as Shodan finds them.

@main.command()
@click.option('--color/--no-color', default=True)
@click.option('--fields', help='List of properties to show in the search results.', default='ip_str,port,hostnames,data')
@click.option('--limit', help='The number of search results that should be returned. Maximum: 1000', default=100, type=int)
@click.option('--separator', help='The separator between the properties of the search results.', default='\t')
@click.argument('query', metavar='<search query>', nargs=-1)
def search(color, fields, limit, separator, query): (source)

Search the Shodan database

@main.command()
@click.option('--limit', help='The number of results to return.', default=10, type=int)
@click.option('--facets', help='List of facets to get statistics for.', default='country,org')
@click.option('--filename', '-O', help='Save the results in a CSV file of the provided name.', default=None)
@click.argument('query', metavar='<search query>', nargs=-1)
def stats(limit, facets, filename, query): (source)

Provide summary information about a search query

@main.command()
@click.option('--streamer', help='Specify a custom Shodan stream server to use for grabbing data.', default='https://stream.shodan.io', type=str)
@click.option('--fields', help='List of properties to output.', default='ip_str,port,hostnames,data')
@click.option('--separator', help='The separator between the properties of the search results.', default='\t')
@click.option('--datadir', help='Save the stream data into the specified directory as .json.gz files.', default=None, type=str)
@click.option('--asn', help='A comma-separated list of ASNs to grab data on.', default=None, type=str)
@click.option('--alert', help='The network alert ID or "all" to subscribe to all network alerts on your account.', default=None, type=str)
@click.option('--countries', help='A comma-separated list of countries to grab data on.', default=None, type=str)
@click.option('--custom-filters', help='A space-separated list of filters query to grab data on.', default=None, type=str)
@click.option('--ports', help='A comma-separated list of ports to grab data on.', default=None, type=str)
@click.option('--tags', help='A comma-separated list of tags to grab data on.', default=None, type=str)
@click.option('--vulns', help='A comma-separated list of vulnerabilities to grab data on.', default=None, type=str)
@click.option('--limit', help='The number of results you want to download. -1 to download all the data possible.', default=-1, type=int)
@click.option('--compresslevel', help='The gzip compression level (0-9; 0 = no compression, 9 = most compression', default=9, type=int)
@click.option('--timeout', help='Timeout. Should the shodan stream cease to send data, then timeout after <timeout> seconds.', default=0, type=int)
@click.option('--color/--no-color', default=True)
@click.option('--quiet', help='Disable the printing of information to the screen.', is_flag=True)
def stream(streamer, fields, separator, datadir, asn, alert, countries, custom_filters, ports, tags, vulns, limit, compresslevel, timeout, color, quiet): (source)

Stream data in real-time.

@main.command()
def version(): (source)

Print version of this tool.

CONTEXT_SETTINGS = (source)

Undocumented

Value
dict(help_option_names=['-h', '--help'])
CONVERTERS = (source)

Undocumented

Value
{'kml': KmlConverter,
 'csv': CsvConverter,
 'geo.json': GeoJsonConverter,
 'images': ImagesConverter,
 'xlsx': ExcelConverter}