UJP - 技術情報2 : macosでmasscanを使ってみる SecurityTool/masscan/mac

Life is fun and easy!

不正IP報告数

Okan Sensor
 
メイン
ログイン
ブログ カテゴリ一覧

Page Top

はじめに anchor.png Edit

 IoTなどもあるので自分のネットワーク上に何が存在しているかわからない今日この頃.ネットワークスキャンのMasscanを使って,「ネットワーク上に存在している何か」を探してみようと思う.

 MasscanはIPv4の指定したアドレス空間を高速にスキャンするために作成されたツールの1つで,調査目的で使えるということで攻撃者も使うツールとして知られる.  つまり,使い方を間違えれば,自分自身が攻撃者として扱われる可能性もあるので,慎重に使わなければならないツールであることに注意する.

Page Top

インストール anchor.png Edit

 今回もHomeBrewでインストール.  まずは情報を確認.

$ brew info masscan🆑
masscan: stable 1.0.5 (bottled), HEAD
TCP port scanner, scans entire Internet in under 5 minutes
https://github.com/robertdavidgraham/masscan/
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/masscan.rb
==> Options
--HEAD
	Install HEAD version
==> Analytics
install: 274 (30 days), 861 (90 days), 3,435 (365 days)
install-on-request: 274 (30 days), 856 (90 days), 3,388 (365 days)
build-error: 0 (30 days)
$

1年で3435インストールというのは,多いいのか少ないのか. 気にせずインストールしてみる.

$ brew install masscan🆑
Updating Homebrew...
==> Auto-updated Homebrew!
Updated Homebrew from a1939cfe7 to 99a8f15fb.
Updated 2 taps (homebrew/core and homebrew/cask).
==> New Formulae
cargo-c  devdash       monolith      postgresql@11
==> Updated Formulae
nss ✔    cstore_fdw   fluxctl  gwyddion     maxwell  pgroonga     pspg     streamlink
wget ✔   dcos-cli     gcc@6    haproxy  n    pgrouting    restic   stunnel
awscli   eslint   gcc@8    helmfile     navi     phpmyadmin   salt     temporal_tables
babel    evince   gitleaks     juju     nsd      postgis  scipy    terrahub
cfn-lint     exploitdb    glooctl  libpq    paket    postgresql   simple-scan  wal2json
citus    file-roller  goreleaser   libpqxx  pgloader     proftpd  sn0int   yelp-tools

==> Downloading https://homebrew.bintray.com/bottles/masscan-1.0.5.high_sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring masscan-1.0.5.high_sierra.bottle.tar.gz
🍺  /usr/local/Cellar/masscan/1.0.5: 5 files, 284.6KB
$

 問題なく完了.

Page Top

masscanを使って80番ポートをスキャン anchor.png Edit

 まず簡単に使って見る. ポート80番(HTTP)でlocalhostをスキャン.

$ /usr/local/bin/masscan -p80 127.0.0.1🆑
FAIL: en0: You don't have permission to capture on that device ((cannot open BPF device) /dev/bpf0: Permission denied)
 [hint] need to sudo or run as root or something
 [hint] I've got some local priv escalation 0days that might work
adapter[en0].init: failed
$

 root権限が必要だそうだ.  sudoして実行する.

$ sudo /usr/local/bin/masscan -p80 127.0.0.1🆑
Password:🆑

Starting masscan 1.0.4 (http://bit.ly/14GZzcT) at 2019-11-24 11:24:55 GMT
 -- forced options: -sS -Pn -n --randomize-hosts -v --send-eth
Initiating SYN Stealth Scan
Scanning 1 hosts [1 port/host]
$

 localhost(127.0.0.1)なので1台見つかったとされる.

Page Top

セグメント全体をスキャンして見る anchor.png Edit

 0番ポートから65535ポートまでを指定してセグメト全体を指定.

$ date;sudo /usr/local/bin/masscan -p0-65535 192.168.20.1/24;date🆑
日 11 24 20:27:07 JST 2019

Starting masscan 1.0.4 (http://bit.ly/14GZzcT) at 2019-11-24 11:27:08 GMT
 -- forced options: -sS -Pn -n --randomize-hosts -v --send-eth
Initiating SYN Stealth Scan
Scanning 256 hosts [65536 ports/host]
Discovered open port 62078/tcp on 192.168.20.126
Discovered open port 62078/tcp on 192.168.20.103
Discovered open port 62078/tcp on 192.168.20.108
 Cwaiting several seconds to exit...
saving resume file to: paused.conf
月 11 25 01:13:45 JST 2019
$

 5時間かかっても終わらないので,停止してみた.  次に,自分自身1台だけと対象を絞って,0番ポートから65535ポートで調べて見る.

$ date;sudo /usr/local/bin/masscan -p0-65535 192.168.20.32;date🆑
月 11 25 22:47:29 JST 2019
Password:

Starting masscan 1.0.4 (http://bit.ly/14GZzcT) at 2019-11-25 13:47:33 GMT
 -- forced options: -sS -Pn -n --randomize-hosts -v --send-eth
Initiating SYN Stealth Scan
Scanning 1 hosts [65536 ports/host]
月 11 25 22:58:41 JST 2019
$

 1台だけでも11分程度かかっている模様.

 そしてこのあと大問題が・・・・

Page Top

ルータが停止した anchor.png Edit

 セグメント全体をスキャンしていても問題なかったから,localhostをスキャンしても問題ないだろうと思ったけれど,それが大きな間違いでルータに負荷をかけてしまった模様.ルータがハングアップした.  セグメント全体をスキャンといっても40%位までだったので,ローカルをスキャンするところまでいってないわけだから,偶然,問題発生にヒットしなかったことになる.

 使い方を間違えるとダウンさせてしまうという例かな.実験環境でよかった.ふぅ...


Front page   Edit Diff Backup Upload Copy Rename Reload   New Page Page list Search Recent changes   Help   RSS of recent changes (RSS 1.0) RSS of recent changes (RSS 2.0) RSS of recent changes (RSS Atom)
Counter: 2223, today: 1, yesterday: 2
Last-modified: 2019-11-25 (Mon) 23:45:36 (JST) (2367d) by nobuaki

広告スペース
Google