# Descubrimiento de host

## ARP

### Máquina local

```shell
# Linux/Unix
arp
# Windows
arp -a
```

### Herramientas

```shell
arp-scan -l
arp-scan -I <interface> <CIDR>
netdiscover -i <interface> -r <CIDR>
```

* \<interface> = interfaz de red.
* \<CIDR> = Classless Inter-Domain Routing.

## Ping

```bash
# Windows
# Símbolo del sistema (cmd)
for /l %i in (1,1,254) do @ping -4 -n 1 -w 100 X.X.X.%i | findstr TTL
# PowerShell
1..254 | % {ping -4 -n 1 -w 100 X.X.X.$_} | Select-String TTL
1..254 | % {ping -4 -n 1 -w 100 X.X.X.$_} | Select-String TTL | % {$regex = [regex] '\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b'; $regex.Matches($_)} | % {$_.value}

# Linux/Unix
for i in $(seq 1 254); do (ping -c 1 X.X.X.${i} | grep "bytes from" &); done;
```

## fping

Utiliza Internet Control Message Protocol (ICMP) para determinar si un host está activo.

<table><thead><tr><th width="308">Descripción</th><th>Tipo</th><th>Código</th></tr></thead><tbody><tr><td>Echo request (petición de eco)</td><td>8</td><td>0</td></tr><tr><td>Echo reply (respuesta de eco)</td><td>0</td><td>0</td></tr></tbody></table>

```shell
fping -a -A -n <IP-address> 2>/dev/null
fping -a -A -n -g -q <start-IP-address> <end-IP-address> 2>/dev/null
fping -a -A -n -g -q <CIDR> 2>/dev/null
fping -a -A -n -g -q <CIDR> | tr -d '()' | awk '{print $2"\t"$1}' | column -t >> fping.txt
```

* -a = host activos.
* -A = muestra host por dirección IP.
* -n = muestra host por nombre (DNS).
* \<IP-address> = dirección IP.
* -g = hosts a descubrir.
  * \<start-IP-address> = dirección IP inicio.
  * \<end-IP-address> = dirección IP final.
  * \<CIDR> = Classless Inter-Domain Routing.
* 2>/dev/null = envía todos los errores producidos por el comando a `/dev/null`, son ignorarlos y no se muestran.

## Nmap

### Listado de host utilizando resolución inversa de DNS

```shell
nmap -sL <IP-address>
nmap -sL <CIDR>
nmap -sL X.X.X.0-255
nmap -sL X.X.X.*
nmap -sL X.X.0-255.*
```

* -sL = listado de host utilizando resolución inversa de DNS. No envía ningún paquete a los host.
  * \<IP-address> = dirección IP.
  * \<CIDR> = Classless Inter-Domain Routing.

### Descubrimiento de host activos

```shell
nmap -sn <IP-address>
nmap -sn <CIDR> -oN nmap-host-discovery.txt
nmap -sn X.X.X.0-255
nmap -sn X.X.X.*
nmap -sn X.X.0-255.*
nmap -sn -PS21,22,23,25,53,80,110,111,135,139,143,443,445,993,995,1723,3306,3389,5900,8080 {CIDR} -oN nmap-host-discovery-top-ports.txt
```

* -sn = descubrimiento de host utilizando:

<table><thead><tr><th width="289.3333333333333">ICMP</th><th>Tipo</th><th>Código</th></tr></thead><tbody><tr><td>Echo request (petición de eco)</td><td>8</td><td>0</td></tr><tr><td>Echo reply (respuesta de eco)</td><td>0</td><td>0</td></tr></tbody></table>

| Protocolo | Puerto | Petición |
| --------- | ------ | -------- |
| TCP       | 80     | ACK      |
| TCP       | 443    | SYN      |

{% hint style="info" %}
La opción **`-sn`** no completa el procedimiento de negociación de tres pasos de TCP (3 way handshake).
{% endhint %}

### Descubrimiento de host activos vía escaneo de puertos

```shell
nmap -Pn <IP-address>
nmap -Pn <CIDR>
nmap -Pn X.X.X.0-255
nmap -Pn X.X.X.*
nmap -Pn X.X.0-255.*
```

* -Pn = no realiza fase de descubrimiento de host, considera a todos como activos y realiza un escaneo de puertos para determinar los host activos.
  * \<IP-address> = dirección IP.
  * \<CIDR> = Classless Inter-Domain Routing.

### Descubrimiento de servidores por servicio

```shell
# DNS, Domain Name System
nmap -sS -sU -p 53 --open <CIDR> -oN nmap-dns-servers.txt
# SNMP, Simple Network Management Protocol
nmap -sS -sU -p 161,162 --open <CIDR> -oN nmap-snmp.txt
```

* -sS = escaneo TCP SYN (stealth/sigilo).
* -sU = escaneo puertos UDP.
* -p = puerto TCP/UDP.
* \--open = mostrar solo puertos abiertos (o posiblemente abiertos).
* \<CIDR> = Classless Inter-Domain Routing.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://pentesting.mrw0l05zyn.cl/escaneo-y-enumeracion/descubrimiento-de-host.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
