-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.py
72 lines (66 loc) · 3.96 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
from shodan import Shodan
import os
from sys import exit
banner2 = """
██████ ██░ ██ ▒█████ ▓█████▄ ▄▄▄ ███▄ █ ██████ ▄████▄ ██▀███ ▄▄▄ ██▓███ ▓█████ ██▀███
▒██ ▒ ▓██░ ██▒▒██▒ ██▒▒██▀ ██▌▒████▄ ██ ▀█ █ ▒██ ▒ ▒██▀ ▀█ ▓██ ▒ ██▒▒████▄ ▓██░ ██▒▓█ ▀ ▓██ ▒ ██▒
░ ▓██▄ ▒██▀▀██░▒██░ ██▒░██ █▌▒██ ▀█▄ ▓██ ▀█ ██▒ ░ ▓██▄ ▒▓█ ▄ ▓██ ░▄█ ▒▒██ ▀█▄ ▓██░ ██▓▒▒███ ▓██ ░▄█ ▒
▒ ██▒░▓█ ░██ ▒██ ██░░▓█▄ ▌░██▄▄▄▄██ ▓██▒ ▐▌██▒ ▒ ██▒▒▓▓▄ ▄██▒▒██▀▀█▄ ░██▄▄▄▄██ ▒██▄█▓▒ ▒▒▓█ ▄ ▒██▀▀█▄
▒██████▒▒░▓█▒░██▓░ ████▓▒░░▒████▓ ▓█ ▓██▒▒██░ ▓██░ ▒██████▒▒▒ ▓███▀ ░░██▓ ▒██▒ ▓█ ▓██▒▒██▒ ░ ░░▒████▒░██▓ ▒██▒
▒ ▒▓▒ ▒ ░ ▒ ░░▒░▒░ ▒░▒░▒░ ▒▒▓ ▒ ▒▒ ▓▒█░░ ▒░ ▒ ▒ ▒ ▒▓▒ ▒ ░░ ░▒ ▒ ░░ ▒▓ ░▒▓░ ▒▒ ▓▒█░▒▓▒░ ░ ░░░ ▒░ ░░ ▒▓ ░▒▓░
░ ░▒ ░ ░ ▒ ░▒░ ░ ░ ▒ ▒░ ░ ▒ ▒ ▒ ▒▒ ░░ ░░ ░ ▒░ ░ ░▒ ░ ░ ░ ▒ ░▒ ░ ▒░ ▒ ▒▒ ░░▒ ░ ░ ░ ░ ░▒ ░ ▒░
░ ░ ░ ░ ░░ ░░ ░ ░ ▒ ░ ░ ░ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ░░ ░ ░ ▒ ░░ ░ ░░ ░
░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░
░ ░
"""
def init():
os.system("cls || clear")
print(banner2)
#config
count = True
key = ""
api = ""
queried = []
init()
try:
keys = []
i = 1
with open("key.txt","r") as keyfile:
keys = keyfile.read().splitlines()
for k in keys:
print(str(i)+". "+k)
i+=1
num = input("Choose an API key>>> ").strip()
try:
key = keys[int(num)-1]
except: print("[-] Error: invalid choice"); exit(1)
except:
print("[-] Error: key.txt not found")
key = input("Enter your Shodan API key>>> ").strip()
try:
api = Shodan(key)
except: print("[-] Error: invalid Shodan API key")
def searchloop():
while True:
try:
init()
query = input("Enter your query>>> ")
if count:
print(f"[+] Found {api.count(query)['total']} matches")
try:
for banner in api.search_cursor(query):
queried.append(banner)
with open("results.txt","a") as results:
results.write(banner["ip_str"]+"\n")
print(banner["ip_str"])
except: pass
print("[+] Saved IPs to results.txt")
if input("Show IP details? y/n>>> ").strip().lower() == "y":
for host in queried:
print(f'IP:{host["ip_str"]} ISP:{host["isp"]} GEO:{host["location"]["country_name"]} {host["location"]["longitude"]}:{host["location"]["latitude"]}')
input('Press any key to continue...')
except KeyboardInterrupt:
break
except Exception as e: pass
if __name__ == "__main__":
searchloop()