shodan

package
v1.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2024 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package shodan is an interface for the Shodan API

Index

Constants

This section is empty.

Variables

View Source
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 New

func New(key string) *Client

New returns a new Client.

func (*Client) APIInfo

func (c *Client) APIInfo() (*APIInfo, error)

APIInfo calls '/api-info' and returns the unmarshalled response.

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

func (c *Client) Exploits(query string, facets []string) (*Exploit, error)

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

func (c *Client) Host(ip string, opts url.Values) (*Host, error)

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

func (c *Client) HostCount(query string, facets []string) (*HostCount, error)

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

func (c *Client) HostSearch(query string, facets []string, opts url.Values) (*HostSearch, error)

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

func (c *Client) Protocols() (map[string]string, error)

Protocols calls '/shodan/protocols' and returns the unmarshalled response.

func (*Client) Query

func (c *Client) Query(opts url.Values) (*Query, error)

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

func (c *Client) QuerySearch(query string, opts url.Values) (*Query, error)

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.

func (*Client) QueryTags

func (c *Client) QueryTags(opts url.Values) (*QueryTags, error)

QueryTags calls '/shodan/query/tags' and returns the unmarshalled response. opts are additional query parameters. You do not need to provide your API key.

func (*Client) Services

func (c *Client) Services() (map[string]string, error)

Services calls '/shodan/services' and returns the unmarshalled response.

type DNSResolve

type DNSResolve struct {
	Hostname string
	IP       string
}

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

type DNSReverse struct {
	IP        string
	Hostnames []string
}

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"`
		HTTP struct {
			RobotsHash      interface{}            `json:"robots_hash"`
			Redirects       []interface{}          `json:"redirects"`
			Securitytxt     interface{}            `json:"securitytxt"`
			Title           string                 `json:"title"`
			SitemapHash     interface{}            `json:"sitemap_hash"`
			Robots          interface{}            `json:"robots"`
			Server          string                 `json:"server"`
			Host            string                 `json:"host"`
			HTML            string                 `json:"html"`
			Location        string                 `json:"location"`
			Components      map[string]interface{} `json:"components"`
			SecuritytxtHash interface{}            `json:"securitytxt_hash"`
			Sitemap         interface{}            `json:"sitemap"`
			HTMLHash        int                    `json:"html_hash"`
		}
		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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL