SlideShare a Scribd company logo
1 of 33
Download to read offline
Trend Micro CTF 2019の
機械学習カテゴリの問題に挑んだ
meow (id: meow_noisy)
第31回ゼロから始めるセキュリティ入門 勉強会
2019/09/25(水)
発表の要旨
 CTF勉強会に参加しているので、実際の
CTFにも初めて参加した
 一番解ける可能性のある、機械学習
ジャンルに絞って問題に挑んだ(解けたとは言っていない)
発表の流れ
1. 自己紹介(資料では割愛)
2. Trend Micro CTF 2019について
3. CTFの問題の説明
4. 自分の回答
5. 答え合わせ
発表の流れ
1. 自己紹介
2. Trend Micro CTF 2019について
3. CTFの問題の説明
4. 自分の回答
5. 答え合わせ
そもそもCTFとは
 https://kotobank.jp/word/CTF-683695よ
り
 《capture the flag》デフコンやセクコンを
はじめとする、コンピューターのハッキング
技術を競うコンテストなどで採用される競技。
 コンピューターセキュリティーに関する攻撃・
防御の両方の立場から、暗号、ネットワーク
技術、プログラミングなど、さまざまな問題を
解くことで技量や知識を競う。
[余談]私とCTF
 今回初参加
 動機: 参加して実際の空気のようなものを味わいた
かった
 CTFが何なのか私自身よく分かってないです
 提示された問題に対して、コンピュータハックの
知恵・技術・アイディアを駆使して解答するプロ
コンの一種という認識です
Trend Micro CTF 2019
– Raimund Genes Cup
 トレンドマイクロ社が主催するCTF
 https://www.trendmicro.com/ja_jp/campaign
s/capture-the-flag.html
 9月にオンライン予選の選抜、11月に本戦
 優勝賞金100万円
オンライン予選
 競技形式
 ジョパディ型
 問題カテゴリー
 リバースエンジニアリング
 フォレンジック エクスプロイト
 IoT
 モバイル
 OSINT
 機械学習
オンライン予選
 競技形式
 ジョパディ型
 問題カテゴリー
 リバースエンジニアリング
 フォレンジック エクスプロイト
 IoT
 モバイル
 OSINT
 機械学習
自分の解けそうな
ものを解くことに
[補足] 機械学習? Deep
Learning? AI?
 機械学習
 プログラムの処理判断基準をデータから自動的に獲得させ
る技術
 Deep Learning
 機械学習手法の1種。Deep Neural Networkという機械学
習モデルの学習方法。特徴抽出に長けており性能が高い。
 AI
 機械学習を知らない人に機械学習プロダクトを
“なんとなく”分かってもらう時に使う言葉。
図: https://semla.polymtl.ca/wp-content/uploads/2019/06/Ma-semla.pdf
発表の流れ
1. 自己紹介
2. Trend Micro CTF 2019について
3. CTFの問題の説明
4. 自分の回答
5. 答え合わせ
問題サーバの画面
 カテゴリと解答スコアが表示
 事前告知されていたカテゴリと若干違った
が、”Wildcard 100”を選択
Wildcard 100の内容
1. 与えられたフォルダ内には画像が34,022枚
あり、数字の”3”と”6”の画像が混在している
1. 画像に”3”と”6”のラベル(メタ情報)はない
2. また、画像には重複しているものもある
3. タスクは、”3”と”6”のユニークな枚数を計算
し、フラグをつくること
1. フラグ: TMCTF{x_y}
1. x: ユニークな”3”の画像枚数
2. y: ユニークな”6”の画像枚数
なお、総当たりを試みると
時間のペナルティ
画像を見て一言
_人人人人人人_
> MNISTだ! <
 ̄Y^Y^Y^Y^Y^Y^ ̄
MNIST(database)とは
 画像データセットの1つ
 0~9の手書きの数字から成る
 Deep Learningで画像認識を行う練習問題
の題材としてよく採用される
えむにすと
図: https://en.wikipedia.org/wiki/MNIST_database
発表の流れ
1. 自己紹介
2. Trend Micro CTF 2019について
3. CTFの問題の説明
4. 自分の回答
5. 答え合わせ
解答の方針
下記の4step
1. ダブりのある画像の除外
2. MNISTデータをDeep Neural Networkで
学習し、数字分類器を作る
3. CTFの問題データをstep2で作った分類器
で分類し、人の目視で誤りがないか
チェック
4. 画像の枚数をカウントする
なんかラクそう(フラグ)
step1. ダブりの除外
 検索で「linux 重複 ファイル 削除 コマン
ド」とかでヒットする方法を使った
 34,022枚あった画像が15,310枚に
step2. MNIST分類器の学習
 「あ!これPyTorch本でやったところだ!」
 PyTorch: ディープラーニングのソフトウェア
フレームワーク。直感的に実装しやすく人気。
 本の第4章にDeep Learningで画像分類をする
レッスンがある
 サンプルコードもある
 https://github.com/miyamotok0105/pytorch_handbook
 Deep LearningではGPU環境が必須だが、Google
Colaboratoryサービスを使えば、
vGPUの学習環境を無料で使うことが可能
 MNISTのデータに差し替えて、
モデル(AlexNet)を学習
 評価データに対して、正解率98.2%
 DNNの値にしては小さい方だが、これで十分
https://www.shuwasystem.co
.jp/book/9784798055473.htm
l
step3. 分類
 CTFの問題データをstep2で作った分類器
で分類
 0~9までの数字を学習しているので、何件か
認識誤りを起こしている
 そんなに多くないので目視で確認し人手で補正
分類結果別にファイルを移動
‘3’の画像を‘5’と認識誤りを起こした例
ん?
 あれ、画像同じじゃない?
 ファイルのmd5確認すると別物だった
 私「なるほど、見た目のダブリも考慮して
除去する必要があるのか」
ファイルが異なる原因
 グレー画像なので実際には中間の値の画素
が存在するため
同じ座標の画素を比較。微妙に画素の値が異なる。
グレー画像の2値化
 したがって、画素を255と0に分ける
処理(2値化)をかける
図: http://labs.eecs.tottori-
u.ac.jp/sd/Member/oyamada/OpenCV/html/py_tutorials/py_imgproc/py_thresh
olding/py_thresholding.html
改めて重複削除してみたが...
 15,310枚あった画像が6,654枚に
 完全にはダブリが削除されない
 どこかの画素が異なっている模様
画素同士のXOR演算
 各画素でXORを取る
 同じ値だったら0、違ったら1
 ダブリの画像なら1の数は少ないはず
 6,654枚の画像に対して、それぞれXORを
とり、白画素の数でダブリチェックをする
⊕ =
XORの結果
 6,654枚→4,539枚に
 この時点で”3”の画像が4,184枚、”6”の
画像が344枚、それ以外に分類されたもの
が11枚
 それ以外の画像(↓)を人手で分類
 分類困難な画像もあるので、あとは総当り
ダブリがなくなった
フラグを送るが...
 「正しくない」という結果が表示される
 値を揺らして投稿する
結果: 時間切れ
発表の流れ
1. 自己紹介
2. Trend Micro CTF 2019について
3. CTFの問題の説明
4. 自分の回答
5. 答え合わせ
答え(他人のwrite up)を見る
 https://qiita.com/kusano_k/items/6a95f
8079ac7ce2c91a8
 TMCTF{14962_347}
 つまり、見た目がいくら同じように見えて
いても、値が違えばユニークとみなす模様
 ダブリ除去は完全に無駄な作業だった。。。
 それどころか、ドツボにハマる要因となった
この段階でフラグを
投稿していれば...
負け犬の遠吠えタイム
 現実から見てこの問題、意味ある?
 ダブリをハッシュ値だけ見て消して、画像分類
する
CTF初参加の感想
 たのしかった(幼並感)
 スマートに解いているように話したが、
実際には、泥臭くコード書く必要もあった
りして、それのおかげで力がついた感じが
する
 別のCTFの過去問に機械学習カテゴリが
あるようなので、これからも定期的に解き
たい
まとめ
 自分の技術バックグラウンドである機械
学習を切り口にCTFに参加
 問題は解けなかったが力がついたので
結果オーライ
明後日はCTFの勉強会が開催!

More Related Content

Featured

Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Featured (20)

Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 

Trend Micro CTF 2019の機械学習カテゴリの問題に挑んだ