-
-
Save AnonQuebec/151e02b83ac760664b5aaca7fc9b57bc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment