Nmap

単一IPをスキャンする

一のホストをスキャンしてオープンポートとそのサービスを調べる前に、まずそれが生きているかどうかを判断する

snowyowl644@htb[/htb]$ sudo nmap 10.129.2.18 -sn -oA host 

Starting Nmap 7.80 ( https://nmap.org ) at 2020-06-14 23:59 CEST
Nmap scan report for 10.129.2.18
Host is up (0.087s latency).
MAC Address: DE:AD:00:00:BE:EF
Nmap done: 1 IP address (1 host up) scanned in 0.11 seconds
スキャンオプション 説明
10.129.2.18 ターゲットに対して定義されたスキャンを実行します。
-sn ポートスキャンを無効にします。
-oA host 結果を「ホスト」という名前で始まるすべての形式で保存します。
snowyowl644@htb[/htb]$ sudo nmap 10.129.2.18 -sn -oA host -PE --packet-trace 

Starting Nmap 7.80 ( https://nmap.org ) at 2020-06-15 00:08 CEST
SENT (0.0074s) ARP who-has 10.129.2.18 tell 10.10.14.2
RCVD (0.0309s) ARP reply 10.129.2.18 is-at DE:AD:00:00:BE:EF
Nmap scan report for 10.129.2.18
Host is up (0.023s latency).
MAC Address: DE:AD:00:00:BE:EF
Nmap done: 1 IP address (1 host up) scanned in 0.05 seconds
スキャンオプション 説明
10.129.2.18 ターゲットに対して定義されたスキャンを実行します。
-sn ポートスキャンを無効にします。
-oA host 結果を「ホスト」という名前で始まるすべての形式で保存します。
-PE ターゲットに対して「ICMPエコー要求」を使用してpingスキャンを実行します。
--packet-trace 送受信されたすべてのパケットを表示します

複数のIPをスキャン

snowyowl644@htb[/htb]$ sudo nmap -sn -oA tnet 10.129.2.18 10.129.2.19 10.129.2.20| grep for | cut -d" " -f5

10.129.2.18
10.129.2.19
10.129.2.20

オクテットでの指定もできる

snowyowl644@htb[/htb]$ sudo nmap -sn -oA tnet 10.129.2.18-20| grep for | cut -d" " -f5

10.129.2.18
10.129.2.19
10.129.2.20
snowyowl644@htb[/htb]$ sudo nmap 10.129.2.18 -sn -oA host -PE --packet-trace --disable-arp-ping 

Starting Nmap 7.80 ( https://nmap.org ) at 2020-06-15 00:12 CEST
SENT (0.0107s) ICMP [10.10.14.2 > 10.129.2.18 Echo request (type=8/code=0) id=13607 seq=0] IP [ttl=255 id=23541 iplen=28 ]
RCVD (0.0152s) ICMP [10.129.2.18 > 10.10.14.2 Echo reply (type=0/code=0) id=13607 seq=0] IP [ttl=128 id=40622 iplen=28 ]
Nmap scan report for 10.129.2.18
Host is up (0.086s latency).
MAC Address: DE:AD:00:00:BE:EF
Nmap done: 1 IP address (1 host up) scanned in 0.11 seconds

IPスキャンリスト

snowyowl644@htb[/htb]$ cat hosts.lst

10.129.2.4
10.129.2.10
10.129.2.11
10.129.2.18
10.129.2.19
10.129.2.20
10.129.2.28

事前定義されたリストで同じスキャン手法を使用すると、コマンドはこんな感じ

snowyowl644@htb[/htb]$ sudo nmap -sn -oA tnet -iL hosts.lst | grep for | cut -d" " -f5

10.129.2.18
10.129.2.19
10.129.2.20
スキャンオプション 説明
-sn ポートスキャンを無効にします。
-oA tnet 結果を「tnet」という名前で始まるすべての形式で保存します。
-iL 提供された「hosts.lst」リストのターゲットに対して定義されたスキャンを実行します。

ネットワーク範囲のスキャン

snowyowl644@htb[/htb]$ sudo nmap 10.129.2.0/24 -sn -oA tnet | grep for | cut -d" " -f5

10.129.2.4
10.129.2.10
...
スキャンオプション 説明
10.129.2.0/24 ターゲットネットワーク範囲。
-sn ポートスキャンを無効にします。
-oA tnet 結果を「tnet」という名前で始まるすべての形式で保存します。