Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gopkg.in/ns3777k/go-shodan.v2

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gopkg.in/ns3777k/go-shodan.v2

  • v2.0.4
  • Go
  • Socket score

Version published
Created
Source

go-shodan

Build Status Build status codecov GoDoc MIT License Go Report Card codebeat badge

To start working with Shodan you have to get your token first. You can do this at https://www.shodan.io.

Installation

Download the package:

go get "gopkg.in/ns3777k/go-shodan.v2"

2nd version has some breaking changes:

  • Dropped support for old golang versions (1.1 - 1.5)
  • GetHttpHeaders is renamed to GetHTTPHeaders
  • Invalid url will now panic
  • Stream methods no longer return error

Streaming API methods will be totally reworked at version 3.

To use the old version:

go get "gopkg.in/ns3777k/go-shodan.v1"

That's it. You're ready to roll :-)

Usage

Simple example of resolving hostnames:

package main

import (
    "log"

    "gopkg.in/ns3777k/go-shodan.v2/shodan"
)

func main() {
    client := shodan.NewEnvClient(nil)
    dns, err := client.GetDNSResolve([]string{"google.com", "ya.ru"})

    if err != nil {
        log.Panic(err)
    } else {
        log.Println(*dns["google.com"])
    }
}

Output for above:

2015/09/05 18:50:52 173.194.115.35

Streaming example:

package main

import (
    "log"

    "gopkg.in/ns3777k/go-shodan.v2/shodan"
)

func main() {
    client := shodan.NewEnvClient(nil)

    go func() {
        for {
            banner, ok := <- client.StreamChan
            if !ok {
                log.Fatalln("channel got closed")
            }

            // Do something here with banner
        }
    }()

    go client.GetBanners()

    for {
        time.Sleep(time.Second * 10)
    }
}

Implemented REST API

Search Methods
  • /shodan/host/{ip}
  • /shodan/host/count
  • /shodan/host/search
  • /shodan/host/search/tokens
  • /shodan/ports
On-Demand Scanning
  • /shodan/protocols
  • /shodan/scan
  • /shodan/scan/internet
  • /shodan/scan/{id}
Network Alerts
  • /shodan/alert
  • /shodan/alert/{id}/info
  • /shodan/alert/{id}
  • /shodan/alert/info
Directory Methods
  • /shodan/query
  • /shodan/query/search
  • /shodan/query/tags
Account Methods
  • /account/profile
DNS Methods
  • /dns/resolve
  • /dns/reverse
Utility Methods
  • /tools/httpheaders
  • /tools/myip
API Status Methods
  • /api-info
Experimental Methods
  • /labs/honeyscore/{ip}

Implemented Streaming API

Data Streams
  • /shodan/banners
  • /shodan/asn/{asn}
  • /shodan/countries/{countries}
  • /shodan/ports/{ports}
Network Alerts
  • /shodan/alert
  • /shodan/alert/{id}

If a method is absent or something doesn't work properly don't hesitate to create an issue.

FAQs

Package last updated on 22 Jan 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc