Problemas con la biblioteca de Shodan para Python

Iniciado por Electrónico, Diciembre 07, 2016, 01:38:44 AM

Tema anterior - Siguiente tema

0 Miembros y 1 Visitante están viendo este tema.

Diciembre 07, 2016, 01:38:44 AM Ultima modificación: Diciembre 07, 2016, 01:45:10 AM por Gabriela
Buenas a tod@s:

Aprovechando la promoción que hacían para el BlackFriday, aproveché para comprarme unos cuantos libros de la editorial 0XWorld sobre hacking. Siempre me ha gustado el mundillo y quería empezar a empaparme ya de libros y entrar más en detalle.

Después de empezar a leer un poco, ya estoy enganchado, y no paro de leer y aprovechar cualquier oportunidad para continuar con el siguiente capítulo del libro.

Ahora que ya llevo el primer libro algo avanzado, quiero empezar a prácticar con los scripts que sugiere en los diversos capítulos.

En este caso, trata sobre la biblioteca de Shodan.

Si hago un simple sudo easy_install shodan me dice que ha hecho correctamente la instalación:

CitarSearching for shodan
Best match: shodan 1.5.6
Processing shodan-1.5.6-py2.7.egg
shodan 1.5.6 is already the active version in easy-install.pth
Installing shodan script to /usr/local/bin

Using /usr/local/lib/python2.7/dist-packages/shodan-1.5.6-py2.7.egg
Processing dependencies for shodan
Finished processing dependencies for shodan

Sin embargo, cuando voy a ejecutar el primer de los scripts me sale el siguiente error:

CitarTraceback (most recent call last):
  File "./ShodanSimpleSearch.py", line 6, in <module>
    import Shodan
ImportError: No module named Shodan

Entonces, no se ha instalado correctamente la biblioteca?

He probado con algun comando de Shodan que he encontrado navegando tipo:
Código: php
shodan myip



O con el siguiente script:

Código: php
#!/usr/bin/env python
#
# shodan_ips.py
# Search SHODAN and print a list of IPs matching the query
#
import shodan
import sys
# Configuration
API_KEY = "API_KEY"
# Input validation
if len(sys.argv) == 1:
    print 'Usage: %s <search query>' % sys.argv[0]
    sys.exit(1)
try:
# Setup the api
    api = shodan.Shodan(API_KEY)
# Perform the search
    query = ' '.join(sys.argv[1:])
    result = api.search(query)
# Loop through the matches and print each IP
    for service in result['matches']:
        print service['ip_str']
except Exception as e:
    print 'Error: %s' % e
    sys.exit(1)



Y funciona perfectamente. Entonces, por qué no funciona el primer script???


Muchas gracias de antemano

Da error en el modulo llamado Shodan, que por lo que me imagino es la primera línea del código donde hay varios modulos después de "shodan".

Revisa bien que se haya instalado las bibliotecas, después realiza un apt-get update y asignale permisos 777 al Script.

Saludos

Diciembre 07, 2016, 06:58:14 AM #2 Ultima modificación: Diciembre 09, 2016, 10:29:38 AM por Gabriela
Buenas a tod@s:

Muchas gracias por tu respuesta.

Entiendo que sí el segundo script, que tamibén importa la biblioteca de Shodan me funciona, es que esta está instalada.

A parte si escribo en el terminal Shodan me devuelve el siguiente mensaje:

Código: php
Usage: shodan [OPTIONS] COMMAND [ARGS]...

Options:
  -h, --help  Show this message and exit.

Commands:
  alert       Manage the network alerts for your account
  convert     Convert the given input data file into a...
  count       Returns the number of results for a search
  download    Download search results and save them in a...
  honeyscore  Check whether the IP is a honeypot or not.
  host        View all available information for an IP...
  info        Shows general information about your account
  init        Initialize the Shodan command-line
  myip        Print your external IP address
  parse       Extract information out of compressed JSON...
  scan        Scan an IP/ netblock using Shodan.
  search      Search the Shodan database
  stats       Provide summary information about a search...
  stream      Stream data in real-time.


Con lo cual, entiendo que debe estar instalado correctamente.

Continuaré indagando





Edición:

Buenas a tod@s:

También he hecho la prueba de ejecutar python directamente desde el terminal e importar la biblioteca de Shodan y no me da ningún error. Con lo cual, se entiende que la instalación ha sido satisfactoria.