Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ns3777k/go-shodan
Shodan API client
https://github.com/ns3777k/go-shodan
exploits security security-scanner shodan shodan-api shodan-client
Last synced: 11 days ago
JSON representation
Shodan API client
- Host: GitHub
- URL: https://github.com/ns3777k/go-shodan
- Owner: ns3777k
- License: mit
- Created: 2015-09-03T12:50:31.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2022-01-12T22:49:02.000Z (almost 3 years ago)
- Last Synced: 2024-11-02T20:42:04.635Z (14 days ago)
- Topics: exploits, security, security-scanner, shodan, shodan-api, shodan-client
- Language: Go
- Size: 190 KB
- Stars: 212
- Watchers: 11
- Forks: 32
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ip-search-engines - Go Shodan
README
# go-shodan
[![msisdn CI](https://github.com/ns3777k/go-shodan/actions/workflows/test.yml/badge.svg)](https://github.com/ns3777k/go-shodan/actions/workflows/test.yml)
[![GoDoc](https://godoc.org/github.com/ns3777k/go-shodan/shodan?status.svg)](https://godoc.org/github.com/ns3777k/go-shodan/shodan)
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE)
[![Go Report Card](https://goreportcard.com/badge/github.com/ns3777k/go-shodan)](https://goreportcard.com/report/github.com/ns3777k/go-shodan)To start working with Shodan you have to get your token first. You can do this at [https://www.shodan.io](https://www.shodan.io).
### Usage
The import path depends on whether you use go modules:
```go
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:
```go
package mainimport (
"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:
```bash
2015/09/05 18:50:52 173.194.115.35
```Streaming example:
```go
package mainimport (
"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 := <-chif !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
- [x] /shodan/host/{ip}
- [x] /shodan/host/count
- [x] /shodan/host/search
- [x] /shodan/host/search/facets
- [x] /shodan/host/search/filters
- [x] /shodan/host/search/tokens
- [x] /shodan/ports#### On-Demand Scanning
- [x] /shodan/protocols
- [x] /shodan/scan
- [x] /shodan/scan/internet
- [x] /shodan/scan/{id}#### Network Alerts
- [x] /shodan/alert
- [x] /shodan/alert/{id}/info
- [x] /shodan/alert/{id}
- [x] /shodan/alert/info
- [x] /shodan/alert/triggers
- [x] /shodan/alert/{id}/notifier/{notifier_id}
- [x] /shodan/alert/{id}/trigger/{trigger}
- [x] /shodan/alert/{id}/trigger/{trigger}/ignore/{service}#### Notifiers
- [x] /notifier
- [x] /notifier/provider
- [x] /notifier/{id}#### Directory Methods
- [x] /shodan/query
- [x] /shodan/query/search
- [x] /shodan/query/tags#### Account Methods
- [x] /account/profile#### DNS Methods
- [x] /dns/resolve
- [x] /dns/reverse
- [x] /dns/domain/{domain}#### Bulk Data
- [x] /shodan/data
- [x] /shodan/data/{dataset}#### Manage Organization
- [x] /org
- [x] /org/member/{user}#### Utility Methods
- [x] /tools/httpheaders
- [x] /tools/myip#### API Status Methods
- [x] /api-info#### Experimental Methods
- [x] /labs/honeyscore/{ip}#### Exploits
- [x] /search
- [x] /count### Implemented Streaming API
#### Data Streams
- [x] /shodan/banners
- [x] /shodan/asn/{asn}
- [x] /shodan/countries/{countries}
- [x] /shodan/ports/{ports}#### Network Alerts
- [x] /shodan/alert
- [x] /shodan/alert/{id}### Implemented GeoNet API
- [x] /api/ping/{ip}
- [x] /api/geoping/{ip}
- [x] /api/dns/{hostname}
- [x] /api/geodns/{hostname}If a method is absent or something doesn't work properly don't hesitate to create an issue.
### Links
* [Shodan.io](http://shodan.io)
* [API Documentation](https://developer.shodan.io/api)