はじめに
ncを使ったポートスキャン
- ポートスキャン…普段やっちゃいけないことなので、自身のマシンや自PC上の仮想マシンに対して試したことがちょっとあるだけなので…ちょっと背徳感w
- 知ってはいましたが…あらためてこんな簡単に開いているポートが見つかるなんて…という思いです。
ncを使ったポートスキャン
コマンド全出力
┌──(kali㉿kali)-[~]
└─$ sudo nc -zv 10.0.177.5 1-65535
ip-10-0-177-5.ap-northeast-1.compute.internal [10.0.177.5] 80 (http) open
ip-10-0-177-5.ap-northeast-1.compute.internal [10.0.177.5] 22 (ssh) open
ip-10-0-177-5.ap-northeast-1.compute.internal [10.0.177.5] 21 (ftp) open
nmapを使ったポートスキャン
- ncコマンドより…うわあ…強力ですね…。
- ftpサーバのバージョンがわかっちゃったりします…。
- SD読み直したら…匿名ユーザのログインもできますね…。
ftp-anon: Anonymous FTP login allowed (FTP code 230) って書いてありました。
- httpは…ページタイトルからstrutsってわかりますね…。
- ブラウザで見るまでもなく、最初のページの中身がざっと見れてしまうとは…。
nmapを使ったポートスキャン
コマンド全出力
┌──(kali㉿kali)-[~]
└─$ sudo nmap -A 10.0.177.5 -p-
Starting Nmap 7.95 ( https://nmap.org ) at 2025-08-10 18:27 JST
Nmap scan report for ip-10-0-177-5.ap-northeast-1.compute.internal (10.0.177.5)
Host is up (0.00022s latency).
Not shown: 65532 closed tcp ports (reset)
PORT STATE SERVICE VERSION
21/tcp open ftp vsftpd 2.3.4
| ftp-syst:
| STAT:
| FTP server status:
| Connected to 10.0.176.5
| Logged in as ftp
| TYPE: ASCII
| No session bandwidth limit
| Session timeout in seconds is 300
| Control connection is plain text
| Data connections will be plain text
| At session startup, client count was 3
| vsFTPd 2.3.4 - secure, fast, stable
|_End of status
|_ftp-anon: Anonymous FTP login allowed (FTP code 230)
22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 2048 98:10:f5:3c:cf:a1:f7:f0:4e:76:c9:47:a0:fe:6f:eb (RSA)
| 256 3b:9d:af:52:73:0a:d8:14:c3:d6:1e:c4:0d:e3:3e:82 (ECDSA)
|_ 256 05:be:70:a6:62:83:ca:8e:77:23:35:7b:ba:1b:f1:6a (ED25519)
80/tcp open http
| http-title: Struts2 Showcase
|_Requested resource was /struts2-showcase/showcase.action
| fingerprint-strings:
| GetRequest:
| HTTP/1.1 302
| Set-Cookie: JSESSIONID=3A181E2A1B8DDCC2DA1C11585883CEA3; Path=/; HttpOnly
| Location: http://localhost/struts2-showcase/showcase.action
| Content-Type: text/html;charset=ISO-8859-1
| Content-Length: 0
| Date: Sun, 10 Aug 2025 09:27:31 GMT
| Connection: close
| HTTPOptions:
| HTTP/1.1 405
| Content-Type: text/html;charset=utf-8
| Content-Language: ja
| Content-Length: 1143
| Date: Sun, 10 Aug 2025 09:27:31 GMT
| Connection: close
| <!doctype html><html lang="ja"><head><title>HTTP
| Method Not Allowed</title><style type="text/css">h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}</styl
| RTSPRequest:
| HTTP/1.1 400
| Content-Type: text/html;charset=utf-8
| Content-Language: ja
| Content-Length: 2227
| Date: Sun, 10 Aug 2025 09:27:31 GMT
| Connection: close
| <!doctype html><html lang="ja"><head><title>HTTP
|_ Request</title><style type="text/css">h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></hea
1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service :
SF-Port80-TCP:V=7.95%I=7%D=8/10%Time=68986604%P=x86_64-pc-linux-gnu%r(GetR
SF:equest,110,"HTTP/1\.1\x20302\x20\r\nSet-Cookie:\x20JSESSIONID=3A181E2A1
SF:B8DDCC2DA1C11585883CEA3;\x20Path=/;\x20HttpOnly\r\nLocation:\x20http://
SF:localhost/struts2-showcase/showcase\.action\r\nContent-Type:\x20text/ht
SF:ml;charset=ISO-8859-1\r\nContent-Length:\x200\r\nDate:\x20Sun,\x2010\x2
SF:0Aug\x202025\x2009:27:31\x20GMT\r\nConnection:\x20close\r\n\r\n")%r(HTT
SF:POptions,513,"HTTP/1\.1\x20405\x20\r\nContent-Type:\x20text/html;charse
SF:t=utf-8\r\nContent-Language:\x20ja\r\nContent-Length:\x201143\r\nDate:\
SF:x20Sun,\x2010\x20Aug\x202025\x2009:27:31\x20GMT\r\nConnection:\x20close
SF:\r\n\r\n<!doctype\x20html><html\x20lang=\"ja\"><head><title>HTTP\xe3\x8
SF:2\xb9\xe3\x83\x86\xe3\x83\xbc\xe3\x82\xbf\xe3\x82\xb9\x20405\x20-\x20Me
SF:thod\x20Not\x20Allowed</title><style\x20type=\"text/css\">h1\x20{font-f
SF:amily:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font
SF:-size:22px;}\x20h2\x20{font-family:Tahoma,Arial,sans-serif;color:white;
SF:background-color:#525D76;font-size:16px;}\x20h3\x20{font-family:Tahoma,
SF:Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;}\
SF:x20body\x20{font-family:Tahoma,Arial,sans-serif;color:black;background-
SF:color:white;}\x20b\x20{font-family:Tahoma,Arial,sans-serif;color:white;
SF:background-color:#525D76;}\x20p\x20{font-family:Tahoma,Arial,sans-serif
SF:;background:white;color:black;font-size:12px;}\x20a\x20{color:black;}\x
SF:20a\.name\x20{color:black;}\x20\.line\x20{height:1px;background-color:#
SF:525D76;border:none;}</styl")%r(RTSPRequest,94F,"HTTP/1\.1\x20400\x20\r\
SF:nContent-Type:\x20text/html;charset=utf-8\r\nContent-Language:\x20ja\r\
SF:nContent-Length:\x202227\r\nDate:\x20Sun,\x2010\x20Aug\x202025\x2009:27
SF::31\x20GMT\r\nConnection:\x20close\r\n\r\n<!doctype\x20html><html\x20la
SF:ng=\"ja\"><head><title>HTTP\xe3\x82\xb9\xe3\x83\x86\xe3\x83\xbc\xe3\x82
SF:\xbf\xe3\x82\xb9\x20400\x20-\x20Bad\x20Request</title><style\x20type=\"
SF:text/css\">h1\x20{font-family:Tahoma,Arial,sans-serif;color:white;backg
SF:round-color:#525D76;font-size:22px;}\x20h2\x20{font-family:Tahoma,Arial
SF:,sans-serif;color:white;background-color:#525D76;font-size:16px;}\x20h3
SF:\x20{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#
SF:525D76;font-size:14px;}\x20body\x20{font-family:Tahoma,Arial,sans-serif
SF:;color:black;background-color:white;}\x20b\x20{font-family:Tahoma,Arial
SF:,sans-serif;color:white;background-color:#525D76;}\x20p\x20{font-family
SF::Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}\
SF:x20a\x20{color:black;}\x20a\.name\x20{color:black;}\x20\.line\x20{heigh
SF:t:1px;background-color:#525D76;border:none;}</style></hea");
MAC Address: 06:03:78:20:E3:93 (Unknown)
Device type: general purpose
Running: Linux 5.X
OS CPE: cpe:/o:linux:linux_kernel:5.4
OS details: Linux 5.4
Network Distance: 1 hop
Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel
TRACEROUTE
HOP RTT ADDRESS
1 0.22 ms ip-10-0-177-5.ap-northeast-1.compute.internal (10.0.177.5)
OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 18.95 seconds
- 実際にブラウザで見てみると↓でした。
- テストページをまんま公開しているのは、割とよくある話と聞きますが…。
strutsのテストページ
- NSEスクリプトは…Nmap Script Engineの略で、脆弱性の有無の検証やらなんやらいろいろなものを詳細に調べるためのスクリプト群のようです。
NSEスクリプト検索
- 実行すると…CVE-2017-5638が見つかりましたね…。
脆弱性発見
おわりに
- これ、結構いい教材ですね…。
- 攻撃用環境、攻撃対象環境をともにモックではなく、仮想マシン(Dockerとかなのかな?)で作ってくれるので、他のコマンドも普通に触れるので違和感がなく、とてもよかったです。
- 次号のSoftware Designの「はじめてのオフェンシブセキュリティ」の連載も楽しみです。
- 今回は侵入前の調査でしたが…次回はハッキングだとか。
- サーバセキュリティコースにもっといろいろあるので、そっちもやってみようかと思います。
- 自分で攻撃していい環境を作るのはかなり大変なので、これは大変ありがたい感じです。
- おすすめ!