Installing and Using Shodan CLI on Linux: A Complete Walkthrough

Installing and Using Shodan CLI on Linux: A Complete Walkthrough

Shodan is a powerful search engine designed to find internet-connected devices across the globe. It goes beyond conventional search engines by enabling the discovery of specific hardware and software configurations. This guide covers installing and effectively using Shodan’s Command-Line Interface (CLI) on Linux systems including Debian-based (like Ubuntu) and CentOS/RHEL.

Prerequisites

Step 1: Install Python and Pip

First, ensure you have Python and pip installed:

Debian/Ubuntu:

sudo apt-get update
sudo apt-get install python3 python3-pip

CentOS/RHEL:

sudo yum install python3 python3-pip

Step 2: Install Shodan CLI

Shodan’s CLI tool comes bundled with its Python library. Install it using pip:

pip3 install shodan

Step 3: Initialize Shodan with Your API Key

Retrieve your API key from your Shodan account dashboard (https://account.shodan.io).

Initialize Shodan CLI with:

shodan init YOUR_API_KEY

Step 4: Basic Shodan CLI Usage

Now that you have Shodan installed, here are some fundamental commands:

  • Search the Shodan database
shodan search apache
  • Get host details
shodan host <IP_ADDRESS>
  • View your account information
shodan info
  • Check your external IP
shodan myip

Step 5: Advanced CLI Commands

  • Downloading Data Download and save search results for further analysis:
shodan download results.json.gz apache
  • Parsing downloaded results Extract specific data from downloaded results:
shodan parse --fields ip_str,port,org results.json.gz
  • Real-time data streaming Stream real-time data collected by Shodan crawlers:
shodan stream --ports 80,443

Step 6: Automating Scans

Request Shodan to perform a scan on specific IP addresses or ranges:

shodan scan submit 198.20.69.0/24

Step 7: Monitoring Network Alerts

Create alerts for real-time monitoring:

shodan alert create "Production Network" 198.20.69.0/24
shodan stream --alert <ALERT_ID>

Step 8: Exporting Results

Export search results to different formats (CSV, KML, etc.):

shodan convert results.json.gz csv

Thoughts

The Shodan CLI is a versatile tool that significantly enhances network exploration, vulnerability assessment, and security analysis. By following this guide, Linux users can efficiently install, configure, and harness the extensive capabilities of the Shodan command-line interface.

Posts Carousel

Leave a Comment

Your email address will not be published. Required fields are marked with *

Latest Posts

Most Commented

Featured Videos