-
Notifications
You must be signed in to change notification settings - Fork 0
/
shodus.py
143 lines (124 loc) · 5.31 KB
/
shodus.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/usr/bin/python3
#coding:utf-8
#Autor: xaxxjs (https://sergioab7.github.io/)
import sys,os,time
from colorama import Fore,Style
from argparse import ArgumentParser
import argparse
import shodan
from time import sleep
import requests
from beautifultable import BeautifulTable
import warnings
warnings.filterwarnings("ignore")
def api():
f=open("api.txt", "w")
comando=input(Fore.BLUE + "\n\t\tINSERTA TU API>>" + Fore.RESET)
while(len(comando)<29):
comando=input(Fore.BLUE + "\n\t\tINSERTA TU API>>" + Fore.RESET)
print(Fore.YELLOW + "\n\t\t[API AGREGADA CON ÉXITO]" + Fore.RESET)
print(Fore.YELLOW + "\n\tReiniciando el servicio para que se apliquen los cambios\n\n" + Fore.RESET)
f.write(comando)
f.close()
sys.exit()
if(os.path.isfile("api.txt")):
with open("api.txt", "r") as app:
API = app.read()
app.close()
else:
api()
shodus=shodan.Shodan(API)
print("""
_ _
| | | |
___| |__ ___ __| |_ _ ___
/ __| '_ \ / _ \ / _` | | | / __|
\__ \ | | | (_) | (_| | |_| \__ |
|___/_| |_|\___/ \__,_|\__,_|___/ v.1
"""+Fore.RED+"by:xaxxjs (https://sergioab7.github.io/)"+Fore.RESET+"""
""")
parser=argparse.ArgumentParser(description="¡Welcome to shodus!", epilog="Example: sudo python3 shodus.py -H 8.8.8.8 -S || sudo python3 shodus.py -s apache --show")
parser.add_argument("-H","--host",dest="host",type=str, help="Insert IP to search")
parser.add_argument("-S","--simple", dest="simple",help="simple search", action="store_const", const=True)
parser.add_argument("-A","--advanced", dest="advanced",help="advanced search",action="store_const", const=True)
parser.add_argument("-s","--search",dest="search",type=str,help="Insert some search")
parser.add_argument("-show","--show", dest="show",help="Muestra todas las IP",action="store_const", const=True)
results=parser.parse_args()
def shodan_search_ip(busqueda):
try:
busqueda=busqueda.lower()
print(Fore.YELLOW+"[>] "+Fore.RESET+"Búsqueda: "+Fore.MAGENTA+"%s"%busqueda+Fore.RESET)
results = shodus.search(busqueda)
print(Fore.BLUE+"[i]"+Fore.RESET+" Resultados encontrados: "+Fore.MAGENTA+"%s"%results['total']+Fore.RESET)
sleep(2)
print("")
for service in results['matches']:
print(Style.BRIGHT)
print(Fore.GREEN+"\t[+] "+Fore.RESET+"%s"%(service['ip_str']))
print(Style.RESET_ALL)
except Exception as e:
print(Fore.RED+"[!]"+Fore.RESET+" Error: ", e)
def shodan_search(busqueda):
try:
busqueda=busqueda.lower()
print(Fore.YELLOW+"[>] "+Fore.RESET+"Búsqueda: "+Fore.MAGENTA+"%s"%busqueda+Fore.RESET)
results = shodus.search(busqueda)
print(Fore.BLUE+"[i]"+Fore.RESET+" Resultados encontrados: "+Fore.MAGENTA+"%s"%results['total']+Fore.RESET)
sleep(2)
print("")
for result in results['matches']:
print(Style.BRIGHT)
print(Fore.YELLOW+'[+] IP:'+Fore.RESET+' {}'.format(result['ip_str']))
print(result['data'])
print('')
print(Style.RESET_ALL)
except Exception as e:
print(Fore.RED+"[!]"+Fore.RESET+" Error: ", e)
def shodan_simple(busqueda):
try:
print(Fore.GREEN+"[+]"+Fore.RESET+"Iniciando búsqueda "+Fore.MAGENTA+"simple"+Fore.RESET)
sleep(1.5)
host_machine = shodus.host(results.host)
for item in host_machine['data']:
print(Style.BRIGHT)
print("""[>] Port:"""+Fore.YELLOW+f"{item['port']}"+Fore.RESET + """
[>] Banner: """+Fore.YELLOW +f"{item['data']}"+Fore.RESET+"""
[>] Domains: """+Fore.YELLOW +f"{item['domains']}"+Fore.RESET+"""
--------------------------------------------------------
""")
print(Style.RESET_ALL)
except:
print(Fore.RED + "[-]Error" + Fore.RESET)
def shodan_avanzado(busqueda):
try:
print(Fore.GREEN+"[+]"+Fore.RESET+"Iniciando búsqueda "+Fore.MAGENTA+"avanzada"+Fore.RESET)
sleep(1.5)
host_machine = shodus.host(results.host)
for item in host_machine['data']:
print(Style.BRIGHT)
print("""[>] Port:"""+Fore.YELLOW+f"{item['port']}"+Fore.RESET + """
[>] Banner: """+Fore.YELLOW +f"{item['data']}"+Fore.RESET+"""
[>] Domains: """+Fore.YELLOW +f"{item['domains']}"+Fore.RESET+"""
[>] Organization: """+Fore.YELLOW +f"{item['org']}"+Fore.RESET+"""
[>] Transport: """+Fore.YELLOW +f"{item['transport']}"+Fore.RESET+"""
--------------------------------------------------------
""")
print(Style.RESET_ALL)
except Exception as e:
print(Fore.RED+"[!]"+Fore.RESET+" Error: ", e)
if(results.host):
if(results.simple):
shodan_simple(results.host)
elif(results.advanced):
shodan_avanzado(results.host)
elif(results.search):
sys.exit(1)
else:
print(Fore.RED+"[!]"+Fore.RESET+" Debes añadir parametro:")
print("\tBúsqueda simple: "+Fore.MAGENTA+"-S"+Fore.RESET)
print("\tBúsqueda avanzada: "+Fore.MAGENTA+"-A"+Fore.RESET)
if(results.search):
if(results.show):
shodan_search_ip(results.search)
else:
shodan_search(results.search)