SlideShare a Scribd company logo
redhung@hung.red
TA-LESSON @ INFORMATION SECURITY
— BINARY EXPLOITATION ( PWN )
>_ ECHO `WHOAMI`
Interning at CHT Security Co., Ltd.
CTF Player
Woof Woof Pwning dog 🐶
Focusing on Reversing, Pwning
>_ CAT ./OVERVIEW
What Is
Pwn
Program
Section
Security
Options
Buffer
Overflow
0x0
0x1
0x2
0x3
What is Pwn
>_ WHAT IS PWN
Start EndInput Output
簡單來說,控制程式流程,進而達到我們的目的,稱之為Pwn
藉由使用者輸入(Input)的地方來輸入偽造好的Payload
藉由螢幕輸出(Output)的地方來Leak程式資訊
>_ WHAT IS PWN
Start
Segmetation
FaultInput Output
藉由惡意的輸入來導致程式Crash
則代表此程式有⼈人為疏漏的地⽅方,例例如陣列列邊界超越、指標釋放後未清除
攻擊者則藉由這些漏洞洞來來構造完整的Payload進⾏行行攻擊
>_ WHAT IS PWN
Start
Get
Shell !!
Input Output
攻擊者想要的並不只是讓程式Crash
攻擊者的最終⽬目的是藉由程式漏洞洞來來獲取運⾏行行程式的主機控制權
經由⼀一個漏洞洞來來讓我們串串起攻擊鍊鍊,從運⾏行行程式突破到主機內部
Program Section
>_ PROGRAM SECTION
Stack
Heap
BSS
Data
Text
Stack
Heap
BSS
Data
Text
>_ PROGRAM SECTION
Stack
Heap
BSS
Data
Text
Text
存放程式碼
可讀、不可寫、可執⾏行行
( r - x )
>_ PROGRAM SECTION
Stack
Heap
BSS
Data
Text
Data
存放初始化過的
全域變數或區域靜態變數
E.g. int i = 1;
>_ PROGRAM SECTION
Stack
Heap
BSS
Data
Text
BSS
存放未初始化過的
全域變數或區域靜態變數
E.g. int i;
>_ PROGRAM SECTION
Stack
Heap
BSS
Data
Text
Heap
動態分配的記憶體空間
Malloc()、Free()
由低位址往⾼高位址長
>_ PROGRAM SECTION
Stack
Heap
BSS
Data
Text
Stack
存放區域變數、
參參數、return address
由⾼高位址往低位址長
>_ PROGRAM SECTION
Stack Frame
Local variables
saved rbp
canary
return address
Stack存放了了許多重要資訊
因此在Pwn的領域中
玩轉Stack是⼀一項非常重要
的技術
>_ PROGRAM SECTION
Stack Frame
0x0 (num)
>_ PROGRAM SECTION
Stack Frame
0x0 (num)
return address (num = num+1)
>_ PROGRAM SECTION
Stack Frame
0x0 (num)
return address (num = num+1)
saved rbp
canary
>_ PROGRAM SECTION
Stack Frame
0x0 (num)
return address (num = num+1)
saved rbp
canary
>_ PROGRAM SECTION
Stack Frame
0x0 (num)
Security Options
>_ SECURITY OPTIONS
RELRO
Stack Canary
NX ( No-Execute )
PIE
ASLR
>_ SECURITY OPTIONS
RELRO — RELocation Read Only
Level : No / Partial / Full
No RELRO — Link map 可寫 、 GOT 可寫
Partial RELRO — Link map 不可寫、GOT可寫
Full RELRO — Link map 不可寫、GOT不可寫
>_ SECURITY OPTIONS
Stack Canary
在 SAVED RBP 之前塞⼀一個隨機的值,
在 return 前檢查是否⼀一致,
不⼀一致的話則將此次 input abort,並結束程式
>_ SECURITY OPTIONS
NX — No execute
⼜又稱 DEP (Data Execution Prevention)
可寫的不可執⾏行行,可執⾏行行的不可寫
>_ SECURITY OPTIONS
PIE — Position Independent Executable
開啟時,Data段以及Text段位址隨機化
關閉時,Data段以及Text段位址固定
>_ SECURITY OPTIONS
ASLR — Address Space Layout Randomization
記憶體位址隨機變化
每次執⾏行行時,Stack、Heap、libc的位址都不⼀一樣
ASLR是系統設定,並不是程式設定
Buffer Overflow
>_ BUFFER OVERFLOW
當程式沒有限制使⽤用者輸入,
⽽而使⽤用者輸入超出字元陣列列的範圍,
即造成Buffer Overflow
>_ BUFFER OVERFLOW
Local variables
saved rbp
canary
return address
>_ BUFFER OVERFLOW
AAAAAAAAAAAAA
AAAAAAAAAAAAA
AAAAAAAAAAAAA
AAAAAAAAAAAAA
saved rbp
canary
return address
>_ BUFFER OVERFLOW
AAAAAAAAAAAAA
AAAAAAAAAAAAA
AAAAAAAAAAAAA
AAAAAAAAAAAAA
AAAAAAAAAAAAA
AAAAAAAAAAAAA
AAAAAAAAAAAAA
>_ BUFFER OVERFLOW
AAAAAAAAAAAAA
AAAAAAAAAAAAA
AAAAAAAAAAAAA
AAAAAAAAAAAAA
AAAAAAAAAAAAA
AAAAAAAAAAAAA
AAAAAAAAAAAAA
CRASHED
>_ BUFFER OVERFLOW
AAAAAAAAAAAAA
AAAAAAAAAAAAA
AAAAAAAAAAAAA
AAAAAAAAAAAAA
AAAAAAAAAAAAA
AAAAAAAAAAAAA
System(/bin/sh)
>_ BUFFER OVERFLOW
AAAAAAAAAAAAA
AAAAAAAAAAAAA
AAAAAAAAAAAAA
AAAAAAAAAAAAA
AAAAAAAAAAAAA
AAAAAAAAAAAAA
System(/bin/sh)
GET SHELL !!
LAB
THANK YOU!
redhung@hung.red
r3dhun9 @r3dhun9 Philip Chen

More Related Content

More from Redhung @ Nationtal Chung Cheng University, Chiayi, Taiwan.

Reverse Engineering - Assembly & Introduction
Reverse Engineering - Assembly & IntroductionReverse Engineering - Assembly & Introduction
Reverse Engineering - Assembly & Introduction
Redhung @ Nationtal Chung Cheng University, Chiayi, Taiwan.
 
TA Lesson3 - Method
TA Lesson3 - MethodTA Lesson3 - Method
Web Introduction
Web IntroductionWeb Introduction
Java - TA課 - Let's Begin
Java - TA課 - Let's BeginJava - TA課 - Let's Begin
Java - TA課 - 開發環境
Java - TA課 - 開發環境Java - TA課 - 開發環境
IoT Penetration Talk
IoT Penetration TalkIoT Penetration Talk
Introduction to computer network
Introduction to computer networkIntroduction to computer network
Assembly Language Redhung ( x86 ) @ TDOH
Assembly Language Redhung ( x86 ) @ TDOHAssembly Language Redhung ( x86 ) @ TDOH
Assembly Language Redhung ( x86 ) @ TDOH
Redhung @ Nationtal Chung Cheng University, Chiayi, Taiwan.
 
TP-Link SR20 Zero-day attack
TP-Link SR20 Zero-day attackTP-Link SR20 Zero-day attack
滲透測試入門 Penetration test - white hat hacking introduction
 滲透測試入門 Penetration test - white hat hacking introduction 滲透測試入門 Penetration test - white hat hacking introduction
滲透測試入門 Penetration test - white hat hacking introduction
Redhung @ Nationtal Chung Cheng University, Chiayi, Taiwan.
 

More from Redhung @ Nationtal Chung Cheng University, Chiayi, Taiwan. (10)

Reverse Engineering - Assembly & Introduction
Reverse Engineering - Assembly & IntroductionReverse Engineering - Assembly & Introduction
Reverse Engineering - Assembly & Introduction
 
TA Lesson3 - Method
TA Lesson3 - MethodTA Lesson3 - Method
TA Lesson3 - Method
 
Web Introduction
Web IntroductionWeb Introduction
Web Introduction
 
Java - TA課 - Let's Begin
Java - TA課 - Let's BeginJava - TA課 - Let's Begin
Java - TA課 - Let's Begin
 
Java - TA課 - 開發環境
Java - TA課 - 開發環境Java - TA課 - 開發環境
Java - TA課 - 開發環境
 
IoT Penetration Talk
IoT Penetration TalkIoT Penetration Talk
IoT Penetration Talk
 
Introduction to computer network
Introduction to computer networkIntroduction to computer network
Introduction to computer network
 
Assembly Language Redhung ( x86 ) @ TDOH
Assembly Language Redhung ( x86 ) @ TDOHAssembly Language Redhung ( x86 ) @ TDOH
Assembly Language Redhung ( x86 ) @ TDOH
 
TP-Link SR20 Zero-day attack
TP-Link SR20 Zero-day attackTP-Link SR20 Zero-day attack
TP-Link SR20 Zero-day attack
 
滲透測試入門 Penetration test - white hat hacking introduction
 滲透測試入門 Penetration test - white hat hacking introduction 滲透測試入門 Penetration test - white hat hacking introduction
滲透測試入門 Penetration test - white hat hacking introduction
 

Recently uploaded

Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
ICS
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
mz5nrf0n
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
Rakesh Kumar R
 
Liberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptxLiberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptx
Massimo Artizzu
 
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
gapen1
 
What next after learning python programming basics
What next after learning python programming basicsWhat next after learning python programming basics
What next after learning python programming basics
Rakesh Kumar R
 
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
Bert Jan Schrijver
 
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
safelyiotech
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
Lecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptxLecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptx
TaghreedAltamimi
 
Preparing Non - Technical Founders for Engaging a Tech Agency
Preparing Non - Technical Founders for Engaging  a  Tech AgencyPreparing Non - Technical Founders for Engaging  a  Tech Agency
Preparing Non - Technical Founders for Engaging a Tech Agency
ISH Technologies
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
Remote DBA Services
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
Green Software Development
 
Malibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed RoundMalibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed Round
sjcobrien
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
dakas1
 
fiscal year variant fiscal year variant.
fiscal year variant fiscal year variant.fiscal year variant fiscal year variant.
fiscal year variant fiscal year variant.
AnkitaPandya11
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
dakas1
 

Recently uploaded (20)

Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
 
Liberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptxLiberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptx
 
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
 
What next after learning python programming basics
What next after learning python programming basicsWhat next after learning python programming basics
What next after learning python programming basics
 
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
 
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
Lecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptxLecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptx
 
Preparing Non - Technical Founders for Engaging a Tech Agency
Preparing Non - Technical Founders for Engaging  a  Tech AgencyPreparing Non - Technical Founders for Engaging  a  Tech Agency
Preparing Non - Technical Founders for Engaging a Tech Agency
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
 
Malibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed RoundMalibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed Round
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
 
fiscal year variant fiscal year variant.
fiscal year variant fiscal year variant.fiscal year variant fiscal year variant.
fiscal year variant fiscal year variant.
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
 

TA Lesson Binary Exploitation (Pwn)