Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from shodan import Shodan
- import subprocess as sp
- import requests
- api = Shodan("iG0r3X7hjuIVWlopWTyy8DPO7eIF3wEG")
- def clrscr():
- sp.call(["clear"], shell=True)
- def breakline():
- print("-"*60)
- def shodan_ip_search(shodan_obj, ip_to_search):
- port_target = []
- result = ""
- try:
- print("\nSearching Shodan for info about " + ip_to_search + "...\n")
- result = shodan_obj.host(ip_to_search)
- try:
- for i in result['data']:
- print('Port: %s' % i['port'])
- port_target.append(i['port'])
- except Exception as e:
- print(str(e))
- except Exception as e:
- print(str(e))
- return port_target
- def main():
- breakline()
- print("1) For Your IP.")
- print("2) Shodan Search to scan IPs, Hostnames, ports.")
- print("3) Scan a specific Host.")
- print("0) To Exit.")
- breakline()
- choice = int(input("Your choice: "))
- breakline()
- if choice == 1:
- print(f'Your public ip is: {requests.get("https://ident.me").content.decode("utf8")}')
- elif choice == 2:
- query = input("Input your query to search: ")
- results = api.search(query)
- for result in results['matches']:
- print(result['ip_str'])
- elif choice == 3:
- ip = input("Enter the ip: ")
- shodan_ip_search(api, ip)
- elif choice == 0:
- exit()
- main()
- clrscr()
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement