shodanidb

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package shodanidb exposes the Shodan InternetDB API as a kit Domain driver. A multi-domain host (ant) enables it with a single blank import:

import _ "github.com/tamnd/shodan-idb-cli/shodan-idb"

The same Domain also builds the standalone shodan binary (see cli/root.go), so the binary and a host share one source of truth.

Package shodanidb is the library behind the shodan command line: the HTTP client, request shaping, and the typed data models for the Shodan InternetDB API (internetdb.shodan.io).

No API key required. The API is public and free. The Client sets a real User-Agent, paces requests to stay polite, and retries transient failures (429 and 5xx). A 404 response (IP not in index) is returned as an empty IPInfo record, not an error.

Index

Constants

View Source
const Host = "internetdb.shodan.io"

Host is the site this client talks to.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client talks to the Shodan InternetDB API over HTTP.

func NewClient

func NewClient(cfg Config) *Client

NewClient returns a Client configured with cfg.

func (*Client) Batch

func (c *Client) Batch(ctx context.Context, ips []string) ([]IPInfo, error)

Batch fetches IP intelligence for multiple IP addresses sequentially.

func (*Client) Lookup

func (c *Client) Lookup(ctx context.Context, ip string) (*IPInfo, error)

Lookup fetches IP intelligence for a single IP address. A 404 response (IP not in the Shodan index) returns an IPInfo with just the IP set and all slice fields empty — it is not treated as an error.

type Config

type Config struct {
	BaseURL   string
	UserAgent string
	Rate      time.Duration
	Timeout   time.Duration
	Retries   int
}

Config holds all tunable parameters for the Client.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config with sensible defaults.

type Domain

type Domain struct{}

Domain is the shodan-idb driver.

func (Domain) Classify

func (Domain) Classify(input string) (uriType, id string, err error)

Classify validates an IP address input and returns type "ip" and the IP as id.

func (Domain) Info

func (Domain) Info() kit.DomainInfo

Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.

func (Domain) Locate

func (Domain) Locate(uriType, id string) (string, error)

Locate returns the live https URL for a (type, id).

func (Domain) Register

func (Domain) Register(app *kit.App)

Register installs the client factory and every operation onto app.

type IPInfo

type IPInfo struct {
	IP        string   `json:"ip"`
	Ports     []int    `json:"ports"`
	Hostnames []string `json:"hostnames"`
	Tags      []string `json:"tags"`
	CPEs      []string `json:"cpes"`
	Vulns     []string `json:"vulns"`
}

IPInfo is the structured data for a single IP from the Shodan InternetDB.

Jump to

Keyboard shortcuts

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