SlideShare a Scribd company logo
1 of 34
Hack into the Genie
我把在網頁框架發現的密碼學漏洞變成 CTF 題了
splitline @ HITCON FreeTalk
>
- The CTF challenge is designed by both me and @maple3142
- I found the 2 vulnerabilities in Genie.jl and reported
them in issue Genie.jl#493 and #495 (deleted)
- @maple3142 wrote the whole CTF challenge, and reported
the padding bug in Nettle.jl#110
Disclaimer
> whoami
- @splitline
- Web 🐶
- NYCU CSIE
- CTF @ ⚔️TSJ⚔️ / 10sec
How it Started
欸,Julia 有沒有反
序列化 漏洞R
2 × New Vulnerability
1 × CTF Challenge (?
1 × Real World Case
How it Ended
How it Started
欸,Julia 有沒有反
序列化 漏洞R
2 × New Vulnerability
1 × CTF Challenge (?
1 × Real World Case
How it Ended
Ans:有
> Julia#32601
Julia Web Framework
Genie.jl
Genie.jl
Let's Play a Game CTF
> Overview
Sessions.init()
route("/upload", method = POST) do
if infilespayload(:file)
file = filespayload(:file)
path = joinpath(upload_dir, file.name)
write(path, file.data)
# ... Add file path into session ...
end
end
> Path Traversal
Sessions.init()
route("/upload", method = POST) do
if infilespayload(:file)
file = filespayload(:file)
path = joinpath(upload_dir, file.name)
write(path, file.data)
# ... Add file path into session ...
end
end
../../../
> Session?
Sessions.init()
route("/upload", method = POST) do
if infilespayload(:file)
file = filespayload(:file)
path = joinpath(upload_dir, file.name)
write(path, file.data)
# ... Add file path into session ...
end
end
> Session?
1.Serialized data
2.File-based implementation
3.Encrypted session id
> Session?
1.Serialized data -> 控制到就能 RCE
2.File-based implementation -> 已可任意寫檔
3.Encrypted session id -> ???
AES_CBC::decrypt(__geniesid)
open("sessions/" + <明文 session id (64 bytes)>)
Serialization.deserialize(內容)
> AES CBC?
- Padding Oracle?
- Bit Flipping?
> AES CBC Decrypt
Decrypt ⚙️
Key 🔑
密文 🔒
Decrypt ⚙️
Key 🔑
密文 🔒
明文 💬 明文 💬
IV
> How They Implemented?
Decrypt ⚙️
Key 🔑
密文 🔒
Decrypt ⚙️
Key 🔑
密文 🔒
明文 💬 明文 💬
IV
__geniesid
Genie.secret_token
> AES CBC?
- Padding Oracle ❌
1. 密文不包含 IV
2. Unpadding 不會報錯
- Bit Flipping?
> AES CBC?
- Padding Oracle ❌
1. 密文不包含 IV
2. Unpadding 不會報錯
- Bit Flipping?
… … … … … … … … … … … … … 01 03 09
正常狀況
> AES CBC?
- Padding Oracle ❌
1. 密文不包含 IV
2. Unpadding 不會報錯
- Bit Flipping?
… … … … … … … … … … … … … 01 03 09
最後 9 bytes 皆須為 0x09
Padding Error!
正常狀況
> AES CBC?
- Padding Oracle ❌
1. 密文不包含 IV
2. Unpadding 不會報錯
- Bit Flipping?
… … … … … … … … … … … … … 01 03 09
Genie 的做法
> AES CBC?
- Padding Oracle ❌
1. 密文不包含 IV
2. Unpadding 不會報錯
- Bit Flipping?
… … … … … … … … … … … … … 01 03 09
Remove 9 bytes without checking
Genie 的做法
> AES CBC?
- Padding Oracle?
- Bit Flipping?
- Yes, but…
>
遭竄改的密文 🔒
AES CBC Decrypt: Bit Flipping
Decrypt ⚙️
Key 🔑 Decrypt ⚙️
Key 🔑
密文 🔒
垃圾 💩 遭竄改的明文 💬
IV
> How to Forge
Block#1 Block#2 Block#3 Block#4 Block#5
Filename[:16] Filename[16:32] Filename[32:48] Filename[48:64] "x10"*16
ForgedCiphertext(block#4) = ("x10"*16) ⊕ Ciphertext(block#4) ⊕ Target(block#5)
(Padding)
<Plaintext>
> How to Forge
Block#4 Block#5
Garbage 💩 "x1f"*16
Forged = (("x10" * 16) ⊕ Ciphertext(block#4) ⊕ ("x1f"*16)) + CipherText(block#5)
(Padding)
<New Plaintext>
chr(32 - 1)
Block#4 Block#5
Garbage 💩 "x1f"*16
unpad( Filename[:16] + "x1f" * 16 )
Random 1 Byte
> Final Exploit
1. 上傳一堆 x01 ~ xff 的檔案到 ../sessions/<byte>
2. 生成惡意的 session id (解密後只會有 1 byte)
3. 用該 session 去 request 兩次
4. pwned!
Bonus
http://example.com////etc/passwd
slashes (/) >= 4 -> 任意讀檔!
Real World Story
> Reference
- Genie https://github.com/GenieFramework/Genie.jl
- CTF Challenge, Write-up and Exploit:
https://github.com/splitline/My-CTF-
Challenges/tree/master/tsj-ctf/genie
Thanks for Listening!
</slides>

More Related Content

What's hot

PHP 良好實踐 (Best Practice)
PHP 良好實踐 (Best Practice)PHP 良好實踐 (Best Practice)
PHP 良好實踐 (Best Practice)Win Yu
 
JavaScript難読化読経
JavaScript難読化読経JavaScript難読化読経
JavaScript難読化読経Yosuke HASEGAWA
 
資訊安全入門
資訊安全入門資訊安全入門
資訊安全入門Tyler Chen
 
意識の低い自動化
意識の低い自動化意識の低い自動化
意識の低い自動化greenasparagus
 
Indeedなう A日程 解説
Indeedなう A日程 解説Indeedなう A日程 解説
Indeedなう A日程 解説AtCoder Inc.
 
フリーでやろうぜ!セキュリティチェック!
フリーでやろうぜ!セキュリティチェック!フリーでやろうぜ!セキュリティチェック!
フリーでやろうぜ!セキュリティチェック!zaki4649
 
10+ Deploys Per Day: Dev and Ops Cooperation at Flickr
10+ Deploys Per Day: Dev and Ops Cooperation at Flickr10+ Deploys Per Day: Dev and Ops Cooperation at Flickr
10+ Deploys Per Day: Dev and Ops Cooperation at FlickrJohn Allspaw
 
如何靠自學成為工程師
如何靠自學成為工程師如何靠自學成為工程師
如何靠自學成為工程師Joseph Lu
 
HITCON GIRLS: CTF 介紹 (小魚&念奇)
HITCON GIRLS: CTF 介紹 (小魚&念奇)HITCON GIRLS: CTF 介紹 (小魚&念奇)
HITCON GIRLS: CTF 介紹 (小魚&念奇)HITCON GIRLS
 
Pythonを使った簡易診断スクリプトの作り方
Pythonを使った簡易診断スクリプトの作り方Pythonを使った簡易診断スクリプトの作り方
Pythonを使った簡易診断スクリプトの作り方Yuichi Hattori
 
Format string Attack
Format string AttackFormat string Attack
Format string Attackicchy
 
Got Your PW - 一場入門資安的微旅行
Got Your PW - 一場入門資安的微旅行Got Your PW - 一場入門資安的微旅行
Got Your PW - 一場入門資安的微旅行Allen Chou
 
Git 實務圖解
Git 實務圖解Git 實務圖解
Git 實務圖解Pokai Chang
 
淺談 Startup 公司的軟體開發流程 v2
淺談 Startup 公司的軟體開發流程 v2淺談 Startup 公司的軟體開發流程 v2
淺談 Startup 公司的軟體開發流程 v2Wen-Tien Chang
 
競技プログラミングでの線型方程式系
競技プログラミングでの線型方程式系競技プログラミングでの線型方程式系
競技プログラミングでの線型方程式系tmaehara
 
HITCON FreeTalk 2022 - 自己的SOC自己管-- SOC建置的心路歷程分享
HITCON FreeTalk 2022 - 自己的SOC自己管-- SOC建置的心路歷程分享HITCON FreeTalk 2022 - 自己的SOC自己管-- SOC建置的心路歷程分享
HITCON FreeTalk 2022 - 自己的SOC自己管-- SOC建置的心路歷程分享Hacks in Taiwan (HITCON)
 
組織にテストを書く文化を根付かせる戦略と戦術
組織にテストを書く文化を根付かせる戦略と戦術組織にテストを書く文化を根付かせる戦略と戦術
組織にテストを書く文化を根付かせる戦略と戦術Takuto Wada
 

What's hot (20)

PHP 良好實踐 (Best Practice)
PHP 良好實踐 (Best Practice)PHP 良好實踐 (Best Practice)
PHP 良好實踐 (Best Practice)
 
ヤフオクで1年間 Scrumを推進した結果
ヤフオクで1年間 Scrumを推進した結果ヤフオクで1年間 Scrumを推進した結果
ヤフオクで1年間 Scrumを推進した結果
 
ABC001 解説
ABC001 解説ABC001 解説
ABC001 解説
 
JavaScript難読化読経
JavaScript難読化読経JavaScript難読化読経
JavaScript難読化読経
 
資訊安全入門
資訊安全入門資訊安全入門
資訊安全入門
 
意識の低い自動化
意識の低い自動化意識の低い自動化
意識の低い自動化
 
Indeedなう A日程 解説
Indeedなう A日程 解説Indeedなう A日程 解説
Indeedなう A日程 解説
 
フリーでやろうぜ!セキュリティチェック!
フリーでやろうぜ!セキュリティチェック!フリーでやろうぜ!セキュリティチェック!
フリーでやろうぜ!セキュリティチェック!
 
10+ Deploys Per Day: Dev and Ops Cooperation at Flickr
10+ Deploys Per Day: Dev and Ops Cooperation at Flickr10+ Deploys Per Day: Dev and Ops Cooperation at Flickr
10+ Deploys Per Day: Dev and Ops Cooperation at Flickr
 
如何靠自學成為工程師
如何靠自學成為工程師如何靠自學成為工程師
如何靠自學成為工程師
 
HITCON GIRLS: CTF 介紹 (小魚&念奇)
HITCON GIRLS: CTF 介紹 (小魚&念奇)HITCON GIRLS: CTF 介紹 (小魚&念奇)
HITCON GIRLS: CTF 介紹 (小魚&念奇)
 
Pythonを使った簡易診断スクリプトの作り方
Pythonを使った簡易診断スクリプトの作り方Pythonを使った簡易診断スクリプトの作り方
Pythonを使った簡易診断スクリプトの作り方
 
Format string Attack
Format string AttackFormat string Attack
Format string Attack
 
Got Your PW - 一場入門資安的微旅行
Got Your PW - 一場入門資安的微旅行Got Your PW - 一場入門資安的微旅行
Got Your PW - 一場入門資安的微旅行
 
Git 實務圖解
Git 實務圖解Git 實務圖解
Git 實務圖解
 
淺談 Startup 公司的軟體開發流程 v2
淺談 Startup 公司的軟體開發流程 v2淺談 Startup 公司的軟體開發流程 v2
淺談 Startup 公司的軟體開發流程 v2
 
競技プログラミングでの線型方程式系
競技プログラミングでの線型方程式系競技プログラミングでの線型方程式系
競技プログラミングでの線型方程式系
 
集約署名
集約署名集約署名
集約署名
 
HITCON FreeTalk 2022 - 自己的SOC自己管-- SOC建置的心路歷程分享
HITCON FreeTalk 2022 - 自己的SOC自己管-- SOC建置的心路歷程分享HITCON FreeTalk 2022 - 自己的SOC自己管-- SOC建置的心路歷程分享
HITCON FreeTalk 2022 - 自己的SOC自己管-- SOC建置的心路歷程分享
 
組織にテストを書く文化を根付かせる戦略と戦術
組織にテストを書く文化を根付かせる戦略と戦術組織にテストを書く文化を根付かせる戦略と戦術
組織にテストを書く文化を根付かせる戦略と戦術
 

Similar to 【HITCON FreeTalk 2022 - 我把在網頁框架發現的密碼學漏洞變成 CTF 題了】

How shit works: the CPU
How shit works: the CPUHow shit works: the CPU
How shit works: the CPUTomer Gabel
 
Velocity 2012 - Learning WebOps the Hard Way
Velocity 2012 - Learning WebOps the Hard WayVelocity 2012 - Learning WebOps the Hard Way
Velocity 2012 - Learning WebOps the Hard WayCosimo Streppone
 
CCNA Lab 1-Configuring a Switch Part I
CCNA Lab 1-Configuring a Switch Part ICCNA Lab 1-Configuring a Switch Part I
CCNA Lab 1-Configuring a Switch Part IAmir Jafari
 
CPU vulnerabilities - where are we now?
CPU vulnerabilities - where are we now?CPU vulnerabilities - where are we now?
CPU vulnerabilities - where are we now?DefCamp
 
Scaling Twitter
Scaling TwitterScaling Twitter
Scaling TwitterBlaine
 
Scaling Twitter 12758
Scaling Twitter 12758Scaling Twitter 12758
Scaling Twitter 12758davidblum
 
[PH-Neutral 0x7db] Exploit Next Generation®
[PH-Neutral 0x7db] Exploit Next Generation®[PH-Neutral 0x7db] Exploit Next Generation®
[PH-Neutral 0x7db] Exploit Next Generation®Nelson Brito
 
[CB20] Reverse Engineering archeology : Reverse engineering multiple devices ...
[CB20] Reverse Engineering archeology : Reverse engineering multiple devices ...[CB20] Reverse Engineering archeology : Reverse engineering multiple devices ...
[CB20] Reverse Engineering archeology : Reverse engineering multiple devices ...CODE BLUE
 
SMP Implementation for OpenBSD/sgi [Japanese Edition]
SMP Implementation for OpenBSD/sgi [Japanese Edition]SMP Implementation for OpenBSD/sgi [Japanese Edition]
SMP Implementation for OpenBSD/sgi [Japanese Edition]Takuya ASADA
 
[Ruxcon 2011] Post Memory Corruption Memory Analysis
[Ruxcon 2011] Post Memory Corruption Memory Analysis[Ruxcon 2011] Post Memory Corruption Memory Analysis
[Ruxcon 2011] Post Memory Corruption Memory AnalysisMoabi.com
 
[Kiwicon 2011] Post Memory Corruption Memory Analysis
[Kiwicon 2011] Post Memory Corruption Memory Analysis[Kiwicon 2011] Post Memory Corruption Memory Analysis
[Kiwicon 2011] Post Memory Corruption Memory AnalysisMoabi.com
 
CCNA Lab 2-Configuring a Switch Part II
CCNA Lab 2-Configuring a Switch Part IICCNA Lab 2-Configuring a Switch Part II
CCNA Lab 2-Configuring a Switch Part IIAmir Jafari
 
리눅스 드라이버 실습 #3
리눅스 드라이버 실습 #3리눅스 드라이버 실습 #3
리눅스 드라이버 실습 #3Sangho Park
 
Continuously Integrating Distributed Code at Netflix
Continuously Integrating Distributed Code at NetflixContinuously Integrating Distributed Code at Netflix
Continuously Integrating Distributed Code at NetflixAtlassian
 
[HITB Malaysia 2011] Exploit Automation
[HITB Malaysia 2011] Exploit Automation[HITB Malaysia 2011] Exploit Automation
[HITB Malaysia 2011] Exploit AutomationMoabi.com
 
mmsys2019 live streaming at scale
mmsys2019 live streaming at scalemmsys2019 live streaming at scale
mmsys2019 live streaming at scaleJordi Cenzano
 
44CON 2014 - Stupid PCIe Tricks, Joe Fitzpatrick
44CON 2014 - Stupid PCIe Tricks, Joe Fitzpatrick44CON 2014 - Stupid PCIe Tricks, Joe Fitzpatrick
44CON 2014 - Stupid PCIe Tricks, Joe Fitzpatrick44CON
 
44CON 2014 - Simple Hardware Sidechannel Attacks for 10 GBP or Less, Joe Fitz...
44CON 2014 - Simple Hardware Sidechannel Attacks for 10 GBP or Less, Joe Fitz...44CON 2014 - Simple Hardware Sidechannel Attacks for 10 GBP or Less, Joe Fitz...
44CON 2014 - Simple Hardware Sidechannel Attacks for 10 GBP or Less, Joe Fitz...44CON
 

Similar to 【HITCON FreeTalk 2022 - 我把在網頁框架發現的密碼學漏洞變成 CTF 題了】 (20)

How shit works: the CPU
How shit works: the CPUHow shit works: the CPU
How shit works: the CPU
 
Velocity 2012 - Learning WebOps the Hard Way
Velocity 2012 - Learning WebOps the Hard WayVelocity 2012 - Learning WebOps the Hard Way
Velocity 2012 - Learning WebOps the Hard Way
 
CCNA Lab 1-Configuring a Switch Part I
CCNA Lab 1-Configuring a Switch Part ICCNA Lab 1-Configuring a Switch Part I
CCNA Lab 1-Configuring a Switch Part I
 
CPU vulnerabilities - where are we now?
CPU vulnerabilities - where are we now?CPU vulnerabilities - where are we now?
CPU vulnerabilities - where are we now?
 
Scaling Twitter
Scaling TwitterScaling Twitter
Scaling Twitter
 
Scaling Twitter 12758
Scaling Twitter 12758Scaling Twitter 12758
Scaling Twitter 12758
 
[PH-Neutral 0x7db] Exploit Next Generation®
[PH-Neutral 0x7db] Exploit Next Generation®[PH-Neutral 0x7db] Exploit Next Generation®
[PH-Neutral 0x7db] Exploit Next Generation®
 
Rac 12c optimization
Rac 12c optimizationRac 12c optimization
Rac 12c optimization
 
[CB20] Reverse Engineering archeology : Reverse engineering multiple devices ...
[CB20] Reverse Engineering archeology : Reverse engineering multiple devices ...[CB20] Reverse Engineering archeology : Reverse engineering multiple devices ...
[CB20] Reverse Engineering archeology : Reverse engineering multiple devices ...
 
SMP Implementation for OpenBSD/sgi [Japanese Edition]
SMP Implementation for OpenBSD/sgi [Japanese Edition]SMP Implementation for OpenBSD/sgi [Japanese Edition]
SMP Implementation for OpenBSD/sgi [Japanese Edition]
 
QCon São Paulo 2018
QCon São Paulo 2018QCon São Paulo 2018
QCon São Paulo 2018
 
[Ruxcon 2011] Post Memory Corruption Memory Analysis
[Ruxcon 2011] Post Memory Corruption Memory Analysis[Ruxcon 2011] Post Memory Corruption Memory Analysis
[Ruxcon 2011] Post Memory Corruption Memory Analysis
 
[Kiwicon 2011] Post Memory Corruption Memory Analysis
[Kiwicon 2011] Post Memory Corruption Memory Analysis[Kiwicon 2011] Post Memory Corruption Memory Analysis
[Kiwicon 2011] Post Memory Corruption Memory Analysis
 
CCNA Lab 2-Configuring a Switch Part II
CCNA Lab 2-Configuring a Switch Part IICCNA Lab 2-Configuring a Switch Part II
CCNA Lab 2-Configuring a Switch Part II
 
리눅스 드라이버 실습 #3
리눅스 드라이버 실습 #3리눅스 드라이버 실습 #3
리눅스 드라이버 실습 #3
 
Continuously Integrating Distributed Code at Netflix
Continuously Integrating Distributed Code at NetflixContinuously Integrating Distributed Code at Netflix
Continuously Integrating Distributed Code at Netflix
 
[HITB Malaysia 2011] Exploit Automation
[HITB Malaysia 2011] Exploit Automation[HITB Malaysia 2011] Exploit Automation
[HITB Malaysia 2011] Exploit Automation
 
mmsys2019 live streaming at scale
mmsys2019 live streaming at scalemmsys2019 live streaming at scale
mmsys2019 live streaming at scale
 
44CON 2014 - Stupid PCIe Tricks, Joe Fitzpatrick
44CON 2014 - Stupid PCIe Tricks, Joe Fitzpatrick44CON 2014 - Stupid PCIe Tricks, Joe Fitzpatrick
44CON 2014 - Stupid PCIe Tricks, Joe Fitzpatrick
 
44CON 2014 - Simple Hardware Sidechannel Attacks for 10 GBP or Less, Joe Fitz...
44CON 2014 - Simple Hardware Sidechannel Attacks for 10 GBP or Less, Joe Fitz...44CON 2014 - Simple Hardware Sidechannel Attacks for 10 GBP or Less, Joe Fitz...
44CON 2014 - Simple Hardware Sidechannel Attacks for 10 GBP or Less, Joe Fitz...
 

More from Hacks in Taiwan (HITCON)

HITCON FreeTalk 2024 台灣駭客協會媒體小聚【議題二:Cyber War - 網路戰與地緣政治】
HITCON FreeTalk 2024 台灣駭客協會媒體小聚【議題二:Cyber War - 網路戰與地緣政治】HITCON FreeTalk 2024 台灣駭客協會媒體小聚【議題二:Cyber War - 網路戰與地緣政治】
HITCON FreeTalk 2024 台灣駭客協會媒體小聚【議題二:Cyber War - 網路戰與地緣政治】Hacks in Taiwan (HITCON)
 
HITCON FreeTalk 2024 台灣駭客協會媒體小聚【議題一:資安地圖 - 資安領域與趨勢介紹】
HITCON FreeTalk 2024 台灣駭客協會媒體小聚【議題一:資安地圖 - 資安領域與趨勢介紹】HITCON FreeTalk 2024 台灣駭客協會媒體小聚【議題一:資安地圖 - 資安領域與趨勢介紹】
HITCON FreeTalk 2024 台灣駭客協會媒體小聚【議題一:資安地圖 - 資安領域與趨勢介紹】Hacks in Taiwan (HITCON)
 
HITCON FreeTalk 2022 - Zero Trust Architecture 讀書筆記
 HITCON FreeTalk 2022 - Zero Trust Architecture 讀書筆記  HITCON FreeTalk 2022 - Zero Trust Architecture 讀書筆記
HITCON FreeTalk 2022 - Zero Trust Architecture 讀書筆記 Hacks in Taiwan (HITCON)
 
【HITCON FreeTalk 2021 - From fakespy to Guerilla: Understanding Android malw...
【HITCON FreeTalk 2021 -  From fakespy to Guerilla: Understanding Android malw...【HITCON FreeTalk 2021 -  From fakespy to Guerilla: Understanding Android malw...
【HITCON FreeTalk 2021 - From fakespy to Guerilla: Understanding Android malw...Hacks in Taiwan (HITCON)
 
【HITCON FreeTalk 2021 - SolarWinds 供應鏈攻擊事件分析】
【HITCON FreeTalk 2021 -  SolarWinds 供應鏈攻擊事件分析】【HITCON FreeTalk 2021 -  SolarWinds 供應鏈攻擊事件分析】
【HITCON FreeTalk 2021 - SolarWinds 供應鏈攻擊事件分析】Hacks in Taiwan (HITCON)
 
【HITCON FreeTalk 2018 - Spectre & Meltdown 漏洞的修補策略與 risk mitigation】
【HITCON FreeTalk 2018 - Spectre & Meltdown 漏洞的修補策略與 risk mitigation】【HITCON FreeTalk 2018 - Spectre & Meltdown 漏洞的修補策略與 risk mitigation】
【HITCON FreeTalk 2018 - Spectre & Meltdown 漏洞的修補策略與 risk mitigation】Hacks in Taiwan (HITCON)
 
【HITCON FreeTalk 2018 - 從晶片設計角度看硬體安全】
【HITCON FreeTalk 2018 - 從晶片設計角度看硬體安全】【HITCON FreeTalk 2018 - 從晶片設計角度看硬體安全】
【HITCON FreeTalk 2018 - 從晶片設計角度看硬體安全】Hacks in Taiwan (HITCON)
 
【HITCON FreeTalk】HITCON 2017 下半年活動介紹
【HITCON FreeTalk】HITCON 2017 下半年活動介紹【HITCON FreeTalk】HITCON 2017 下半年活動介紹
【HITCON FreeTalk】HITCON 2017 下半年活動介紹Hacks in Taiwan (HITCON)
 
【HITCON Hackathon 2017】 TrendMicro Datasets
【HITCON Hackathon 2017】 TrendMicro Datasets【HITCON Hackathon 2017】 TrendMicro Datasets
【HITCON Hackathon 2017】 TrendMicro DatasetsHacks in Taiwan (HITCON)
 
HITCON TALK 技術解析 SWIFT Network 攻擊
HITCON TALK 技術解析 SWIFT Network 攻擊 HITCON TALK 技術解析 SWIFT Network 攻擊
HITCON TALK 技術解析 SWIFT Network 攻擊 Hacks in Taiwan (HITCON)
 
HITCON TALK 台灣駭客協會年度活動簡介
HITCON TALK 台灣駭客協會年度活動簡介HITCON TALK 台灣駭客協會年度活動簡介
HITCON TALK 台灣駭客協會年度活動簡介Hacks in Taiwan (HITCON)
 
Hacker as a maker 如何利用 mtk 7688 設計出超炫的 ctf 決賽戰場燈控效果
Hacker as a maker 如何利用 mtk 7688 設計出超炫的 ctf 決賽戰場燈控效果Hacker as a maker 如何利用 mtk 7688 設計出超炫的 ctf 決賽戰場燈控效果
Hacker as a maker 如何利用 mtk 7688 設計出超炫的 ctf 決賽戰場燈控效果Hacks in Taiwan (HITCON)
 
2015 資安從業人員的寶(鬼)島求生
2015 資安從業人員的寶(鬼)島求生2015 資安從業人員的寶(鬼)島求生
2015 資安從業人員的寶(鬼)島求生Hacks in Taiwan (HITCON)
 

More from Hacks in Taiwan (HITCON) (20)

HITCON FreeTalk 2024 台灣駭客協會媒體小聚【議題二:Cyber War - 網路戰與地緣政治】
HITCON FreeTalk 2024 台灣駭客協會媒體小聚【議題二:Cyber War - 網路戰與地緣政治】HITCON FreeTalk 2024 台灣駭客協會媒體小聚【議題二:Cyber War - 網路戰與地緣政治】
HITCON FreeTalk 2024 台灣駭客協會媒體小聚【議題二:Cyber War - 網路戰與地緣政治】
 
HITCON FreeTalk 2024 台灣駭客協會媒體小聚【議題一:資安地圖 - 資安領域與趨勢介紹】
HITCON FreeTalk 2024 台灣駭客協會媒體小聚【議題一:資安地圖 - 資安領域與趨勢介紹】HITCON FreeTalk 2024 台灣駭客協會媒體小聚【議題一:資安地圖 - 資安領域與趨勢介紹】
HITCON FreeTalk 2024 台灣駭客協會媒體小聚【議題一:資安地圖 - 資安領域與趨勢介紹】
 
HITCON CISO Summit 2023 - Closing
HITCON CISO Summit 2023 - ClosingHITCON CISO Summit 2023 - Closing
HITCON CISO Summit 2023 - Closing
 
HITCON FreeTalk 2022 - Zero Trust Architecture 讀書筆記
 HITCON FreeTalk 2022 - Zero Trust Architecture 讀書筆記  HITCON FreeTalk 2022 - Zero Trust Architecture 讀書筆記
HITCON FreeTalk 2022 - Zero Trust Architecture 讀書筆記
 
【HITCON FreeTalk 2021 - From fakespy to Guerilla: Understanding Android malw...
【HITCON FreeTalk 2021 -  From fakespy to Guerilla: Understanding Android malw...【HITCON FreeTalk 2021 -  From fakespy to Guerilla: Understanding Android malw...
【HITCON FreeTalk 2021 - From fakespy to Guerilla: Understanding Android malw...
 
【HITCON FreeTalk 2021 - SolarWinds 供應鏈攻擊事件分析】
【HITCON FreeTalk 2021 -  SolarWinds 供應鏈攻擊事件分析】【HITCON FreeTalk 2021 -  SolarWinds 供應鏈攻擊事件分析】
【HITCON FreeTalk 2021 - SolarWinds 供應鏈攻擊事件分析】
 
【HITCON FreeTalk 2018 - Spectre & Meltdown 漏洞的修補策略與 risk mitigation】
【HITCON FreeTalk 2018 - Spectre & Meltdown 漏洞的修補策略與 risk mitigation】【HITCON FreeTalk 2018 - Spectre & Meltdown 漏洞的修補策略與 risk mitigation】
【HITCON FreeTalk 2018 - Spectre & Meltdown 漏洞的修補策略與 risk mitigation】
 
【HITCON FreeTalk 2018 - 從晶片設計角度看硬體安全】
【HITCON FreeTalk 2018 - 從晶片設計角度看硬體安全】【HITCON FreeTalk 2018 - 從晶片設計角度看硬體安全】
【HITCON FreeTalk 2018 - 從晶片設計角度看硬體安全】
 
【HITCON FreeTalk】Supply Chain Attack
【HITCON FreeTalk】Supply Chain Attack【HITCON FreeTalk】Supply Chain Attack
【HITCON FreeTalk】Supply Chain Attack
 
【HITCON FreeTalk】HITCON 2017 下半年活動介紹
【HITCON FreeTalk】HITCON 2017 下半年活動介紹【HITCON FreeTalk】HITCON 2017 下半年活動介紹
【HITCON FreeTalk】HITCON 2017 下半年活動介紹
 
【HITCON Hackathon 2017】 TrendMicro Datasets
【HITCON Hackathon 2017】 TrendMicro Datasets【HITCON Hackathon 2017】 TrendMicro Datasets
【HITCON Hackathon 2017】 TrendMicro Datasets
 
HITCON TALK 技術解析 SWIFT Network 攻擊
HITCON TALK 技術解析 SWIFT Network 攻擊 HITCON TALK 技術解析 SWIFT Network 攻擊
HITCON TALK 技術解析 SWIFT Network 攻擊
 
HITCON TALK ATM 金融攻擊事件解析
HITCON TALK ATM 金融攻擊事件解析HITCON TALK ATM 金融攻擊事件解析
HITCON TALK ATM 金融攻擊事件解析
 
HITCON TALK 產業視野下的 InfoSec
HITCON TALK 產業視野下的 InfoSecHITCON TALK 產業視野下的 InfoSec
HITCON TALK 產業視野下的 InfoSec
 
HITCON TALK 台灣駭客協會年度活動簡介
HITCON TALK 台灣駭客協會年度活動簡介HITCON TALK 台灣駭客協會年度活動簡介
HITCON TALK 台灣駭客協會年度活動簡介
 
HITCON CTF 導覽
HITCON CTF 導覽HITCON CTF 導覽
HITCON CTF 導覽
 
Ctf hello,world!
Ctf hello,world! Ctf hello,world!
Ctf hello,world!
 
Hacker as a maker 如何利用 mtk 7688 設計出超炫的 ctf 決賽戰場燈控效果
Hacker as a maker 如何利用 mtk 7688 設計出超炫的 ctf 決賽戰場燈控效果Hacker as a maker 如何利用 mtk 7688 設計出超炫的 ctf 決賽戰場燈控效果
Hacker as a maker 如何利用 mtk 7688 設計出超炫的 ctf 決賽戰場燈控效果
 
2015 資安從業人員的寶(鬼)島求生
2015 資安從業人員的寶(鬼)島求生2015 資安從業人員的寶(鬼)島求生
2015 資安從業人員的寶(鬼)島求生
 
CTF 經驗分享
CTF 經驗分享CTF 經驗分享
CTF 經驗分享
 

Recently uploaded

Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 

Recently uploaded (20)

Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 

【HITCON FreeTalk 2022 - 我把在網頁框架發現的密碼學漏洞變成 CTF 題了】

  • 1. Hack into the Genie 我把在網頁框架發現的密碼學漏洞變成 CTF 題了 splitline @ HITCON FreeTalk
  • 2. > - The CTF challenge is designed by both me and @maple3142 - I found the 2 vulnerabilities in Genie.jl and reported them in issue Genie.jl#493 and #495 (deleted) - @maple3142 wrote the whole CTF challenge, and reported the padding bug in Nettle.jl#110 Disclaimer
  • 3. > whoami - @splitline - Web 🐶 - NYCU CSIE - CTF @ ⚔️TSJ⚔️ / 10sec
  • 4. How it Started 欸,Julia 有沒有反 序列化 漏洞R 2 × New Vulnerability 1 × CTF Challenge (? 1 × Real World Case How it Ended
  • 5. How it Started 欸,Julia 有沒有反 序列化 漏洞R 2 × New Vulnerability 1 × CTF Challenge (? 1 × Real World Case How it Ended Ans:有
  • 10. Let's Play a Game CTF
  • 11. > Overview Sessions.init() route("/upload", method = POST) do if infilespayload(:file) file = filespayload(:file) path = joinpath(upload_dir, file.name) write(path, file.data) # ... Add file path into session ... end end
  • 12. > Path Traversal Sessions.init() route("/upload", method = POST) do if infilespayload(:file) file = filespayload(:file) path = joinpath(upload_dir, file.name) write(path, file.data) # ... Add file path into session ... end end ../../../
  • 13. > Session? Sessions.init() route("/upload", method = POST) do if infilespayload(:file) file = filespayload(:file) path = joinpath(upload_dir, file.name) write(path, file.data) # ... Add file path into session ... end end
  • 14. > Session? 1.Serialized data 2.File-based implementation 3.Encrypted session id
  • 15. > Session? 1.Serialized data -> 控制到就能 RCE 2.File-based implementation -> 已可任意寫檔 3.Encrypted session id -> ???
  • 16. AES_CBC::decrypt(__geniesid) open("sessions/" + <明文 session id (64 bytes)>) Serialization.deserialize(內容)
  • 17. > AES CBC? - Padding Oracle? - Bit Flipping?
  • 18. > AES CBC Decrypt Decrypt ⚙️ Key 🔑 密文 🔒 Decrypt ⚙️ Key 🔑 密文 🔒 明文 💬 明文 💬 IV
  • 19. > How They Implemented? Decrypt ⚙️ Key 🔑 密文 🔒 Decrypt ⚙️ Key 🔑 密文 🔒 明文 💬 明文 💬 IV __geniesid Genie.secret_token
  • 20. > AES CBC? - Padding Oracle ❌ 1. 密文不包含 IV 2. Unpadding 不會報錯 - Bit Flipping?
  • 21. > AES CBC? - Padding Oracle ❌ 1. 密文不包含 IV 2. Unpadding 不會報錯 - Bit Flipping? … … … … … … … … … … … … … 01 03 09 正常狀況
  • 22. > AES CBC? - Padding Oracle ❌ 1. 密文不包含 IV 2. Unpadding 不會報錯 - Bit Flipping? … … … … … … … … … … … … … 01 03 09 最後 9 bytes 皆須為 0x09 Padding Error! 正常狀況
  • 23. > AES CBC? - Padding Oracle ❌ 1. 密文不包含 IV 2. Unpadding 不會報錯 - Bit Flipping? … … … … … … … … … … … … … 01 03 09 Genie 的做法
  • 24. > AES CBC? - Padding Oracle ❌ 1. 密文不包含 IV 2. Unpadding 不會報錯 - Bit Flipping? … … … … … … … … … … … … … 01 03 09 Remove 9 bytes without checking Genie 的做法
  • 25. > AES CBC? - Padding Oracle? - Bit Flipping? - Yes, but…
  • 26. > 遭竄改的密文 🔒 AES CBC Decrypt: Bit Flipping Decrypt ⚙️ Key 🔑 Decrypt ⚙️ Key 🔑 密文 🔒 垃圾 💩 遭竄改的明文 💬 IV
  • 27. > How to Forge Block#1 Block#2 Block#3 Block#4 Block#5 Filename[:16] Filename[16:32] Filename[32:48] Filename[48:64] "x10"*16 ForgedCiphertext(block#4) = ("x10"*16) ⊕ Ciphertext(block#4) ⊕ Target(block#5) (Padding) <Plaintext>
  • 28. > How to Forge Block#4 Block#5 Garbage 💩 "x1f"*16 Forged = (("x10" * 16) ⊕ Ciphertext(block#4) ⊕ ("x1f"*16)) + CipherText(block#5) (Padding) <New Plaintext> chr(32 - 1)
  • 29. Block#4 Block#5 Garbage 💩 "x1f"*16 unpad( Filename[:16] + "x1f" * 16 ) Random 1 Byte
  • 30. > Final Exploit 1. 上傳一堆 x01 ~ xff 的檔案到 ../sessions/<byte> 2. 生成惡意的 session id (解密後只會有 1 byte) 3. 用該 session 去 request 兩次 4. pwned!
  • 33. > Reference - Genie https://github.com/GenieFramework/Genie.jl - CTF Challenge, Write-up and Exploit: https://github.com/splitline/My-CTF- Challenges/tree/master/tsj-ctf/genie