Documentation ¶
Overview ¶
Package shodan is an interface for the Shodan API
Index ¶
- Variables
- type APIInfo
- type Client
- func (c *Client) APIInfo() (*APIInfo, error)
- func (c *Client) DNSResolve(hostnames []string) ([]DNSResolve, error)
- func (c *Client) DNSReverse(ips []string) ([]DNSReverse, error)
- func (c *Client) Exploits(query string, facets []string) (*Exploit, error)
- func (c *Client) Host(ip string, opts url.Values) (*Host, error)
- func (c *Client) HostCount(query string, facets []string) (*HostCount, error)
- func (c *Client) HostSearch(query string, facets []string, opts url.Values) (*HostSearch, error)
- func (c *Client) HostSearchTokens(query string) (*HostSearchTokens, error)
- func (c *Client) Protocols() (map[string]string, error)
- func (c *Client) Query(opts url.Values) (*Query, error)
- func (c *Client) QuerySearch(query string, opts url.Values) (*Query, error)
- func (c *Client) QueryTags(opts url.Values) (*QueryTags, error)
- func (c *Client) Services() (map[string]string, error)
- type DNSResolve
- type DNSReverse
- type Error
- type Exploit
- type Host
- type HostCount
- type HostSearch
- type HostSearchTokens
- type Query
- type QueryTags
- type Scan
- type ScanInternet
Constants ¶
This section is empty.
Variables ¶
var ( APIHost = "https://api.shodan.io" ExploitAPIHost = "https://exploits.shodan.io" )
APIHost is the URL of the Shodan API. Debug toggles debug information.
Functions ¶
This section is empty.
Types ¶
type APIInfo ¶
type APIInfo struct { QueryCredits int `json:"query_credits"` ScanCredits int `json:"scan_credits"` Telnet bool `json:"telnet"` Plan string `json:"plan"` HTTPS bool `json:"https"` Unlocked bool `json:"unlocked"` }
APIInfo is used to unmarshal the JSON response from '/shodan/api-info'.
type Client ¶
type Client struct {
Key string
}
Client stores shared data that is used to interact with the API. Key is our Shodan API Key.
func (*Client) DNSResolve ¶
func (c *Client) DNSResolve(hostnames []string) ([]DNSResolve, error)
DNSResolve calls '/dns/resolve' and returns the unmarshalled response.
func (*Client) DNSReverse ¶
func (c *Client) DNSReverse(ips []string) ([]DNSReverse, error)
DNSReverse calls '/dns/reverse' and returns the unmarshalled response.
func (*Client) Exploits ¶
Exploits calls '/api/exploits' from the exploit API and returns the unmarshalled response. query is the search query string. facets are any facets to add to the request.
func (*Client) Host ¶
Host calls '/shodan/host/{ip}' and returns the unmarshalled response. ip is the IP address to search for. opts are all query paramters to pass in the request. You do not have to provide your API key.
func (*Client) HostCount ¶
HostCount calls '/shodan/host/count' and returns the unmarshalled response. query is the search query to pass in the request. facets are any facets to pass in the request.
func (*Client) HostSearch ¶
HostSearch calls '/shodan/host/search' and returns the unmarshalled response. query is the search query to pass in the request. facets are any facets to pass in the request. opts are any additional query parameters to set, such as page and minify.
func (*Client) HostSearchTokens ¶
func (c *Client) HostSearchTokens(query string) (*HostSearchTokens, error)
HostSearchTokens calls '/shodan/host/search/tokens' and returns the unmarshalled response. query is the search query to pass in the request.
func (*Client) Protocols ¶
Protocols calls '/shodan/protocols' and returns the unmarshalled response.
func (*Client) Query ¶
Query calls '/shodan/query' and returns the unmarshalled response. opts are additional query parameters. You do not need to provide your API key.
func (*Client) QuerySearch ¶
QuerySearch calls '/shodan/query/search' and returns the unmarshalled response. query is the search query to pass in the request. opts are additional query parameters. You do not need to provide your API key.
type DNSResolve ¶
DNSResolve is used to transform the map[string]string response from '/dns/resolve' into a struct that is a bit easier to work with.
type DNSReverse ¶
DNSReverse is used to transform the map[string][]string response from '/dns/reverse' into a struct that is a bit easier to work with.
type Error ¶
type Error struct {
Error string `json:"error"`
}
Error used to unmarshal the JSON response of an error.
type Exploit ¶
type Exploit struct { Matches []struct { Source string `json:"source"` ID interface{} `json:"_id"` Author interface{} `json:"author"` Code interface{} `json:"code"` Date time.Time `json:"date"` Platform interface{} `json:"platform"` Port int `json:"port"` Type string `json:"type"` Description string `json:"description"` Osvdb []int `json:"osvdb"` Bid []int `json:"bid"` Cve []string `json:"cve"` Msb []interface{} `json:"msb"` } `json:"matches"` Total int `json:"total"` }
Exploit is used to unmarshal the JSON response from '/api/search'.
type Host ¶
type Host struct { RegionCode string `json:"region_code"` IP int `json:"ip"` AreaCode int `json:"area_code"` Latitude float64 `json:"latitude"` Hostnames []string `json:"hostnames"` PostalCode string `json:"postal_code"` DmaCode int `json:"dma_code"` CountryCode string `json:"country_code"` Org string `json:"org"` Data []struct { Product string `json:"product"` Title string `json:"title"` Opts struct { } `json:"opts"` Timestamp string `json:"timestamp"` Isp string `json:"isp"` Cpe []string `json:"cpe"` Data string `json:"data"` HTML string `json:"html"` Location struct { City string `json:"city"` RegionCode string `json:"region_code"` AreaCode int `json:"area_code"` Longitude float64 `json:"longitude"` CountryCode3 string `json:"country_code3"` Latitude float64 `json:"latitude"` PostalCode string `json:"postal_code"` DmaCode int `json:"dma_code"` CountryCode string `json:"country_code"` CountryName string `json:"country_name"` } `json:"location"` IP int `json:"ip"` Domains []string `json:"domains"` Org string `json:"org"` Os interface{} `json:"os"` Port int `json:"port"` Hostnames []string `json:"hostnames"` IPStr string `json:"ip_str"` } `json:"data"` City string `json:"city"` Isp string `json:"isp"` Asn string `json:"asn"` Longitude float64 `json:"longitude"` LastUpdate string `json:"last_update"` CountryCode3 string `json:"country_code3"` CountryName string `json:"country_name"` IPStr string `json:"ip_str"` Os interface{} `json:"os"` Ports []int `json:"ports"` }
Host is used to unmarshal the JSON response from '/shodan/host/{ip}'.
type HostCount ¶
type HostCount struct { Matches []interface{} `json:"matches"` Facets struct { Org []struct { Count int `json:"count"` Value string `json:"value"` } `json:"org"` } `json:"facets"` Total int `json:"total"` }
HostCount is used to unmarshal the JSON response from '/shodan/host/count'.
type HostSearch ¶
type HostSearch struct { Matches []struct { Os interface{} `json:"os"` Timestamp string `json:"timestamp"` Isp string `json:"isp"` Asn string `json:"asn"` Hostnames []interface{} `json:"hostnames"` Location struct { City interface{} `json:"city"` RegionCode interface{} `json:"region_code"` AreaCode interface{} `json:"area_code"` Longitude float64 `json:"longitude"` CountryCode3 string `json:"country_code3"` CountryName string `json:"country_name"` PostalCode interface{} `json:"postal_code"` DmaCode interface{} `json:"dma_code"` CountryCode string `json:"country_code"` Latitude float64 `json:"latitude"` } `json:"location"` IP int64 `json:"ip"` Domains []interface{} `json:"domains"` Data string `json:"data"` Org string `json:"org"` Port int `json:"port"` IPStr string `json:"ip_str"` } `json:"matches"` Facets struct { Org []struct { Count int `json:"count"` Value string `json:"value"` } `json:"org"` } `json:"facets"` Total int `json:"total"` }
HostSearch is used to unmarshal the JSON response from '/shodan/host/search'.
type HostSearchTokens ¶
type HostSearchTokens struct { Attributes struct { Ports []int `json:"ports"` } `json:"attributes"` Errors []interface{} `json:"errors"` String string `json:"string"` Filters []string `json:"filters"` }
HostSearchTokens is used to unmarshal the JSON response from '/shodan/host/search/tokens'.
type Query ¶
type Query struct { Total int `json:"total"` Matches []struct { Votes int `json:"votes"` Description string `json:"description"` Title string `json:"title"` Timestamp string `json:"timestamp"` Tags []string `json:"tags"` Query string `json:"query"` } `json:"matches"` }
Query is used to unmarshal the JSON response from '/shodan/query/{search}'.
type QueryTags ¶
type QueryTags struct { Total int `json:"total"` Matches []struct { Value string `json:"value"` Count int `json:"count"` } `json:"matches"` }
QueryTags is used to unmarshal the JSON response from '/shodan/query/tags'.
type Scan ¶
type Scan struct { ID string `json:"id"` Count int `json:"count"` CreditsLeft int `json:"credits_left"` }
Scan is used to unmarshal the JSON response from '/shodan/scan'. This is not implemented.
type ScanInternet ¶
type ScanInternet struct {
ID string `json:"id"`
}
ScanInternet is used to unmarshal the JSON response from '/shodan/scan/internet'. This is not implemented.