import shodan
from authenticate import shodan_py, api_key
import os
import urllib2
import json

def exploits():
	while True:
		usr_inp=raw_input("exploits>>>")
		
		if usr_inp=="clear":
			os.system("clear")
		
		elif usr_inp=="back":
			return

		elif usr_inp=="quit" or usr_inp=="exit":
			quit()

		elif usr_inp=="":
			usr_inp=raw_input("exploits>>>")

		else:
			try:	
				url="https://exploits.shodan.io/api/search?key=%s&query=%s" %(api_key,usr_inp)	
			except:
				print("There is some issue.Please try again!")
				exploits()

			exp=urllib2.urlopen(url).read()
			expjs=json.loads(exp)
			for i in expjs['matches']:
				print("\n\n\n\n\n\n\n\n")
	     			for j,k in i.items():
	             			print(str(j)+":\t\t "+str(k)) 
