shodan

package
v0.0.0-...-d7f4059 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProviderName      = "shodan"
	APIURL            = "https://api.shodan.io"
	HostIPPath        = "/shodan/host"
	IndentPipeHyphens = " |-----"

	ResultTTL  = 12 * time.Hour
	APITimeout = 10 * time.Second
)

Variables

This section is empty.

Functions

func NewProviderClient

func NewProviderClient(c session.Session) (providers.ProviderClient, error)

Types

type Client

type Client struct {
	Config     Config
	HTTPClient *retryablehttp.Client
}

func (*Client) GetConfig

func (c *Client) GetConfig() *session.Session

func (*Client) GetData

func (c *Client) GetData() (*HostSearchResult, error)

type Config

type Config struct {
	session.Session
	Host   netip.Addr
	APIKey string
	// contains filtered or unexported fields
}

type DNS

type DNS struct {
	ResolverHostname any  `json:"resolver_hostname"`
	Recursive        bool `json:"recursive"`
	ResolverID       any  `json:"resolver_id"`
	Software         any  `json:"software"`
}

type HTTP

type HTTP struct {
	Status     int `json:"status"`
	RobotsHash int `json:"robots_hash"`
	Redirects  []struct {
		Host     string `json:"host"`
		Data     string `json:"data"`
		Location string `json:"location"`
	}
	SecurityTxt string `json:"security_txt"`
	Title       string `json:"title"`
	SitemapHash int    `json:"sitemap_hash"`
	HTMLHash    int    `json:"html_hash"`
	Robots      string `json:"robots"`
	Favicon     struct {
		Hash     int    `json:"hash"`
		Data     string `json:"data"`
		Location string `json:"location"`
	} `json:"favicon"`
	HeadersHash     int      `json:"headers_hash"`
	Host            string   `json:"host"`
	HTML            string   `json:"html"`
	Location        string   `json:"location"`
	Components      struct{} `json:"components"`
	Server          string   `json:"server"`
	Sitemap         string   `json:"sitemap"`
	SecurityTxtHash int      `json:"securitytxt_hash"`
}

type HostSearchResult

type HostSearchResult struct {
	Raw         []byte   `json:"raw"`
	City        string   `json:"city"`
	RegionCode  string   `json:"region_code"`
	Os          any      `json:"os"`
	Tags        []any    `json:"tags"`
	IP          int      `json:"ip"`
	Isp         string   `json:"isp"`
	AreaCode    any      `json:"area_code"`
	Longitude   float64  `json:"longitude"`
	LastUpdate  string   `json:"last_update"`
	Ports       []int    `json:"ports"`
	Latitude    float64  `json:"latitude"`
	Hostnames   []string `json:"hostnames"`
	CountryCode string   `json:"country_code"`
	CountryName string   `json:"country_name"`
	Domains     []string `json:"domains"`
	Org         string   `json:"org"`
	Data        []HostSearchResultData
	Asn         string `json:"asn"`
	IPStr       string `json:"ip_str"`
	Error       string `json:"error"`
}

func (*HostSearchResult) CreateTable

func (ssr *HostSearchResult) CreateTable() *table.Writer

type HostSearchResultData

type HostSearchResultData struct {
	Hash      int      `json:"hash"`
	Opts      struct{} `json:"opts,omitempty"`
	Timestamp string   `json:"timestamp"`
	Isp       string   `json:"isp"`
	Data      string   `json:"data"`
	Shodan    struct {
		Region  string   `json:"region"`
		Module  string   `json:"module"`
		Ptr     bool     `json:"ptr"`
		Options struct{} `json:"options"`
		ID      string   `json:"id"`
		Crawler string   `json:"crawler"`
	} `json:"_shodan,omitempty"`
	Port      int      `json:"port"`
	Hostnames []string `json:"hostnames"`
	Location  struct {
		City        string  `json:"city"`
		RegionCode  string  `json:"region_code"`
		AreaCode    any     `json:"area_code"`
		Longitude   float64 `json:"longitude"`
		CountryName string  `json:"country_name"`
		CountryCode string  `json:"country_code"`
		Latitude    float64 `json:"latitude"`
	} `json:"location"`
	DNS       DNS      `json:"dns,omitempty"`
	SSH       SSH      `json:"ssh"`
	HTTP      HTTP     `json:"http,omitempty"`
	IP        int      `json:"ip"`
	Domains   []string `json:"domains"`
	Org       string   `json:"org"`
	Os        any      `json:"os"`
	Asn       string   `json:"asn"`
	Transport string   `json:"transport"`
	IPStr     string   `json:"ip_str"`
	Ssl       Ssl      `json:"ssl,omitempty"`
}

type Provider

type Provider interface {
	LoadData() ([]byte, error)
	CreateTable([]byte) (*table.Writer, error)
}

type ProviderClient

type ProviderClient struct {
	session.Session
}

func (*ProviderClient) CreateTable

func (c *ProviderClient) CreateTable(data []byte) (*table.Writer, error)

func (*ProviderClient) Enabled

func (c *ProviderClient) Enabled() bool

func (*ProviderClient) ExtractThreatIndicators

func (c *ProviderClient) ExtractThreatIndicators(findRes []byte) (*providers.ThreatIndicators, error)

func (*ProviderClient) FindHost

func (c *ProviderClient) FindHost() ([]byte, error)

func (*ProviderClient) GetConfig

func (c *ProviderClient) GetConfig() *session.Session

func (*ProviderClient) Initialise

func (c *ProviderClient) Initialise() error

func (*ProviderClient) Priority

func (c *ProviderClient) Priority() *int32

func (*ProviderClient) RateHostData

func (c *ProviderClient) RateHostData(findRes []byte, ratingConfigJSON []byte) (providers.RateResult, error)

type SSH

type SSH struct {
	Hassh       string `json:"hassh"`
	Fingerprint string `json:"fingerprint"`
	Mac         string `json:"mac"`
	Cipher      string `json:"cipher"`
	Key         string `json:"key"`
	Kex         struct {
		Languages               []string `json:"languages"`
		ServerHostKeyAlgorithms []string `json:"server_host_key_algorithms"`
		EncryptionAlgorithms    []string `json:"encryption_algorithms"`
		KexFollows              bool     `json:"kex_follows"`
		Unused                  int      `json:"unused"`
		KexAlgorithms           []string `json:"kex_algorithms"`
		CompressionAlgorithms   []string `json:"compression_algorithms"`
		MacAlgorithms           []string `json:"mac_algorithms"`
	} `json:"kex"`
	Type string `json:"type"`
}

type Ssl

type Ssl struct {
	ChainSha256   []string `json:"chain_sha256"`
	Jarm          string   `json:"jarm"`
	Chain         []string `json:"chain"`
	Dhparams      any      `json:"dhparams"`
	Versions      []string `json:"versions"`
	AcceptableCas []any    `json:"acceptable_cas"`
	Tlsext        []struct {
		ID   int    `json:"id"`
		Name string `json:"name"`
	} `json:"tlsext"`
	Ja3S string `json:"ja3s"`
	Cert struct {
		SigAlg     string `json:"sig_alg"`
		Issued     string `json:"issued"`
		Expires    string `json:"expires"`
		Expired    bool   `json:"expired"`
		Version    int    `json:"version"`
		Extensions []struct {
			Critical bool   `json:"critical,omitempty"`
			Data     string `json:"data"`
			Name     string `json:"name"`
		} `json:"extensions"`
		Fingerprint struct {
			Sha256 string `json:"sha256"`
			Sha1   string `json:"sha1"`
		} `json:"fingerprint"`
		Serial  json.RawMessage `json:"serial"`
		Subject struct {
			Cn string `json:"CN"`
		} `json:"subject"`
		Pubkey struct {
			Type string `json:"type"`
			Bits int    `json:"bits"`
		} `json:"pubkey"`
		Issuer struct {
			C  string `json:"C"`
			Cn string `json:"CN"`
			O  string `json:"O"`
		} `json:"issuer"`
	} `json:"cert"`
	Cipher struct {
		Version string `json:"version"`
		Bits    int    `json:"bits"`
		Name    string `json:"name"`
	} `json:"cipher"`
	Trust struct {
		Revoked bool `json:"revoked"`
		Browser any  `json:"browser"`
	} `json:"trust"`
	HandshakeStates []string `json:"handshake_states"`
	Alpn            []any    `json:"alpn"`
	Ocsp            struct{} `json:"ocsp"`
}

Jump to

Keyboard shortcuts

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