OWASPルーム最終章。
今までの分
- Task 21 [Severity 8] Insecure Deserialization
- Task 22 [Severity 8] Insecure Deserialization – Objects
- Task 23 [Severity 8] Insecure Deserialization – Deserialization
- Task 24 [Severity 8] Insecure Deserialization – Cookies
- Task 25 [Severity 8] Insecure Deserialization – Cookies Practical
- Task 26 [Severity 8] Insecure Deserialization – Code Execution
- Task 27 [Severity 9] Components With Known Vulnerabilities – Intro
- Task 28 [Severity 9] Components With Known Vulnerabilities – Exploit
- Task 29 [Severity 9] Components With Known Vulnerabilities – Lab
- Task 30 [Severity 10] Insufficient Logging and Monitoring
- Task 31 What Next?
Task 21 [Severity 8] Insecure Deserialization
安全ではないデシリアライゼーション(噛みそう)
アプリケーション内部の構造化データをバイト列で受け取って元の構造化データに戻すことをデシリアライズと呼ぶ。悪意のあるバイト列(シリアライズされたデータ)を受け取ってそれをデシリアライズしてしまうと、意図しないオブジェクトがアプリケーション内に生成される。DoSからRCE(任意コード実行)まで好き放題やられちゃうよ、という話。
- 悪用可能性はそんな高くない(中のことをよく知ってないと攻撃できないから)
- 影響はケースバイケース
Who developed the Tomcat application?
なんで突然この設問なんだろう。
Apache Software Foundation
What type of attack that crashes services can be performed with insecure deserialization?
DoS攻撃って言ってるからね
Denial of Service
Task 22 [Severity 8] Insecure Deserialization – Objects
急にオブジェクト指向とは?みたいな話。(苦手だ)
if a dog was sleeping, would this be:
A Behaviour
Task 23 [Severity 8] Insecure Deserialization – Deserialization
デシリアライゼーションとは、データを伝送・保存するためにバイナリに変えること。
What is the name of the base-2 formatting that data is sent across a network as?
binary
Task 24 [Severity 8] Insecure Deserialization – Cookies
Cookieの説明
- Cookieはブラウザを閉じるとクリアされるものとされないものがあるよ(Expiryの設定によるよ)
- 属性がいくつかあるよ
- Cookieを設定するのは簡単にできるよ
If a cookie had the path of webapp.com/login , what would the URL that the user has to visit be?
Cookieのpath属性が設定されていると、リクエスト先が指定したURLと一致したときだけCookieを送信する。
What is the acronym for the web technology that Secure cookies work over?
Cookieのsecure属性が設定されていると、https通信のときだけCookieが送信される。
このへんの話はこちらの本がとても勉強になります
Task 25 [Severity 8] Insecure Deserialization – Cookies Practical
実践してみよう!
1st flag (cookie value)
タスク21のマシンをデプロイしてブラウザでつなぐ。

上のJoin Usってところから適当にアカウントを作る

開発者ツールからCookieを見てみる

sessionIdがbase64でエンコードされてて怪しいのでデコードする
なんとなくCyberChef使った。便利。

- URL=
2nd flag (admin dashboard)
CookieのuserTypeをadminに変更

画面をリロードすると管理者になってる

フラグはとれたけどこれはCookieの改ざんであってデシリアライゼーション関係あるの?という疑問が残る。
Task 26 [Severity 8] Insecure Deserialization – Code Execution
We get into the nitty-gritty(確信に迫る)らしい。
flag.txt
まずCookieを元(user)に戻す。
挙動の確認
2. Exchange your vim
をクリックすると
encodedPayloadというクッキーが保存される。

次の 3. Provide your feedback!
をクリックするとこのcookieの値がデコードされる。とのこと。
クラック
こちらのコードをコピーしてくる
- URL=
YOUR_TRYHACKME_VPN_IPってところを自分のIPアドレスに書き換える

実行するとペイロードがでてくる

アポストロフィの間のコードをコピーして、CookieのencodePayloadにペーストする。

自分のローカルPCで待ち受ける
nc -lvnp 4444

Cookieを改ざんしたページをリロードするとCookieが再度サーバに送信され、待ち受けていたローカルの方でシェルがとれる。

あとはflag.txtを探すだけ。

Task 27 [Severity 9] Components With Known Vulnerabilities – Intro
No answer needed
既知の脆弱性が放置されていることがあるよ、っていう話。
結構懐かしいWordPressの脆弱性。
Task 28 [Severity 9] Components With Known Vulnerabilities – Exploit
No answer needed
exploit-dbでエクスプロイトコードが見つかったら
ちょっとした修正をするだけで実行できる可能性があるよって話。
Task 29 [Severity 9] Components With Known Vulnerabilities – Lab
脆弱なアプリケーションをクラックしてみよう。
脆弱性とエクスプロイトコードの探索
まずお約束のnmap
nmap -sV -sC -vv -Pn -oN initial.nmap $IP

目ぼしい脆弱性が見当たらないのでとりあえずhttpでつなぐ

なんか本屋。よく知らんけど多分CMSの脆弱性的なものだろうとアタリをつけて CSE Bookstore RCE
でぐぐる。RCEはRemote Code Executionのこと。
Exploit-dbがヒットするので多分これで良さそう。
コードがpythonぽいので、コピーしてrce.pyとして保存する。
エクスプロイトコードの実行
そのままターゲットのURLを引数で与えて実行(http://付け忘れ注意)
python3 rce.py http://TARGET/

少し待つとシェルがとれる。

How many characters are in /etc/passwd (use wc -c /etc/passwd to get the answer)
なぜ文字数を答えさせるのかよくわからないがwcコマンドで数えられる。
wc -c /etc/passwd

Task 30 [Severity 10] Insufficient Logging and Monitoring
不十分なロギングとモニタリングについて。
なんかあったときはログが大事になるからちゃんと必要な項目をとりましょう、普段から監視して急に変な動きがあったら気づけるようにしておきましょう。みたいな、当たり前だけど割とこういうのやりだすと難しいんだよねっていう話。
簡単なログファイルが与えられるのでそれを見て答える。

What IP address is the attacker using?
後半のヤケクソみたいなのが明らかに怪しい
What kind of attack is being carried out?
Brute force
どっちかというと Dictionary Attack
か List Based Attack
では?とも思うけど答えはブルートフォースらしい。納得いかない。
Task 31 What Next?
No answer needed
初心者パスか別の部屋に取り組もう!
長かった〜〜!1個1個の難易度は低いのにやたら長くて根気のいるRoomだった。今は最新のOWASP Top 10 2021が出ているので内容が変わっている。セキュリティは終わりがないなあ。
- URL=