1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Nmapによるポートスキャンの実行

Last updated at Posted at 2024-11-02

はじめに

以前に簡易的なポートスキャナを作ってみましたが、やはりちゃんとしたツールを使ってみようということで、試しにNmapを使ってみた時の記録を記事としてまとめてみました。

使用した環境

  • 今回は手軽に試してみたかったので、WSL2環境を利用しました。

Nmapのインストール

  • WSL環境でUbuntuを使っているため、apt-getで簡単にインストールできました。
    • RHEL系でもdnf install nmapでインストールできるようです。
# apt-get install nmap

Nmapの利用

最も簡単な使用方法

  • nmap {IPアドレス}と指定するだけで、簡単にポートスキャンを実行できます。
    • ここでは22番と80番のポートが開放されていました。
  • このようにオプションを付けずに実行すると、代表的な1000ポートを選んでスキャンを実行してくれるようです。
    • 最初はオプションなしの「お任せモード」で試してみるのが良いと思います。
# nmap xxx.xxx.xxx.xxx
Starting Nmap 7.80 ( https://nmap.org ) at 2024-09-11 15:05 JST
Nmap scan report for ec2-xxx-xxx-xxx-xxx.ap-northeast-1.compute.amazonaws.com (xxx.xxx.xxx.xxx)
Host is up (0.082s latency).
Not shown: 998 filtered ports
PORT   STATE SERVICE
22/tcp open  ssh
80/tcp open  http
Nmap done: 1 IP address (1 host up) scanned in 10.96 seconds

スキャンするポート番号を指定する

  • 以下は-p 1-65525というオプションを指定して、1番~65535番までのポートをスキャンしています。
  • スキャンするポートを増やすと当然ながらスキャン時間が長くなるので、この辺りは上手く調整しながら使うのが良さそうです。
# nmap -p 1-65535 xxx.xxx.xxx.xxx
Starting Nmap 7.80 ( https://nmap.org ) at 2024-09-11 15:34 JST
Nmap scan report for ec2-xxx-xxx-xxx-xxx.ap-northeast-1.compute.amazonaws.com (xxx.xxx.xxx.xxx)
Host is up (0.013s latency).
Not shown: 65533 filtered ports
PORT   STATE SERVICE
22/tcp open  ssh
80/tcp open  http
Nmap done: 1 IP address (1 host up) scanned in 104.60 seconds

バージョンのスキャン

  • -sVオプションを付けることで、バージョンスキャンを行うことができます。
  • 以下の例だと、Apacheについてはhttpd.confの設定を変えているのでバージョンが表示されていませんが、OpenSSHについてはバージョンが表示されています。
# nmap -sV xxx.xxx.xxx.xxx
Starting Nmap 7.80 ( https://nmap.org ) at 2024-11-02 16:36 JST
Nmap scan report for ec2-xxx-xxx-xxx-xxx.ap-northeast-1.compute.amazonaws.com (xxx.xxx.xxx.xxx)
Host is up (0.024s latency).
Not shown: 997 filtered ports
PORT    STATE  SERVICE VERSION
22/tcp  open   ssh     OpenSSH 8.7 (protocol 2.0)
80/tcp  open   http    Apache httpd
443/tcp closed https

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 12.42 seconds

参考URL

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?