Documentation
¶
Index ¶
- Constants
- Variables
- type APIInfo
- type Alert
- type AlertFilters
- type Client
- func (c *Client) BreakQueryIntoTokens(query string) (*HostQueryTokens, error)
- func (c *Client) CalcHoneyScore(ip string) (float64, error)
- func (c *Client) CountExploits(options *ExploitSearchOptions) (*ExploitSearch, error)
- func (c *Client) CreateAlert(name string, ip []string, expires int) (*Alert, error)
- func (c *Client) DeleteAlert(id string) (bool, error)
- func (c *Client) GetAPIInfo() (*APIInfo, error)
- func (c *Client) GetAccountProfile() (*Profile, error)
- func (c *Client) GetAlert(id string) (*Alert, error)
- func (c *Client) GetAlerts() ([]*Alert, error)
- func (c *Client) GetBanners()
- func (c *Client) GetBannersByAlert(id string)
- func (c *Client) GetBannersByAlerts()
- func (c *Client) GetBannersByPorts(ports []int)
- func (c *Client) GetDNSResolve(hostnames []string) (map[string]*string, error)
- func (c *Client) GetDNSReverse(ip []string) (map[string]*[]string, error)
- func (c *Client) GetHTTPHeaders() (map[string]string, error)
- func (c *Client) GetHostsCountForQuery(options *HostQueryOptions) (*HostMatch, error)
- func (c *Client) GetHostsForQuery(options *HostQueryOptions) (*HostMatch, error)
- func (c *Client) GetMyIP() (string, error)
- func (c *Client) GetPorts() ([]int, error)
- func (c *Client) GetProtocols() (map[string]string, error)
- func (c *Client) GetQueries(options *QueryOptions) (*QuerySearch, error)
- func (c *Client) GetQueryTags(options *QueryTagsOptions) (*QueryTags, error)
- func (c *Client) GetServices() (map[string]string, error)
- func (c *Client) GetServicesForHost(ip string, options *HostServicesOptions) (*Host, error)
- func (c *Client) Scan(ip []string) (*CrawlScanStatus, error)
- func (c *Client) ScanInternet(port int, protocol string) (string, error)
- func (c *Client) SearchExploits(options *ExploitSearchOptions) (*ExploitSearch, error)
- func (c *Client) SearchQueries(options *SearchQueryOptions) (*QuerySearch, error)
- type CrawlScanStatus
- type Exploit
- type ExploitPlatform
- type ExploitSearch
- type ExploitSearchOptions
- type ExploitSource
- type ExploitType
- type Facet
- type Host
- type HostData
- type HostLocation
- type HostMatch
- type HostQueryOptions
- type HostQueryTokens
- type HostServicesOptions
- type HostVersion
- type Profile
- type QueryOptions
- type QuerySearch
- type QuerySearchMatch
- type QueryTags
- type QueryTagsMatch
- type QueryTagsOptions
- type SearchQueryOptions
Constants ¶
const ( // ExploitSourceCVE is "CVE". ExploitSourceCVE ExploitSource = "CVE" // ExploitSourceMetasploit is "Metasploit". ExploitSourceMetasploit ExploitSource = "Metasploit" // ExploitSourceExploitDB is "ExploitDB". ExploitSourceExploitDB ExploitSource = "ExploitDB" // ExploitTypeDOS is "dos". ExploitTypeDOS ExploitType = "dos" // ExploitTypeExploit is "exploit". ExploitTypeExploit ExploitType = "exploit" // ExploitTypeLocal is "local". ExploitTypeLocal ExploitType = "local" // ExploitTypeRemote is "remote". ExploitTypeRemote ExploitType = "remote" // ExploitTypeShellcode is "shellcode". ExploitTypeShellcode ExploitType = "shellcode" // ExploitTypeWebapps is "webapps". ExploitTypeWebapps ExploitType = "webapps" // ExploitPlatformAix is "aix". ExploitPlatformAix ExploitPlatform = "aix" // ExploitPlatformCGI is "cgi". ExploitPlatformCGI ExploitPlatform = "cgi" // ExploitPlatformFreeBSD is "freebsd". ExploitPlatformFreeBSD ExploitPlatform = "freebsd" // ExploitPlatformHardware is "hardware". ExploitPlatformHardware ExploitPlatform = "hardware" // ExploitPlatformJava is "Java". ExploitPlatformJava ExploitPlatform = "Java" // ExploitPlatformJSP is "jsp". ExploitPlatformJSP ExploitPlatform = "jsp" // ExploitPlatformLin86 is "lin_x86". ExploitPlatformLin86 ExploitPlatform = "lin_x86" // ExploitPlatformLinux is "Linux". ExploitPlatformLinux ExploitPlatform = "Linux" // ExploitPlatformMultiple is "multiple". ExploitPlatformMultiple ExploitPlatform = "multiple" // ExploitPlatformNovell is "novell". ExploitPlatformNovell ExploitPlatform = "novell" // ExploitPlatformOSX is "osx". ExploitPlatformOSX ExploitPlatform = "osx" // ExploitPlatformPHP is "PHP". ExploitPlatformPHP ExploitPlatform = "PHP" // ExploitPlatformTrue64 is "true64". ExploitPlatformTrue64 ExploitPlatform = "true64" // ExploitPlatformUnix is "Unix". ExploitPlatformUnix ExploitPlatform = "Unix" // ExploitPlatformWindows is "Windows". ExploitPlatformWindows ExploitPlatform = "Windows" )
Variables ¶
var ( // ErrInvalidQuery is returned when query is not valid. ErrInvalidQuery = errors.New("query is invalid") // ErrBodyRead is returned when response's body cannot be read. ErrBodyRead = errors.New("could not read error response") )
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"` UnlockedLeft int `json:"unlocked_left"` }
APIInfo holds API information.
type Alert ¶ added in v1.0.2
type Alert struct { ID string `json:"id"` Name string `json:"name"` Created string `json:"created"` Expiration string `json:"expiration"` Expires int `json:"expires"` Expired bool `json:"expired"` Size int `json:"size"` Filters *AlertFilters `json:"filters"` }
Alert represents a trigger to react to network scan request.
type AlertFilters ¶ added in v1.0.2
type AlertFilters struct {
IP []string `json:"ip"`
}
AlertFilters holds alert criteria (only ip for now).
type Client ¶
type Client struct { Token string BaseURL string ExploitBaseURL string StreamBaseURL string StreamChan chan HostData Client *http.Client }
Client represents Shodan HTTP client
func (*Client) BreakQueryIntoTokens ¶
func (c *Client) BreakQueryIntoTokens(query string) (*HostQueryTokens, error)
BreakQueryIntoTokens determines which filters are being used by the query string and what parameters were provided to the filters.
func (*Client) CalcHoneyScore ¶
CalcHoneyScore calculates a honeypot probability score ranging from 0 (not a honeypot) to 1.0 (is a honeypot)
func (*Client) CountExploits ¶
func (c *Client) CountExploits(options *ExploitSearchOptions) (*ExploitSearch, error)
CountExploits behaves identical to the "/search" method with the difference that it doesn't return any results.
func (*Client) CreateAlert ¶ added in v1.0.2
CreateAlert creates a network alert for a defined IP/ netblock which can be used to subscribe to changes/ events that are discovered within that range.
func (*Client) DeleteAlert ¶ added in v1.0.2
DeleteAlert removes the specified network alert.
func (*Client) GetAPIInfo ¶
GetAPIInfo returns information about the API plan belonging to the given API key.
func (*Client) GetAccountProfile ¶
GetAccountProfile returns information about the Shodan account linked to the API key
func (*Client) GetAlert ¶ added in v1.0.2
GetAlert returns the information about a specific network alert.
func (*Client) GetAlerts ¶ added in v1.0.2
GetAlerts returns a listing of all the network alerts that are currently active on the account.
func (*Client) GetBanners ¶
func (c *Client) GetBanners()
GetBanners provides ALL of the data that Shodan collects. Use this stream if you need access to everything and / or want to store your own Shodan database locally. If you only care about specific ports, please use the Ports stream.
func (*Client) GetBannersByAlert ¶
GetBannersByAlert subscribes to banners discovered on the IP range defined in a specific network alert.
func (*Client) GetBannersByAlerts ¶
func (c *Client) GetBannersByAlerts()
GetBannersByAlerts subscribes to banners discovered on all IP ranges described in the network alerts.
func (*Client) GetBannersByPorts ¶
GetBannersByPorts returns only banner data for the list of specified hosts. This stream provides a filtered, bandwidth-saving view of the Banners stream in case you are only interested in a specific list of ports.
func (*Client) GetDNSResolve ¶
GetDNSResolve looks up the IP address for the provided list of hostnames
func (*Client) GetDNSReverse ¶
GetDNSReverse looks up the hostnames that have been defined for the given list of IP addresses
func (*Client) GetHTTPHeaders ¶
GetHTTPHeaders shows the HTTP headers that your client sends when connecting to a webserver.
func (*Client) GetHostsCountForQuery ¶
func (c *Client) GetHostsCountForQuery(options *HostQueryOptions) (*HostMatch, error)
GetHostsCountForQuery behaves identical to "/shodan/host/search" with the only difference that this method does not return any host results, it only returns the total number of results that matched the query and any facet information that was requested. As a result this method does not consume query credits
func (*Client) GetHostsForQuery ¶
func (c *Client) GetHostsForQuery(options *HostQueryOptions) (*HostMatch, error)
GetHostsForQuery searches Shodan using the same query syntax as the website and use facets to get summary information for different properties. This method may use API query credits depending on usage. If any of the following criteria are met, your account will be deducated 1 query credit: 1. The search query contains a filter 2. Accessing results past the 1st page using the "page". For every 100 results past the 1st page 1 query credit is deducted
func (*Client) GetMyIP ¶
GetMyIP returns your current IP address as seen from the Internet API key for this method is unnecessary
func (*Client) GetProtocols ¶
GetProtocols returns an object containing all the protocols that can be used when launching an Internet scan
func (*Client) GetQueries ¶
func (c *Client) GetQueries(options *QueryOptions) (*QuerySearch, error)
GetQueries obtains a list of search queries that users have saved in Shodan.
func (*Client) GetQueryTags ¶
func (c *Client) GetQueryTags(options *QueryTagsOptions) (*QueryTags, error)
GetQueryTags obtains a list of popular tags for the saved search queries in Shodan.
func (*Client) GetServices ¶
GetServices returns an object containing all the services that the Shodan crawlers look at It can also be used as a quick and practical way to resolve a port number to the name of a service
func (*Client) GetServicesForHost ¶
func (c *Client) GetServicesForHost(ip string, options *HostServicesOptions) (*Host, error)
GetServicesForHost returns all services that have been found on the given host IP
func (*Client) Scan ¶
func (c *Client) Scan(ip []string) (*CrawlScanStatus, error)
Scan requests Shodan to crawl a network. This method uses API scan credits: 1 IP consumes 1 scan credit. You must have a paid API plan (either one-time payment or subscription) in order to use this method.
func (*Client) ScanInternet ¶
ScanInternet requests Shodan to crawl the Internet for a specific port. This method is restricted to security researchers and companies with a Shodan Data license. To apply for access to this method as a researcher, please email jmath@shodan.io with information about your project. Access is restricted to prevent abuse.
func (*Client) SearchExploits ¶
func (c *Client) SearchExploits(options *ExploitSearchOptions) (*ExploitSearch, error)
SearchExploits searches across a variety of data sources for exploits and use facets to get summary information.
func (*Client) SearchQueries ¶
func (c *Client) SearchQueries(options *SearchQueryOptions) (*QuerySearch, error)
SearchQueries searches the directory of search queries that users have saved in Shodan.
type CrawlScanStatus ¶
type CrawlScanStatus struct { ID string `json:"id"` Count int `json:"count"` CreditsLeft int `json:"credits_left"` }
CrawlScanStatus is the result of a scan.
type Exploit ¶
type Exploit struct { // Unique ID for the exploit/ vulnerability (integer or string) ID interface{} `json:"_id"` // An array of Bugtraq IDs that reference this vulnerability BID []int `json:"bid"` // An array of relevant CVE IDs that reference this exploit CVE []string `json:"cve"` // An array of Microsoft Security Bulletin reference IDs for this exploit MSB []string `json:"msb"` // An array (integer or string) of OSVDB IDs that are relevant to this exploit OSVDB []interface{} `json:"osvdb"` // A description explaining the details of the exploit Description string `json:"description"` // The name of the data source Source ExploitSource `json:"source"` // The author of the exploit/vulnerability Author interface{} `json:"author"` // The actual code for the exploit Code string `json:"code"` // The timestamp for when the exploit was released in the UTC timezone. Example: "2014-01-15T05:49:56.283713" Date string `json:"date"` // An array of platforms or a single platform that the exploit targets Platform interface{} `json:"platform"` // The port number for the affected service Port int `json:"port"` // The type of exploit Type ExploitType `json:"type"` // Is Privileged? Privileged bool `json:"privileged"` // Rank, i.e. "excellent" Rank string `json:"rank"` // Version Version string `json:"version"` }
Exploit represents the normalized data from a variety of vulnerability data sources.
type ExploitSearch ¶
type ExploitSearch struct { Matches []*Exploit `json:"matches"` Facets map[string][]*Facet `json:"facets"` Total int `json:"total"` }
ExploitSearch is exploit search results.
type ExploitSearchOptions ¶
type ExploitSearchOptions struct { // Search query used to search the database of known exploits Query string `url:"query"` // A comma-separated list of properties to get summary information on Facets string `url:"facets,omitempty"` // The page number to page through results 100 at a time. It is ignored in CountExploits method Page int `url:"page,omitempty"` }
ExploitSearchOptions is options for exploit search query.
type Host ¶
type Host struct { OS string `json:"os"` Ports []int `json:"ports"` IPLong int `json:"ip"` IP string `json:"ip_str"` ISP string `json:"isp"` Hostnames []string `json:"hostnames"` Organization string `json:"org"` Vulnerabilities []string `json:"vulns"` ASN string `json:"asn"` LastUpdate string `json:"last_update"` Data []*HostData `json:"data"` HostLocation }
Host is the all information about the host.
type HostData ¶
type HostData struct { Product string `json:"product"` Hostnames []string `json:"hostnames"` Version HostVersion `json:"version"` Title string `json:"title"` IPLong int `json:"ip"` IP string `json:"ip_str"` OS string `json:"os"` Organization string `json:"org"` ISP string `json:"isp"` CPE []string `json:"cpe"` Data string `json:"data"` ASN string `json:"asn"` Port int `json:"port"` HTML string `json:"html"` Banner string `json:"banner"` Link string `json:"link"` Transport string `json:"transport"` Domains []string `json:"domains"` Timestamp string `json:"timestamp"` DeviceType string `json:"devicetype"` Location *HostLocation `json:"location"` ShodanData map[string]interface{} `json:"_shodan"` Opts map[string]interface{} `json:"opts"` }
HostData is all services that have been found on the given host IP.
type HostLocation ¶
type HostLocation struct { City string `json:"city"` RegionCode string `json:"region_code"` AreaCode int `json:"area_code"` Latitude float64 `json:"latitude"` Longitude float64 `json:"longitude"` Country string `json:"country_name"` CountryCode string `json:"country_code"` CountryCode3 string `json:"country_code3"` Postal string `json:"postal_code"` DMA int `json:"dma_code"` }
HostLocation is the location of the host.
type HostMatch ¶
type HostMatch struct { Total int `json:"total"` Facets map[string][]*Facet `json:"facets"` Matches []*HostData `json:"matches"` }
HostMatch is the search results with all matched hosts.
type HostQueryOptions ¶
type HostQueryOptions struct { Query string `url:"query"` Facets string `url:"facets,omitempty"` Minify bool `url:"minify,omitempty"` Page int `url:"page,omitempty"` }
HostQueryOptions is Shodan search query options.
type HostQueryTokens ¶
type HostQueryTokens struct { Filters []string `json:"filters"` String string `json:"string"` Errors []string `json:"errors"` // FIXME: should it really be interface{} ? Attributes map[string]interface{} `json:"attributes"` }
HostQueryTokens is filters are being used by the query string and what parameters were provided to the filters.
type HostServicesOptions ¶
type HostServicesOptions struct { History bool `url:"history,omitempty"` Minify bool `url:"minify,omitempty"` }
HostServicesOptions is options for querying services.
type HostVersion ¶
type HostVersion string
HostVersion is string with custom unmarshaling.
func (*HostVersion) String ¶
func (v *HostVersion) String() string
func (*HostVersion) UnmarshalJSON ¶
func (v *HostVersion) UnmarshalJSON(b []byte) error
UnmarshalJSON handles either a string or a number and casts it to string.
type Profile ¶
type Profile struct { Member bool `json:"member"` Credits int `json:"credits"` Name string `json:"display_name"` Created string `json:"created"` }
Profile holds account's information
type QueryOptions ¶
type QueryOptions struct { // Page number to iterate over results; each page contains 10 items. Page int `url:"page,omitempty"` // Sort the list based on a property. Possible values are: votes, timestamp. Sort string `url:"sort,omitempty"` // Whether to sort the list in ascending or descending order. Possible values are: asc, desc. Order string `url:"order,omitempty"` }
QueryOptions represents query options for fetching saved queries.
type QuerySearch ¶
type QuerySearch struct { Total int `json:"total"` Matches []*QuerySearchMatch `json:"matches"` }
QuerySearch is the results of querying saved search queries.
type QuerySearchMatch ¶
type QuerySearchMatch struct { Title string `json:"title"` Description string `json:"description"` Query string `json:"query"` Votes int `json:"votes"` Timestamp string `json:"timestamp"` Tags []string `json:"tags"` }
QuerySearchMatch is a match of QuerySearch.
type QueryTags ¶
type QueryTags struct { Total int `json:"total"` Matches []*QueryTagsMatch `json:"matches"` }
QueryTags represents matched tags.
type QueryTagsMatch ¶
QueryTagsMatch represents a matched tag.
type QueryTagsOptions ¶
type QueryTagsOptions struct { // The number of tags to return (default: 10). Size int `url:"size,omitempty"` }
QueryTagsOptions represents options for GetQueryTags.
type SearchQueryOptions ¶
type SearchQueryOptions struct { // What to search for in the directory of saved search queries. Query string `url:"query"` // Page number to iterate over results; each page contains 10 items. Page int `url:"page,omitempty"` }
SearchQueryOptions is options for SearchQueries.