CYBERGON CTF 2023 Writeup

この大会は2023/8/19 2:30(JST)~2023/8/21 2:30(JST)に開催されました。
今回もチームで参戦。結果は3115点で517チーム中13位でした。
自分で解けた問題をWriteupとして書いておきます。

Discord (MISC)

Discordに入り、#rulesチャネルのトピックを見ると、フラグが書いてあった。

CybergonCTF{Good_Luck_Have_Fun}

Storm Zero Five Five Eight (MISC)

Exchange Online を攻撃し、OWA を使用して不正な電子メール アクセスを取得したインシデントで、アクセスに使った鍵は何の鍵かという問題。
問題文そのもので検索すると、以下の鍵を使っていることがわかる。

MSA consumer signing key
CybergonCTF{MSA}

Operation Ghost (MISC)

Operation Ghostでデータを難読化するためにどのような MITRE 技術が使用されたかという問題。
「obfuscation in the Operation Ghost」で検索すると、以下のページが見つかる。

https://attack.mitre.org/campaigns/C0023/

データ難読化のテクニックIDは T1001.002

CybergonCTF{T1001.002}

Back Door (MISC)

サイバースパイ活動に chinoxy バックドアが使用されたキャンペーンで、使われたvbsファイル名を答える問題。
「chinoxy backdoor vbs」で検索すると、以下のページが見つかる。

https://attack.mitre.org/campaigns/C0007/

vbsのファイル名は wmiexec.vbs

CybergonCTF{wmiexec.vbs}

Find Me (MISC)

xlsxをzip解凍する。xl\sharedStrings.xmlに以下のように書いてある。

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="1" uniqueCount="1"><si><t xml:space="preserve">C
y
b
e
r
g
o
n
C
T
F
{
H
i
d
d
e
n
_
W
o
r
d
s
_
4
_
U
}
</t></si></sst>
CybergonCTF{Hidden_Words_4_U}

Basic - 1 (IR)

FTK Imagerで開き、[root]-[Windows]-[System32]-[config]-[SYSTEM]をエクスポートする。Registry Viewerでそれぞれ該当するパスを見てみる。

・タイムゾーン
[SYSTEM]-[ControlSet001]-[Control]-[TimeZoneInformation]
StandardName=SE Asia Standard Time

・ホスト名
[SYSTEM]-[ControlSet001]-[Control]-[ComputerName]-[ComputerName]
ComputerName=CYBERGON-CTF
CyberGonCTF{SE Asia Standard Time_CYBERGON-CTF}

Basic - 2 (IR)

FTK Imagerで開き、[root]-[Windows]-[System32]-[winevt]-[Logs]-[System.evtx]をエクスポートする。
イベントビューアで開き、イベントID 6011でフィルタリングする。2件のみログが表示される。

2023/07/17 17:27:45
このコンピューターの NetBIOS 名と DNS ホスト名は、WIN-OS9LHVGJOHH から DESKTOP-1INR457 に変更されました。

2023/07/22 18:46:34
このコンピューターの NetBIOS 名と DNS ホスト名は、DESKTOP-1INR457 から CYBERGON-CTF に変更されました。

マシンのタイムゾーンは「SE Asia Standard Time」でUTC +07:00なので、時刻については2時間前にする。

CyberGonCTF{22/07/2023 04:46:34 PM, DESKTOP-1INR457}

Warm Up 1 (OSINT)

写真の場所の州を答える問題。画像検索すると、以下と一致する。

https://www.myanmarbusiness-directory.com/templates/mbd_tmpl/top10/hpaan.php

ここには以下のような記載がある。

3. Shwe Yin Myaw Pagoda

This riverside pagoda is like a landmark pagoda of Hpa-Ann for local people. Located near the main market and perfect place to see the sun going down with the Than Lwin River.

さらに「Shwe Yin Myaw Pagoda」で検索すると、州の名前は Kayin State であるとわかる。

CybergonCTF{Kayin_State}

Device Info (ep1) (FORENSICS)

FTK Imagerで開き、/etc/issueを見てみる。

Ubuntu 20.04.5 LTS
CyberGonCTF{Ubuntu 20.04.5 LTS}

Hide and Seek (FORENSICS)

docxをzip解凍する。word\header1.xmlにBrainf*ck言語がある。

++++++++++[&gt;+&gt;+++&gt;+++++++&gt;++++++++++&lt;&lt;&lt;&lt;-]&gt;&gt;&gt;---.&gt;+++++++++++++++++++++.-----------------------.+++.+++++++++++++.&lt;++++.&gt;---.-.&lt;----.+++++++++++++++++.--------------.&gt;+++++++++++++.&lt;-----------------.--.&gt;------------------------.-----------------.&lt;.++++.&gt;+++++++++++++.&lt;+++++++++++++.----------------.+++.---.&gt;.&lt;---.&gt;+++++++++++++++.---------------.&lt;+++++++++++++++++++++++.&lt;+++++++++++++++++++++.+.&gt;&gt;+++++.&lt;&lt;-.&gt;++++++++++.&gt;+++++++++++++++++++++++++.

書き直すと以下のようになる。

++++++++++[>+>+++>+++++++>++++++++++<<<<-]>>>---.>+++++++++++++++++++++.-----------------------.+++.+++++++++++++.<++++.>---.-.<----.+++++++++++++++++.--------------.>+++++++++++++.<-----------------.--.>------------------------.-----------------.<.++++.>+++++++++++++.<+++++++++++++.----------------.+++.---.>.<---.>+++++++++++++++.---------------.<+++++++++++++++++++++++.<+++++++++++++++++++++.+.>>+++++.<<-.>++++++++++.>+++++++++++++++++++++++++.

https://sange.fi/esoteric/brainfuck/impl/interp/i.htmlで実行する。

CyberGonCTF{53cR37_D474_1n_H34d3R}

Malfunctioning File (FORENSICS)

後ろにzipがくっついているので、切り出す。切り出したzipを解凍すると、flag.pngが展開される。先頭3、4バイト目が間違っているので、修正する。TweakPNGで確認すると、IHDRチャンクのCRCが合わない。flag.pngの幅が間違っている。幅を総当たりで画像を出力してみる。

#!/usr/bin/env python3
import struct
import binascii

with open('flag_sig_fix.png', 'rb') as f:
    data = f.read()

head = data[:16]
tail = data[33:]

h = 1024
for w in range(1, 2048):
    width = struct.pack('>I', w)
    height = struct.pack('>I', h)
    ihdr = data[12:16] + width + height + data[24:29]
    crc = struct.pack('!I', binascii.crc32(ihdr))
    out = head + width + height
    out += data[24:29]
    out += crc + tail

    fname = 'png/flag_fix_w%04d.png' % w
    with open(fname, 'wb') as f:
        f.write(out)

幅が1500のときに正しく画像が表示され、フラグが書いてあった。

CyberGonCTF{D1m3N510N_c0rRuP73d}

8cel (FORENSICS)

zipをxlsxにして開くが、シートの保護がされている。zip解凍したもので、以下のファイルのsheetProtectionタブの要素を削除する。

xl\worksheets\sheet2.xml

再び圧縮し、xlsxにして開く。Sheet1 に B2:H26でbase64文字列を含むデータが並んでいる。E14だけbase64文字列の長さが異なるものがある。

$ echo Q3liZXJHb25DVEZ7eTB1X0cwN183aDNfNTNjUjM3XzFOZjB9 | base64 -d
CyberGonCTF{y0u_G07_7h3_53cR37_1Nf0}
CyberGonCTF{y0u_G07_7h3_53cR37_1Nf0}

Warm Up 1 (STEGANO)

$ exiftool IMG_6380.HEIC 
ExifTool Version Number         : 12.57
File Name                       : IMG_6380.HEIC
Directory                       : .
File Size                       : 952 kB
File Modification Date/Time     : 2023:08:19 06:53:59+09:00
File Access Date/Time           : 2023:08:19 07:04:11+09:00
File Inode Change Date/Time     : 2023:08:19 06:57:20+09:00
File Permissions                : -rwxrwx---
File Type                       : HEIC
File Type Extension             : heic
MIME Type                       : image/heic
Major Brand                     : High Efficiency Image Format HEVC still image (.HEIC)
Minor Version                   : 0.0.0
Compatible Brands               : mif1, MiHE, MiPr, miaf, MiHB, heic
Handler Type                    : Picture
Primary Item Reference          : 49
Meta Image Size                 : 4032x3024
XMP Toolkit                     : XMP Core 6.0.0
HDR Gain Map Version            : 65536
Exif Byte Order                 : Big-endian (Motorola, MM)
Make                            : Apple
Camera Model Name               : iPhone 14
Orientation                     : Rotate 90 CW
X Resolution                    : 72
Y Resolution                    : 72
Resolution Unit                 : inches
Software                        : 16.5.1
Modify Date                     : 2023:07:31 10:14:57
Host Computer                   : iPhone 14
Exposure Time                   : 1/7463
F Number                        : 1.5
Exposure Program                : Program AE
ISO                             : 50
Exif Version                    : 0232
Date/Time Original              : 2023:07:31 10:14:57
Create Date                     : 2023:07:31 10:14:57
Offset Time                     : +07:00
Offset Time Original            : +07:00
Offset Time Digitized           : +07:00
Shutter Speed Value             : 1/7463
Aperture Value                  : 1.5
Brightness Value                : 11.04737818
Exposure Compensation           : 0
Metering Mode                   : Multi-segment
Flash                           : Off, Did not fire
Focal Length                    : 5.7 mm
Subject Area                    : 2016 1509 2326 1327
Maker Note Version              : 14
Run Time Flags                  : Valid
Run Time Value                  : 35974004432000
Run Time Scale                  : 1000000000
Run Time Epoch                  : 0
AE Stable                       : Yes
AE Target                       : 216
AE Average                      : 212
AF Stable                       : Yes
Acceleration Vector             : -0.002158903516 -0.9705183506 0.2326851489
Focus Distance Range            : 0.31 - 0.36 m
Media Group UUID                : 841756DD-D886-4A0C-86F7-0D682A36B40C
Live Photo Video Index          : 5251076
HDR Headroom                    : 1
Signal To Noise Ratio           : 65.25109097
Focus Position                  : 48
HDR Gain                        : 0
Semantic Style                  : {0=1,1=0,2=0,3=0}
Front Facing Camera             : No
Sub Sec Time Original           : 296
Sub Sec Time Digitized          : 296
Color Space                     : Uncalibrated
Exif Image Width                : 4032
Exif Image Height               : 3024
Sensing Method                  : One-chip color area
Scene Type                      : Directly photographed
Exposure Mode                   : Auto
White Balance                   : Auto
Digital Zoom Ratio              : 1.749133733
Focal Length In 35mm Format     : 45 mm
Lens Info                       : 1.539999962-5.7mm f/1.5-2.4
Lens Make                       : Apple
Lens Model                      : iPhone 14 back dual wide camera 5.7mm f/1.5
Composite Image                 : General Composite Image
GPS Latitude Ref                : North
GPS Longitude Ref               : East
GPS Altitude Ref                : Above Sea Level
GPS Speed Ref                   : km/h
GPS Speed                       : 0
GPS Img Direction Ref           : True North
GPS Img Direction               : 346.1432193
GPS Dest Bearing Ref            : True North
GPS Dest Bearing                : 346.1432193
GPS Date Stamp                  : 2023:07:31
GPS Horizontal Positioning Error: 4.686741236 m
Profile CMM Type                : Apple Computer Inc.
Profile Version                 : 4.0.0
Profile Class                   : Display Device Profile
Color Space Data                : RGB
Profile Connection Space        : XYZ
Profile Date Time               : 2022:01:01 00:00:00
Profile File Signature          : acsp
Primary Platform                : Apple Computer Inc.
CMM Flags                       : Not Embedded, Independent
Device Manufacturer             : Apple Computer Inc.
Device Model                    : 
Device Attributes               : Reflective, Glossy, Positive, Color
Rendering Intent                : Perceptual
Connection Space Illuminant     : 0.9642 1 0.82491
Profile Creator                 : Apple Computer Inc.
Profile ID                      : ecfda38e388547c36db4bd4f7ada182f
Profile Description             : Display P3
Profile Copyright               : Copyright Apple Inc., 2022
Media White Point               : 0.96419 1 0.82489
Red Matrix Column               : 0.51512 0.2412 -0.00105
Green Matrix Column             : 0.29198 0.69225 0.04189
Blue Matrix Column              : 0.1571 0.06657 0.78407
Red Tone Reproduction Curve     : (Binary data 32 bytes, use -b option to extract)
Chromatic Adaptation            : 1.04788 0.02292 -0.0502 0.02959 0.99048 -0.01706 -0.00923 0.01508 0.75168
Blue Tone Reproduction Curve    : (Binary data 32 bytes, use -b option to extract)
Green Tone Reproduction Curve   : (Binary data 32 bytes, use -b option to extract)
HEVC Configuration Version      : 1
General Profile Space           : Conforming
General Tier Flag               : Main Tier
General Profile IDC             : Main Still Picture
Gen Profile Compatibility Flags : Main Still Picture, Main 10, Main
Constraint Indicator Flags      : 176 0 0 0 0 0
General Level IDC               : 90 (level 3.0)
Min Spatial Segmentation IDC    : 0
Parallelism Type                : 0
Chroma Format                   : 4:2:0
Bit Depth Luma                  : 8
Bit Depth Chroma                : 8
Average Frame Rate              : 0
Constant Frame Rate             : Unknown
Num Temporal Layers             : 1
Temporal ID Nested              : No
Image Width                     : 4032
Image Height                    : 3024
Image Spatial Extent            : 4032x3024
Rotation                        : 270
Image Pixel Depth               : 8
Auxiliary Image Type            : urn:com:apple:photo:2020:aux:hdrgainmap
Media Data Size                 : 948331
Media Data Offset               : 3752
Run Time Since Power Up         : 9:59:34
Aperture                        : 1.5
Image Size                      : 4032x3024
Megapixels                      : 12.2
Scale Factor To 35 mm Equivalent: 7.9
Shutter Speed                   : 1/7463
Create Date                     : 2023:07:31 10:14:57.296+07:00
Date/Time Original              : 2023:07:31 10:14:57.296+07:00
Modify Date                     : 2023:07:31 10:14:57+07:00
GPS Altitude                    : 811.3 m Above Sea Level
GPS Latitude                    : 16 deg 47' 21.64" N
GPS Longitude                   : 101 deg 3' 4.46" E
Circle Of Confusion             : 0.004 mm
Field Of View                   : 43.6 deg
Focal Length                    : 5.7 mm (35 mm equivalent: 45.0 mm)
GPS Position                    : 16 deg 47' 21.64" N, 101 deg 3' 4.46" E
Hyperfocal Distance             : 5.69 m
Light Value                     : 15.0
Lens ID                         : iPhone 14 back dual wide camera 5.7mm f/1.5

写真撮影日時は 2023:07:31 10:14:57

CybergonCTF{2023:07:31-10:14:57}

Catch Me If You Can (STEGANO)

gifの先頭4バイトが欠けているので、修復する。修復したgifの画像にフラグが書いてあった。

CybergonCTF{YOU_GOT_ME}

Warm Up 1 (CRYPTO)

問題は以下の画像。

The Author Cipherが書かれている。https://www.dcode.fr/gravity-falls-author-cipherでデコードする。

JOHN WICK
CybergonCTF{John Wick}

Warm Up 2 (CRYPTO)

問題の暗号は以下の通り。

IATMWVTEAIO·NSR·NIO·

·はパディング文字か。転置暗号と見て等間隔でスキップするよう並び替える。4文字ずつで改行し、縦に読む。

IATM
WVTE
AIO·
NSR·
NIO·
I WANNA VISIT TO ROME
CybergonCTF{ROME}

Now You See Me 1 (CRYPTO)

Whitespace言語。https://vii5ard.github.io/whitespace/で実行する。

Congratulations this is for you !!

CybergonCTF{Always_Look_Beyond_What_You_Can_See}
CybergonCTF{Always_Look_Beyond_What_You_Can_See}

Dots (CRYPTO)

点字になっているので、https://www.dcode.fr/braille-alphabetでデコードする。

THEEYESAREUSELESWHENTHEMINDISBLIND

大文字だと受け付けなかったので、小文字にする。

CybergonCTF{theeyesareuselesswhenthemindisblind}

EZ RSA (CRYPTO)

暗号化処理の概要は以下の通り。

・m: フラグの数値化したもの
・p, q: 512ビット素数
・m = p * q
・e = 0x10001
・c = pow(m, e, n)
・num: ランダム100以上999以下整数
・p_encode = []
・q_encode = []
・p_list: pの各桁の値を文字としてリスト化したもの
・q_list: qの各桁の値を文字としてリスト化したもの
・p_listの長さ分だけ、以下を実行
 ・p_encodeにp_listの各値とnumとのXORを追加
 ・q_encodeにq_listの各値とnumとのXORを追加
・c, n, p_encode, q_encodeを出力

numをブルートフォースして、p_encode, q_encodeの値からp, qを求める。あとは通常通り復号する。

#!/usr/bin/env python3
from Crypto.Util.number import *

with open('output.txt', 'r') as f:
    params = f.read().splitlines()

c = int(params[0].split(' = ')[1])
n = int(params[2].split(' = ')[1])
p_encode = eval(params[4].split(' = ')[1])
q_encode = eval(params[6].split(' = ')[1])
e = 0x10001

for num in range(100, 1000):
    error = False

    p_list = []
    for i in range(len(p_encode)):
        pd = int(p_encode[i]) ^ num
        if pd >= 10:
            error = True
            break
        p_list.append(str(pd))
    if error:
        continue

    q_list = []
    for i in range(len(q_encode)):
        qd = int(q_encode[i]) ^ num
        if qd >= 10:
            error = True
            break
        q_list.append(str(qd))
    if error:
        continue

    p = int(''.join(p_list))
    q = int(''.join(q_list))
    if p * q == n:
        break

phi = (p - 1) * (q - 1)
d = inverse(e, phi)
m = pow(c, d, n)
flag = long_to_bytes(m).decode()
print(flag)
CyberGonCTF{345y_p34sy_R54_c1ph3R}

dO nOT aCCESS (CRYPTO)

Hexahue。https://www.dcode.fr/hexahue-cipherでデコードする。

ACTTCGTAGT
TGCGATTCCC
ATTGGAATTC
TGGTTGCTCG
CTTCTTTGAA
GTTCCTCTCG

DNA Codeになっているので、https://github.com/karma9874/DNA-Cipher-Script-CTFを参考にデコードする。

ACTTCGTAGTTGCGATTCCCATTGGAATTCTGGTTGCTCGCTTCTTTGAAGTTCCTCTCG
h  3  Y     y  0  u     G  0  7     D  N  4     c  0  D  3
CyberGonCTF{h3Y_y0u_G07_DN4_c0D3}