好奇心の足跡

飽きっぽくすぐ他のことをしてしまうので、忘れないため・形にして頭に残すための備忘録。

2020 SANS Holiday Hack Challenge writeup [Objective 1~5]

2020 SANS Holiday Hack Challenge ~ KringleCon 3 ~ の Objective 1~5のwriteupです。
イベントの紹介や他のchallengeのwriteupはこちらの記事へ。

tech.kusuwada.com

1) Uncover Santa's Gift List

Difficulty: 🎄

There is a photo of Santa's Desk on that billboard with his personal gift list. What gift is Santa planning on getting Josh Wright for the holidays? Talk to Jingle Ringford at the bottom of the mountain for advice.

まず Holiday Hack Challenge の世界に慣れなくて、何をしていいかさっぱりわからないところからスタート。ようやく設定っぽい画面から問題を見ることが出来ることがわかる。

エルフとの会話履歴が見れるので上から見ていくと、Jingle Ringford さんとの会話にこんなのが。

Oh, and before you head off up the mountain, you might want to try to figure out what's written on that advertising bilboard.

Have you managed to read the gift list at the center?

It can be hard when things are twirly. There are tools that can help!

It also helps to select the correct twirly area.

こんな会話をしていた。そういえば最初のゴンドラに乗る前に、奥の方に看板があって突っついてみたら大きなイメージが落ちてきたんだった。

f:id:kusuwada:20210110062751p:plain

これの渦巻部分をなおすと。以前他のCTF(RiceTeaCatPandaかな?)でもイメージの渦巻を直す問題があったんだけど、このときはgimpでなんとか読んだ感じ。綺麗に元には戻らなかったのでツールが有るなら知りたいな。

Hintsに、いろんなところで得たヒントがまとまっていて、

Image Edit Tool

From: Jingle Ringford

Objective: 1) Uncover Santa's Gift List

There are tools out there that could help Filter the Distortion that is this Twirl.

ヒントもらってたのか!ということで飛んでみると、photopeaというツール。なオンラインで使えるらしい!マジ!?

f:id:kusuwada:20210110062818p:plain

My Presonal Gift List:

Ed - Two Front Teeth
*An - OU Jersey
*remy - Blanket
Brian - bei?
Josh Wright - Proxmark
Clag - Darth Vader Suit
Tad - Holiday bights?
Phil - Stuffed Pikachu
Jerry - Trip to North Pole

多少の歪みは残るものの、めっちゃ楽ちんに解読できた。
Josh Wrightに贈る予定のものは Proxmark らしいので、これを回答すればOK。

2) Investigate S3 Bucket

Difficulty: 🎄

When you unwrap the over-wrapped file, what text string is inside the package? Talk to Shinny Upatree in front of the castle for hints on this challenge.

1Fの庭にある Inbestigate S3 Bucket 端末を開きます。

Can you help me? Santa has been experimenting with new wrapping technology, and we've run into a ribbon-curling nightmare! We store our essential data assets in the cloud, and what a joy it's been! Except I don't remember where, and the Wrapper3000 is on the fritz! Can you find the missing package, and unwrap it all the way?

wordlistにあるbucket名について、存在するか確認してくれるみたい。
アクセスが禁止されているbucketしか出てこなかったので、どこかにIAMとか落ちてるのかと思ったけど、この端末のセッション内で完結するよと TIPS に書いてあったので、bucket名を推測して確認してもらうことにした。

上記の文章で緑になってた Wrapper3000 が怪しい。

$ vi wordlist   # wordlistに Wrapper3000, wrapper3000 を追加
$ cat wordlist 
kringlecastle
wrapper
santa
Wrapper3000
wrapper3000
$ ./bucket_finder.rb wordlist 
http://s3.amazonaws.com/kringlecastle
Bucket found but access denied: kringlecastle
http://s3.amazonaws.com/wrapper
Bucket found but access denied: wrapper
http://s3.amazonaws.com/santa
Bucket santa redirects to: santa.s3.amazonaws.com
http://santa.s3.amazonaws.com/
        Bucket found but access denied: santa
http://s3.amazonaws.com/Wrapper3000
Bucket does not exist: Wrapper3000
http://s3.amazonaws.com/wrapper3000
Bucket Found: wrapper3000 ( http://s3.amazonaws.com/wrapper3000 )
        <Public> http://s3.amazonaws.com/wrapper3000/package

お!Publicのが見つかりました!URLにアクセスしてlocalにDLしてみます。

$ file package 
package: ASCII text, with very long lines
$ cat package 
UEsDBAoAAAAAAIAwhFEbRT8anwEAAJ8BAAAcABwAcGFja2FnZS50eHQuWi54ei54eGQudGFyLmJ6MlVUCQADoBfKX6AXyl91eAsAAQT2AQAABBQAAABCWmg5MUFZJlNZ2ktivwABHv+Q3hASgGSn//AvBxDwf/xe0gQAAAgwAVmkYRTKe1PVM9U0ekMg2poAAAGgPUPUGqehhCMSgaBoAD1NNAAAAyEmJpR5QGg0bSPU/VA0eo9IaHqBkxw2YZK2NUASOegDIzwMXMHBCFACgIEvQ2Jrg8V50tDjh61Pt3Q8CmgpFFunc1Ipui+SqsYB04M/gWKKc0Vs2DXkzeJmiktINqjo3JjKAA4dLgLtPN15oADLe80tnfLGXhIWaJMiEeSX992uxodRJ6EAzIFzqSbWtnNqCTEDML9AK7HHSzyyBYKwCFBVJh17T636a6YgyjX0eE0IsCbjcBkRPgkKz6q0okb1sWicMaky2Mgsqw2nUm5ayPHUeIktnBIvkiUWxYEiRs5nFOM8MTk8SitV7lcxOKst2QedSxZ851ceDQexsLsJ3C89Z/gQ6Xn6KBKqFsKyTkaqO+1FgmImtHKoJkMctd2B9JkcwvMr+hWIEcIQjAZGhSKYNPxHJFqJ3t32Vjgn/OGdQJiIHv4u5IpwoSG0lsV+UEsBAh4DCgAAAAAAgDCEURtFPxqfAQAAnwEAABwAGAAAAAAAAAAAAKSBAAAAAHBhY2thZ2UudHh0LloueHoueHhkLnRhci5iejJVVAUAA6AXyl91eAsAAQT2AQAABBQAAABQSwUGAAAAAAEAAQBiAAAA9QEAAAAA

何だこれは?SSH公開鍵っぽい感じ?

とりあえずBase64 decodeしてみたら先頭が PK になってので、zipファイルかもと言うことで確認してみます。

$ cat package | base64 -D > package.zip
$ file package.zip 
package.zip: Zip archive data, at least v1.0 to extract

やったね!解凍

$ unzip package.zip 
Archive:  package.zip
 extracting: package.txt.Z.xz.xxd.tar.bz2
$ file package.txt.Z.xz.xxd.tar.bz2 
package.txt.Z.xz.xxd.tar.bz2: bzip2 compressed data, block size = 900k

今度はtarだった。

$ tar zxvf package.txt.Z.xz.xxd.tar.bz2 
x package.txt.Z.xz.xxd
$ file package.txt.Z.xz.xxd
package.txt.Z.xz.xxd: ASCII text
$ cat package.txt.Z.xz.xxd
00000000: fd37 7a58 5a00 0004 e6d6 b446 0200 2101  .7zXZ......F..!.
00000010: 1600 0000 742f e5a3 0100 2c1f 9d90 4ede  ....t/....,...N.
00000020: c8a1 8306 0494 376c cae8 0041 054d 1910  ......7l...A.M..
00000030: 46e4 bc99 4327 4d19 8a06 d984 19f3 f08d  F...C'M.........
00000040: 1b10 45c2 0c44 a300 0000 0000 c929 dad6  ..E..D.......)..
00000050: 64ef da24 0001 452d 1e52 57e8 1fb6 f37d  d..$..E-.RW....}
00000060: 0100 0000 0004 595a                      ......YZ

なんと今度はhex dump!戻したら7zの圧縮ファイルになりそう。

$ xxd -r package.txt.Z.xz.xxd package.7z
$ file package.7z 
package.7z: XZ compressed data
$ unar package.7z
package.7z: XZ
  package... OK.
Successfully extracted to "./package".
$ file package
package: compress'd data 16 bits

また名前がpackageに戻ってきたけど、compress'd data 16 bitsということでpackage.Zにrename。
というかここで気づいたけど package.txt.Z.xz.xxd.tar.bz2 の時点で次からの圧縮形式を教えてくれてたんだね…。

$ mv package.z package.Z
$ uncompress package.Z
$ cat package
North Pole: The Frostiest Place on Earth

これをObjectveの2に入れるとClear!

3) Point-of-Sale Password Recovery

Difficulty: 🎄

Help Sugarplum Mary in the Courtyard find the supervisor password for the point-of-sale terminal. What's the password?

Sugarplum Mary と近くにある端末 Santa Shopを調べます。
どうやら端末に入ろうと思ったらパスワードを聞かれるんだけど設定してなくてわからないとのこと。

Shinny says this might be an Electron application. I hear there's a way to extract an ASAR file from the binary, but I haven't looked into it yet.

Santa Shop端末にアクセスすると、santa-shop.exeというのが配布される。

$ file santa-shop.exe 
santa-shop.exe: PE32 executable (GUI) Intel 80386, for MS Windows, Nullsoft Installer self-extracting archive

exeを解凍して grep password してみると、全然違いそうなのを除いてこんな出力。

$ grep -ri password .
Binary file ./app-64/locales/it.pak matches
Binary file ./app-64/resources/app.asar matches
Binary file ./app-64/resources.pak matches
Binary file ./app-64/santa-shop.exe matches
Binary file ./nsis7z.dll matches

回収したHint一覧を眺めていると、ASARツールガイドへのリンクがあったので、これを試してみる。お、上記2番目にasarファイルが有るぞ!
ガイドの通り、asarファイル(app.asar)からコードを抽出してみます。

$ npm install -g asar
$ asar extract app.asar santa-shop-src
(node:3208) ExperimentalWarning: The fs.promises API is experimental
$ tree santa-shop-src/
santa-shop-src/
├── README.md
├── img
│   ├── network1.png
│   ├── network2.png
│   ├── network3.png
│   └── network4.png
├── index.html
├── main.js
├── package.json
├── preload.js
├── renderer.js
└── style.css

おー!出てきた!
抽出されたファイルのmain.jsに、passwordが書いてありました。

const SANTA_PASSWORD = 'santapass';

4) Operate the Santavator

Difficulty: 🎄🎄

Talk to Pepper Minstix in the entryway to get some hints about the Santavator.

拾った鍵でエレベーターの操作パネルを開き、更に色んな所で拾ったアイテムを使って、下から出ている蒸気をそれぞれのライトに向くようにすると動いた。

f:id:kusuwada:20210110062844p:plain

この写真はアイテムを更に拾った後なんだけど、実質右の方にある丸い物たちは使わずに全部のライトを付けられた。

5) Open HID Lock

Difficulty: 🎄🎄

Open the HID lock in the Workshop. Talk to Bushy Evergreen near the talk tracks for hints on this challenge. You may also visit Fitzy Shortstack in the kitchen for tips.

2Fのtalk roomの前にいたBushy Evergreenは、彼の近くの端末にある課題をクリアする毎にHIDの課題を教えてくれました。会話をまとめるとこんな感じ。

Santa asked me to ask you to evaluate the security of our new HID lock.If ever you find yourself in posession of a Proxmark3, click it in your badge to interact with it. It's a slick device that can read others' badges!

Oh, did I mention that the Proxmark can simulate badges? Cool, huh?There are lots of references online to help. In fact, there's a talk going on right now!

And that Proxmark thing? Some people scan other people's badges and try those codes at locked doors. Other people scan one or two and just try to vary room numbers. Do whatever works best for you!

proxmarkというのが鍵になりそう。
更に、Bushy EvergreenがくれたObjective 5のHintを一通り読んでみる。

Hints: Proxmark Talk

Larry Pesce knows a thing or two about HID attacks. He's the author of a course on wireless hacking!

Hints: What's a Proxmark?

The Proxmark is a multi-function RFID device, capable of capturing and replaying RFID events. The Proxmark is a multi-function RFID device, capable of capturing and replaying RFID events.

Short List of Essential Proxmark Commands

There's a short list of essential Proxmark commands also available.

お、チートシートだ。こういうのがあるととっかかりやすくて有り難い。

Impersonating Badges with Proxmark

You can also use a Proxmark to impersonate a badge to unlock a door, if the badge you impersonate has access. lf hid sim -r 2006......

Reading Badges with Proxmark

You can use a Proxmark to capture the facility code and ID value of HID ProxCard badge by running lf hid read when you are close enough to someone with a badge.

確認してみたところ、proxmark3というアイテムをどこかで拾っていた。気づいたらアイテムの中に入っていた。

f:id:kusuwada:20210111061639p:plain

このアイテムはterminalを立ち上げられるらしい。

  ██████╗ ███╗   ███╗█████╗ 
  ██╔══██╗████╗ ████║╚═══██╗
  ██████╔╝██╔████╔██║ ████╔╝
  ██╔═══╝ ██║╚██╔╝██║ ╚══██╗
  ██║     ██║ ╚═╝ ██║█████╔╝       Iceman ☕
  ╚═╝     ╚═╝     ╚═╝╚════╝    ❄️ bleeding edge
  https://github.com/rfidresearchgroup/proxmark3/
  
[=] Session log /home/elf/.proxmark3/logs/log_20201220.txt
[=] Creating initial preferences file
[=] Saving preferences...
[+] saved to json file /home/elf/.proxmark3/preferences.json
 [ Proxmark3 RFID instrument ]
 [ CLIENT ]
  client: RRG/Iceman/master/v4.9237-2066-g3de856045 2020-11-25 16:29:31
  compiled with GCC 7.5.0 OS:Linux ARCH:x86_64
 [ PROXMARK3 ]
  firmware.................. PM3RDV4
  external flash............ present
  smartcard reader.......... present
  FPC USART for BT add-on... absent
 [ ARM ]
  LF image built for 2s30vq100 on 2020-07-08 at 23: 8: 7
  HF image built for 2s30vq100 on 2020-07-08 at 23: 8:19
  HF FeliCa image built for 2s30vq100 on 2020-07-08 at 23: 8:30
 [ Hardware ]
  
  --= uC: AT91SAM7S512 Rev B
  --= Embedded Processor: ARM7TDMI
  --= Nonvolatile Program Memory Size: 512K bytes, Used: 304719 bytes (58%) Free: 219569 byt
es (42%)
  --= Second Nonvolatile Program Memory Size: None
  --= Internal SRAM Size: 64K bytes
  --= Architecture Identifier: AT91SAM7Sxx Series
  --= Nonvolatile Program Memory Type: Embedded Flash Memory
[magicdust] pm3 --> 

ふむふむ。とにかく持ち歩くitemの中にあるということと、近くのカードから情報を読み取るという性質上、これを持ってウロウロして

pm3 --> lf hid read

して反応があるところを調べてみる。おそらく、誰かのカードから情報を盗んで歩けるのだろう。
下記7個見つけた。elfやsantaの近くに行ったら窃取できるかと思ったけど、そういうわけでもないらしい。

1F

  • kitchen 左のほう

    #db# TAG ID: 2006e22f10 (6024) - Format Len: 26 bit - FC: 113 - Card: 6024

  • splank room 右のほう

    #db# TAG ID: 2006e22f31 (6040) - Format Len: 26 bit - FC: 113 - Card: 6040

  • 広場kiosk前

    #db# TAG ID: 2006e22f13 (6025) - Format Len: 26 bit - FC: 113 - Card: 6025

  • Entryway エレベーター前

    #db# TAG ID: 2006e22f0d (6022) - Format Len: 26 bit - FC: 113 - Card: 6022

  • Dining room の机の下の方

    #db# TAG ID: 2006e22f15 (6026) - Format Len: 26 bit - FC: 113 - Card: 6026

1.5F

  • TagGenerator terminalの前

    #db# TAG ID: 2006e22ee1 (6000) - Format Len: 26 bit - FC: 113 - Card: 6000

2F

  • Talkroom3と4の間らへん

    #db# TAG ID: 2006e22f0e (6023) - Format Len: 26 bit - FC: 113 - Card: 6023

R

みつからず

これらのカード情報を使って、いかにも「ロックされてます」って感じの怪しいドアの前で、チートシートにあった「他人のカード情報をシミュレーションする」をやってみます。
またitemのproxmark3を立ち上げて、いろんなカードをシミュレーション。広場のkiosk端末前で拾った

pm3 --> lf hid sim -r 2006e22f13

これにして、

pm3 --> lf hid sim -w Kastle --fc 113 --cn 6000

これを試してみたら、ドアが開いてClear🙌

この後、開いたドアの部屋に入ると暗がり。一本道を光の方に歩いていって、光の先は大広間!
なんと出てみたらサンタさんになってた。

f:id:kusuwada:20210111061909p:plain

これはもしかして「サンタじゃないと駄目」系のアイテムが使える…?エレベーターとか屋上のソリとか!ワクワク。
あと、エルフたちもサンタだと思って話しかけてくれる👍

更にテレポート機能が使えるようになった!

f:id:kusuwada:20210111061924p:plain