SlideShare a Scribd company logo
1 of 47
Download to read offline
CNIT 127: Exploit Development



Ch 1: Before you begin
Updated 1-14-16
Basic Concepts
Vulnerability
• A flaw in a system that allows an attacker
to do something the designer did not
intend, such as
– Denial of service (loss of availability)
– Elevating privileges (e.g. user to
Administrator)
– Remote Code Execution (typically a remote
shell)
Exploit
• Exploit (v.)
– To take advantage of a vulnerability and
cause a result the designer did not intend
• Exploit (n.)
– The code that is used to take advantage of a
vulnerability
– Also called a Proof of Concept (PoC)
0Day and Fuzzer
• 0Day
– An exploit that has not been publicly
disclosed
– Sometimes used to refer to the vulnerability
itself
• Fuzzer
– A tool that sends a large range of unexpected
input values to a system
– The purpose is to find bugs which could later
be exploited
Memory Management
• Specifically for Intel 32-bit architecture
• Most exploits we'll use involve
overwriting or overflowing one portion of
memory into another
• Understanding memory management is
therefore crucial
Instructions and Data
• There is no intrinsic difference between
data and executable instructions
– Although there are some defenses like Data
Execution Prevention
• They are both just a series of bytes
• This ambiguity makes system exploitation
possible
Program Address Space
• Created when a program is run, including
– Actual program instructions
– Required data
• Three types of segments
– .text contains program instructions (read-
only)
– .data contains static initialized global
variables (writable)
– .bss contains uninitialized global variables
(writable)
Stack
• Last In First Out (LIFO)
• Most recently pushed data is the first popped
• Ideal for storing transitory information
– Local variables
– Information relating to function calls
– Other information used to clean up the stack
after a function is called
• Grows down
– As more data is added, it uses lower address
values
Heap
• Holds dynamic variables
• Roughly First In First Out (FIFO)
• Grows up in address space
Program Layout in RAM
• From link Ch 1a (.bss = Block Started by Symbols)
Assembly
Assembly Language
• Different versions for each type of
processor
• x86 – 32-bit Intel (most common)
• x64 – 64-bit Intel
• SPARC, PowerPC, MIPS, ARM – others
• Windows runs on x86 or x64
• x64 machines can run x86 programs
• Most malware is designed for x86
Instructions
• Mnemonic followed by operands
• mov ecx 0x42
– Move into Extended C register the value 42
(hex)
• mov ecx is 0xB9 in hexadecimal
• The value 42 is 0x4200000000
• In binary this instruction is
• 0xB942000000
Endianness
• Big-Endian
– Most significant byte first
– 0x42 as a 64-bit value would be 0x00000042
• Little-Endian
– Least significant byte first
– 0x42 as a 64-bit value would be 0x42000000
• Network data uses big-endian
• x86 programs use little-endian
IP Addresses
• 127.0.0.1, or in hex, 7F 00 00 01
• Sent over the network as 0x7F000001
• Stored in RAM as 0x0100007F
Operands
• Immediate
– Fixed values like 0x42
• Register
– eax, ebx, ecx, and so on
• Memory address
– Denoted with brackets, like [eax]
Registers
Registers
• General registers
– Used by the CPU during execution
• Segment registers
– Used to track sections of memory
• Status flags
– Used to make decisions
• Instruction pointer
– Address of next instruction to execute
Size of Registers
• General registers are all 32 bits in size
– Can be referenced as either 32bits (edx) or 16
bits (dx)
• Four registers (eax, ebx, ecx, edx) can
also be referenced as 8-bit values
– AL is lowest 8 bits
– AH is higher 8 bits
General Registers
• Typically store data or memory addresses
• Normally interchangeable
• Some instructions reference specific
registers
– Multiplication and division use EAX and EDX
• Conventions
– Compilers use registers in consistent ways
– EAX contains the return value for function
calls
Flags
• EFLAGS is a status register
• 32 bits in size
• Each bit is a flag
• SET (1) or Cleared (0)
Important Flags
• ZF Zero flag
– Set when the result of an operation is zero
• CF Carry flag
– Set when result is too large or small for
destination
• SF Sign Flag
– Set when result is negative, or when most
significant bit is set after arithmetic
• TF Trap Flag
– Used for debugging—if set, processor executes
only one instruction at a time
EIP (Extended Instruction Pointer)
• Contains the memory address of the next
instruction to be executed
• If EIP contains wrong data, the CPU will
fetch non-legitimate instructions and
crash
• Buffer overflows target EIP
Simple Instructions
Simple Instructions
• mov destination, source
– Moves data from one location to another
• Intel format is favored by Windows
developers, with destination first
Simple Instructions
• Remember indirect addressing
– [ebx] means the memory location pointed to
by EBX
lea (Load Effective Address)
• lea destination, source
• lea eax, [ebx+8]
– Puts ebx + 8 into eax
• Compare
– mov eax, [ebx+8]
– Moves the data at location ebx+8 into eax
Arithmetic
• sub Subtracts
• add Adds
• inc Increments
• dec Decrements
• mul Multiplies
• div Divides
NOP
• Does nothing
• 0x90
• Commonly used as a NOP Sled
• Allows attackers to run code even if they
are imprecise about jumping to it
The Stack
• Memory for functions, local variables, and
flow control
• Last in, First out
• ESP (Extended Stack Pointer) – top of stack
• EBP (Extended Base Pointer) – bottom of
stack
• PUSH puts data on the stack
• POP takes data off the stack
Other Stack Instructions
• All used with functions
– Call
– Leave
– Enter
– Ret
Function Calls
• Small programs that do one thing and
return, like printf()
• Prologue
– Instructions at the start of a function that
prepare stack and registers for the function
to use
• Epilogue
– Instructions at the end of a function that
restore the stack and registers to their state
before the function was called
Conditionals
• test
– Compares two values the way AND does, but
does not alter them
– test eax, eax
• Sets Zero Flag if eax is zero
• cmp eax, ebx
– Sets Zero Flag if the arguments are equal
Branching
• jz loc
– Jump to loc if the Zero Flag is set
• jnz loc
– Jump to loc if the Zero Flag is cleared
C Main Method
• Every C program has a main() function
• int main(int argc, char** argv)
– argc contains the number of arguments on
the command line
– argv is a pointer to an array of names
containing the arguments
Example
• cp foo bar
• argc = 3
• argv[0] = cp
• argv[1] = foo
• argv[2] = bar
Recognizing C Constructs in
Assembly
Incrementing
C
int number;
...
number++;
Assembler
number dw 0
...
mov eax, number
inc eax
mov number, eax
•dw: Define Word
Incrementing
C
int number;
if (number<0)
{
...
}
Assembler
number dw 0
mov eax, number
or eax, eax
jge label
...
label :
•or compares numbers,
like test (link Ch 1b)
Array
C
int array[4];
...
array[2]=9;
Assembler
array dw 0,0,0,0
...
mov ebx, 2
mov array[ebx], 9
Triangle
C
int triangle (int
width, int height)
{
int array[5] =
{0,1,2,3,4};
int area
area = width *
height/2;
return (area);
}

More Related Content

What's hot

Blending MongoDB and RDBMS for ecommerce
Blending MongoDB and RDBMS for ecommerceBlending MongoDB and RDBMS for ecommerce
Blending MongoDB and RDBMS for ecommerce
Steven Francia
 
Bash Shell Scripting
Bash Shell ScriptingBash Shell Scripting
Bash Shell Scripting
Raghu nath
 
Bash shell
Bash shellBash shell
Bash shell
xylas121
 
SANS Forensics 2009 - Memory Forensics and Registry Analysis
SANS Forensics 2009 - Memory Forensics and Registry AnalysisSANS Forensics 2009 - Memory Forensics and Registry Analysis
SANS Forensics 2009 - Memory Forensics and Registry Analysis
mooyix
 

What's hot (20)

Product management class rookie to pro
Product management class rookie to proProduct management class rookie to pro
Product management class rookie to pro
 
Blending MongoDB and RDBMS for ecommerce
Blending MongoDB and RDBMS for ecommerceBlending MongoDB and RDBMS for ecommerce
Blending MongoDB and RDBMS for ecommerce
 
CNIT 126 5: IDA Pro
CNIT 126 5: IDA ProCNIT 126 5: IDA Pro
CNIT 126 5: IDA Pro
 
Windows kernel basic exploit
Windows kernel basic exploitWindows kernel basic exploit
Windows kernel basic exploit
 
Projekte Schneiden
Projekte SchneidenProjekte Schneiden
Projekte Schneiden
 
Instalar SDK Google Cloud
Instalar SDK Google CloudInstalar SDK Google Cloud
Instalar SDK Google Cloud
 
Arch linux
Arch linuxArch linux
Arch linux
 
Bash Shell Scripting
Bash Shell ScriptingBash Shell Scripting
Bash Shell Scripting
 
Version Control with SVN
Version Control with SVNVersion Control with SVN
Version Control with SVN
 
Visualizing Systems with Statemaps
Visualizing Systems with StatemapsVisualizing Systems with Statemaps
Visualizing Systems with Statemaps
 
From oracle to hadoop with Sqoop and other tools
From oracle to hadoop with Sqoop and other toolsFrom oracle to hadoop with Sqoop and other tools
From oracle to hadoop with Sqoop and other tools
 
Optimizing Hive Queries
Optimizing Hive QueriesOptimizing Hive Queries
Optimizing Hive Queries
 
Spark shuffle introduction
Spark shuffle introductionSpark shuffle introduction
Spark shuffle introduction
 
127 Ch 2: Stack overflows on Linux
127 Ch 2: Stack overflows on Linux127 Ch 2: Stack overflows on Linux
127 Ch 2: Stack overflows on Linux
 
MacOS memory allocator (libmalloc) Exploitation
MacOS memory allocator (libmalloc) ExploitationMacOS memory allocator (libmalloc) Exploitation
MacOS memory allocator (libmalloc) Exploitation
 
Hive: Loading Data
Hive: Loading DataHive: Loading Data
Hive: Loading Data
 
Subversion
SubversionSubversion
Subversion
 
Redis + Apache Spark = Swiss Army Knife Meets Kitchen Sink
Redis + Apache Spark = Swiss Army Knife Meets Kitchen SinkRedis + Apache Spark = Swiss Army Knife Meets Kitchen Sink
Redis + Apache Spark = Swiss Army Knife Meets Kitchen Sink
 
Bash shell
Bash shellBash shell
Bash shell
 
SANS Forensics 2009 - Memory Forensics and Registry Analysis
SANS Forensics 2009 - Memory Forensics and Registry AnalysisSANS Forensics 2009 - Memory Forensics and Registry Analysis
SANS Forensics 2009 - Memory Forensics and Registry Analysis
 

Viewers also liked

Viewers also liked (20)

CNIT 127 Ch 2: Stack overflows on Linux
CNIT 127 Ch 2: Stack overflows on LinuxCNIT 127 Ch 2: Stack overflows on Linux
CNIT 127 Ch 2: Stack overflows on Linux
 
CNIT 127 Ch 5: Introduction to heap overflows
CNIT 127 Ch 5: Introduction to heap overflowsCNIT 127 Ch 5: Introduction to heap overflows
CNIT 127 Ch 5: Introduction to heap overflows
 
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 2 of 3)
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 2 of 3)CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 2 of 3)
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 2 of 3)
 
CNIT 127 Ch 4: Introduction to format string bugs (rev. 2-9-17)
CNIT 127 Ch 4: Introduction to format string bugs (rev. 2-9-17)CNIT 127 Ch 4: Introduction to format string bugs (rev. 2-9-17)
CNIT 127 Ch 4: Introduction to format string bugs (rev. 2-9-17)
 
CNIT 121: 2 IR Management Handbook
CNIT 121: 2 IR Management HandbookCNIT 121: 2 IR Management Handbook
CNIT 121: 2 IR Management Handbook
 
CNIT 129S: Securing Web Applications Ch 1-2
CNIT 129S: Securing Web Applications Ch 1-2CNIT 129S: Securing Web Applications Ch 1-2
CNIT 129S: Securing Web Applications Ch 1-2
 
CNIT 129S: 9: Attacking Data Stores (Part 1 of 2)
CNIT 129S: 9: Attacking Data Stores (Part 1 of 2)CNIT 129S: 9: Attacking Data Stores (Part 1 of 2)
CNIT 129S: 9: Attacking Data Stores (Part 1 of 2)
 
CNIT 129S: Ch 5: Bypassing Client-Side Controls
CNIT 129S: Ch 5: Bypassing Client-Side ControlsCNIT 129S: Ch 5: Bypassing Client-Side Controls
CNIT 129S: Ch 5: Bypassing Client-Side Controls
 
CNIT 121: 12 Investigating Windows Systems (Part 2 of 3)
CNIT 121: 12 Investigating Windows Systems (Part 2 of 3)CNIT 121: 12 Investigating Windows Systems (Part 2 of 3)
CNIT 121: 12 Investigating Windows Systems (Part 2 of 3)
 
CNIT 129S: 8: Attacking Access Controls
CNIT 129S: 8: Attacking Access ControlsCNIT 129S: 8: Attacking Access Controls
CNIT 129S: 8: Attacking Access Controls
 
CNIT 121: 11 Analysis Methodology
CNIT 121: 11 Analysis MethodologyCNIT 121: 11 Analysis Methodology
CNIT 121: 11 Analysis Methodology
 
CNIT 129S: Ch 3: Web Application Technologies
CNIT 129S: Ch 3: Web Application TechnologiesCNIT 129S: Ch 3: Web Application Technologies
CNIT 129S: Ch 3: Web Application Technologies
 
CNIT 40: 6: DNSSEC and beyond
CNIT 40: 6: DNSSEC and beyondCNIT 40: 6: DNSSEC and beyond
CNIT 40: 6: DNSSEC and beyond
 
CNIT 121: 12 Investigating Windows Systems (Part 3)
CNIT 121: 12 Investigating Windows Systems (Part 3)CNIT 121: 12 Investigating Windows Systems (Part 3)
CNIT 121: 12 Investigating Windows Systems (Part 3)
 
CNIT 129S: Ch 4: Mapping the Application
CNIT 129S: Ch 4: Mapping the ApplicationCNIT 129S: Ch 4: Mapping the Application
CNIT 129S: Ch 4: Mapping the Application
 
CNIT 129S: Ch 6: Attacking Authentication
CNIT 129S: Ch 6: Attacking AuthenticationCNIT 129S: Ch 6: Attacking Authentication
CNIT 129S: Ch 6: Attacking Authentication
 
CNIT 121: 4 Getting the Investigation Started on the Right Foot & 5 Initial D...
CNIT 121: 4 Getting the Investigation Started on the Right Foot & 5 Initial D...CNIT 121: 4 Getting the Investigation Started on the Right Foot & 5 Initial D...
CNIT 121: 4 Getting the Investigation Started on the Right Foot & 5 Initial D...
 
CNIT 121: Computer Forensics Ch 1
CNIT 121: Computer Forensics Ch 1CNIT 121: Computer Forensics Ch 1
CNIT 121: Computer Forensics Ch 1
 
CNIT 129S: 13: Attacking Users: Other Techniques (Part 1 of 2)
CNIT 129S: 13: Attacking Users: Other Techniques (Part 1 of 2)CNIT 129S: 13: Attacking Users: Other Techniques (Part 1 of 2)
CNIT 129S: 13: Attacking Users: Other Techniques (Part 1 of 2)
 
CNIT 121: 6 Discovering the Scope of the Incident & 7 Live Data Collection
CNIT 121: 6 Discovering the Scope of the Incident & 7 Live Data CollectionCNIT 121: 6 Discovering the Scope of the Incident & 7 Live Data Collection
CNIT 121: 6 Discovering the Scope of the Incident & 7 Live Data Collection
 

Similar to CNIT 127 Ch Ch 1: Before you Begin

10 instruction sets characteristics
10 instruction sets characteristics10 instruction sets characteristics
10 instruction sets characteristics
Sher Shah Merkhel
 
CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...
CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...
CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...
CanSecWest
 

Similar to CNIT 127 Ch Ch 1: Before you Begin (20)

CNIT 126 4: A Crash Course in x86 Disassembly
CNIT 126 4: A Crash Course in x86 DisassemblyCNIT 126 4: A Crash Course in x86 Disassembly
CNIT 126 4: A Crash Course in x86 Disassembly
 
Practical Malware Analysis: Ch 4 A Crash Course in x86 Disassembly
Practical Malware Analysis: Ch 4 A Crash Course in x86 Disassembly Practical Malware Analysis: Ch 4 A Crash Course in x86 Disassembly
Practical Malware Analysis: Ch 4 A Crash Course in x86 Disassembly
 
10 instruction sets characteristics
10 instruction sets characteristics10 instruction sets characteristics
10 instruction sets characteristics
 
Os lectures
Os lecturesOs lectures
Os lectures
 
Basic buffer overflow part1
Basic buffer overflow part1Basic buffer overflow part1
Basic buffer overflow part1
 
10 instruction sets characteristics
10 instruction sets characteristics10 instruction sets characteristics
10 instruction sets characteristics
 
Computer Organization: Introduction to Microprocessor and Microcontroller
Computer Organization: Introduction to Microprocessor and MicrocontrollerComputer Organization: Introduction to Microprocessor and Microcontroller
Computer Organization: Introduction to Microprocessor and Microcontroller
 
Windows kernel
Windows kernelWindows kernel
Windows kernel
 
10 instruction sets characteristics
10 instruction sets characteristics10 instruction sets characteristics
10 instruction sets characteristics
 
Smash the Stack: Writing a Buffer Overflow Exploit (Win32)
Smash the Stack: Writing a Buffer Overflow Exploit (Win32)Smash the Stack: Writing a Buffer Overflow Exploit (Win32)
Smash the Stack: Writing a Buffer Overflow Exploit (Win32)
 
Computer_Organization and architecture _unit 1.pptx
Computer_Organization and architecture _unit 1.pptxComputer_Organization and architecture _unit 1.pptx
Computer_Organization and architecture _unit 1.pptx
 
02-OS-review.pptx
02-OS-review.pptx02-OS-review.pptx
02-OS-review.pptx
 
CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...
CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...
CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...
 
Presentation of mpu
Presentation of mpuPresentation of mpu
Presentation of mpu
 
Let's write a Debugger!
Let's write a Debugger!Let's write a Debugger!
Let's write a Debugger!
 
Intro reverse engineering
Intro reverse engineeringIntro reverse engineering
Intro reverse engineering
 
W8_1: Intro to UoS Educational Processor
W8_1: Intro to UoS Educational ProcessorW8_1: Intro to UoS Educational Processor
W8_1: Intro to UoS Educational Processor
 
CNIT 127 14: Protection Mechanisms
CNIT 127 14: Protection MechanismsCNIT 127 14: Protection Mechanisms
CNIT 127 14: Protection Mechanisms
 
cs-procstruc.ppt
cs-procstruc.pptcs-procstruc.ppt
cs-procstruc.ppt
 
digital logic circuits, digital component
digital logic circuits, digital componentdigital logic circuits, digital component
digital logic circuits, digital component
 

More from Sam Bowne

More from Sam Bowne (20)

Cyberwar
CyberwarCyberwar
Cyberwar
 
3: DNS vulnerabilities
3: DNS vulnerabilities 3: DNS vulnerabilities
3: DNS vulnerabilities
 
8. Software Development Security
8. Software Development Security8. Software Development Security
8. Software Development Security
 
4 Mapping the Application
4 Mapping the Application4 Mapping the Application
4 Mapping the Application
 
3. Attacking iOS Applications (Part 2)
 3. Attacking iOS Applications (Part 2) 3. Attacking iOS Applications (Part 2)
3. Attacking iOS Applications (Part 2)
 
12 Elliptic Curves
12 Elliptic Curves12 Elliptic Curves
12 Elliptic Curves
 
11. Diffie-Hellman
11. Diffie-Hellman11. Diffie-Hellman
11. Diffie-Hellman
 
2a Analyzing iOS Apps Part 1
2a Analyzing iOS Apps Part 12a Analyzing iOS Apps Part 1
2a Analyzing iOS Apps Part 1
 
9 Writing Secure Android Applications
9 Writing Secure Android Applications9 Writing Secure Android Applications
9 Writing Secure Android Applications
 
12 Investigating Windows Systems (Part 2 of 3)
12 Investigating Windows Systems (Part 2 of 3)12 Investigating Windows Systems (Part 2 of 3)
12 Investigating Windows Systems (Part 2 of 3)
 
10 RSA
10 RSA10 RSA
10 RSA
 
12 Investigating Windows Systems (Part 1 of 3
12 Investigating Windows Systems (Part 1 of 312 Investigating Windows Systems (Part 1 of 3
12 Investigating Windows Systems (Part 1 of 3
 
9. Hard Problems
9. Hard Problems9. Hard Problems
9. Hard Problems
 
8 Android Implementation Issues (Part 1)
8 Android Implementation Issues (Part 1)8 Android Implementation Issues (Part 1)
8 Android Implementation Issues (Part 1)
 
11 Analysis Methodology
11 Analysis Methodology11 Analysis Methodology
11 Analysis Methodology
 
8. Authenticated Encryption
8. Authenticated Encryption8. Authenticated Encryption
8. Authenticated Encryption
 
7. Attacking Android Applications (Part 2)
7. Attacking Android Applications (Part 2)7. Attacking Android Applications (Part 2)
7. Attacking Android Applications (Part 2)
 
7. Attacking Android Applications (Part 1)
7. Attacking Android Applications (Part 1)7. Attacking Android Applications (Part 1)
7. Attacking Android Applications (Part 1)
 
5. Stream Ciphers
5. Stream Ciphers5. Stream Ciphers
5. Stream Ciphers
 
6 Scope & 7 Live Data Collection
6 Scope & 7 Live Data Collection6 Scope & 7 Live Data Collection
6 Scope & 7 Live Data Collection
 

Recently uploaded

Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Recently uploaded (20)

Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 

CNIT 127 Ch Ch 1: Before you Begin

  • 1. CNIT 127: Exploit Development
 
 Ch 1: Before you begin Updated 1-14-16
  • 3. Vulnerability • A flaw in a system that allows an attacker to do something the designer did not intend, such as – Denial of service (loss of availability) – Elevating privileges (e.g. user to Administrator) – Remote Code Execution (typically a remote shell)
  • 4. Exploit • Exploit (v.) – To take advantage of a vulnerability and cause a result the designer did not intend • Exploit (n.) – The code that is used to take advantage of a vulnerability – Also called a Proof of Concept (PoC)
  • 5. 0Day and Fuzzer • 0Day – An exploit that has not been publicly disclosed – Sometimes used to refer to the vulnerability itself • Fuzzer – A tool that sends a large range of unexpected input values to a system – The purpose is to find bugs which could later be exploited
  • 6. Memory Management • Specifically for Intel 32-bit architecture • Most exploits we'll use involve overwriting or overflowing one portion of memory into another • Understanding memory management is therefore crucial
  • 7. Instructions and Data • There is no intrinsic difference between data and executable instructions – Although there are some defenses like Data Execution Prevention • They are both just a series of bytes • This ambiguity makes system exploitation possible
  • 8. Program Address Space • Created when a program is run, including – Actual program instructions – Required data • Three types of segments – .text contains program instructions (read- only) – .data contains static initialized global variables (writable) – .bss contains uninitialized global variables (writable)
  • 9. Stack • Last In First Out (LIFO) • Most recently pushed data is the first popped • Ideal for storing transitory information – Local variables – Information relating to function calls – Other information used to clean up the stack after a function is called • Grows down – As more data is added, it uses lower address values
  • 10. Heap • Holds dynamic variables • Roughly First In First Out (FIFO) • Grows up in address space
  • 11. Program Layout in RAM • From link Ch 1a (.bss = Block Started by Symbols)
  • 13. Assembly Language • Different versions for each type of processor • x86 – 32-bit Intel (most common) • x64 – 64-bit Intel • SPARC, PowerPC, MIPS, ARM – others • Windows runs on x86 or x64 • x64 machines can run x86 programs • Most malware is designed for x86
  • 14. Instructions • Mnemonic followed by operands • mov ecx 0x42 – Move into Extended C register the value 42 (hex) • mov ecx is 0xB9 in hexadecimal • The value 42 is 0x4200000000 • In binary this instruction is • 0xB942000000
  • 15. Endianness • Big-Endian – Most significant byte first – 0x42 as a 64-bit value would be 0x00000042 • Little-Endian – Least significant byte first – 0x42 as a 64-bit value would be 0x42000000 • Network data uses big-endian • x86 programs use little-endian
  • 16. IP Addresses • 127.0.0.1, or in hex, 7F 00 00 01 • Sent over the network as 0x7F000001 • Stored in RAM as 0x0100007F
  • 17. Operands • Immediate – Fixed values like 0x42 • Register – eax, ebx, ecx, and so on • Memory address – Denoted with brackets, like [eax]
  • 19. Registers • General registers – Used by the CPU during execution • Segment registers – Used to track sections of memory • Status flags – Used to make decisions • Instruction pointer – Address of next instruction to execute
  • 20. Size of Registers • General registers are all 32 bits in size – Can be referenced as either 32bits (edx) or 16 bits (dx) • Four registers (eax, ebx, ecx, edx) can also be referenced as 8-bit values – AL is lowest 8 bits – AH is higher 8 bits
  • 21.
  • 22. General Registers • Typically store data or memory addresses • Normally interchangeable • Some instructions reference specific registers – Multiplication and division use EAX and EDX • Conventions – Compilers use registers in consistent ways – EAX contains the return value for function calls
  • 23. Flags • EFLAGS is a status register • 32 bits in size • Each bit is a flag • SET (1) or Cleared (0)
  • 24. Important Flags • ZF Zero flag – Set when the result of an operation is zero • CF Carry flag – Set when result is too large or small for destination • SF Sign Flag – Set when result is negative, or when most significant bit is set after arithmetic • TF Trap Flag – Used for debugging—if set, processor executes only one instruction at a time
  • 25. EIP (Extended Instruction Pointer) • Contains the memory address of the next instruction to be executed • If EIP contains wrong data, the CPU will fetch non-legitimate instructions and crash • Buffer overflows target EIP
  • 27. Simple Instructions • mov destination, source – Moves data from one location to another • Intel format is favored by Windows developers, with destination first
  • 28. Simple Instructions • Remember indirect addressing – [ebx] means the memory location pointed to by EBX
  • 29.
  • 30. lea (Load Effective Address) • lea destination, source • lea eax, [ebx+8] – Puts ebx + 8 into eax • Compare – mov eax, [ebx+8] – Moves the data at location ebx+8 into eax
  • 31.
  • 32. Arithmetic • sub Subtracts • add Adds • inc Increments • dec Decrements • mul Multiplies • div Divides
  • 33. NOP • Does nothing • 0x90 • Commonly used as a NOP Sled • Allows attackers to run code even if they are imprecise about jumping to it
  • 34. The Stack • Memory for functions, local variables, and flow control • Last in, First out • ESP (Extended Stack Pointer) – top of stack • EBP (Extended Base Pointer) – bottom of stack • PUSH puts data on the stack • POP takes data off the stack
  • 35. Other Stack Instructions • All used with functions – Call – Leave – Enter – Ret
  • 36. Function Calls • Small programs that do one thing and return, like printf() • Prologue – Instructions at the start of a function that prepare stack and registers for the function to use • Epilogue – Instructions at the end of a function that restore the stack and registers to their state before the function was called
  • 37.
  • 38.
  • 39. Conditionals • test – Compares two values the way AND does, but does not alter them – test eax, eax • Sets Zero Flag if eax is zero • cmp eax, ebx – Sets Zero Flag if the arguments are equal
  • 40. Branching • jz loc – Jump to loc if the Zero Flag is set • jnz loc – Jump to loc if the Zero Flag is cleared
  • 41. C Main Method • Every C program has a main() function • int main(int argc, char** argv) – argc contains the number of arguments on the command line – argv is a pointer to an array of names containing the arguments
  • 42. Example • cp foo bar • argc = 3 • argv[0] = cp • argv[1] = foo • argv[2] = bar
  • 44. Incrementing C int number; ... number++; Assembler number dw 0 ... mov eax, number inc eax mov number, eax •dw: Define Word
  • 45. Incrementing C int number; if (number<0) { ... } Assembler number dw 0 mov eax, number or eax, eax jge label ... label : •or compares numbers, like test (link Ch 1b)
  • 46. Array C int array[4]; ... array[2]=9; Assembler array dw 0,0,0,0 ... mov ebx, 2 mov array[ebx], 9
  • 47. Triangle C int triangle (int width, int height) { int array[5] = {0,1,2,3,4}; int area area = width * height/2; return (area); }