imprimir todos os ipaddress dentro da rede

0

Estou tentando executar uma maneira de obter cada endereço IP e endereço MAC conectados ao roteador (incluir sem fio).

Consigo descobrir quais IPs eu tenho dentro da minha rede usando o nmap: nmap -sP 192.168.1.* >> IPs.txt

e este retorno:

Starting Nmap 7.40 ( https://nmap.org ) at 2017-04-27 18:31 ???? ÷?? ???????
Nmap scan report for 192.168.1.1
Host is up (0.0010s latency).
MAC Address: 2C:E4:12:EF:5B:72 (Sagemcom Broadband SAS)
Nmap scan report for 192.168.1.10
Host is up (0.074s latency).
MAC Address: 48:02:2A:06:A4:6F (B-Link Electronic Limited)
Nmap scan report for 192.168.1.11
Host is up (0.0030s latency).
MAC Address: 6E:2E:85:FF:FF:FF (Unknown)
Nmap scan report for 192.168.1.12
Host is up (0.071s latency).
MAC Address: 8C:18:D9:C8:A3:94 (Shenzhen RF Technology)
Nmap scan report for 192.168.1.13
Host is up (0.070s latency).
MAC Address: B4:43:0D:AA:3F:6C (Broadlink)
Nmap scan report for 192.168.1.16
Host is up (0.0020s latency).
MAC Address: F8:D1:11:18:74:89 (Tp-link Technologies)
Nmap scan report for 192.168.1.17
Host is up (0.056s latency).
MAC Address: 34:23:BA:4C:82:42 (Samsung Electro-mechanics(thailand))
Nmap scan report for 192.168.1.20
Host is up.
Nmap done: 256 IP addresses (8 hosts up) scanned in 8.24 seconds

Estou procurando uma maneira de filtrar o conteúdo e a impressão é assim: IP:MAC;

Obrigado!

    
por itzikb 27.04.2017 / 17:48

1 resposta

1
@Echo off&SetLocal EnableExtensions EnableDelayedExpansion
For /f "tokens=1-5" %%A in (
  'nmap -sP 192.168.1.*'
) Do If /I "%%B" equ "scan" (
  set "IP=%%E"
) Else if /I "%%A" equ "MAC" (
  Echo !IP!,%%C;
)

Exemplo de saída dos seus dados de teste:

192.168.1.1,2C:E4:12:EF:5B:72;
192.168.1.10,48:02:2A:06:A4:6F;
192.168.1.11,6E:2E:85:FF:FF:FF;
192.168.1.12,8C:18:D9:C8:A3:94;
192.168.1.13,B4:43:0D:AA:3F:6C;
192.168.1.16,F8:D1:11:18:74:89;
192.168.1.17,34:23:BA:4C:82:42;
    
por 28.04.2017 / 17:07