はじめに
IoTなどもあるので自分のネットワーク上に何が存在しているかわからない今日この頃.ネットワークスキャンのMasscanを使って,「ネットワーク上に存在している何か」を探してみようと思う.
MasscanはIPv4の指定したアドレス空間を高速にスキャンするために作成されたツールの1つで,調査目的で使えるということで攻撃者も使うツールとして知られる. つまり,使い方を間違えれば,自分自身が攻撃者として扱われる可能性もあるので,慎重に使わなければならないツールであることに注意する.
インストール
今回も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 $
問題なく完了.
masscanを使って80番ポートをスキャン
まず簡単に使って見る. ポート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台見つかったとされる.
セグメント全体をスキャンして見る
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分程度かかっている模様.
そしてこのあと大問題が・・・・
Counter: 1635,
today: 2,
yesterday: 0
最終更新: 2019-11-25 (月) 23:45:36 (JST) (1575d) by nobuaki