The second part is devoted to Shodan’s search capabilities. It describes in detail the structure of search queries, filter syntax, and the principle of operation of the search engine. Shodan maps, visualization styles, vulnerabilities, and the module for working with web components and interfaces are separately considered. You will learn how to effectively form queries, find non-standard services, and analyze the results. Examples of practical exercises and external tools are added to expand the functionality.
The Shodan Command Line Interface (CLI) is bundled with the official Shodan Python library. This means that if you are using the latest version of the library, you already have access to the CLI. To install the new tool, run the command:
Once the installation is complete, the tool needs to be initialized with your API key:
You can get an API key for your account on the website https://account.shodan.io
The alert command allows you to create, view, clear, and delete network alerts. It is used to monitor changes in your environment or to receive alerts about new devices within a specified IP network.
The convert command converts the compressed JSON file generated by Shodan to other file formats. Currently, conversion to kml and csv formats is supported. This is useful when you want to present the results in a table or plot them on a map.
The count command shows the number of results that match a given search query. Example usage:
Result:
This example shows the number of Microsoft IIS 6.0 servers found in the Shodan database.
The download command searches Shodan and saves the results to a file, where each line contains a separate JSON banner. By default, only 1000 results are downloaded. If you need more, you can use the –limit flag.
The download command is one of the most commonly used commands because it allows you to not only retrieve the results, but also save them for further processing by the parse command. Since scrolling through the results uses up your query credits, it is a good idea to store the data locally so that you don’t waste your credits again when you make repeated requests.
View information about a host: its geographic location, open ports, and the organization that owns the IP address.
Example:
$ shodan host 189.201.128.250
honeyscore — checks whether an IP address is a honeypot, i.e. a system that simulates an industrial device to detect attack attempts.
Example:
info — shows basic information about your API plan, including the number of requests and scans remaining this month.
Example:
myip — shows your external IP address from which you access the Internet.
Example:
parse — used to parse a file obtained using the download command. Allows you to filter out the required fields, convert JSON to CSV, and easily integrates with other scripts.
Example: