Home

Awesome

Shodan client

Build Status code style: prettier Downloads stability-stable

:eyes: Library for accessing the Shodan API.

<div align="center"> <p> <img src="https://raw.githubusercontent.com/jesusprubio/shodan-client/master/artifacts/demo.gif" alt="demo"> </p> <p> <sub>:gift: Ping me on <a href="https://twitter.com/jesusprubio"><code>Twitter</code></a> if you like this project</sub> </p> </div>

Install

:coffee: Install latest Node.js stable version (or LTS) and then:

npm i -g shodan-client

Use

:pencil: All methods of the API need a valid key, you can get one here.

const util  = require('util');
const client = require('shodan-client');

const searchOpts = {
  facets: 'port:100,country:100',
  // minify: false,
};
client
  .search('asterisk port:5060', 'YOURKEYHERE', searchOpts)
  .then(res => {
    console.log('Result:');
    console.log(util.inspect(res, { depth: 6 }));
  })
  .catch(err => {
    console.log('Error:');
    console.log(err);
  });

You can find more examples in the tests.

Contributing

:sunglasses: If you'd like to help please take a look to this file.

Test

To run the tests you need set your API key.

API_KEY=YOUR_KEY_HERE npm test

API

:eyes: The content of the result is the same provided by the HTTP API. You can check them in the API documentation.

version

Library version.

async host(ip, key, opts)

Returns all services that have been found on the given host IP. Supported options:

async search(query, key, opts)

Search using the same query syntax as the website and use facets to get summary information for different properties. This method may use API query credits depending on usage, please check the API documentation.

async count(query, key, opts)

This method behaves identical to "search" with the only difference that this method does not return any host results, it only returns the total number of results that matched the query and any facet information that was requested. As a result this method does not consume query credits.

async searchTokens(query, key, opts)

Search using the same query syntax as the website and use facets to get summary information for different properties. This method may use API query credits depending on usage, please check the API documentation.

async ports(key, opts)

List of port numbers that the crawlers are looking for.

async protocols(key, opts)

All the protocols that can be used when launching an Internet scan.

async scan(ips, key, opts)

Ask Shodan to crawl a network. This method uses API scan credits, please check the API documentation.

async scanInternet(port, protocol, key, opts)

Ask Shodan to crawl the Internet for a specific port and protocol. This method is restricted to security researchers and companies with a Shodan Data license, please check the [API documentation for more details.

async scanResult(ips, key, opts)

Get the result of a scan you asked for before.

async services(key, opts)

All the services that the Shodan crawlers look at. It can also be used as a quick and practical way to resolve a port number to the name of a service.

async query(key, opts)

To obtain a list of search queries that users have saved.

async querySearch(query, key, opts)

To search the directory of search queries that users have saved.

async queryTags(key, opts)

To obtain a list of popular tags for the saved search queries.

async accountProfile(key, opts)

Returns information about the account linked to this API key.

async dnsResolve(hostnames, key, opts)

Look up the IP address for the provided list of hostnames.

async dnsReverse(ips, key, opts)

Look up the hostnames that have been defined for the given list of IP addresses.

async toolsMyip(key, opts)

Get your external IP address.

async apiInfo(key, opts)

Information of the actual APi version.

Streams

From here the endpoints documented at this section.

async streams.banners(key, opts)

Provides all collected data. Use this stream if you need access to everything and/ or want to store your own Shodan database locally. If you only care about specific ports, please use the Ports stream.

async streams.asn(asn, key, opts)

Provides a filtered, bandwidth-saving view of the Banners stream in case you are only interested in devices located in certain ASNs.

async streams.countries(countries, key, opts)

Provides a filtered, bandwidth-saving view of the Banners stream in case you are only interested in devices located in certain countries.

async streams.ports(ports, key, opts)

Only returns banner data for the list of specified hosts. Provides a filtered, bandwidth-saving view of the Banners stream in case you are only interested in a specific list of ports.

Exploits

From here the endpoints documented at this section.

async exploits.search(query, key, opts)

Search across a variety of data sources for exploits and use facets to get summary information.

async exploits.count(query, key, opts)

This is similar to the last one but it doesn't return any exploit data, only the total count.

Error handling

The response can include a message containing the reason for the failure. In example:

{
 "error": "Invalid IP"
}