Shodan search with python

With the search function offered by the Python API, you can search in the same way that you can with the web interface. If we execute the following example from the Python interpreter, we see that if we look for the "apache" string, we get 15,684,960 results.

Here, we can see the total results and the execution of the Shodan module from the interpreter:

We can also create our own class (ShodanSearch), which has the __init__ method to initialize the Shodan object from API_KEY that we obtained when we registered. We can also have a method to search for the search string by parameter and call the search method of shodan's API.

You can find the following code in the ShodanSearch.py file in the shodan folder on the github repository:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import shodan
import re

class ShodanSearch:
""" Class for search in Shodan """
def __init__(self,API_KEY):
self.api = shodan.Shodan(API_KEY)

def search(self,search):
""" Search from the search string"""
try:
result = self.api.search(str(search))
return result
except Exception as e:
print 'Exception: %s' % e
result = []
return result
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.39.144