OSINT Rápido y Efectivo
theHarvester es la herramienta de OSINT más rápida para reconocimiento inicial. Diseñada para ser simple: un dominio como input, y en segundos devuelve emails, subdominios, IPs y nombres de empleados recopilados de decenas de fuentes públicas simultáneamente. Es el primer paso estándar en cualquier reconocimiento de pentest.
¿Qué puede descubrir theHarvester?
theHarvester en el Flujo de Reconocimiento
theHarvester viene preinstalado en Kali Linux. En otras distribuciones se instala fácilmente con pip o desde el repositorio de GitHub. Las API keys opcionales multiplican la efectividad.
# Kali Linux (ya incluido) theHarvester --help # Desde pip pip3 install theHarvester # Desde fuente (última versión — recomendado) git clone https://github.com/laramies/theHarvester.git cd theHarvester pip3 install -r requirements/base.txt python3 theHarvester.py --help # Docker docker pull ghcr.io/laramies/theharvester docker run -it ghcr.io/laramies/theharvester -d example.com -b all # Verificar versión theHarvester --version theHarvester 4.6.0
Configurar API Keys
# Las API keys se guardan en: ~/.theHarvester/api-keys.yaml # (o en el directorio de instalación) cat ~/.theHarvester/api-keys.yaml apikeys: bevigil: key: null bing: key: null binaryedge: key: null censys: id: null secret: null fullhunt: key: null github: key: null hunter: key: null intelx: key: null shodan: key: null virustotal: key: null # Editar el archivo nano ~/.theHarvester/api-keys.yaml # O directamente: sed -i 's/ shodan:\n key: null/ shodan:\n key: TU_SHODAN_KEY/' ~/.theHarvester/api-keys.yaml # APIs gratuitas disponibles github → github.com/settings/tokens (rate limit sin key) shodan → account.shodan.io virustotal → virustotal.com/gui/join-us hunter → hunter.io (25 búsquedas/mes gratis) censys → search.censys.io (250 queries/mes) bing → portal.azure.com (Bing Web Search API)
theHarvester tiene una interfaz CLI muy simple: dominio, fuentes y opciones de salida. La mayoría de las veces solo se necesitan tres flags para obtener resultados excelentes.
theHarvester -d DOMINIO -b FUENTES [opciones] ## FLAGS PRINCIPALES -d DOMAIN → dominio objetivo (obligatorio) -b SOURCE → fuente(s) de datos — separadas por comas o "all" -l LIMIT → límite de resultados (default: 500) -S START → número de resultado desde el que empezar -f FILENAME → guardar resultados en HTML y XML -v → verificar resolución DNS de hosts encontrados -n → lookup DNS reverso en todos los rangos IP -r → DNS TLD expansion (busca TLDs del dominio) -e DNS_SERVER → usar servidor DNS específico -t → comprobar transferencia de zona DNS -p → buscar puertos en Shodan -s → búsqueda en Google Scholar ## EJEMPLOS BÁSICOS # Búsqueda rápida con Google y Bing (sin API key) theHarvester -d example.com -b google,bing # Búsqueda con todas las fuentes disponibles theHarvester -d example.com -b all # Guardar en HTML con límite ampliado theHarvester -d example.com -b all -l 1000 -f /tmp/recon_example # Con verificación DNS de los hosts encontrados theHarvester -d example.com -b all -v # Solo fuentes que no necesitan API theHarvester -d example.com -b google,bing,certspotter,crtsh,dnsdumpster,hackertarget,otx,rapiddns,threatminer,urlscan
theHarvester incluye decenas de fuentes que funcionan sin ninguna API key. Son el punto de partida óptimo para cualquier reconocimiento.
# El combo más efectivo sin API keys theHarvester -d example.com \ -b certspotter,crtsh,dnsdumpster,hackertarget,otx,rapiddns,threatminer,urlscan \ -l 500 -f /tmp/recon_example # Solo para subdominios (DNS-focused) theHarvester -d example.com -b certspotter,crtsh,dnsdumpster,hackertarget,rapiddns # Para emails (búsqueda-focused) theHarvester -d example.com -b google,bing,yahoo -l 200
Las fuentes con API key multiplican la calidad y profundidad de los resultados. La mayoría tienen planes gratuitos con límites suficientes para reconocimiento individual.
| Fuente | Qué aporta | Plan gratuito | URL registro |
|---|---|---|---|
shodan | Puertos, banners, CVEs de todas las IPs encontradas | 100 queries/mes | account.shodan.io |
virustotal | Subdominios, historial DNS, detecciones de malware | 500 req/día | virustotal.com |
github | Emails en commits, repos de la organización | Rate limit más alto | github.com/settings/tokens |
hunter | Emails corporativos verificados y su formato | 25 búsquedas/mes | hunter.io |
censys | Datos de escaneo de internet, certificados, servicios | 250 queries/mes | search.censys.io |
intelx | Dark web, pastes, brechas de datos | Limitado | intelx.io |
bevigil | Subdominios y endpoints de apps móviles | Disponible | bevigil.com |
binaryedge | Escaneo de internet, puertos y servicios | Limitado | binaryedge.io |
fullhunt | Attack surface, subdominios, tecnologías | 10 dominios/día | fullhunt.io |
# Con Shodan (mejor para IPs y puertos) theHarvester -d example.com -b shodan -l 500 # Con GitHub (mejor para emails de desarrolladores) theHarvester -d example.com -b github-code -l 500 # Combo completo con las mejores fuentes theHarvester -d example.com \ -b certspotter,crtsh,hackertarget,shodan,virustotal,github-code,hunter \ -l 1000 -f /tmp/full_recon_example # Con verificación DNS activada theHarvester -d example.com -b all -v -l 500 -f /tmp/recon
Lista completa de fuentes disponibles en theHarvester 4.x con su tipo de datos principal y si requieren API key.
theHarvester -h 2>&1 | grep -A5 "Specify the data source" -b SOURCE baidu, bevigil, binaryedge, bing, bingapi, brave, bufferoverun, censys, certspotter, criminalip, crtsh, dnsdumpster, duckduckgo, fullhunt, github-code, google, hackertarget, hunter, hunterhow, intelx, netlas, onyphe, otx, pentesttools, projectdiscovery, rapiddns, rocketreach, securityTrails, shodan, sitedossier, subdomaincenter, sublist3r, threatminer, tomba, urlscan, virustotal, yahoo, zoomeye, all ## AGRUPADAS POR TIPO DE DATO PRINCIPAL SUBDOMINIOS (DNS): certspotter, crtsh, dnsdumpster, hackertarget, rapiddns sublist3r, subdomaincenter, bufferoverun, projectdiscovery virustotal, shodan, censys, fullhunt, bevigil, netlas EMAILS: google, bing, yahoo, duckduckgo, brave hunter, hunterhow, tomba, rocketreach github-code, linkedin (limitado) THREAT INTEL / HISTORIAL: otx, threatminer, urlscan, intelx sitedossier, binaryedge, onyphe securityTrails (excelente para DNS histórico) IPs / PUERTOS: shodan, censys, binaryedge, onyphe, netlas, zoomeye
El harvesting de emails es el caso de uso original de theHarvester. Combina búsquedas en motores, Hunter.io y fuentes especializadas para construir una lista de emails corporativos reales.
## BÚSQUEDA FOCALIZADA EN EMAILS # Fuentes más efectivas para emails sin API theHarvester -d example.com -b google,bing,yahoo,duckduckgo -l 500 # Con Hunter.io (emails verificados y formato inferido) theHarvester -d example.com -b hunter -l 100 # GitHub para emails de desarrolladores theHarvester -d example.com -b github-code -l 200 # Combo óptimo para emails theHarvester -d example.com -b google,bing,hunter,github-code,hunterhow -l 500 -f /tmp/emails_recon ## EXTRAER SOLO LOS EMAILS DEL ARCHIVO DE SALIDA # Del XML generado por -f grep -oP '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}' /tmp/emails_recon.xml | sort -u > /tmp/emails.txt wc -l /tmp/emails.txt 12 /tmp/emails.txt # Desde la salida en pantalla (redirigir a grep) theHarvester -d example.com -b all -l 500 2>/dev/null | grep "@example.com" | sort -u ## INFERIR EL PATRÓN DE EMAIL # Si encontramos: john.doe@example.com y j.smith@example.com # El patrón es: nombre.apellido@example.com # Útil para construir listas de usuarios para pentests autorizados ## VALIDAR EMAILS ENCONTRADOS pip3 install validate-email-address python3 -c " from validate_email_address import validate_email emails = open('/tmp/emails.txt').read().splitlines() for e in emails: valid = validate_email(e, verify=True) status = 'VÁLIDO' if valid else 'INVÁLIDO' print(f'[{status}] {e}') "
theHarvester es especialmente potente para enumeración de subdominios gracias a su integración con Certificate Transparency Logs, que indexa todos los certificados SSL emitidos y los subdominios que cubren.
## FUENTES PRINCIPALES PARA SUBDOMINIOS # crt.sh — Certificate Transparency (el más completo sin API) theHarvester -d example.com -b crtsh -l 500 [*] Hosts found: 23 ------------------ api.example.com:93.184.216.34 dev.example.com:93.184.216.36 mail.example.com:93.184.216.35 staging.example.com:93.184.216.37 vpn.example.com:93.184.216.38 admin.example.com:93.184.216.39 ← panel de admin! beta.example.com:93.184.216.40 # hackertarget — rápido sin API theHarvester -d example.com -b hackertarget # Combo DNS óptimo (sin APIs) theHarvester -d example.com \ -b certspotter,crtsh,dnsdumpster,hackertarget,rapiddns,otx,urlscan \ -l 1000 -v # -v verifica la resolución DNS de cada subdominio encontrado # Con Shodan (agrega puertos a los hosts) theHarvester -d example.com -b crtsh,shodan -l 500 -v ## EXTRAER SUBDOMINIOS DEL OUTPUT theHarvester -d example.com -b all 2>/dev/null | \ grep -oP '[a-zA-Z0-9-]+\.example\.com' | sort -u > /tmp/subdominios.txt ## RESOLVER SUBDOMINIOS A IPS cat /tmp/subdominios.txt | while read sub; do ip=$(dig +short "$sub" 2>/dev/null | head -1) [ -n "$ip" ] && echo "$sub → $ip" done api.example.com → 93.184.216.34 mail.example.com → 93.184.216.35 dev.example.com → (no resolution — posiblemente offline) staging.example.com → 93.184.216.37 ## TLD EXPANSION — buscar en dominios similares theHarvester -d example -b crtsh -r # -r prueba example.com, example.net, example.org, example.es...
theHarvester puede mapear la infraestructura IP del objetivo: IPs asociadas a subdominios, rangos de red y puertos expuestos via Shodan.
# Con -v: resolver IPs de todos los hosts encontrados theHarvester -d example.com -b crtsh,hackertarget -v -l 500 Hosts found with IP: api.example.com:93.184.216.34 mail.example.com:93.184.216.35 IPs found: 5 93.184.216.34 93.184.216.35 93.184.216.36 93.184.216.37 93.184.216.38 # Con -n: DNS reverso en rangos de IPs theHarvester -d example.com -b all -n -v -f /tmp/recon_ips # Con Shodan: puertos abiertos de cada IP theHarvester -d example.com -b shodan -p -v Shodan results for 93.184.216.34: Port: 80 (HTTP) Port: 443 (HTTPS) Port: 22 (SSH) Banner: nginx/1.18.0 Ubuntu ## EXTRAER IPs Y PROCESARLAS theHarvester -d example.com -b all -v 2>/dev/null | \ grep -oP '\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b' | sort -u > /tmp/ips.txt # Usar las IPs con nmap para verificar servicios nmap -sV -p 80,443,22,21,3306,8080 -iL /tmp/ips.txt -oX /tmp/nmap_results.xml # Verificar ASN de las IPs encontradas for ip in $(cat /tmp/ips.txt); do asn=$(whois "$ip" | grep -i "^AS\|^OriginAS\|^route" | head -3) echo "$ip: $asn" done
theHarvester puede extraer nombres de empleados de LinkedIn y otras fuentes sociales. El soporte de LinkedIn es limitado debido a sus restricciones, pero otras fuentes como GitHub dan buenos resultados para perfiles técnicos.
## NOMBRES DE EMPLEADOS # LinkedIn (requiere cookies de sesión — uso limitado) theHarvester -d "Example Corp" -b linkedin -l 200 # Google dork sobre LinkedIn (más efectivo) theHarvester -d example.com -b google -l 500 # theHarvester ejecuta automáticamente: site:linkedin.com "example.com" [*] Users found (LinkedIn): John Doe - CTO at Example Corp Jane Smith - CISO at Example Corp Bob Johnson - Senior Developer at Example Corp # GitHub — emails de commits públicos theHarvester -d example.com -b github-code -l 300 [*] Emails found from GitHub: john.doe@example.com (from commit in example-corp/api repo) dev@example.com ## COMBINAR NOMBRES + EMAILS → LISTA DE USUARIOS python3 << 'EOF' # Si sabemos el formato de email (nombre.apellido@example.com) # y tenemos lista de empleados, generamos la lista de emails empleados = [ "John Doe", "Jane Smith", "Bob Johnson" ] dominio = "example.com" for nombre in empleados: partes = nombre.lower().split() if len(partes) >= 2: print(f"{partes[0]}.{partes[1]}@{dominio}") print(f"{partes[0][0]}.{partes[1]}@{dominio}") print(f"{partes[0]}@{dominio}") EOF john.doe@example.com j.doe@example.com john@example.com jane.smith@example.com ...
theHarvester genera resultados en pantalla y puede exportar a HTML y XML. El XML es especialmente útil para parsear con scripts y alimentar otras herramientas.
## GUARDAR EN HTML Y XML (-f) theHarvester -d example.com -b all -l 500 -f /tmp/recon_example # Genera: # /tmp/recon_example.html ← informe visual # /tmp/recon_example.xml ← datos estructurados ## VER EL HTML firefox /tmp/recon_example.html ## PARSEAR EL XML CON PYTHON python3 << 'EOF' import xml.etree.ElementTree as ET tree = ET.parse('/tmp/recon_example.xml') root = tree.getroot() print("=== EMAILS ===") for email in root.findall('.//email'): print(f" {email.text}") print("\n=== HOSTS ===") for host in root.findall('.//host'): nombre = host.find('hostname').text if host.find('hostname') is not None else '' ip = host.find('ip').text if host.find('ip') is not None else '' print(f" {nombre:<40} {ip}") EOF ## EXTRAER SOLO EMAILS DEL XML xmllint --xpath '//email/text()' /tmp/recon_example.xml 2>/dev/null | tr ' ' '\n' | sort -u ## GUARDAR SALIDA EN TEXTO theHarvester -d example.com -b crtsh,hackertarget -l 500 > /tmp/recon_output.txt 2>&1 ## PARSEAR SALIDA DE TEXTO CON GREP grep -oP '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}' /tmp/recon_output.txt | sort -u grep -oP '[a-zA-Z0-9-]+\.example\.com' /tmp/recon_output.txt | sort -u grep -oP '\b(?:\d{1,3}\.){3}\d{1,3}\b' /tmp/recon_output.txt | sort -u
Integrar theHarvester en pipelines de reconocimiento automatizado: alimentar sus resultados a otras herramientas y ejecutar reconocimientos completos con un solo script.
## PIPELINE 1: theHarvester → nmap # 1. Extraer subdominios con theHarvester theHarvester -d example.com -b crtsh,hackertarget -l 500 2>/dev/null | \ grep -oP '[a-zA-Z0-9-]+\.example\.com' | sort -u > /tmp/hosts.txt # 2. Resolver a IPs while read host; do ip=$(dig +short "$host" 2>/dev/null | head -1) [ -n "$ip" ] && echo "$ip" done < /tmp/hosts.txt | sort -u > /tmp/ips.txt # 3. Escanear con nmap nmap -sV -p 80,443,8080,8443,22,21 -iL /tmp/ips.txt -oX /tmp/nmap.xml ## PIPELINE 2: theHarvester → Recon-ng # Exportar hosts para importar en Recon-ng theHarvester -d example.com -b crtsh,hackertarget 2>/dev/null | \ grep -oP '[a-zA-Z0-9-]+\.example\.com' | sort -u > /tmp/hosts_for_reconng.txt # En Recon-ng: modules load import/list options set FILENAME /tmp/hosts_for_reconng.txt options set TABLE hosts options set COLUMN host run ## SCRIPT COMPLETO DE RECONOCIMIENTO cat > /tmp/full_recon.sh << 'EOF' #!/bin/bash DOMAIN=$1 OUT="/tmp/recon_${DOMAIN//./_}" mkdir -p "$OUT" echo "[*] theHarvester — reconocimiento de: $DOMAIN" # Fase 1: Emails y subdominios theHarvester -d "$DOMAIN" \ -b certspotter,crtsh,dnsdumpster,hackertarget,google,bing,otx,urlscan \ -l 500 -f "$OUT/harvester" 2>/dev/null # Extraer resultados grep -oP '[a-zA-Z0-9._%+-]+@'"$DOMAIN" "$OUT/harvester.xml" 2>/dev/null | \ sort -u > "$OUT/emails.txt" grep -oP '[a-zA-Z0-9-]+\.'"$DOMAIN" "$OUT/harvester.xml" 2>/dev/null | \ sort -u > "$OUT/subdomains.txt" grep -oP '\b(?:\d{1,3}\.){3}\d{1,3}\b' "$OUT/harvester.xml" 2>/dev/null | \ sort -u > "$OUT/ips.txt" echo "[+] Emails: $(wc -l < "$OUT/emails.txt")" echo "[+] Subdominios: $(wc -l < "$OUT/subdomains.txt")" echo "[+] IPs: $(wc -l < "$OUT/ips.txt")" echo "[+] HTML: $OUT/harvester.html" EOF chmod +x /tmp/full_recon.sh /tmp/full_recon.sh example.com
Las tres herramientas OSINT principales de la colección tienen perfiles distintos. Elegir la correcta depende del tiempo disponible y la profundidad necesaria.
| Característica | theHarvester | SpiderFoot | Recon-ng |
|---|---|---|---|
| Velocidad | Muy rápido | Medio (completo) | Medio (modular) |
| Profundidad | Media | Alta (automatizado) | Alta (manual) |
| Control | Limitado | Medio | Total |
| Curva de aprendizaje | Muy baja | Baja (GUI web) | Media |
| Base de datos | No | Sí (SQLite) | Sí (SQLite) |
| Correlación entre datos | No | Automática | Manual/encadenada |
| Ideal para | Primer barrido rápido | Reconocimiento completo automatizado | Reconocimiento estructurado y controlado |
Reconocimiento completo de un dominio con theHarvester, usando objetivos legales de práctica (hackthebox.com, tryhackme.com o tu propio dominio).
Objetivo: obtener emails, subdominios e IPs de un dominio usando fuentes gratuitas. Usar hackthebox.com como objetivo de práctica (OSINT pasivo legal).
## PASO 1: Reconocimiento inicial sin API keys theHarvester -d hackthebox.com \ -b certspotter,crtsh,dnsdumpster,hackertarget,otx,urlscan \ -l 500 -f /tmp/lab_hackthebox ## PASO 2: Ver el informe HTML firefox /tmp/lab_hackthebox.html ## PASO 3: Extraer y analizar resultados echo "=== EMAILS ===" && \ grep -oP '[a-zA-Z0-9._%+-]+@hackthebox\.com' /tmp/lab_hackthebox.xml 2>/dev/null | sort -u echo "=== SUBDOMINIOS ===" && \ grep -oP '[a-zA-Z0-9-]+\.hackthebox\.com' /tmp/lab_hackthebox.xml 2>/dev/null | sort -u echo "=== IPs ===" && \ grep -oP '\b(?:\d{1,3}\.){3}\d{1,3}\b' /tmp/lab_hackthebox.xml 2>/dev/null | sort -u ## PASO 4: Verificar subdominios con dig grep -oP '[a-zA-Z0-9-]+\.hackthebox\.com' /tmp/lab_hackthebox.xml 2>/dev/null | \ sort -u | while read sub; do ip=$(dig +short "$sub" 2>/dev/null | head -1) [ -n "$ip" ] && echo "$sub → $ip" done ## PASO 5: Búsqueda adicional con Google (para emails) theHarvester -d hackthebox.com -b google,bing -l 300
Reconocimiento orientado a empresa: combinar theHarvester con herramientas complementarias para construir un perfil completo de infraestructura y personal.
## FASE 1: theHarvester — barrido inicial DOMAIN="target-company.com" theHarvester -d "$DOMAIN" -b all -l 500 -f /tmp/phase1_harvester 2>/dev/null ## FASE 2: Extraer resultados EMAILS=$(grep -oP '[a-zA-Z0-9._%+-]+@'"$DOMAIN" /tmp/phase1_harvester.xml 2>/dev/null | sort -u) HOSTS=$(grep -oP '[a-zA-Z0-9-]+\.'"$DOMAIN" /tmp/phase1_harvester.xml 2>/dev/null | sort -u) IPS=$(grep -oP '\b(?:\d{1,3}\.){3}\d{1,3}\b' /tmp/phase1_harvester.xml 2>/dev/null | sort -u) echo "Emails: $(echo "$EMAILS" | wc -l)" echo "Hosts: $(echo "$HOSTS" | wc -l)" echo "IPs: $(echo "$IPS" | wc -l)" ## FASE 3: Completar con theHarvester focalizado en emails theHarvester -d "$DOMAIN" -b google,bing,github-code -l 300 2>/dev/null | \ grep "@$DOMAIN" >> /tmp/all_emails.txt sort -u /tmp/all_emails.txt ## FASE 4: Verificar DNS de hosts encontrados echo "$HOSTS" | while read host; do ip=$(dig +short "$host" 2>/dev/null | head -1) [ -n "$ip" ] && echo "$host|$ip" done | tee /tmp/resolved_hosts.txt ## FASE 5: Resumen ejecutivo python3 << 'PYTHON' import subprocess, re domain = "target-company.com" # Leer resultados emails_count = len(open('/tmp/all_emails.txt').read().splitlines()) hosts_count = len(open('/tmp/resolved_hosts.txt').read().splitlines()) print(f"{'='*50}") print(f"PERFIL OSINT: {domain}") print(f"{'='*50}") print(f" Emails encontrados: {emails_count}") print(f" Subdominios resueltos: {hosts_count}") print(f"\n Archivos generados:") print(f" - /tmp/phase1_harvester.html (informe visual)") print(f" - /tmp/all_emails.txt (emails)") print(f" - /tmp/resolved_hosts.txt (hosts con IP)") PYTHON
Script bash reutilizable que automatiza todo el reconocimiento con theHarvester: múltiples fuentes, extracción de resultados, verificación DNS y generación de informe consolidado.
## harvester_recon.sh — Script de reconocimiento con theHarvester cat > harvester_recon.sh << 'EOF' #!/bin/bash # GhostAcademy — theHarvester Recon Script # Uso: ./harvester_recon.sh dominio.com set -e DOMAIN="${1:?Uso: $0 dominio.com}" OUTDIR="/tmp/recon_$(echo "$DOMAIN" | tr '.' '_')_$(date +%Y%m%d_%H%M)" mkdir -p "$OUTDIR" echo "╔══════════════════════════════════════╗" echo "║ theHarvester Recon: $DOMAIN" echo "╚══════════════════════════════════════╝" # ─── Fase 1: Fuentes gratuitas (sin API) ─────────────────────────── echo "[1/3] Fuentes gratuitas..." theHarvester -d "$DOMAIN" \ -b certspotter,crtsh,dnsdumpster,hackertarget,otx,rapiddns,urlscan,threatminer \ -l 500 -f "$OUTDIR/free_sources" 2>/dev/null || true # ─── Fase 2: Fuentes de búsqueda (emails) ───────────────────────── echo "[2/3] Motores de búsqueda (emails)..." theHarvester -d "$DOMAIN" -b google,bing -l 300 \ >> "$OUTDIR/search_output.txt" 2>/dev/null || true # ─── Fase 3: Consolidar resultados ──────────────────────────────── echo "[3/3] Consolidando resultados..." # Emails { grep -oP "[a-zA-Z0-9._%+-]+@${DOMAIN}" "$OUTDIR/free_sources.xml" 2>/dev/null grep -oP "[a-zA-Z0-9._%+-]+@${DOMAIN}" "$OUTDIR/search_output.txt" 2>/dev/null } | sort -u > "$OUTDIR/emails.txt" # Subdominios grep -oP "[a-zA-Z0-9-]+\\.${DOMAIN}" "$OUTDIR/free_sources.xml" 2>/dev/null | \ sort -u > "$OUTDIR/subdomains.txt" # IPs grep -oP '\b(?:\d{1,3}\.){3}\d{1,3}\b' "$OUTDIR/free_sources.xml" 2>/dev/null | \ sort -u > "$OUTDIR/ips.txt" # Resolución DNS de subdominios echo "" > "$OUTDIR/resolved.txt" while read sub; do ip=$(dig +short "$sub" 2>/dev/null | head -1) [ -n "$ip" ] && echo "$sub -> $ip" >> "$OUTDIR/resolved.txt" done < "$OUTDIR/subdomains.txt" # ─── Resumen ────────────────────────────────────────────────────── echo "" echo "╔══════════════════════════════════════╗" echo "║ RESULTADOS" echo "╠══════════════════════════════════════╣" echo "║ Emails: $(wc -l < "$OUTDIR/emails.txt" | tr -d ' ')" echo "║ Subdominios: $(wc -l < "$OUTDIR/subdomains.txt" | tr -d ' ')" echo "║ IPs: $(wc -l < "$OUTDIR/ips.txt" | tr -d ' ')" echo "║ Hosts resueltos:$(wc -l < "$OUTDIR/resolved.txt" | tr -d ' ')" echo "╠══════════════════════════════════════╣" echo "║ Informe HTML: $OUTDIR/free_sources.html" echo "╚══════════════════════════════════════╝" EOF chmod +x harvester_recon.sh ./harvester_recon.sh hackthebox.com
Cheatsheet de theHarvester para reconocimiento OSINT rápido.
Comandos Esenciales
- Barrido rápido sin API:
theHarvester -d dominio.com -b crtsh,hackertarget,google,bing,otx -l 500 - Todas las fuentes:
theHarvester -d dominio.com -b all -l 500 - Guardar HTML/XML: añadir
-f /tmp/nombre_recon - Verificar DNS: añadir
-v - Resolver IPs con DNS reverso: añadir
-n - TLD expansion: añadir
-r - Ver fuentes disponibles:
theHarvester -h
Fuentes por Objetivo
| Objetivo | Fuentes recomendadas | API necesaria |
|---|---|---|
| Subdominios (rápido) | crtsh,hackertarget,rapiddns | No |
| Subdominios (completo) | certspotter,crtsh,dnsdumpster,otx,urlscan,virustotal | Virustotal opcional |
| Emails corporativos | google,bing,hunter,github-code | Hunter opcional |
| IPs y puertos | shodan,crtsh -v | Shodan recomendado |
| Reconocimiento completo | all | Varias opcionales |
Extraer Resultados del XML
- Emails:
grep -oP '[a-zA-Z0-9._%+-]+@dominio\.com' recon.xml | sort -u - Subdominios:
grep -oP '[a-zA-Z0-9-]+\.dominio\.com' recon.xml | sort -u - IPs:
grep -oP '\b(?:\d{1,3}\.){3}\d{1,3}\b' recon.xml | sort -u - Ver HTML:
firefox recon.html
Comparativa de Velocidad
- 1-2 min:
-b crtsh,hackertarget— subdominios esenciales - 3-5 min:
-b certspotter,crtsh,hackertarget,otx,urlscan— completo sin API - 5-10 min:
-b all -l 500— todas las fuentes - 10-20 min:
-b all -l 1000 -v -n— máxima cobertura con resolución DNS