Git Product home page Git Product logo

go-shodan's Introduction

go-shodan

Build Status Build status codecov 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.

Usage

The import path depends on whether you use go modules:

import "github.com/ns3777k/go-shodan/v4/shodan"	// with go modules enabled (GO111MODULE=on or outside GOPATH)
import "github.com/ns3777k/go-shodan/shodan" // with go modules disabled

Simple example of resolving hostnames:

package main

import (
	"log"
	"context"

	"github.com/ns3777k/go-shodan/v4/shodan" // go modules required
)

func main() {
	client := shodan.NewEnvClient(nil)
	dns, err := client.GetDNSResolve(context.Background(), []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"
	"context"

	"github.com/ns3777k/go-shodan/v4/shodan" // go modules required
)

func main() {
	client := shodan.NewEnvClient(nil)
	ch := make(chan *shodan.HostData)
	err := client.GetBannersByASN(context.Background(), []string{"3303", "32475"}, ch)
	if err != nil {
		panic(err)
	}

	for {
		banner, ok := <-ch

		if !ok {
			log.Println("channel was closed")
			break
		}

		log.Println(banner.Product)
	}
}

Tips and tricks

Every method accepts context in the first argument so you can easily cancel any request.

You can also use SetDebug(true) to see the actual request data (method, url, body).

Implemented REST API

Search Methods

  • /shodan/host/{ip}
  • /shodan/host/count
  • /shodan/host/search
  • /shodan/host/search/facets
  • /shodan/host/search/filters
  • /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
  • /shodan/alert/triggers
  • /shodan/alert/{id}/notifier/{notifier_id}
  • /shodan/alert/{id}/trigger/{trigger}
  • /shodan/alert/{id}/trigger/{trigger}/ignore/{service}

Notifiers

  • /notifier
  • /notifier/provider
  • /notifier/{id}

Directory Methods

  • /shodan/query
  • /shodan/query/search
  • /shodan/query/tags

Account Methods

  • /account/profile

DNS Methods

  • /dns/resolve
  • /dns/reverse
  • /dns/domain/{domain}

Bulk Data

  • /shodan/data
  • /shodan/data/{dataset}

Manage Organization

  • /org
  • /org/member/{user}

Utility Methods

  • /tools/httpheaders
  • /tools/myip

API Status Methods

  • /api-info

Experimental Methods

  • /labs/honeyscore/{ip}

Exploits

  • /search
  • /count

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

go-shodan's People

Contributors

ns3777k avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.