Shodan search guide

Tips and search filters for obtaining host and IP data from Shodan. All users that sign up with 
an educational address get free Shodan accounts. As with any search engine, Shodan works 
well with basic, single-term searches, but the real power comes with customized queries.

Here are the basic search filters you can use:

city: find devices in a particular city i.e.  city:helsinki
 • country: find devices in a particular country i.e.  country: GB 
 • geo: you can pass it coordinates
 • software types: iis 5.0 type in the software and version number to find nodes running it.
 • hostname: find values that match the hostname i.e.  hostname:"" 
 • net: network i.e.  net:"" 
 • net and proto: search based on an IP also with CIDR i.e.  NTP net:"" 
 • os: search based on operating system
 • port: find particular ports that are open i.e.  port:445 country:"GB" org:"University" 
 • before/after: find results within a timeframe i.e.  org:"The University of Manchester" after:"17/5/2017" or ip: before:"10/05/2017"
 • org: use organisation name in search i.e.  org:"FireEye" 
 • Wordpress: http.component:"wordpress" country:"GB" org:"University"
 • HTTP componet: country:GB org:"Oxford University" http.component:"drupal"
 • Product: net: product:pulse • vuln:CVE-2021-27065 vulnerable Microsoft Exchange Server boxes with tag

Other cool searches:

• NTP daemon servers in Helsinki, a method for finding some open NTP servers  ntpd city:helsinki

Further reading:

Shodan CLI

Installing: pip3 install shodan, you may use the Shodan CLI using "shodan init <>". This python script below runs set query from command line, sent to TI community by Command style: shodan search --fields ip_str,hostnames,transport,port,banner ip: after:09/07/2018 Another example: shodan search --fields ip_str,hostnames,transport,port,product,org,banner net:

$ #!/usr/bin/env python3.4 import shodan import sys SHODAN_API_KEY = "YOUR-API-KEY" api = shodan.Shodan(SHODAN_API_KEY) #querystr = sys.argv[1] querystr = "port:445 country:GB org:University" # Wrap the request in a try/ except block to catch errors try: # Search Shodan results = # Show the results print ('Results found: %s' % results['total']) for result in results['matches']: if 'SMB Version: 1' in result['data']: print ('IP: %s' % result['ip_str']) if 'org' in result: print ('Organisation: %s' % result['org']) if 'os' in result: print ('OS: %s' % result['os']) if 'devicetype' in result: print ('Devicetype: %s' % result['devicetype']) if 'product' in result: print ('Product: %s' % result['product']) if 'info' in result: print ('Info: %s' % result['info']) print (result['data']) print ('') except shodan.APIError as e: print ('Error: %s' % e)