コード例 #1
0
def create_shodan_object():
    # Add your shodan API key here
    api_key = "TYPEAPIKEYHERE"

    shodan_object = shodan.WebAPI(api_key)

    return shodan_object
コード例 #2
0
def create_shodan_object():
    # Add your shodan API key here
    api_key = "gJjajiqnwelsDZhWrwGSB1IUiETCm8lL"

    shodan_object = shodan.WebAPI(api_key)

    return shodan_object
コード例 #3
0
def create_shodan_object():
    # Add your shodan API key here
    #    api_key = "TYPE  API SHODAN HQ"
    api_key = "pHHlgpFt8Ka3Stb5UlTxcaEwciOeF2QM"

    shodan_object = shodan.WebAPI(api_key)

    return shodan_object
コード例 #4
0
def get_shodan_result(query, page=1):
    logger.info("Fetching shodan results query: %s page: %s", query, page)
    api = shodan.WebAPI(API_KEY)
    try:
        res = api.search(query, page=page)
    except shodan.api.WebAPIError:
        logger.info('Finished shodan results with %s page(s).', page - 1)
    else:
        if res:
            get_shodan_result.apply_async(args=[query],
                                          kwargs={'page': page + 1},
                                          queue='get_shodan_result')
        for r in res.get('matches', []):
            get_screenshot.apply_async(args=[r], queue='get_screenshot')
        return res
コード例 #5
0
 def collectIP(self, searchString):
     ip_address = []
     try:
         # Setup the api
         api = shodan.WebAPI(API_KEY)
         # Perform the search
         query = searchString
         result = api.search(query)
         print 'Results found: %s' % result['total']
         # Loop through the matches and print each IP
         for host in result['matches']:
             ip_address.append(host['ip'])
     except Exception, e:
         print 'Error: %s' % e
         sys.exit(1)
コード例 #6
0
#Initialize userinput
oparser = OptionParser("usage: %prog [options] [command]*", version="v%d.%d.%d" % (1, 0, 0))
oparser.add_option("-d", "--debug", dest="debug", action = "store_true", help="Be extremely verbose", default=False)
oparser.add_option("-k", "--key", dest="AKEY", help="Use your personal API key",default="GETYOUROWNKEY")
oparser.add_option("-s", "--search", dest="searchQuery", help="Insert shodan search query",default=False)
oparser.add_option("-o", "--output", dest="outputFileName", help="output filename",default="output.csv")

(options,args) = oparser.parse_args(sys.argv)

if (options.searchQuery == False):
print 'Type shodanToCSV.py --help for syntax'
sys.exit(1)

try:
# Setup the api
api = shodan.WebAPI(options.AKEY)

# Perform the search
result = api.search(options.searchQuery)
csvHeader = "ip,port,os,country,lastupdate,header\n"
fo = open(options.outputFileName, 'w')
fo.write(str(csvHeader))
# Loop through the matches and print each IP
for result in result['matches']:
row = result['ip'] + ',' + str(result['port']) + ',' + str(result['os']).replace(",",";;;") + ',' + result['country_name'] + ',' + result['updated'] + ',' + str(result['data']).replace(",",";;;")
row = row.replace("\r\n","").replace("\n","") + str(os.linesep)
if(options.debug != False):
print str(row)
fo.write(str(row))
fo.close()
except Exception, e:
コード例 #7
0
#!/usr/bin/python
"""Searches exploit-db exploit database"""
# coded by: bostonlink @ pentest-labs.org
# thanks to shodanhq and exploit-db
# usage: ./exploit_db_search.py search_string

import sys, shodan

usage = '''\nexploit_db_search.py coded by: bostonlink @ pentest-labs.org
     usage: ./exploit_db_search.py [search_string]
          example: ./exploit_db_search.py ftp
      example2: ./exploit_db_search.py \'Windows XP\'
'''

SHODAN_API_KEY = 'Enter API Key Here'
api = shodan.WebAPI(SHODAN_API_KEY)

if len(sys.argv) != 2:
    print(usage)
    sys.exit(0)

if len(SHODAN_API_KEY) < 32:
    print('\nPlease Enter Your Shodan API key to use this script')
    print('If you have not obtained an API key sign up @ shodanhq.com')
    print(usage)
    sys.exit(0)

# initial exploit-db search search

search_query = sys.argv[1]
results = api.exploitdb.search(search_query)