theHardvester: Request library not found, please install it before proceeding

Estuve actualizando la versión del programa the Hardvester en mi pc y luego al ejecutarlo me encontraba con este error:

theHarvester.py -d dominio.com -b google
Request library not found, please install it before proceeding

Instalé la librería request:

sudo pip install request
[sudo] password for root: 
Collecting request
 Downloading request-0.0.26.tar.gz
Collecting get (from request)
 Downloading get-0.0.39.tar.gz
Collecting post (from request)
 Downloading post-0.0.26.tar.gz
Collecting query_string (from get->request)
 Downloading query_string-0.0.28.tar.gz
Collecting public (from query_string->get->request)
 Downloading public-0.0.65.tar.gz
Installing collected packages: public, query-string, get, post, request
 Running setup.py install for public ... done
 Running setup.py install for query-string ... done
 Running setup.py install for get ... done
 Running setup.py install for post ... done
 Running setup.py install for request ... done
Successfully installed get-0.0.39 post-0.0.26 public-0.0.65 query-string-0.0.28 request-0.0.26

Pero el error persistía. La versión anterior de theHardvester indicada que era resquests (con una S al final) el módulo requerido:

/theHarvester.py -d dominio.com -b google
Traceback (most recent call last):
 File "./theHarvester.py", line 10, in <module>
 from discovery import *
 File "/home/jvallecillo/dev/theHarvester/discovery/googlesearch.py", line 6, in <module>
 import requests
ImportError: No module named requests

Pero ese también estaba instalado:

pip install requests
Requirement already satisfied: requests in /usr/lib/python3.6/site-packages
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/lib/python3.6/site-packages (from requests)
Requirement already satisfied: idna<2.7,>=2.5 in /usr/lib/python3.6/site-packages (from requests)
Requirement already satisfied: urllib3<1.23,>=1.21.1 in /usr/lib/python3.6/site-packages (from requests)
Requirement already satisfied: certifi>=2017.4.17 in /usr/lib/python3.6/site-packages (from requests)

Haciendo una traza a las llamadas al sistema me enteré que era en /usr/lib/python2.7/site-packages/requests donde buscaba la librería:

strace ./theHarvester.py -d dominio.com -b google
execve("./theHarvester.py", ["./theHarvester.py", "-d", "dominio.com", "-b", "google"], 0x7ffd89897af0 /* 64 vars */) = 0
brk(NULL) = 0x55de09050000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=136511, ...}) = 0
mmap(NULL, 136511, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f6bbf9ac000
close(3) = 0
...

...
stat("/usr/lib/python2.7/site-packages/requests", 0x7ffdb9c86f90) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/python2.7/site-packages/requests.so", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/python2.7/site-packages/requestsmodule.so", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/python2.7/site-packages/requests.py", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/python2.7/site-packages/requests.pyc", O_RDONLY) = -1 ENOENT (No such file or directory)
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 2), ...}) = 0
write(1, "Request library not found, pleas"..., 63Request library not found, please install it before proceeding
) = 63
write(1, "\n", 1
) = 1
rt_sigaction(SIGINT, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f8bedd52080}, {sa_handler=0x7f8bee0dba60, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f8bedd52080}, 8) = 0
close(7) = 0
exit_group(0) = ?
+++ exited with 0 +++

Por ello instalé pip para python2:

sudo zypper in python2-pip

Loading repository data...
Reading installed packages...
Resolving package dependencies...

The following NEW package is going to be installed:
 python2-pip

1 new package to install.
Overall download size: 1.3 MiB. Already cached: 0 B. After the operation, additional 7.3 MiB will be used.
Continue? [y/n/...? shows all options] (y): y
Retrieving package python2-pip-9.0.1-3.2.noarch (1/1), 1.3 MiB ( 7.3 MiB unpacked)
Retrieving: python2-pip-9.0.1-3.2.noarch.rpm .........................................[done (502.2 KiB/s)]
Checking for file conflicts: .......................................................................[done]
(1/1) Installing: python2pip-9.0.1-3.2.noarch ......................................................[done]

Y luego instalé requests para python 2.7:

pip2.7 install requests
Collecting requests
 Downloading requests-2.18.4-py2.py3-none-any.whl (88kB)
 100% |████████████████████████████████| 92kB 490kB/s 
Requirement already satisfied: idna<2.7,>=2.5 in /usr/lib/python2.7/site-packages (from requests)
Collecting urllib3<1.23,>=1.21.1 (from requests)
 Downloading urllib3-1.22-py2.py3-none-any.whl (132kB)
 100% |████████████████████████████████| 133kB 537kB/s 
Collecting certifi>=2017.4.17 (from requests)
 Downloading certifi-2018.1.18-py2.py3-none-any.whl (151kB)
 100% |████████████████████████████████| 153kB 140kB/s 
Collecting chardet<3.1.0,>=3.0.2 (from requests)
 Downloading chardet-3.0.4-py2.py3-none-any.whl (133kB)
 100% |████████████████████████████████| 143kB 625kB/s 
Installing collected packages: urllib3, certifi, chardet, requests
Successfully installed certifi-2018.1.18 chardet-3.0.4 requests-2.18.4 urllib3-1.22

Con esto ya quedó funcional el programa que requería la librería.

Un par de pensamientos con respecto a esto:

  • Para quien no viene del mundo de python (en mi caso tenía algunos vagos indicios de lo que podía estar pasando) es común ignorar que pueden estar conviviendo distintas versiones de este y que un programa puede requerir una librería de python2.7 o de python3.6.
  • En el caso de theHardvester el error únicamente indicaba que no encontraba la librería pero no supe la versión de python que requería hasta que hice la traza con strace para darme cuenta que era en python2.7 donde lo buscaba.
  • theHardvester usa el shebang “#!/usr/bin/env python” por lo que YO pensaría que mi entorno está configurado para trabajar con esa versión de python pero pip estaba instalando módulos para 3.6 por defecto por lo cual no estaría acordes el uno con el otro (el entorno de python y el de pip?).

Un poco de confusión por ahora.

Anuncios

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión /  Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión /  Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión /  Cambiar )

Conectando a %s

A %d blogueros les gusta esto: