Cómo instalar la herramienta sublist3r (clonando el repositorio GitHub en Linux) para hacer Information Gathering y obtener, con análisis pasivo, información DNS, IP y subdominios de un dominio de una organización. Mostramos otras herramientas contenidas en Kali Linux para enumerar subdominios (subdomain enumeration), como técnica de Information Gathering, que forman parte del Hacking Ético.

Requisitos para hacer Information Gathering

Aunque no es un requisito imprescindible, sí que es recomendable, para todas las técnicas de Hacking Ético, disponer de una máquina virtual con Kali Linux, distribución diseñada para este cometido: Penetration Testing, Information Gathering, etc.. Cuenta con numerosas herramientas para estos propósitos y en el modo gráfico las incluye agrupadas por 13 categorías: Information Gathering, Vulnerability Analysis, Web Application Analysis, Database Assessment, Password Attacks, Reverse Enginieering, Explotation Tools, Sniffing & Spoofing, Post Explotation, Forensic, Reporting Tools y Social Engineering Tools.

En el siguiente enlace mostramos un tutorial donde indicamos cómo desplegar una máquina virtual Kali Linux en un entorno de virtualización VMware ESXi:

Si no podemos contar con una máquina Kali Linux, tendremos que instalar las herramientas que mostramos a continuación para hacer Information Gathering, y dentro de este grupo de técnicas de Hacking Ético, para hacer Enumeración de Subdominios (Subdomains Enumeration).

Clonar repositorio GitHub en Kali Linux, instalar sublist3r

Para clonar un repositorio de GitHub en Linux, necesitaremos saber la URL del repositorio. Podremos obtenerla o bien directamente desde GitHub o bien buscándola en un buscador. Por ejemplo, para clonar el repositorio sublist3r, podremos buscar el Google:

github sublist3r

En caso de no conocer la herramienta, dado que queremos buscar herramientas para enumerar subdominios, hechas en Python, introduciríamos en Google (o cualquier otro navegador):

github python3 subdomain enumeration

Una vez que tengamos la URL de la herramienta en GitHub, la copiaremos. Para el caso de sublist3r será:

https://github.com/aboul3la/Sublist3r

Para clonar el repositorio sublist3r de GitHub en nuestro equipo Linux, accederemos a la carpeta /opt, que es donde se suelen instalar las herramientas en Linux:

Y ejecutaremos el siguiente comando para descargar el repositorio GitHub de sublist3r en nuestro equipo:

Clonar repositorio GitHub en Kali Linux, instalar sublist3r

Ejecutar sublist3r para enumerar subdominios como técnica de Information Gathering

En la instalación anterior de sublist3r se habrá creado la carpeta Sublist3r dentro de /opt, accederemos a ella:

Dentro tendremos los mismos ficheros que en repositorio GitHub, entre ellos tenemos el ejecutable sublist3r.py. Para ejecutarlo usaremos Python, con el comando:

Clonar repositorio GitHub en Kali Linux, instalar sublist3r

El comando anterior nos mostrará la ayuda con los parámetros posibles para la herramienta sublist3r, que son:

-h, –helpshow this help message and exit
-d DOMAIN, –domain DOMAINDomain name to enumerate it’s subdomains
-b [BRUTEFORCE], –bruteforce [BRUTEFORCE]Enable the subbrute bruteforce module
-p PORTS, –ports PORTSScan the found subdomains against specified tcp ports
-v [VERBOSE], –verbose [VERBOSE]Enable Verbosity and display results in realtime
-t THREADS, –threads THREADSNumber of threads to use for subbrute bruteforce
-e ENGINES, –engines ENGINESSpecify a comma-separated list of search engines
-o OUTPUT, –output OUTPUTSave the results to text file
-n, –no-colorOutput without color

Si queremos hacer un análisis de subdominios pasivo, NO usaremos el parámetro -b (fuerza bruta), ni tampoco -p (escaneo de puertos).

Para obtener los posibles subdominios/dominios de ajpdsoft.com ejecutaremos el comando:

Esta herramienta buscará en los motores: Baidu, Google, Bing, Ask, Netcraft, DNSdumpster, Virustotal, ThreatCrowd, SSL Certificates, PassiveDNS. Mostrará los subdominios encontrados:

[-] Total Unique Subdomains Found: 2
www.ajpdsoft.com
ftp.ajpdsoft.com

Clonar repositorio GitHub en Kali Linux, instalar sublist3r

Esta herramienta, en principio y siempre que no se use fuerza bruta ni escaneo de puertos, es legal para Information Gathering, dado que hace una búsqueda en motores públicos y no en posibles sitios web de la organización, del dominio pasado por parámetro. Además, disponemos del código fuente en Python por si queremos hacer cualquier modificación.

theHarvester

La herramienta theHarvester, que suele venir instalada en Kali Linux, también nos obtendrá los subdominios de un dominio y mucha más información para nuestro informe de auditoría sobre Information Gathering. Esta herramienta, si no se le indica el parámetro –dns-brute, hará un análisis pasivo y, por lo tanto, legal (no se requerirá la autorización de la entidad a analizar).

Para ver todos los parámetros posibles de que dispone ejecutaremos el comando:

Que nos devolverá:

-h, –helpshow this help message and exit
-d DOMAIN, –domain DOMAINCompany name or domain to search
-l LIMIT, –limit LIMITLimit the number of search results, default=500
-S START, –start STARTStart with result number X, default=0
-g, –google-dorkUse Google Dorks for Google search
-p, –proxiesUse proxies for requests, enter proxies in proxies.yaml
-s, –shodanUse Shodan to query discovered hosts
–screenshot SCREENSHOTTake screenshots of resolved domains specify output directory: –screenshot output_directory
-v, –virtual-hostVerify host name via DNS resolution and search for virtual hosts
-e DNS_SERVER, –dns-serverServer to use for lookup
-t DNS_TLD, –dns-tld DNS_TLD DNS_SERVER DNSPerform a DNS TLD expansion discovery, default False
-r, –take-overCheck for takeovers
-n, –dns-lookupEnable DNS server lookup, default False
-c, –dns-brutePerform a DNS brute force on the domain
-f FILENAME, –filename FILENAMESave the results to an XML and JSON file
-b SOURCE, –source SOURCEanubis, baidu, bing, binaryedge, bingapi, bufferoverun, censys, certspotter, crtsh, dnsdumpster, duckduckgo, fullhunt, github-code, google, hackertarget, hunter, intelx, linkedin, linkedin_links, n45ht, omnisint, otx, pentesttools, projectdiscovery, qwant, rapiddns, rocketreach, securityTrails, spyse, sublist3r, threatcrowd, threatminer, trello, twitter, urlscan, virustotal, yahoo, zoomeye

Para obtener los subdominios, emails, IP, etc. del dominio ajpdsoft.com, y que busque en todos sus fuentes, ejecutaremos:

Con el parámetro -b all indicamos que busque en todos los motores posibles y con -l 200 indicamos que limite la búsqueda a 200 elementos como máximo. Si queremos que la búsqueda sea más rápida, podremos indicar los motores a buscar, por ejemplo, para buscar en Google y Linkedin:

Nos devolverá, buscando en los motores indicados (salvo que se indique «all» en -b), cualquier subdominio que encuentre, IP pública, dirección de correo electrónico, …

theHarvester

Para el ejemplo, obtiene:

dnsenum

Continuando con las herramientas para obtener subdominios y algunos otros datos, la herramienta dnsenum también es interesante y viene con Kali Linux. Sus opciones:

–enumShortcut option equivalent to –threads 5 -s 15 -w
-h, –helpPrint this help message
–noreverseSkip the reverse lookup operations
–nocolorisable ANSIColor output
–privateShow and save private ips at the end of the file domain_ips.txt
–subfile <file>Write all valid subdomains to this file
-t, –timeout <value>The tcp and udp timeout values in seconds (default: 10s)
–threads <value>The number of threads that will perform different queries
-v, –verboseBe verbose: show all the progress and all the error messages
-p, –pages <value>GOOGLE SCRAPING OPTIONS: The number of google search pages to process when scraping names, the default is 5 pages, the -s switch must be specified
-s, –scrap <value>GOOGLE SCRAPING OPTIONS: The maximum number of subdomains that will be scraped from Google (default 15)
-f, –file <file>BRUTE FORCE OPTIONS: Read subdomains from this file to perform brute force. (Takes priority over default dns.txt)
-u, –update <a|g|r|z>BRUTE FORCE OPTIONS: Update the file specified with the -f switch with valid subdomains.
a (all) Update using all results.
g Update using only google scraping results.
r Update using only reverse lookup results.
z Update using only zonetransfer result
-r, –recursionBRUTE FORCE OPTIONS: Recursion on subdomains, brute force all discovered subdomains that have an NS record
-d, –delay <value>WHOIS NETRANGE OPTIONS: The maximum value of seconds to wait between whois queries, the value is defined randomly, default: 3s
-w, –whoisWHOIS NETRANGE OPTIONS: Perform the whois queries on c class network ranges.
Warning: this can generate very large netranges and it will take lot of time to perform reverse lookups
-e, –exclude <regexp>REVERSE LOOKUP OPTIONS: Exclude PTR records that match the regexp expression from reverse lookup results, useful on invalid hostnames
-o –output <file>Output in XML format. Can be imported in MagicTree

Si queremos que no sea activo (passive mode), deberemos crear un fichero vacío, por ejemplo en /tmp, con el comando:

Y ejecutar la herramienta dnsenum con los siguientes parámetros:

Obtendrá los subdominios del dominio pasado por parámetro y otros datos DNS. Al indicar un fichero vacío con el parámetro -f, no hará fuerza bruta, por lo que se considerará un análisis pasivo.

dnsenum

Devolviendo:

dnsrecon

Al igual que los anteriores, la herramienta dnsrecon también servirá para hacer subdomains enumeration:

dnsrecon

host

Otra herramienta útil para obtener información DNS e IPs de dominios es host, que tiene las opciones:

-ais equivalent to -v -t ANY
-Ais like -a but omits RRSIG, NSEC, NSEC3
-cspecifies query class for non-IN data
-Ccompares SOA records on authoritative nameservers
-dis equivalent to -v
-llists all hosts in a domain, using AXFR
-mset memory debugging flag (trace|record|usage)
-Nchanges the number of dots allowed before root lookup is done
-pspecifies the port on the server to query
-rdisables recursive processing
-Rspecifies number of retries for UDP packets
-sa SERVFAIL response should stop query
-tspecifies the query type
-Tenables TCP/IP mode
-Uenables UDP mode
-venables verbose output
-Vprint version number and exit
-wspecifies to wait forever for a reply
-Wspecifies how long to wait for a reply
-4use IPv4 query transport only
-6use IPv6 query transport only

Para obtener información DNS del dominio ajpdsoft.com ejecutaremos el comando:

Para obtener la información básica, más limpia, podremos ejecutar:

Que nos devolverá:

ajpdsoft.com has address 82.98.136.69
ajpdsoft.com mail is handled by 10 aspmx.l.google.com.

Si queremos que nos devuelva sólo las IPs obtenidas, ejecutaremos el comando: