Bienvenidos a un nuevo post en ByteMind. En este caso les vamos a enseñar la herramienta Dirb, una herramienta de fuerza bruta para el descubrimiento de directorios y ficheros en un sitio web.
Índice
¿Qué es DIRB?
Dirb es un escáner de contenido web, también conocido como una herramienta de fuerza bruta para el descubrimiento de ficheros y directorios existentes en un portal web.
Funciona lanzando un ataque basado en diccionario contra un servidor web y analizando las respuestas devueltas por este.
El objetivo de esta herramienta es tratar de descubrir rutas que el administrador a dejado públicas de forma descuidada o simplemente para tratar de hacerse una idea de la estructura web del servidor.
Instalación de Dirb
Para aquellos usuarios de Kali Linux, esta herramienta ya viene preinstalada en el sistema, aunque es posible instalarla en sistemas basados en debian con el siguiente comando:
1 |
sudo apt-get install dirb |
También es posible descargar la misma desde la web de sourceforge.
O mediante la descarga desde el repositorio de github:
1 |
git clone https://github.com/v0re/dirb.git |
Y posteriormente acceder a la carpeta recién creada y ejecutar el script de instalación:
1 2 |
cd dirb ./install-sh |
Como utilizar Dirb
Al igual que la gran mayoría de herramientas dispone de una amplía ayuda ejecutando el comando sin parámetros donde explica las diferentes opciones del mismo:
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 |
$ dirb ----------------- DIRB v2.22 By The Dark Raver ----------------- dirb <url_base> [<wordlist_file(s)>] [options] ========================= NOTES ========================= <url_base> : Base URL to scan. (Use -resume for session resuming) <wordlist_file(s)> : List of wordfiles. (wordfile1,wordfile2,wordfile3...) ======================== HOTKEYS ======================== 'n' -> Go to next directory. 'q' -> Stop scan. (Saving state for resume) 'r' -> Remaining scan stats. ======================== OPTIONS ======================== -a <agent_string> : Specify your custom USER_AGENT. -b : Use path as is. -c <cookie_string> : Set a cookie for the HTTP request. -E <certificate> : path to the client certificate. -f : Fine tunning of NOT_FOUND (404) detection. -H <header_string> : Add a custom header to the HTTP request. -i : Use case-insensitive search. -l : Print "Location" header when found. -N <nf_code>: Ignore responses with this HTTP code. -o <output_file> : Save output to disk. -p <proxy[:port]> : Use this proxy. (Default port is 1080) -P <proxy_username:proxy_password> : Proxy Authentication. -r : Don't search recursively. -R : Interactive recursion. (Asks for each directory) -S : Silent Mode. Don't show tested words. (For dumb terminals) -t : Don't force an ending '/' on URLs. -u <username:password> : HTTP Authentication. -v : Show also NOT_FOUND pages. -w : Don't stop on WARNING messages. -X <extensions> / -x <exts_file> : Append each word with this extensions. -z <millisecs> : Add a milliseconds delay to not cause excessive Flood. ======================== EXAMPLES ======================= dirb http://url/directory/ (Simple Test) dirb http://url/ -X .html (Test files with '.html' extension) dirb http://url/ /usr/share/dirb/wordlists/vulns/apache.txt (Test with apache.txt wordlist) dirb https://secure_url/ (Simple Test with SSL) |
Los usuarios de kali ya disponen de varios diccionarios como vemos en el siguiente ejemplo:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
$ ls -l /usr/share/wordlists/dirb/ total 260 -rw-r--r-- 1 root root 184073 ene 24 2012 big.txt -rw-r--r-- 1 root root 1292 ene 27 2012 catala.txt -rw-r--r-- 1 root root 35849 nov 17 2014 common.txt -rw-r--r-- 1 root root 1492 may 23 2012 euskera.txt -rw-r--r-- 1 root root 142 dic 29 2005 extensions_common.txt -rw-r--r-- 1 root root 75 mar 16 2012 indexes.txt -rw-r--r-- 1 root root 244 dic 29 2005 mutations_common.txt drwxr-xr-x 2 root root 4096 mar 18 19:10 others -rw-r--r-- 1 root root 6561 mar 4 2014 small.txt -rw-r--r-- 1 root root 3731 nov 12 2014 spanish.txt drwxr-xr-x 2 root root 4096 mar 18 19:10 stress drwxr-xr-x 2 root root 4096 mar 18 19:10 vulns |
Para aquellos que no utilicen esta distribución, pueden encontrar una lista de diccionarios en el propio repositorio de github de la herramienta.
Ejemplos de uso
El uso básico de la herramienta sería el siguiente:
1 |
$ dirb url_to_scan |
Si no se indica un diccionario, utilizará el diccionario por defecto common.txt.
Vamos a ver con un ejemplo como funciona esta herramienta:
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 |
$ dirb http://example.com ----------------- DIRB v2.22 By The Dark Raver ----------------- START_TIME: Mon May 4 11:07:12 2020 URL_BASE: http://example.com WORDLIST_FILES: /usr/share/dirb/wordlists/common.txt ----------------- GENERATED WORDS: 4612 —- Scanning URL: http://example.com/ —- + http://example.com/agenda/ ==> DIRECTORY + http://example.com/help/ ==> DIRECTORY + http://example.com/asd/ ==> DIRECTORY + http://example.com/business/ ==> DIRECTORY + http://example.com/carpeta/ ==> DIRECTORY + http://example.com/cataleg/ ==> DIRECTORY + http://example.com/cerca/ ==> DIRECTORY + http://example.com/cgi-bin/ (FOUND: 403 [Forbidden] – Size: 7007) |
En caso de querer incluir nuestro propio diccionario u otro diferente al utilizado por defecto lo haríamos de la siguiente forma:
1 |
dirb http://example.com /path/to/wordlist |
Además de esto podríamos indicarle diferentes opciones como puede ser especificarle un user-agent:
1 |
dirb http://example.com /path/to/wordlist -a "your-user-agent" |
El uso de proxy con o sin autenticación:
1 |
dirb http://example.com /path/to/wordlist -p proxy:port -P username:password |
O guardar los resultados obtenidos en un fichero para un posterior informe del escaneo, entre otras cosas:
1 |
dirb http://example.com /path/to/wordlist -o output_file |
Hasta aquí es todo por ahora, espero les sea de utilidad en sus auditorías y/o investigaciones y como siempre cualquier duda, aporte o sugerencia es bienvenida en la sección de comentarios.
Muy bueno todo, la explicación simple y Clara, Felicitaciones