Enumeración web
Directorios, archivos, vhosts, parámetros y APIs ocultos con gobuster, ffuf, feroxbuster, arjun y katana, más lo primero que hay que mirar en una web y los trucos de curl.
Primer vistazo
- Tecnologías de la web
whatweb http://objetivo.htb - Cabeceras
curl -sI http://objetivo.htb - robots.txt y sitemap
curl -s http://objetivo.htb/robots.txt; curl -s http://objetivo.htb/sitemap.xml - Comentarios en el HTML
curl -s http://objetivo.htb | grep -oE '<!--.*?-->' - Rutas dentro de los JavaScript
curl -s http://objetivo.htb/app.js | grep -oE '"/[a-zA-Z0-9_/.-]+"' | sort -u - ¿Hay un .git expuesto?
curl -s http://objetivo.htb/.git/HEAD - Descargar el .git
git-dumper http://objetivo.htb/.git ./repo - Ver el historial del repo bajado
cd repo && git log --oneline --all && git show <commit> - ¿Un .env expuesto?
curl -s http://objetivo.htb/.env - Dominios del certificado TLS
echo | openssl s_client -connect 10.10.11.20:443 2>/dev/null | openssl x509 -noout -text | grep -A1 "Subject Alternative Name" - Escáner de vulnerabilidades conocidas
nuclei -u http://objetivo.htb - Nikto
nikto -h http://objetivo.htb
Directorios y archivos
- gobuster
gobuster dir -u http://objetivo.htb -w /usr/share/seclists/Discovery/Web-Content/raft-medium-directories.txt -x php,txt,bak -t 50 - ffuf
ffuf -u http://objetivo.htb/FUZZ -w /usr/share/seclists/Discovery/Web-Content/raft-medium-words.txt -e .php,.txt,.bak -fc 404 - ffuf recursivo
ffuf -u http://objetivo.htb/FUZZ -w /usr/share/seclists/Discovery/Web-Content/raft-medium-directories.txt -recursion -recursion-depth 2 -fc 404 - feroxbuster (recursivo)
feroxbuster -u http://objetivo.htb -x php,txt -o ferox.txt - dirsearch
dirsearch -u http://objetivo.htb -e php,html,txt - Copias de seguridad de un archivo conocido
ffuf -u http://objetivo.htb/index.phpFUZZ -w <(printf "%s\n" .bak .old .orig .save .swp ~ .txt .zip) - Con sesión (cookie)
ffuf -u http://objetivo.htb/FUZZ -w /usr/share/seclists/Discovery/Web-Content/common.txt -b "PHPSESSID=tu_cookie" - Filtrar por tamaño, palabras o líneas
ffuf -u http://objetivo.htb/FUZZ -w /usr/share/seclists/Discovery/Web-Content/common.txt -fs 1234 -fw 12 -fl 40 - Pasar ffuf por Burp
ffuf -u http://objetivo.htb/FUZZ -w /usr/share/seclists/Discovery/Web-Content/common.txt -replay-proxy http://127.0.0.1:8080 - IIS: nombres cortos (tilde)
shortscan http://objetivo.htb/
Vhosts y subdominios
- Añadir el dominio a /etc/hosts
echo "10.10.11.20 corp.htb" | sudo tee -a /etc/hosts - ffuf por cabecera Host
ffuf -u http://objetivo.htb -H "Host: FUZZ.corp.htb" -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt -fs 0 - gobuster vhost
gobuster vhost -u http://objetivo.htb -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt --append-domain - Subdominios públicos (objetivos reales con permiso)
subfinder -d corp.htb -silent
Parámetros
- Buscar parámetros GET
ffuf -u "http://objetivo.htb/index.php?FUZZ=test" -w /usr/share/seclists/Discovery/Web-Content/burp-parameter-names.txt -fs 0 - Buscar parámetros POST
ffuf -u http://objetivo.htb/index.php -X POST -d "FUZZ=test" -H "Content-Type: application/x-www-form-urlencoded" -w /usr/share/seclists/Discovery/Web-Content/burp-parameter-names.txt -fs 0 - Arjun
arjun -u http://objetivo.htb/index.php - Recorrer IDs (IDOR)
ffuf -u "http://objetivo.htb/api/users/FUZZ" -w <(seq 1 1000) -fc 404
APIs y GraphQL
- Rutas de API
ffuf -u http://objetivo.htb/api/FUZZ -w /usr/share/seclists/Discovery/Web-Content/api/api-endpoints.txt -fc 404 - Documentación expuesta
for p in swagger.json openapi.json api-docs swagger/index.html v2/api-docs; do echo "$p $(curl -s -o /dev/null -w "%{http_code}" http://objetivo.htb/$p)"; done - POST en JSON con curl
curl -s -X POST http://objetivo.htb/api/login -H "Content-Type: application/json" -d '{"username":"admin","password":"admin"}' - Probar otros métodos
curl -s -X OPTIONS http://objetivo.htb/api/users -i - GraphQL: introspección
curl -s -X POST http://objetivo.htb/graphql -H "Content-Type: application/json" -d '{"query":"{__schema{types{name fields{name}}}}"}'
Rastrear la web
- katana
katana -u http://objetivo.htb -d 3 -jc - gospider
gospider -s http://objetivo.htb -d 2 - Espejo completo con wget
wget -m -k -np http://objetivo.htb
Trucos de curl
- Con cookie
curl -s http://objetivo.htb/admin -b "session=tu_cookie" - Guardar y reusar cookies
curl -s -c cookies.txt -d "user=admin&pass=admin" http://objetivo.htb/login && curl -s -b cookies.txt http://objetivo.htb/admin - Seguir redirecciones y ver todo
curl -skLv http://objetivo.htb - Fingir que vienes de localhost
curl -s http://objetivo.htb/admin -H "X-Forwarded-For: 127.0.0.1" - Cambiar el User-Agent
curl -s http://objetivo.htb -A "Mozilla/5.0" - Pasar curl por Burp
curl -s http://objetivo.htb -x http://127.0.0.1:8080 - Subir un archivo por formulario
curl -s -F "file=@shell.php" http://objetivo.htb/upload.php