spyse.py

Python API wrapper and command-line client for the tools hosted on spyse.com.

"Spyse is a developer of complete DAAS (Data-As-A-Service) solutions for Internet security professionals, corporate and remote system administrators, SSL / TLS encryption certificate providers, data centers and business analysts. All Spyse online solutions are represented by thematic services that have a single platform for collecting, processing and aggregating information." - spyse.com

Supports the following APIs:

NOTE: This API is currently under active development.

What's New

July 6th 2019

Query searches.

Parameter detection.

Support for the domains_starts_with* options (library only)

options (library only) Default parameters.

Installation

pip3 install spyse.py

Updating

pip3 install spyse.py --upgrade

Using the client

Required Arguments

-target

Optional Arguments

-param

-page

-apikey

--raw

What is the param argument?

Spyse allows you to search their database for IPs, IP ranges, domain names, URLs, etc. The parameter argument is meant to specify the type of your input.

As of July 6th 2019, most of the functions do not require you to set a parameter unless you'd like to override the default one.

For example, the default parameter for --domains-on-ip is ip , however you can override this parameter and search by CIDR, or organization instead. You should only need to do this if you're getting an error message, as parameter detection has also been added.

The detection is quite simple:

# detect whether input is cidr or ip or search query (q) if "/" in args . target : param = "cidr" elif ":" in args . target : param = "q" else : param = "ip"

The detection varies from function to function, as certain functions require different default parameters.

List of parameters

cidr

domain

ip

page

url

hash

q

Using search queries

Much like Shodan, Spyse allows you to use search queries.

spyse -target "org: Microsoft" --ssl-certificates

Searching for subdomains

spyse -target xbox.com --subdomains

Reverse IP Lookup

spyse -target 52 .14.144.171 --domains-on-ip

Searching for SSL certificates

spyse -target hotmail.com --ssl-certificates

spyse -target "org: Microsoft" --ssl-certificates

Getting all DNS records

spyse -target xbox.com --dns-all

Manually overriding the parameter argument

spyse -target hackerone.com -param domain --subdomains

Navigating multiple pages using your API key

export SPYSEKEY = "yourkeyhere" spyse -target xbox.com -apikey $SPYSEKEY -page 2 ---ssl-certificates

Piping to jq and aquatone

Initially when I decided to write this client I really wanted it to focus on flexibility within the command-line, which is why there is the --raw option. From there you can work with the raw JSON returned by the API.

spyse -target hackerone.com --dns-soa --raw | jq

spyse -target hackerone.com -param domain --subdomains --raw | aquatone

Other options

usage: spyse [-h] [-target TARGET] [-param PARAM] [-page PAGE] [-apikey APIKEY] [--raw] [--dns-ptr] [--dns-soa] [--dns-mx] [--dns-aaaa] [--dns-ns] [--dns-a] [--dns-txt] [--dns-all] [--domains-with-same-ns] [--domains-using-as-mx] [--domains-on-ip] [--domains-with-same-mx] [--domains-using-as-ns] [--download-dns-aaaa] [--download-dns-soa] [--download-dns-ns] [--download-dns-ptr] [--download-dns-mx] [--download-dns-a] [--download-dns-txt] [--download-dns-all] [--ip-port-lookup] [--ip-port-lookup-aggregate] [--ssl-certificates] [--subdomains] Client for Spyse.com optional arguments: -h, --help show this help message and exit -target TARGET target -param PARAM parameter to use (ip, domain, cidr, url, hash) -page PAGE page -apikey APIKEY set the api key --raw show raw json --dns-ptr show dns ptr records --dns-soa show dns soa records --dns-mx show dns mx records --dns-aaaa show dns aaaa records --dns-ns show dns ns records --dns-a show dns a records --dns-txt show dns txt records --dns-all show all dns records --domains-with-same-ns show domains with same ns --domains-using-as-mx show domains using as mx --domains-on-ip show domains on ip --domains-with-same-mx show domains with same mx --domains-using-as-ns show domains using as ns --download-dns-aaaa download dns aaaa records --download-dns-soa download dns soa records --download-dns-ns download dns ns records --download-dns-ptr download dns ptr records --download-dns-mx download dns mx records --download-dns-a download dns a records --download-dns-txt download dns txt records --download-dns-all download all dns records --ip-port-lookup show ip port lookup --ip-port-lookup-aggregate show ip port lookup aggregate --ssl-certificates show ssl certificates associated with a target --subdomains show subdomains Usage: spyse -target hackerone.com --subdomains

Using the library

Without API Key

from spyse import spyse s = spyse () subdomains = s . subdomains ( "xbox.com" , param = "domain" )

With API Key

from spyse import spyse # Using the API key allows us to go through multiple pages of results s = spyse ( 'API_TOKEN_GOES_HERE' ) subdomains = s . subdomains_aggregate ( "xbox.com" , param = "domain" , page = 2 )

Search using CIDR

from spyse import spyse s = spyse () results = s . domains_on_ip ( "172.217.1.0/24" , param = "cidr" )

Work with an existing file

from spyse import spyse s = spyse () results = [] with open ( "domains.txt" ) as d : for line in d : # default value for param="domain", so we don't # need to specify here r = s . subdomains_aggregate ( line ) results . append ( r ) print ( results )

Available Methods

All of the methods listed on https://api-doc.spyse.com/