Skip to content

ns3777k/go-shodan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-shodan

Build Status Build status Coverage Status GoDoc MIT License Go Report Card

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.v1"

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

Usage

Simple example of resolving hostnames:

package main

import (
    "log"

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

func main() {
    client := shodan.NewClient(nil, "MY_TOKEN")
    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.v1/shodan"
)

func main() {
    client := shodan.NewClient(nil, "MY_TOKEN")

    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.

Links