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




Ch 6: The Wild World of Windows
Revised 3-14-22
Topics
• Win32 API, DLLs, and PE Files


• Heaps


• Threading


• DCOM


• Exception Handling


• Debuggers
Win32 API, DLLs, and PE Files
Windows API


(Application Programming Interface)
• In Linux, a programmer can talk directly to
the kernel with syscalls (INT 0x80)


• But in Windows the kernel is only
accessible through the Windows API


• Implemented as a set of DLLs


• Changes with each Windows version and
Service Pack
Windows API


(Application Programming Interface)
• Every process using the Windows API must
use dynamic linking to the DLLs


• The Windows API changes more often than
Linux Syscalls do


• Here's an API call to make a window
DLLs


(Dynamic Link Libraries)
• Pre-compiled library code


• Loaded as needed when executable files
run


• You can see loaded DLLs with Process
Explorer


– View, Lower Pane View, DLLs


– Link Ch 6b
PE (Portable Executable) Files
• Format used for .EXE and .DLL files


– And some other extensions (link Ch 6c)


• Can be loaded on every 32-bit (or 64-bit)
Windows version


• Contains information about all required
DLLs


• Easy to see with PEView (link Ch 6d)
Import Table for Notepad
• Windows Server 2008 Version
Sections of a PE File
• .text – instructions to execute


• .data – global variables


• .idata – Import descriptors


• .rsrc – Resources (icons, etc.)


• .reloc – Relocation data
Relocating PE Files
• DLLs have a Base Address


– This is where they are designed to load


• But two DLLs might have the same Base
Address


– And both be used by the same EXE


• One of them must be moved--"Rebased"


• This process uses the .reloc section
6a
Imports and Exports
• Imports


– Functions the program needs to use from
other code


– Both EXE and DLL files have imports


– The imports generally point to DLL's


• Exports


– Functions this program offers for others to
use


– DLL's have many exports, EXE's don't
Notepad.exe Imports
• Windows 10 Version
Advapi32.dll Exports
DLL Loading
• When an EXE launches, Windows hunts for the
required DLLs


• Looking first in the current working directory


• This allows a developer to include a DLL version
other than the one in C:WindowsSystem32


– Leads to DLL Hell; users may need to adjust PATH to
resolve DLL version conflicts
Stuxnet: LNK 0day
• Loaded a DLL
from a USB
thumbdrive


• Took over the
machine as soon
as the icons
appear


– Link Ch 6h
Relative Virtual Address (RVA)
• Windows EXE processes are loaded into
0x00400000 by default


– This is a Virtual Address, only visible to each
process


– Error on page 113 of textbook, too many
zeroes in 0x00400000


• RVA is used to aid in rebasing DLLs


– Loading them in non-preferred locations
Example of VA (Virtual Address)
• Link Ch 6g
OllyDbg: Code Starts Near 0x400000
Heaps
Many Heaps
• Heap is used for temporary storage of data


– Via malloc() and free()


• Linux uses one heap, but Windows uses
many heaps


• Each DLL that loads can set up its own
heap


• Heap corruption attacks are very confusing
Threading
One Process, Many Threads
• Each process is subdivided into threads


• Processor time slices are allocated to
threads, not processes


• This allows a single process to operate
more efficiently


– If one thread is waiting for something, other
threads can keep moving
Threads in Task Manager
Handles
• Handles are pointers to objects like open
files


• Each thread has many handles


• You can view details about every thread
with Process Explorer
6b
The Genius and Idiocy of the DCOM


(Distributed Common Object
Model)


and


DCE-RPC


(Distributed Computing Environment
/ Remote Procedure Calls)
Follow the Money
• Microsoft's business model is to distribute
binary packages for money


• You can build a complex application by
purchasing third-party COM modules from
vendors


– And tying them together with Visual Basic
COM Objects
• Can be written in any supported language


• Interoperate seamlessly


• BUT a C++ integer is not the same as a
Visual Basic integer


• So you need to define the input and
outputs with an IDL (Interface Description
Language) file
DCOM Interface Description Language
(IDL) File
DCOM IDL File
• Specifies arguments and return values for
a particular function


– In a particular interface defined by UUID, also
called a GUID


– GUID is 128 bits long; 32 hex characters
Two Ways to Load a COM Object
• Load directly into process space as a DLL


• Launch as a service


– By the Service Control Manager (services.exe)


• Running as a service is more stable and
secure


– But much slower


• In-process calls are 1000 times faster than
calling a COM interface on the same
machine but in a different process
Service Control Manager (SCM)
• Appears in Task Manager as services.exe
DCOM Calls
• Microsoft's priority: make it easy for
developers to write software


• A simple registry or parameter change
tells a program to use a different process


– Or even a different machine


• A process can call a COM interface on a
different machine on the LAN


– 10x slower than calling a COM interface on
the same machine
RPC Endpoint Mapper
• Listening on port TCP 135


• An RPC request in Wireshark
Maps to UUID Values
• Map request shows available RPC
functions
Components that Depend on RPC
• Open Services


• Double-click
"Remote
Procedure Call"
Security Implications
• Code can be designed to run in a trusted
environment


– Calling DLLs that are included in your
application, or Microsoft DLLs


• And easily adapted to run in an untrusted
environment


– Listening on a network port
DEC-RPC Exploitation
• Recon, fuzz, and exploit with Dave Aitel's
SPIKE and other tools
Tokens and Impersonation
Token
• A token is a 32-bit integer like a file handle


• Defines user rights
Exploiting Token Handling
• Attacker can create threads and copy any
available token to them


• There are typically tokens available for
any user that has recently authenticated
Exception Handling
Structured Exception Handler (SEH)
• When an illegal operation occurs, such as


– Divide by zero


– Attempt to execute non-executable memory


– Attempt to use invalid memory location


• The processor sends an Exception


• The OS can handle it, with an error message
or a Blue Screen of Death


• But the application can specify custom
exception handlers
SEH in Immunity Debugger
Exploiting the SEH
• Overwrite the pointer to the SEH chain


• Overwrite the function pointer for the
handler on the stack


• Overwrite the default exception handler
Debuggers
Three Options
• SoftICE


– Old, powerful, difficult to install


• WinDbg


– Used by Microsoft


– Can debug the kernel, using a serial cable and two
computers


• Or Ethernet, for Win 8 or later


• Or LiveKD and one machine


– UI is terrible


• OllyDbg


– Very popular but apparently abandoned
OllyDbg
• OllyDbg version 1.10 is very nice


• OllyDbg 2.x is not much better


• No later version seems to be available
Immunity Debugger
Immunity Debugger
• Based on OllyDbg


• Still alive and under development


• Used by many exploit developers
Immunity Debugger
6c

More Related Content

What's hot

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 Sam Bowne
 
Modern Kernel Pool Exploitation: Attacks and Techniques
Modern Kernel Pool Exploitation: Attacks and TechniquesModern Kernel Pool Exploitation: Attacks and Techniques
Modern Kernel Pool Exploitation: Attacks and TechniquesMichael Scovetta
 
CNIT 126 6: Recognizing C Code Constructs in Assembly
CNIT 126 6: Recognizing C Code Constructs in Assembly CNIT 126 6: Recognizing C Code Constructs in Assembly
CNIT 126 6: Recognizing C Code Constructs in Assembly Sam Bowne
 
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 DisassemblySam Bowne
 
chap 18 multicore computers
chap 18 multicore computers chap 18 multicore computers
chap 18 multicore computers Sher Shah Merkhel
 
File and directories in python
File and directories in pythonFile and directories in python
File and directories in pythonLifna C.S
 
CNIT 126 12: Covert Malware Launching
CNIT 126 12: Covert Malware LaunchingCNIT 126 12: Covert Malware Launching
CNIT 126 12: Covert Malware LaunchingSam Bowne
 
Kernel Module Programming
Kernel Module ProgrammingKernel Module Programming
Kernel Module ProgrammingSaurabh Bangad
 
Embedded Systems: Lecture 7: Lab 1: Preparing the Raspberry Pi
Embedded Systems: Lecture 7: Lab 1: Preparing the Raspberry PiEmbedded Systems: Lecture 7: Lab 1: Preparing the Raspberry Pi
Embedded Systems: Lecture 7: Lab 1: Preparing the Raspberry PiAhmed El-Arabawy
 
Windows internals Essentials
Windows internals EssentialsWindows internals Essentials
Windows internals EssentialsJohn Ombagi
 
Linux Kernel Module - For NLKB
Linux Kernel Module - For NLKBLinux Kernel Module - For NLKB
Linux Kernel Module - For NLKBshimosawa
 
ELF(executable and linkable format)
ELF(executable and linkable format)ELF(executable and linkable format)
ELF(executable and linkable format)Seungha Son
 
Multithreading models.ppt
Multithreading models.pptMultithreading models.ppt
Multithreading models.pptLuis Goldster
 

What's hot (20)

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
 
Modern Kernel Pool Exploitation: Attacks and Techniques
Modern Kernel Pool Exploitation: Attacks and TechniquesModern Kernel Pool Exploitation: Attacks and Techniques
Modern Kernel Pool Exploitation: Attacks and Techniques
 
CNIT 126 6: Recognizing C Code Constructs in Assembly
CNIT 126 6: Recognizing C Code Constructs in Assembly CNIT 126 6: Recognizing C Code Constructs in Assembly
CNIT 126 6: Recognizing C Code Constructs in Assembly
 
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
 
chap 18 multicore computers
chap 18 multicore computers chap 18 multicore computers
chap 18 multicore computers
 
C Programming - Refresher - Part III
C Programming - Refresher - Part IIIC Programming - Refresher - Part III
C Programming - Refresher - Part III
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler Construction
 
File and directories in python
File and directories in pythonFile and directories in python
File and directories in python
 
CNIT 126 12: Covert Malware Launching
CNIT 126 12: Covert Malware LaunchingCNIT 126 12: Covert Malware Launching
CNIT 126 12: Covert Malware Launching
 
Kernel Module Programming
Kernel Module ProgrammingKernel Module Programming
Kernel Module Programming
 
Rapid application developmet
Rapid application developmetRapid application developmet
Rapid application developmet
 
Embedded Systems: Lecture 7: Lab 1: Preparing the Raspberry Pi
Embedded Systems: Lecture 7: Lab 1: Preparing the Raspberry PiEmbedded Systems: Lecture 7: Lab 1: Preparing the Raspberry Pi
Embedded Systems: Lecture 7: Lab 1: Preparing the Raspberry Pi
 
Windows internals Essentials
Windows internals EssentialsWindows internals Essentials
Windows internals Essentials
 
Linux Kernel Module - For NLKB
Linux Kernel Module - For NLKBLinux Kernel Module - For NLKB
Linux Kernel Module - For NLKB
 
ELF(executable and linkable format)
ELF(executable and linkable format)ELF(executable and linkable format)
ELF(executable and linkable format)
 
Multithreading models.ppt
Multithreading models.pptMultithreading models.ppt
Multithreading models.ppt
 
Dll injection
Dll injectionDll injection
Dll injection
 
RTOS - Real Time Operating Systems
RTOS - Real Time Operating SystemsRTOS - Real Time Operating Systems
RTOS - Real Time Operating Systems
 
Software development process
Software development processSoftware development process
Software development process
 
Linux systems - Getting started with setting up and embedded platform
Linux systems - Getting started with setting up and embedded platformLinux systems - Getting started with setting up and embedded platform
Linux systems - Getting started with setting up and embedded platform
 

Similar to Ch 6: The Wild World of Windows

CNIT 127 Ch 6: The Wild World of Windows
CNIT 127 Ch 6: The Wild World of WindowsCNIT 127 Ch 6: The Wild World of Windows
CNIT 127 Ch 6: The Wild World of WindowsSam Bowne
 
CNIT 126: 10: Kernel Debugging with WinDbg
CNIT 126: 10: Kernel Debugging with WinDbgCNIT 126: 10: Kernel Debugging with WinDbg
CNIT 126: 10: Kernel Debugging with WinDbgSam Bowne
 
CNIT 126: 10: Kernel Debugging with WinDbg
CNIT 126: 10: Kernel Debugging with WinDbgCNIT 126: 10: Kernel Debugging with WinDbg
CNIT 126: 10: Kernel Debugging with WinDbgSam Bowne
 
Windows internals
Windows internalsWindows internals
Windows internalsPiyush Jain
 
Practical Malware Analysis: Ch 10: Kernel Debugging with WinDbg
Practical Malware Analysis: Ch 10: Kernel Debugging with WinDbgPractical Malware Analysis: Ch 10: Kernel Debugging with WinDbg
Practical Malware Analysis: Ch 10: Kernel Debugging with WinDbgSam Bowne
 
Practical Malware Analysis: Ch 7: Analyzing Malicious Windows Programs
Practical Malware Analysis: Ch 7: Analyzing Malicious Windows Programs Practical Malware Analysis: Ch 7: Analyzing Malicious Windows Programs
Practical Malware Analysis: Ch 7: Analyzing Malicious Windows Programs Sam Bowne
 
CNIT 126 7: Analyzing Malicious Windows Programs
CNIT 126 7: Analyzing Malicious Windows ProgramsCNIT 126 7: Analyzing Malicious Windows Programs
CNIT 126 7: Analyzing Malicious Windows ProgramsSam Bowne
 
CNIT 126 Ch 7: Analyzing Malicious Windows Programs
CNIT 126 Ch 7: Analyzing Malicious Windows ProgramsCNIT 126 Ch 7: Analyzing Malicious Windows Programs
CNIT 126 Ch 7: Analyzing Malicious Windows ProgramsSam Bowne
 
Computer and multimedia Week 1 Windows Architecture.pptx
Computer and multimedia Week 1 Windows Architecture.pptxComputer and multimedia Week 1 Windows Architecture.pptx
Computer and multimedia Week 1 Windows Architecture.pptxfatahozil
 
Esage on non-existent 0-days, stable binary exploits and user interaction
Esage   on non-existent 0-days, stable binary exploits and user interactionEsage   on non-existent 0-days, stable binary exploits and user interaction
Esage on non-existent 0-days, stable binary exploits and user interactionDefconRussia
 
On non existent 0-days, stable binary exploits and
On non existent 0-days, stable binary exploits andOn non existent 0-days, stable binary exploits and
On non existent 0-days, stable binary exploits andAlisa Esage Шевченко
 
RSA SF Conference talk-2009-ht2-401 sallam
RSA SF Conference talk-2009-ht2-401 sallamRSA SF Conference talk-2009-ht2-401 sallam
RSA SF Conference talk-2009-ht2-401 sallamAhmed Sallam
 
Advanced Internet of Things firmware engineering with Thingsquare and Contiki...
Advanced Internet of Things firmware engineering with Thingsquare and Contiki...Advanced Internet of Things firmware engineering with Thingsquare and Contiki...
Advanced Internet of Things firmware engineering with Thingsquare and Contiki...Adam Dunkels
 
Typhoon Managed Execution Toolkit
Typhoon Managed Execution ToolkitTyphoon Managed Execution Toolkit
Typhoon Managed Execution ToolkitDimitry Snezhkov
 
Learn the java basic programming with example and syntaxchapter1-part-b.pptx
Learn the java basic programming with example and syntaxchapter1-part-b.pptxLearn the java basic programming with example and syntaxchapter1-part-b.pptx
Learn the java basic programming with example and syntaxchapter1-part-b.pptxGaytriMate
 
[若渴計畫] Challenges and Solutions of Window Remote Shellcode
[若渴計畫] Challenges and Solutions of Window Remote Shellcode[若渴計畫] Challenges and Solutions of Window Remote Shellcode
[若渴計畫] Challenges and Solutions of Window Remote ShellcodeAj MaChInE
 
DLL Design with Building Blocks
DLL Design with Building BlocksDLL Design with Building Blocks
DLL Design with Building BlocksMax Kleiner
 

Similar to Ch 6: The Wild World of Windows (20)

CNIT 127 Ch 6: The Wild World of Windows
CNIT 127 Ch 6: The Wild World of WindowsCNIT 127 Ch 6: The Wild World of Windows
CNIT 127 Ch 6: The Wild World of Windows
 
CNIT 126: 10: Kernel Debugging with WinDbg
CNIT 126: 10: Kernel Debugging with WinDbgCNIT 126: 10: Kernel Debugging with WinDbg
CNIT 126: 10: Kernel Debugging with WinDbg
 
CNIT 126: 10: Kernel Debugging with WinDbg
CNIT 126: 10: Kernel Debugging with WinDbgCNIT 126: 10: Kernel Debugging with WinDbg
CNIT 126: 10: Kernel Debugging with WinDbg
 
Windows internals
Windows internalsWindows internals
Windows internals
 
Practical Malware Analysis: Ch 10: Kernel Debugging with WinDbg
Practical Malware Analysis: Ch 10: Kernel Debugging with WinDbgPractical Malware Analysis: Ch 10: Kernel Debugging with WinDbg
Practical Malware Analysis: Ch 10: Kernel Debugging with WinDbg
 
Practical Malware Analysis: Ch 7: Analyzing Malicious Windows Programs
Practical Malware Analysis: Ch 7: Analyzing Malicious Windows Programs Practical Malware Analysis: Ch 7: Analyzing Malicious Windows Programs
Practical Malware Analysis: Ch 7: Analyzing Malicious Windows Programs
 
CNIT 126 7: Analyzing Malicious Windows Programs
CNIT 126 7: Analyzing Malicious Windows ProgramsCNIT 126 7: Analyzing Malicious Windows Programs
CNIT 126 7: Analyzing Malicious Windows Programs
 
CNIT 126 Ch 7: Analyzing Malicious Windows Programs
CNIT 126 Ch 7: Analyzing Malicious Windows ProgramsCNIT 126 Ch 7: Analyzing Malicious Windows Programs
CNIT 126 Ch 7: Analyzing Malicious Windows Programs
 
DLL Injection
DLL InjectionDLL Injection
DLL Injection
 
Computer and multimedia Week 1 Windows Architecture.pptx
Computer and multimedia Week 1 Windows Architecture.pptxComputer and multimedia Week 1 Windows Architecture.pptx
Computer and multimedia Week 1 Windows Architecture.pptx
 
Esage on non-existent 0-days, stable binary exploits and user interaction
Esage   on non-existent 0-days, stable binary exploits and user interactionEsage   on non-existent 0-days, stable binary exploits and user interaction
Esage on non-existent 0-days, stable binary exploits and user interaction
 
On non existent 0-days, stable binary exploits and
On non existent 0-days, stable binary exploits andOn non existent 0-days, stable binary exploits and
On non existent 0-days, stable binary exploits and
 
RSA SF Conference talk-2009-ht2-401 sallam
RSA SF Conference talk-2009-ht2-401 sallamRSA SF Conference talk-2009-ht2-401 sallam
RSA SF Conference talk-2009-ht2-401 sallam
 
Advanced Internet of Things firmware engineering with Thingsquare and Contiki...
Advanced Internet of Things firmware engineering with Thingsquare and Contiki...Advanced Internet of Things firmware engineering with Thingsquare and Contiki...
Advanced Internet of Things firmware engineering with Thingsquare and Contiki...
 
Typhoon Managed Execution Toolkit
Typhoon Managed Execution ToolkitTyphoon Managed Execution Toolkit
Typhoon Managed Execution Toolkit
 
Learn the java basic programming with example and syntaxchapter1-part-b.pptx
Learn the java basic programming with example and syntaxchapter1-part-b.pptxLearn the java basic programming with example and syntaxchapter1-part-b.pptx
Learn the java basic programming with example and syntaxchapter1-part-b.pptx
 
[若渴計畫] Challenges and Solutions of Window Remote Shellcode
[若渴計畫] Challenges and Solutions of Window Remote Shellcode[若渴計畫] Challenges and Solutions of Window Remote Shellcode
[若渴計畫] Challenges and Solutions of Window Remote Shellcode
 
srgoc dotnet_ppt
srgoc dotnet_pptsrgoc dotnet_ppt
srgoc dotnet_ppt
 
DLL Design with Building Blocks
DLL Design with Building BlocksDLL Design with Building Blocks
DLL Design with Building Blocks
 
Presentation1.pptx
Presentation1.pptxPresentation1.pptx
Presentation1.pptx
 

More from Sam Bowne

3: DNS vulnerabilities
3: DNS vulnerabilities 3: DNS vulnerabilities
3: DNS vulnerabilities Sam Bowne
 
8. Software Development Security
8. Software Development Security8. Software Development Security
8. Software Development SecuritySam Bowne
 
4 Mapping the Application
4 Mapping the Application4 Mapping the Application
4 Mapping the ApplicationSam Bowne
 
3. Attacking iOS Applications (Part 2)
 3. Attacking iOS Applications (Part 2) 3. Attacking iOS Applications (Part 2)
3. Attacking iOS Applications (Part 2)Sam Bowne
 
12 Elliptic Curves
12 Elliptic Curves12 Elliptic Curves
12 Elliptic CurvesSam Bowne
 
11. Diffie-Hellman
11. Diffie-Hellman11. Diffie-Hellman
11. Diffie-HellmanSam Bowne
 
2a Analyzing iOS Apps Part 1
2a Analyzing iOS Apps Part 12a Analyzing iOS Apps Part 1
2a Analyzing iOS Apps Part 1Sam Bowne
 
9 Writing Secure Android Applications
9 Writing Secure Android Applications9 Writing Secure Android Applications
9 Writing Secure Android ApplicationsSam Bowne
 
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)Sam Bowne
 
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 3Sam Bowne
 
9. Hard Problems
9. Hard Problems9. Hard Problems
9. Hard ProblemsSam Bowne
 
8 Android Implementation Issues (Part 1)
8 Android Implementation Issues (Part 1)8 Android Implementation Issues (Part 1)
8 Android Implementation Issues (Part 1)Sam Bowne
 
11 Analysis Methodology
11 Analysis Methodology11 Analysis Methodology
11 Analysis MethodologySam Bowne
 
8. Authenticated Encryption
8. Authenticated Encryption8. Authenticated Encryption
8. Authenticated EncryptionSam Bowne
 
7. Attacking Android Applications (Part 2)
7. Attacking Android Applications (Part 2)7. Attacking Android Applications (Part 2)
7. Attacking Android Applications (Part 2)Sam Bowne
 
7. Attacking Android Applications (Part 1)
7. Attacking Android Applications (Part 1)7. Attacking Android Applications (Part 1)
7. Attacking Android Applications (Part 1)Sam Bowne
 
5. Stream Ciphers
5. Stream Ciphers5. Stream Ciphers
5. Stream CiphersSam Bowne
 
6 Scope & 7 Live Data Collection
6 Scope & 7 Live Data Collection6 Scope & 7 Live Data Collection
6 Scope & 7 Live Data CollectionSam 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

Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 

Recently uploaded (20)

Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 

Ch 6: The Wild World of Windows

  • 1. CNIT 127: Exploit Development 
 
 Ch 6: The Wild World of Windows Revised 3-14-22
  • 2. Topics • Win32 API, DLLs, and PE Files • Heaps • Threading • DCOM • Exception Handling • Debuggers
  • 3. Win32 API, DLLs, and PE Files
  • 4. Windows API 
 (Application Programming Interface) • In Linux, a programmer can talk directly to the kernel with syscalls (INT 0x80) • But in Windows the kernel is only accessible through the Windows API • Implemented as a set of DLLs • Changes with each Windows version and Service Pack
  • 5. Windows API 
 (Application Programming Interface) • Every process using the Windows API must use dynamic linking to the DLLs • The Windows API changes more often than Linux Syscalls do • Here's an API call to make a window
  • 6. DLLs 
 (Dynamic Link Libraries) • Pre-compiled library code • Loaded as needed when executable files run • You can see loaded DLLs with Process Explorer – View, Lower Pane View, DLLs – Link Ch 6b
  • 7.
  • 8. PE (Portable Executable) Files • Format used for .EXE and .DLL files – And some other extensions (link Ch 6c) • Can be loaded on every 32-bit (or 64-bit) Windows version • Contains information about all required DLLs • Easy to see with PEView (link Ch 6d)
  • 9. Import Table for Notepad • Windows Server 2008 Version
  • 10. Sections of a PE File • .text – instructions to execute • .data – global variables • .idata – Import descriptors • .rsrc – Resources (icons, etc.) • .reloc – Relocation data
  • 11. Relocating PE Files • DLLs have a Base Address – This is where they are designed to load • But two DLLs might have the same Base Address – And both be used by the same EXE • One of them must be moved--"Rebased" • This process uses the .reloc section
  • 12. 6a
  • 13. Imports and Exports • Imports – Functions the program needs to use from other code – Both EXE and DLL files have imports – The imports generally point to DLL's • Exports – Functions this program offers for others to use – DLL's have many exports, EXE's don't
  • 16. DLL Loading • When an EXE launches, Windows hunts for the required DLLs • Looking first in the current working directory • This allows a developer to include a DLL version other than the one in C:WindowsSystem32 – Leads to DLL Hell; users may need to adjust PATH to resolve DLL version conflicts
  • 17. Stuxnet: LNK 0day • Loaded a DLL from a USB thumbdrive • Took over the machine as soon as the icons appear – Link Ch 6h
  • 18. Relative Virtual Address (RVA) • Windows EXE processes are loaded into 0x00400000 by default – This is a Virtual Address, only visible to each process – Error on page 113 of textbook, too many zeroes in 0x00400000 • RVA is used to aid in rebasing DLLs – Loading them in non-preferred locations
  • 19. Example of VA (Virtual Address) • Link Ch 6g
  • 20. OllyDbg: Code Starts Near 0x400000
  • 21. Heaps
  • 22. Many Heaps • Heap is used for temporary storage of data – Via malloc() and free() • Linux uses one heap, but Windows uses many heaps • Each DLL that loads can set up its own heap • Heap corruption attacks are very confusing
  • 24. One Process, Many Threads • Each process is subdivided into threads • Processor time slices are allocated to threads, not processes • This allows a single process to operate more efficiently – If one thread is waiting for something, other threads can keep moving
  • 25. Threads in Task Manager
  • 26. Handles • Handles are pointers to objects like open files • Each thread has many handles • You can view details about every thread with Process Explorer
  • 27.
  • 28. 6b
  • 29. The Genius and Idiocy of the DCOM 
 (Distributed Common Object Model) 
 and 
 DCE-RPC 
 (Distributed Computing Environment / Remote Procedure Calls)
  • 30. Follow the Money • Microsoft's business model is to distribute binary packages for money • You can build a complex application by purchasing third-party COM modules from vendors – And tying them together with Visual Basic
  • 31. COM Objects • Can be written in any supported language • Interoperate seamlessly • BUT a C++ integer is not the same as a Visual Basic integer • So you need to define the input and outputs with an IDL (Interface Description Language) file
  • 32. DCOM Interface Description Language (IDL) File
  • 33. DCOM IDL File • Specifies arguments and return values for a particular function – In a particular interface defined by UUID, also called a GUID – GUID is 128 bits long; 32 hex characters
  • 34. Two Ways to Load a COM Object • Load directly into process space as a DLL • Launch as a service – By the Service Control Manager (services.exe) • Running as a service is more stable and secure – But much slower • In-process calls are 1000 times faster than calling a COM interface on the same machine but in a different process
  • 35. Service Control Manager (SCM) • Appears in Task Manager as services.exe
  • 36. DCOM Calls • Microsoft's priority: make it easy for developers to write software • A simple registry or parameter change tells a program to use a different process – Or even a different machine • A process can call a COM interface on a different machine on the LAN – 10x slower than calling a COM interface on the same machine
  • 37. RPC Endpoint Mapper • Listening on port TCP 135 • An RPC request in Wireshark
  • 38. Maps to UUID Values • Map request shows available RPC functions
  • 39. Components that Depend on RPC • Open Services • Double-click "Remote Procedure Call"
  • 40. Security Implications • Code can be designed to run in a trusted environment – Calling DLLs that are included in your application, or Microsoft DLLs • And easily adapted to run in an untrusted environment – Listening on a network port
  • 41. DEC-RPC Exploitation • Recon, fuzz, and exploit with Dave Aitel's SPIKE and other tools
  • 43. Token • A token is a 32-bit integer like a file handle • Defines user rights
  • 44. Exploiting Token Handling • Attacker can create threads and copy any available token to them • There are typically tokens available for any user that has recently authenticated
  • 46. Structured Exception Handler (SEH) • When an illegal operation occurs, such as – Divide by zero – Attempt to execute non-executable memory – Attempt to use invalid memory location • The processor sends an Exception • The OS can handle it, with an error message or a Blue Screen of Death • But the application can specify custom exception handlers
  • 47. SEH in Immunity Debugger
  • 48. Exploiting the SEH • Overwrite the pointer to the SEH chain • Overwrite the function pointer for the handler on the stack • Overwrite the default exception handler
  • 50. Three Options • SoftICE – Old, powerful, difficult to install • WinDbg – Used by Microsoft – Can debug the kernel, using a serial cable and two computers • Or Ethernet, for Win 8 or later • Or LiveKD and one machine – UI is terrible • OllyDbg – Very popular but apparently abandoned
  • 51. OllyDbg • OllyDbg version 1.10 is very nice • OllyDbg 2.x is not much better • No later version seems to be available
  • 53. Immunity Debugger • Based on OllyDbg • Still alive and under development • Used by many exploit developers
  • 55. 6c