SlideShare una empresa de Scribd logo
1 de 28
Descargar para leer sin conexión
Abusing Interrupts for
Reliable Windows Kernel Exploitation
2015/11/14
AVTOKYO2015
inaz2
About me
• inaz2
• Security engineer & Python programmer
• Working at NTT Communications
• ブログ「ももいろテクノロジー」
• http://inaz2.hatenablog.com/
2
Windows kernel exploitation
• カーネルランドの脆弱性を突くタイプの攻撃
• デバイスドライバの脆弱性を含む
• Write-what-where condition/vulnerabilityが広く利用される
• 任意のアドレスに任意の値を書き込むことが可能な脆弱性
• 自身のプロセスの権限を昇格させるShellcodeを実行させる
• その後、管理者コマンドプロンプトを起動する
3
Classic technique: halDispatchTable overwrite
• nt!NtQueryIntervalProfile 内部API
• nt!KeQueryIntervalProfile 経由で [nt!halDispatchTable+4] が呼ばれる
• [nt!halDispatchTable+4] の値をShellcodeのアドレスに書き換える
4
Replace token shellcode
• Systemプロセス (PID=4) のToken Objectをコピー
5
41414141hは対象となる
プロセスのPIDに置き換える
It works but …
• nt!NtQueryIntervalProfile の実装に依存
• 将来的に実装が変更される可能性がある(つまり、確実ではない)
• より確実な書き換えのターゲットは存在するか?
6
It works but …
• nt!NtQueryIntervalProfile の実装に依存
• 将来的に実装が変更される可能性がある(つまり、確実ではない)
• より確実な書き換えのターゲットは存在するか?
7
x86 interrupt handling
• ハードウェア割り込み(キーボード入力など)とソフトウェア割り込み
(ゼロ除算など)がある
• ソフトウェア割り込みは “int n” 命令で発生させることができる
• Interrupt Descriptor Table (IDT)
• Interrupt Software Routines (ISR) と呼ばれる割り込みハンドラ関数のアドレ
スを保持
• ISRはRing 0で実行される
• 要するに、なんでもできる
8
x86 privilege levels (protection rings)
• 0から3までの4つの権限レベル
• 数字が大きいほど権限が低い
• Windowsを含むほとんどのOSは、2つのRingのみを利用する
• Ring 0はカーネルモード、Ring 3はユーザモードに対応
9
Interrupt Descriptor Table (1/4)
• Intel Developer’s Manual Volume 3, Chapter 6
10
Interrupt Descriptor Table (2/4)
• Intel Developer’s Manual Volume 3, Chapter 6
11
DPL=3 ならRing 3から
割り込み可能
Interrupt Descriptor Table (3/4)
• WinDbg (KD) view
12
Interrupt Descriptor Table (4/4)
• Interrupt #0に対応するInterrupt Gateの書き換え
13
414184fc
000884fc 4141ee00
DPL=3
IDT overwrite technique
14
IDTが置かれているアドレスを取得する
Interrupt #nに対応するInterrupt Gateを書き換える
“int n” 命令でInterrupt #nを発生させる
Shellcodeが実行される
Detailed procedure
16
Find the write-what-where vulnerability
• ここでは、脆弱なデバイスドライバを用意しインストールする
• IOCTL経由でwrite-what-where脆弱性への攻撃を可能にする
17
Get the IDT address (1/2)
18
Ring 3でも使える!
Get the IDT address (2/2)
• IDTが置かれているアドレスを返す関数
19
alignmentを無効化
Write the Interrupt Software Routine (ISR)
• fsセグメントレジスタの値を切り換える
• 0x33 (TEB) → 0x30 (KPCR)
• ISRの直後にあるShellcodeをcallする
• ret命令の代わりにiretd命令でリターンする
20
Allocate memory & put the codes
• 0x41410000から0x41420000にnop-sledを確保する
• 0x41420000にISR code + shellcodeを置く
21
Overwrite the Interrupt Gate
• Interrupt #32に対応するInterrupt Gateの後半4バイトを0x4141ee00
で書き換える
• #32-255はuser-defined interruptsと定義されている(予約されていない)
22
Trigger the software interrupt
• “int 32” を実行する
• ISRを経由してShellcodeが実行される
• 続けて、cmd.exeを起動する
23
Demo
24
What about 64 bit Windows?
• Interrupt Gateのサイズが16バイトになる
• 0x100000000バイトのnop-sledは厳しいため、Interrupt Gate全体を
書き換える必要がある(つまり、2回書き込む)
• なぜか割り込みを発生させたタイミングでVirtualBox VMがハング
アップしてしまう(PatchGuard??)
25
Comparison with halDispatchTable overwrite
• Pros
• あらゆるバージョンのx86-based Windowsに対して確実
• 書き換えのターゲットとなるアドレスの特定が簡単
• Cons
• ISRのコードを用意する必要がある
• nop-sledを確保する必要がある
• 64 bitでの動作を検証できていない
26
Recap
• IDT overwriteはあらゆるバージョンのx86-based Windowsに対して
確実
• カーネル実装の変更に依存しない
• IDTが置かれているアドレスはRing 3でも取得できる
• There’s more than one way to do it 
27
References
• Windowsでデバイスドライバの脆弱性からの権限昇格をやってみる - もも
いろテクノロジー
• http://inaz2.hatenablog.com/entry/2015/09/15/121926
• Project Zero: One font vulnerability to rule them all #4: Windows 8.1 64-bit
sandbox escape exploitation
• http://googleprojectzero.blogspot.jp/2015/08/one-font-vulnerability-to-rule-
them-all_21.html
• Interrupt Service Routines - OSDev Wiki
• http://wiki.osdev.org/Interrupt_Service_Routines
• SIMPLE IS BETTER: Kernel Information Leak with Unprivileged Instructions
(SIDT, SGDT) on x86 - WHY ?
• http://hypervsir.blogspot.jp/2014/10/kernel-information-leak-with.html
28
Thank you!
inaz2
29

Más contenido relacionado

La actualidad más candente

Lagopus, raw socket build
Lagopus, raw socket buildLagopus, raw socket build
Lagopus, raw socket buildMasaru Oki
 
ネットワークOS野郎 ~ インフラ野郎Night 20160414
ネットワークOS野郎 ~ インフラ野郎Night 20160414ネットワークOS野郎 ~ インフラ野郎Night 20160414
ネットワークOS野郎 ~ インフラ野郎Night 20160414Kentaro Ebisawa
 
Solnik secure enclaveprocessor-pacsec-final-jp
Solnik secure enclaveprocessor-pacsec-final-jpSolnik secure enclaveprocessor-pacsec-final-jp
Solnik secure enclaveprocessor-pacsec-final-jpPacSecJP
 
SDNソフトウェアスイッチlagopus for FreeBSD
SDNソフトウェアスイッチlagopus for FreeBSDSDNソフトウェアスイッチlagopus for FreeBSD
SDNソフトウェアスイッチlagopus for FreeBSDMasaru Oki
 
Man-in-the-Middle Attack for SSH with Scala and JSch
Man-in-the-Middle Attack for SSH with Scala and JSchMan-in-the-Middle Attack for SSH with Scala and JSch
Man-in-the-Middle Attack for SSH with Scala and JSchAtsuhiko Yamanaka
 
産業制御システムに対するStuxnet以来最大の脅威 by Anton Cherepanov, Róbert Lipovský
産業制御システムに対するStuxnet以来最大の脅威 by Anton Cherepanov, Róbert Lipovský産業制御システムに対するStuxnet以来最大の脅威 by Anton Cherepanov, Róbert Lipovský
産業制御システムに対するStuxnet以来最大の脅威 by Anton Cherepanov, Róbert LipovskýCODE BLUE
 
コンテナネットワーキング(CNI)最前線
コンテナネットワーキング(CNI)最前線コンテナネットワーキング(CNI)最前線
コンテナネットワーキング(CNI)最前線Motonori Shindo
 
ネットワーク機器のAPIあれこれ入門 (NetOpsCoding#2)
ネットワーク機器のAPIあれこれ入門(NetOpsCoding#2)ネットワーク機器のAPIあれこれ入門(NetOpsCoding#2)
ネットワーク機器のAPIあれこれ入門 (NetOpsCoding#2)Kentaro Ebisawa
 
plotnetcfg入門 | Introduction to plotnetcfg
plotnetcfg入門 | Introduction to plotnetcfgplotnetcfg入門 | Introduction to plotnetcfg
plotnetcfg入門 | Introduction to plotnetcfgKentaro Ebisawa
 
Interrupt Affinityについて
Interrupt AffinityについてInterrupt Affinityについて
Interrupt AffinityについてTakuya ASADA
 
Lagopus Switch Usecases
Lagopus Switch UsecasesLagopus Switch Usecases
Lagopus Switch UsecasesSakiko Kawai
 
Introduction to Ostinato , network packet crafting and generator.
Introduction to Ostinato, network packet crafting and generator.Introduction to Ostinato, network packet crafting and generator.
Introduction to Ostinato , network packet crafting and generator.Kentaro Ebisawa
 
OpenStack + OpenContrailで実現するマルチテナントIaaSのご紹介
OpenStack + OpenContrailで実現するマルチテナントIaaSのご紹介OpenStack + OpenContrailで実現するマルチテナントIaaSのご紹介
OpenStack + OpenContrailで実現するマルチテナントIaaSのご紹介Takashi Sogabe
 
Shusei tomonaga pac_sec_20171026_jp
Shusei tomonaga pac_sec_20171026_jpShusei tomonaga pac_sec_20171026_jp
Shusei tomonaga pac_sec_20171026_jpPacSecJP
 
[CB16] マイクロソフトウィンドウズカーネルのデスノート by Peter Hlavaty & Jin Long
[CB16] マイクロソフトウィンドウズカーネルのデスノート by Peter Hlavaty & Jin Long[CB16] マイクロソフトウィンドウズカーネルのデスノート by Peter Hlavaty & Jin Long
[CB16] マイクロソフトウィンドウズカーネルのデスノート by Peter Hlavaty & Jin LongCODE BLUE
 
High Performance Networking with DPDK & Multi/Many Core
High Performance Networking with DPDK & Multi/Many CoreHigh Performance Networking with DPDK & Multi/Many Core
High Performance Networking with DPDK & Multi/Many Coreslankdev
 
Node-v0.12のTLSを256倍使いこなす方法
Node-v0.12のTLSを256倍使いこなす方法Node-v0.12のTLSを256倍使いこなす方法
Node-v0.12のTLSを256倍使いこなす方法shigeki_ohtsu
 

La actualidad más candente (20)

Lagopus, raw socket build
Lagopus, raw socket buildLagopus, raw socket build
Lagopus, raw socket build
 
ネットワークOS野郎 ~ インフラ野郎Night 20160414
ネットワークOS野郎 ~ インフラ野郎Night 20160414ネットワークOS野郎 ~ インフラ野郎Night 20160414
ネットワークOS野郎 ~ インフラ野郎Night 20160414
 
Solnik secure enclaveprocessor-pacsec-final-jp
Solnik secure enclaveprocessor-pacsec-final-jpSolnik secure enclaveprocessor-pacsec-final-jp
Solnik secure enclaveprocessor-pacsec-final-jp
 
SDNソフトウェアスイッチlagopus for FreeBSD
SDNソフトウェアスイッチlagopus for FreeBSDSDNソフトウェアスイッチlagopus for FreeBSD
SDNソフトウェアスイッチlagopus for FreeBSD
 
Man-in-the-Middle Attack for SSH with Scala and JSch
Man-in-the-Middle Attack for SSH with Scala and JSchMan-in-the-Middle Attack for SSH with Scala and JSch
Man-in-the-Middle Attack for SSH with Scala and JSch
 
産業制御システムに対するStuxnet以来最大の脅威 by Anton Cherepanov, Róbert Lipovský
産業制御システムに対するStuxnet以来最大の脅威 by Anton Cherepanov, Róbert Lipovský産業制御システムに対するStuxnet以来最大の脅威 by Anton Cherepanov, Róbert Lipovský
産業制御システムに対するStuxnet以来最大の脅威 by Anton Cherepanov, Róbert Lipovský
 
コンテナネットワーキング(CNI)最前線
コンテナネットワーキング(CNI)最前線コンテナネットワーキング(CNI)最前線
コンテナネットワーキング(CNI)最前線
 
ネットワーク機器のAPIあれこれ入門 (NetOpsCoding#2)
ネットワーク機器のAPIあれこれ入門(NetOpsCoding#2)ネットワーク機器のAPIあれこれ入門(NetOpsCoding#2)
ネットワーク機器のAPIあれこれ入門 (NetOpsCoding#2)
 
plotnetcfg入門 | Introduction to plotnetcfg
plotnetcfg入門 | Introduction to plotnetcfgplotnetcfg入門 | Introduction to plotnetcfg
plotnetcfg入門 | Introduction to plotnetcfg
 
Interrupt Affinityについて
Interrupt AffinityについてInterrupt Affinityについて
Interrupt Affinityについて
 
Free bsd jail入門
Free bsd jail入門Free bsd jail入門
Free bsd jail入門
 
Lagopus Switch Usecases
Lagopus Switch UsecasesLagopus Switch Usecases
Lagopus Switch Usecases
 
Introduction to Ostinato , network packet crafting and generator.
Introduction to Ostinato, network packet crafting and generator.Introduction to Ostinato, network packet crafting and generator.
Introduction to Ostinato , network packet crafting and generator.
 
OpenStack + OpenContrailで実現するマルチテナントIaaSのご紹介
OpenStack + OpenContrailで実現するマルチテナントIaaSのご紹介OpenStack + OpenContrailで実現するマルチテナントIaaSのご紹介
OpenStack + OpenContrailで実現するマルチテナントIaaSのご紹介
 
Shusei tomonaga pac_sec_20171026_jp
Shusei tomonaga pac_sec_20171026_jpShusei tomonaga pac_sec_20171026_jp
Shusei tomonaga pac_sec_20171026_jp
 
[CB16] マイクロソフトウィンドウズカーネルのデスノート by Peter Hlavaty & Jin Long
[CB16] マイクロソフトウィンドウズカーネルのデスノート by Peter Hlavaty & Jin Long[CB16] マイクロソフトウィンドウズカーネルのデスノート by Peter Hlavaty & Jin Long
[CB16] マイクロソフトウィンドウズカーネルのデスノート by Peter Hlavaty & Jin Long
 
Dpdk pmd
Dpdk pmdDpdk pmd
Dpdk pmd
 
High Performance Networking with DPDK & Multi/Many Core
High Performance Networking with DPDK & Multi/Many CoreHigh Performance Networking with DPDK & Multi/Many Core
High Performance Networking with DPDK & Multi/Many Core
 
HTTP/2, QUIC入門
HTTP/2, QUIC入門HTTP/2, QUIC入門
HTTP/2, QUIC入門
 
Node-v0.12のTLSを256倍使いこなす方法
Node-v0.12のTLSを256倍使いこなす方法Node-v0.12のTLSを256倍使いこなす方法
Node-v0.12のTLSを256倍使いこなす方法
 

Similar a Abusing Interrupts for Reliable Windows Kernel Exploitation (ja)

図解で理解するvetKD
図解で理解するvetKD図解で理解するvetKD
図解で理解するvetKDryoo toku
 
Secure element for IoT device
Secure element for IoT deviceSecure element for IoT device
Secure element for IoT deviceKentaro Mitsuyasu
 
Exploring the x64
Exploring the x64Exploring the x64
Exploring the x64FFRI, Inc.
 
Secure scheme script suite
Secure scheme script suiteSecure scheme script suite
Secure scheme script suiteTod Morita
 
Secure Scheme Script Suite
Secure Scheme Script SuiteSecure Scheme Script Suite
Secure Scheme Script Suiteshibuya_lisp
 
はじめてのDockerパーフェクトガイド(2017年版)
はじめてのDockerパーフェクトガイド(2017年版)はじめてのDockerパーフェクトガイド(2017年版)
はじめてのDockerパーフェクトガイド(2017年版)Hiroshi Hayakawa
 
みんなのブログ紹介
みんなのブログ紹介みんなのブログ紹介
みんなのブログ紹介Sanae Taniguchi
 
Tremaで試すFirewall
Tremaで試すFirewallTremaで試すFirewall
Tremaで試すFirewallM Hagiwara
 
仮想化技術によるマルウェア対策とその問題点
仮想化技術によるマルウェア対策とその問題点仮想化技術によるマルウェア対策とその問題点
仮想化技術によるマルウェア対策とその問題点Kuniyasu Suzaki
 
近頃のDockerネットワーク
近頃のDockerネットワーク近頃のDockerネットワーク
近頃のDockerネットワークYuji Oshima
 
Rancherなら簡単にできる マルチクラウドコンテナー
Rancherなら簡単にできる マルチクラウドコンテナーRancherなら簡単にできる マルチクラウドコンテナー
Rancherなら簡単にできる マルチクラウドコンテナーIDC Frontier
 
コンテナ型仮想化とはなんだったのか
コンテナ型仮想化とはなんだったのかコンテナ型仮想化とはなんだったのか
コンテナ型仮想化とはなんだったのかえむ ばーど
 
Dbts2012 unconference wttrw_yazekatsu_publish
Dbts2012 unconference wttrw_yazekatsu_publishDbts2012 unconference wttrw_yazekatsu_publish
Dbts2012 unconference wttrw_yazekatsu_publishYohei Azekatsu
 
Open vSwitchソースコードの全体像
Open vSwitchソースコードの全体像 Open vSwitchソースコードの全体像
Open vSwitchソースコードの全体像 Sho Shimizu
 
OpenStackで始めるクラウド環境構築入門
OpenStackで始めるクラウド環境構築入門OpenStackで始めるクラウド環境構築入門
OpenStackで始めるクラウド環境構築入門VirtualTech Japan Inc.
 
Azureの上におとりを置いて、世界中から攻撃される様子を観察した話
Azureの上におとりを置いて、世界中から攻撃される様子を観察した話Azureの上におとりを置いて、世界中から攻撃される様子を観察した話
Azureの上におとりを置いて、世界中から攻撃される様子を観察した話Ryuki Yoshimatsu
 
OpenStackで始めるクラウド環境構築入門
OpenStackで始めるクラウド環境構築入門OpenStackで始めるクラウド環境構築入門
OpenStackで始めるクラウド環境構築入門VirtualTech Japan Inc.
 

Similar a Abusing Interrupts for Reliable Windows Kernel Exploitation (ja) (20)

図解で理解するvetKD
図解で理解するvetKD図解で理解するvetKD
図解で理解するvetKD
 
Secure element for IoT device
Secure element for IoT deviceSecure element for IoT device
Secure element for IoT device
 
Exploring the x64
Exploring the x64Exploring the x64
Exploring the x64
 
Secure scheme script suite
Secure scheme script suiteSecure scheme script suite
Secure scheme script suite
 
Secure Scheme Script Suite
Secure Scheme Script SuiteSecure Scheme Script Suite
Secure Scheme Script Suite
 
Interrupts on xv6
Interrupts on xv6Interrupts on xv6
Interrupts on xv6
 
はじめてのDockerパーフェクトガイド(2017年版)
はじめてのDockerパーフェクトガイド(2017年版)はじめてのDockerパーフェクトガイド(2017年版)
はじめてのDockerパーフェクトガイド(2017年版)
 
みんなのブログ紹介
みんなのブログ紹介みんなのブログ紹介
みんなのブログ紹介
 
Tremaで試すFirewall
Tremaで試すFirewallTremaで試すFirewall
Tremaで試すFirewall
 
仮想化技術によるマルウェア対策とその問題点
仮想化技術によるマルウェア対策とその問題点仮想化技術によるマルウェア対策とその問題点
仮想化技術によるマルウェア対策とその問題点
 
Docker入門 OSC 2018 Tokyo/Spring
Docker入門 OSC 2018 Tokyo/SpringDocker入門 OSC 2018 Tokyo/Spring
Docker入門 OSC 2018 Tokyo/Spring
 
近頃のDockerネットワーク
近頃のDockerネットワーク近頃のDockerネットワーク
近頃のDockerネットワーク
 
Rancherなら簡単にできる マルチクラウドコンテナー
Rancherなら簡単にできる マルチクラウドコンテナーRancherなら簡単にできる マルチクラウドコンテナー
Rancherなら簡単にできる マルチクラウドコンテナー
 
コンテナ型仮想化とはなんだったのか
コンテナ型仮想化とはなんだったのかコンテナ型仮想化とはなんだったのか
コンテナ型仮想化とはなんだったのか
 
Dbts2012 unconference wttrw_yazekatsu_publish
Dbts2012 unconference wttrw_yazekatsu_publishDbts2012 unconference wttrw_yazekatsu_publish
Dbts2012 unconference wttrw_yazekatsu_publish
 
Open vSwitchソースコードの全体像
Open vSwitchソースコードの全体像 Open vSwitchソースコードの全体像
Open vSwitchソースコードの全体像
 
OpenStackで始めるクラウド環境構築入門
OpenStackで始めるクラウド環境構築入門OpenStackで始めるクラウド環境構築入門
OpenStackで始めるクラウド環境構築入門
 
d-kami x86-2
d-kami x86-2d-kami x86-2
d-kami x86-2
 
Azureの上におとりを置いて、世界中から攻撃される様子を観察した話
Azureの上におとりを置いて、世界中から攻撃される様子を観察した話Azureの上におとりを置いて、世界中から攻撃される様子を観察した話
Azureの上におとりを置いて、世界中から攻撃される様子を観察した話
 
OpenStackで始めるクラウド環境構築入門
OpenStackで始めるクラウド環境構築入門OpenStackで始めるクラウド環境構築入門
OpenStackで始めるクラウド環境構築入門
 

Más de inaz2

Can We Prevent Use-after-free Attacks?
Can We Prevent Use-after-free Attacks?Can We Prevent Use-after-free Attacks?
Can We Prevent Use-after-free Attacks?inaz2
 
Why is Security Management So Hard?
Why is Security Management So Hard?Why is Security Management So Hard?
Why is Security Management So Hard?inaz2
 
HTTPプロクシライブラリproxy2の設計と実装
HTTPプロクシライブラリproxy2の設計と実装HTTPプロクシライブラリproxy2の設計と実装
HTTPプロクシライブラリproxy2の設計と実装inaz2
 
Protecting Passwords
Protecting PasswordsProtecting Passwords
Protecting Passwordsinaz2
 
Self Introduction & The Story that I Tried to Make Sayonara ROP Chain in Linux
Self Introduction & The Story that I Tried to Make Sayonara ROP Chain in LinuxSelf Introduction & The Story that I Tried to Make Sayonara ROP Chain in Linux
Self Introduction & The Story that I Tried to Make Sayonara ROP Chain in Linuxinaz2
 
Abusing Interrupts for Reliable Windows Kernel Exploitation (en)
Abusing Interrupts for Reliable Windows Kernel Exploitation (en)Abusing Interrupts for Reliable Windows Kernel Exploitation (en)
Abusing Interrupts for Reliable Windows Kernel Exploitation (en)inaz2
 
WinDbg Primer
WinDbg PrimerWinDbg Primer
WinDbg Primerinaz2
 
proxy2: HTTPS pins and needles
proxy2: HTTPS pins and needlesproxy2: HTTPS pins and needles
proxy2: HTTPS pins and needlesinaz2
 
CRYPT+YOU, UNDERSTAND TODAY!
CRYPT+YOU, UNDERSTAND TODAY!CRYPT+YOU, UNDERSTAND TODAY!
CRYPT+YOU, UNDERSTAND TODAY!inaz2
 
Making a Proxy for Fun and Profit
Making a Proxy for Fun and ProfitMaking a Proxy for Fun and Profit
Making a Proxy for Fun and Profitinaz2
 
Sniffing BitTorrent DHT ~人はBTで何を落とすのか~
Sniffing BitTorrent DHT ~人はBTで何を落とすのか~Sniffing BitTorrent DHT ~人はBTで何を落とすのか~
Sniffing BitTorrent DHT ~人はBTで何を落とすのか~inaz2
 

Más de inaz2 (11)

Can We Prevent Use-after-free Attacks?
Can We Prevent Use-after-free Attacks?Can We Prevent Use-after-free Attacks?
Can We Prevent Use-after-free Attacks?
 
Why is Security Management So Hard?
Why is Security Management So Hard?Why is Security Management So Hard?
Why is Security Management So Hard?
 
HTTPプロクシライブラリproxy2の設計と実装
HTTPプロクシライブラリproxy2の設計と実装HTTPプロクシライブラリproxy2の設計と実装
HTTPプロクシライブラリproxy2の設計と実装
 
Protecting Passwords
Protecting PasswordsProtecting Passwords
Protecting Passwords
 
Self Introduction & The Story that I Tried to Make Sayonara ROP Chain in Linux
Self Introduction & The Story that I Tried to Make Sayonara ROP Chain in LinuxSelf Introduction & The Story that I Tried to Make Sayonara ROP Chain in Linux
Self Introduction & The Story that I Tried to Make Sayonara ROP Chain in Linux
 
Abusing Interrupts for Reliable Windows Kernel Exploitation (en)
Abusing Interrupts for Reliable Windows Kernel Exploitation (en)Abusing Interrupts for Reliable Windows Kernel Exploitation (en)
Abusing Interrupts for Reliable Windows Kernel Exploitation (en)
 
WinDbg Primer
WinDbg PrimerWinDbg Primer
WinDbg Primer
 
proxy2: HTTPS pins and needles
proxy2: HTTPS pins and needlesproxy2: HTTPS pins and needles
proxy2: HTTPS pins and needles
 
CRYPT+YOU, UNDERSTAND TODAY!
CRYPT+YOU, UNDERSTAND TODAY!CRYPT+YOU, UNDERSTAND TODAY!
CRYPT+YOU, UNDERSTAND TODAY!
 
Making a Proxy for Fun and Profit
Making a Proxy for Fun and ProfitMaking a Proxy for Fun and Profit
Making a Proxy for Fun and Profit
 
Sniffing BitTorrent DHT ~人はBTで何を落とすのか~
Sniffing BitTorrent DHT ~人はBTで何を落とすのか~Sniffing BitTorrent DHT ~人はBTで何を落とすのか~
Sniffing BitTorrent DHT ~人はBTで何を落とすのか~
 

Último

IoT in the era of generative AI, Thanks IoT ALGYAN.pptx
IoT in the era of generative AI, Thanks IoT ALGYAN.pptxIoT in the era of generative AI, Thanks IoT ALGYAN.pptx
IoT in the era of generative AI, Thanks IoT ALGYAN.pptxAtomu Hidaka
 
新人研修のまとめ 2024/04/12の勉強会で発表されたものです。
新人研修のまとめ       2024/04/12の勉強会で発表されたものです。新人研修のまとめ       2024/04/12の勉強会で発表されたものです。
新人研修のまとめ 2024/04/12の勉強会で発表されたものです。iPride Co., Ltd.
 
Amazon SES を勉強してみる その12024/04/12の勉強会で発表されたものです。
Amazon SES を勉強してみる その12024/04/12の勉強会で発表されたものです。Amazon SES を勉強してみる その12024/04/12の勉強会で発表されたものです。
Amazon SES を勉強してみる その12024/04/12の勉強会で発表されたものです。iPride Co., Ltd.
 
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略Ryo Sasaki
 
20240412_HCCJP での Windows Server 2025 Active Directory
20240412_HCCJP での Windows Server 2025 Active Directory20240412_HCCJP での Windows Server 2025 Active Directory
20240412_HCCJP での Windows Server 2025 Active Directoryosamut
 
UPWARD_share_company_information_20240415.pdf
UPWARD_share_company_information_20240415.pdfUPWARD_share_company_information_20240415.pdf
UPWARD_share_company_information_20240415.pdffurutsuka
 
Postman LT Fukuoka_Quick Prototype_By Daniel
Postman LT Fukuoka_Quick Prototype_By DanielPostman LT Fukuoka_Quick Prototype_By Daniel
Postman LT Fukuoka_Quick Prototype_By Danieldanielhu54
 
PHP-Conference-Odawara-2024-04-000000000
PHP-Conference-Odawara-2024-04-000000000PHP-Conference-Odawara-2024-04-000000000
PHP-Conference-Odawara-2024-04-000000000Shota Ito
 
スマートフォンを用いた新生児あやし動作の教示システム
スマートフォンを用いた新生児あやし動作の教示システムスマートフォンを用いた新生児あやし動作の教示システム
スマートフォンを用いた新生児あやし動作の教示システムsugiuralab
 

Último (9)

IoT in the era of generative AI, Thanks IoT ALGYAN.pptx
IoT in the era of generative AI, Thanks IoT ALGYAN.pptxIoT in the era of generative AI, Thanks IoT ALGYAN.pptx
IoT in the era of generative AI, Thanks IoT ALGYAN.pptx
 
新人研修のまとめ 2024/04/12の勉強会で発表されたものです。
新人研修のまとめ       2024/04/12の勉強会で発表されたものです。新人研修のまとめ       2024/04/12の勉強会で発表されたものです。
新人研修のまとめ 2024/04/12の勉強会で発表されたものです。
 
Amazon SES を勉強してみる その12024/04/12の勉強会で発表されたものです。
Amazon SES を勉強してみる その12024/04/12の勉強会で発表されたものです。Amazon SES を勉強してみる その12024/04/12の勉強会で発表されたものです。
Amazon SES を勉強してみる その12024/04/12の勉強会で発表されたものです。
 
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
 
20240412_HCCJP での Windows Server 2025 Active Directory
20240412_HCCJP での Windows Server 2025 Active Directory20240412_HCCJP での Windows Server 2025 Active Directory
20240412_HCCJP での Windows Server 2025 Active Directory
 
UPWARD_share_company_information_20240415.pdf
UPWARD_share_company_information_20240415.pdfUPWARD_share_company_information_20240415.pdf
UPWARD_share_company_information_20240415.pdf
 
Postman LT Fukuoka_Quick Prototype_By Daniel
Postman LT Fukuoka_Quick Prototype_By DanielPostman LT Fukuoka_Quick Prototype_By Daniel
Postman LT Fukuoka_Quick Prototype_By Daniel
 
PHP-Conference-Odawara-2024-04-000000000
PHP-Conference-Odawara-2024-04-000000000PHP-Conference-Odawara-2024-04-000000000
PHP-Conference-Odawara-2024-04-000000000
 
スマートフォンを用いた新生児あやし動作の教示システム
スマートフォンを用いた新生児あやし動作の教示システムスマートフォンを用いた新生児あやし動作の教示システム
スマートフォンを用いた新生児あやし動作の教示システム
 

Abusing Interrupts for Reliable Windows Kernel Exploitation (ja)

  • 1. Abusing Interrupts for Reliable Windows Kernel Exploitation 2015/11/14 AVTOKYO2015 inaz2
  • 2. About me • inaz2 • Security engineer & Python programmer • Working at NTT Communications • ブログ「ももいろテクノロジー」 • http://inaz2.hatenablog.com/ 2
  • 3. Windows kernel exploitation • カーネルランドの脆弱性を突くタイプの攻撃 • デバイスドライバの脆弱性を含む • Write-what-where condition/vulnerabilityが広く利用される • 任意のアドレスに任意の値を書き込むことが可能な脆弱性 • 自身のプロセスの権限を昇格させるShellcodeを実行させる • その後、管理者コマンドプロンプトを起動する 3
  • 4. Classic technique: halDispatchTable overwrite • nt!NtQueryIntervalProfile 内部API • nt!KeQueryIntervalProfile 経由で [nt!halDispatchTable+4] が呼ばれる • [nt!halDispatchTable+4] の値をShellcodeのアドレスに書き換える 4
  • 5. Replace token shellcode • Systemプロセス (PID=4) のToken Objectをコピー 5 41414141hは対象となる プロセスのPIDに置き換える
  • 6. It works but … • nt!NtQueryIntervalProfile の実装に依存 • 将来的に実装が変更される可能性がある(つまり、確実ではない) • より確実な書き換えのターゲットは存在するか? 6
  • 7. It works but … • nt!NtQueryIntervalProfile の実装に依存 • 将来的に実装が変更される可能性がある(つまり、確実ではない) • より確実な書き換えのターゲットは存在するか? 7
  • 8. x86 interrupt handling • ハードウェア割り込み(キーボード入力など)とソフトウェア割り込み (ゼロ除算など)がある • ソフトウェア割り込みは “int n” 命令で発生させることができる • Interrupt Descriptor Table (IDT) • Interrupt Software Routines (ISR) と呼ばれる割り込みハンドラ関数のアドレ スを保持 • ISRはRing 0で実行される • 要するに、なんでもできる 8
  • 9. x86 privilege levels (protection rings) • 0から3までの4つの権限レベル • 数字が大きいほど権限が低い • Windowsを含むほとんどのOSは、2つのRingのみを利用する • Ring 0はカーネルモード、Ring 3はユーザモードに対応 9
  • 10. Interrupt Descriptor Table (1/4) • Intel Developer’s Manual Volume 3, Chapter 6 10
  • 11. Interrupt Descriptor Table (2/4) • Intel Developer’s Manual Volume 3, Chapter 6 11 DPL=3 ならRing 3から 割り込み可能
  • 12. Interrupt Descriptor Table (3/4) • WinDbg (KD) view 12
  • 13. Interrupt Descriptor Table (4/4) • Interrupt #0に対応するInterrupt Gateの書き換え 13 414184fc 000884fc 4141ee00 DPL=3
  • 14. IDT overwrite technique 14 IDTが置かれているアドレスを取得する Interrupt #nに対応するInterrupt Gateを書き換える “int n” 命令でInterrupt #nを発生させる Shellcodeが実行される
  • 16. Find the write-what-where vulnerability • ここでは、脆弱なデバイスドライバを用意しインストールする • IOCTL経由でwrite-what-where脆弱性への攻撃を可能にする 17
  • 17. Get the IDT address (1/2) 18 Ring 3でも使える!
  • 18. Get the IDT address (2/2) • IDTが置かれているアドレスを返す関数 19 alignmentを無効化
  • 19. Write the Interrupt Software Routine (ISR) • fsセグメントレジスタの値を切り換える • 0x33 (TEB) → 0x30 (KPCR) • ISRの直後にあるShellcodeをcallする • ret命令の代わりにiretd命令でリターンする 20
  • 20. Allocate memory & put the codes • 0x41410000から0x41420000にnop-sledを確保する • 0x41420000にISR code + shellcodeを置く 21
  • 21. Overwrite the Interrupt Gate • Interrupt #32に対応するInterrupt Gateの後半4バイトを0x4141ee00 で書き換える • #32-255はuser-defined interruptsと定義されている(予約されていない) 22
  • 22. Trigger the software interrupt • “int 32” を実行する • ISRを経由してShellcodeが実行される • 続けて、cmd.exeを起動する 23
  • 24. What about 64 bit Windows? • Interrupt Gateのサイズが16バイトになる • 0x100000000バイトのnop-sledは厳しいため、Interrupt Gate全体を 書き換える必要がある(つまり、2回書き込む) • なぜか割り込みを発生させたタイミングでVirtualBox VMがハング アップしてしまう(PatchGuard??) 25
  • 25. Comparison with halDispatchTable overwrite • Pros • あらゆるバージョンのx86-based Windowsに対して確実 • 書き換えのターゲットとなるアドレスの特定が簡単 • Cons • ISRのコードを用意する必要がある • nop-sledを確保する必要がある • 64 bitでの動作を検証できていない 26
  • 26. Recap • IDT overwriteはあらゆるバージョンのx86-based Windowsに対して 確実 • カーネル実装の変更に依存しない • IDTが置かれているアドレスはRing 3でも取得できる • There’s more than one way to do it  27
  • 27. References • Windowsでデバイスドライバの脆弱性からの権限昇格をやってみる - もも いろテクノロジー • http://inaz2.hatenablog.com/entry/2015/09/15/121926 • Project Zero: One font vulnerability to rule them all #4: Windows 8.1 64-bit sandbox escape exploitation • http://googleprojectzero.blogspot.jp/2015/08/one-font-vulnerability-to-rule- them-all_21.html • Interrupt Service Routines - OSDev Wiki • http://wiki.osdev.org/Interrupt_Service_Routines • SIMPLE IS BETTER: Kernel Information Leak with Unprivileged Instructions (SIDT, SGDT) on x86 - WHY ? • http://hypervsir.blogspot.jp/2014/10/kernel-information-leak-with.html 28