| name | performing-ip-reputation-analysis-with-shodan |
| description | Analyze IP address reputation using the Shodan API to identify open ports, running services, known vulnerabilities, and hosting context for threat intelligence enrichment and incident triage. |
| domain | cybersecurity |
| subdomain | threat-intelligence |
| tags | ["shodan","ip-reputation","enrichment","threat-intelligence","reconnaissance","vulnerability","api","internet-scanning"] |
| version | 1.0 |
| author | mahipal |
| license | Apache-2.0 |
| nist_csf | ["ID.RA-01","ID.RA-05","DE.CM-01","DE.AE-02"] |
| mitre_attack | ["T1591","T1592","T1593","T1589","T1595"] |
Performing IP Reputation Analysis with Shodan
Overview
Shodan is the world's first search engine for internet-connected devices, continuously scanning the IPv4 and IPv6 address space to catalog open ports, running services, SSL certificates, and known vulnerabilities. This skill covers using the Shodan API and InternetDB free API to enrich IP addresses from security alerts, assess threat levels based on exposed services and vulnerabilities, identify hosting infrastructure patterns, and integrate IP reputation data into SOC triage and threat intelligence workflows.
When to Use
- When conducting security assessments that involve performing ip reputation analysis with shodan
- When following incident response procedures for related security events
- When performing scheduled security testing or auditing activities
- When validating security controls through hands-on testing
Prerequisites
- Python 3.9+ with
shodan library (pip install shodan)
- Shodan API key (free tier: limited queries; paid plans for higher limits and streaming)
- Understanding of TCP/UDP ports, common services, and CVE identifiers
- Familiarity with ASN, CIDR notation, and IP geolocation concepts
- Network security knowledge for interpreting scan results
Key Concepts
Shodan Data Model
Each IP record in Shodan contains: open ports and protocols, banner data (service responses), SSL/TLS certificate details, known CVE vulnerabilities, hostname(s) and reverse DNS, ASN and ISP information, geographic location, operating system fingerprint, and historical scan data showing changes over time.
InternetDB API
Shodan's free InternetDB API (internetdb.shodan.io) provides quick IP lookups without authentication, returning open ports, hostnames, tags, CPEs, and known vulnerabilities. This is useful for high-volume enrichment where the full Shodan API would hit rate limits.
Reputation Scoring
IP reputation is assessed by combining: number and type of open ports (unusual ports indicate compromise), vulnerable services (unpatched software with known CVEs), hosting type (residential, cloud, VPN/proxy, bulletproof hosting), historical activity (past associations with malware, scanning, spam), and geographic context (countries known for specific threat activity).
Workflow
Step 1: Basic IP Enrichment with Shodan API
import shodan
import json
from datetime import datetime
class :
():
.api = shodan.Shodan(api_key)
.info = .api.info()
()
():
:
host = .api.host(ip_address)
enrichment = {
: ip_address,
: host.get(, ),
: host.get(, ),
: host.get(, ),
: host.get(, ),
: host.get(, ),
: host.get(, ),
: host.get(),
: host.get(),
: host.get(, ),
: host.get(, []),
: host.get(, []),
: host.get(, []),
: host.get(, []),
: host.get(, []),
: host.get(, ),
: [],
}
service host.get(, []):
svc = {
: service.get(, ),
: service.get(, ),
: service.get(, ),
: service.get(, ),
: service.get(, {}).get(, ),
: service.get(, )[:],
}
service:
svc[] = service[].get(, {}).get(, {})
svc[] = service[].get(, {}).get(, {})
svc[] = service[].get(, {}).get(, )
enrichment[].append(svc)
enrichment[] = ._calculate_reputation(enrichment)
(
)
enrichment
shodan.APIError e:
()
():
score =
factors = []
vuln_count = (data.get(, []))
vuln_count > :
score +=
factors.append()
vuln_count > :
score +=
factors.append()
vuln_count > :
score +=
factors.append()
suspicious_ports = {, , , , , , ,
, , , , , }
open_ports = (data.get(, []))
sus_found = open_ports.intersection(suspicious_ports)
sus_found:
score +=
factors.append()
malicious_tags = {, , , , }
tags = (data.get(, []))
mal_tags = tags.intersection(malicious_tags)
mal_tags:
score +=
factors.append()
port_count = (data.get(, []))
port_count > :
score +=
factors.append()
level = (
score >=
score >=
score >=
)
{: score, : level, : factors}
():
requests
resp = requests.get(, timeout=)
resp.status_code == :
data = resp.json()
(
)
data
enricher = ShodanEnricher()
result = enricher.enrich_ip()
(json.dumps(result, indent=, default=))