Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
SECCON Beginners CTF2021のCryptoを解いてみよう
Search
ushigai
October 17, 2021
Technology
1.1k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
SECCON Beginners CTF2021のCryptoを解いてみよう
ushigai
October 17, 2021
More Decks by ushigai
See All by ushigai
暗号目線で俯瞰するSSL/TLS / security minicamp in Tokyo 2022 TLS
ushigai
0
740
Crypto超入門 / SECCON Beginners Live 2022
ushigai
2
1.9k
Other Decks in Technology
See All in Technology
消えない 動かない 効かない
yama3133
1
110
Omarchy Quattro の日本語設定周り
simosako
2
150
幾何アルゴリズムで なめらかなピン操作を / iOSDC Japan 2026 / smoothpin
kazumanagano
0
270
2026-09-09 【sigma_ucj#1】Sigma を IaC 管理したい! / IaC for Sigma
civitaspo
0
120
DEFCON34-Write-up_HYCu-MYCu
daikiokazaki
0
150
AI 駆動 Terraform 開発/SRE_BizReach_MIXI_2
visional_engineering_and_design
4
2.1k
Gitは怖い?共有ワークスペースから始めるSnowflakeチーム開発
coco_se
0
170
[2026-09-11]SREは誰のもの?運用エンジニアが始める 「SRE領域への越境」とチームの進化の軌跡 〜Road to NEXT CRE
tosite
0
160
『止めない』を設計する — 制約の中で、事業の根幹を支える判断
hiroyaterui
0
270
深夜のクラウド懺悔室 1:29:300 or 1:0:0
kazzpapa3
1
240
Amazon S3 Tablesに全部任せてみた結果——コンパクション/スナップショット管理は本当に手放せるか
shigeruoda
1
480
AI時代、データエンジニアが一番おもろい
genshun9
0
130
Featured
See All Featured
Build your cross-platform service in a week with App Engine
jlugia
234
19k
Site-Speed That Sticks
csswizardry
13
1.5k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.1k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.3k
Paper Plane (Part 1)
katiecoart
PRO
1
11k
Mobile First: as difficult as doing things right
swwweet
225
10k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
Navigating Team Friction
lara
192
16k
The Cost Of JavaScript in 2023
addyosmani
55
10k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
202
76k
Transcript
SECCON Beginners CTF 2021の Cryptoを解いてみよう SECCON Beginners Live 2021 2021/10/17
自己紹介 • うしがぃ@ushigai_sub • 所属 • 都立産業技術高等専門学校(4年) • SECCON Beginners
運営チーム • 趣味 • ピアノ:小6から7年間 • ルービックキューブ3×3:1/5/100=13.89/18.88/23.19 • 将棋:アマ二段 1/24
内容 • simple_RSA解説 • Logical_SEESAW解説 • 発展問題の紹介 2/24
お話の対象層 3/25 Beginner Easy Medium Hard • 過去問解説はBeginner向け • 発展問題はEasy向け
CTF Beginnerへ 4/24 • 昨今のCTFは難しすぎる… • プログラミングはできて当たり前 • 文字コードいじるだけ問題はどこへ? Merkle-Dam
Mersenne T CopperS bcrypto
CTF Beginnerへ • 勉強方法(主観) • 本・常設での勉強 • 迷路本 • picoCTF
• 分からないことがあったら? • 誰かに聞く • おいしいものを食べる 5/24
simple_RSA解説 •simple_RSA • 難易度Beginner • 75points/289solves •RSA暗号の自明な脆弱性を攻撃する問題 → Low public
exponent attack 6/24
RSA暗号 鍵生成: 素数𝑝, 𝑞について𝑛 = 𝑝𝑞, φ 𝑛 = (𝑝
− 1)(𝑞 − 1)とおき、 𝑔𝑐𝑑 φ 𝑛 , 𝑒 = 1を満たす𝑒から𝑑 = 𝑒−1 mod φ(𝑛)とおく。 このとき公開鍵の組を 𝑒, 𝑛 , 秘密鍵を𝑑とする。 暗号化: 任意の平文𝑚について暗号文𝑐は𝑐 = 𝑚𝑒 mod 𝑛となる。 復号: 平文𝑚は𝑚 = 𝑐𝑑 mod 𝑛と複号できる。 7/24
CTFにおけるRSA暗号 • Beginner • 暗号化・復号の計算方法 • factorDB等ツールの使用 • RSA暗号の典型的な脆弱性の攻撃 •
Easy ~ Medium • 簡単な代数方程式の計算 • 鍵共有・署名 • Hard ~ • CopperSmiths Method • 数学力でぶん殴る • etc… 8/24
problem.pyについて① 𝑛 = 𝑝𝑞 𝑒 = 3 𝑐 = 𝑓𝑙𝑎𝑔𝑒
mod 𝑛 9/24
problem.pyについて② • assert 2046 < n.bit_length() → nは2047bit or nは2048bit
• assert 375 == flag.bit_length() → flagは375bitの数 ⇒ 𝑐 = 𝑓𝑙𝑎𝑔𝑒 ∵ 𝑓𝑙𝑎𝑔𝑒 < 𝑛 ⇒ Low public exponent attack 10/24 ⇒ 𝑓𝑙𝑎𝑔 = 𝑒 𝑐
solverの作成 11/24
Logical_SEESAW解説 • Logical_SEESAW • 難易度Beginner • 118points/190solves • パズル問(自作暗号) •
論理演算・コーディング 12/24
problem.pyについて① 13/24
problem.pyについて② flagの各bitに対して適用確立0.5で flagとkeyのAND演算を行っている 14/24
暗号化部分のAND演算 flag key n > m cipher 0 0 0
0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 1 1 1 cipherが1ならflagは確実に1で 0なら8割がた0になる! 15/24
攻撃 • cipherが1ならflagは確実に1 • cipherが0ならflagは8割方0 ⇒ 各bitに対して1個でも1が含まれていれば1で 全部0なら0 ⇒ OR演算で実装・復号できる
16/24
solverの作成 17 /24
復号でノイズが乗る確率は? • 簡単のために入力値は1で固定 • あるiでcipher[0, 16)[i]がすべて0のとき正しく復号できない • 1回でノイズが乗る確率は1/4 ⇒ 1
4 16 ≒ 2.32 × 10−10 18/24 flag key n > m cipher 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 1 1 1 23200000000回に1回しか ノイズのらないんじゃね?
復号でノイズが乗る確率は? • 現実には確率の罠が存在する • 2.32 × 1010回1を入力したとき1回でもノイズが乗る確率 • 確率が1/2を超える入力回数は? 2977044472回
⇒ 2.32 × 1010回と大きな差がある 19/24 1 − 1 − 1 4 16 23200000000 × 100% ≒ 99.5%
誕生日のパラドクス 20/24 クラス40人で同じ誕生日の人が2人以上いる確率はいくつか? 1 − 364 365 ∙ 363 365
∙ ⋯ ∙ 326 365 × 100% ≒ 89.23% 確率が1/2を超えるために必要な人数は何人か? ⇒ 23人
誕生日攻撃 • ハッシュ関数の衝突を見つける攻撃 • 無作為な入力を行いハッシュ値と一致させる 21/24 出力bit 出力の個数 衝突確立 1%
衝突確立 50% 衝突確立 75% 32 4.3 × 109 2.9 × 103回 7.7 × 104回 1.1 × 105回 64 1.8 × 1019 6.1 × 108回 5.1 × 109回 7.2 × 109回 128 3.4 × 1038 2.6 × 1018回 2.2 × 1019回 3.1 × 1019回
発展問題の紹介 22/24
さいごに 23/24 • CTFはとても楽しいです • ぜひ一緒に楽しみましょう
お世話になったところ • イラスト https://www.irasutoya.com/ • 誕生日攻撃の出力bitと衝突確立の関係 https://ja.wikipedia.org/wiki/%E8%AA%95%E7%94%9F%E6%97 %A5%E6%94%BB%E6%92%83 • SECCON
Beginners CTF 2021(GitHub) https://github.com/SECCON/Beginners_CTF_2021 24/24