The Shellcoder's Handbook:

Size: px
Start display at page:

Download "The Shellcoder's Handbook:"

Transcription

1 The Shellcoder's Handbook: Discovering and Exploiting Security Holes Jack Koziol, Dave Aitel, David Litchfield, Chris Anley, Sinan "noir" Eren, Neel Mehta, Riley Hassell WILEY Wiley Publishing, Inc.

2 Contents About the Authors Credits Acknowledgments Part 1 Introduction to Exploitation: Linux on x86 1 Chapter 1 Before You Begin 3 Basic Concepts 3 Memory Management 4 Assembly 6 Registers 7 Recognizing C++ Code Constructs in Assembly 8 Conclusion 10 Chapter 2 Stack Overflows 11 Buffers 12 The Stack 13 Functions and the Stack 15 Overflowing Buffers on the Stack 18 Controlling EIP 20 Using an Exploit to Get Root Privileges 22 The Address Problem 24 The NOP Method 27 Defeating a Non-Executable Stack 29 Return to libc 30 Conclusion 33 v vii xi xiii

3 xiv Contents Chapter 3 Shellcode 35 Understanding System Calls 36 Writing Shellcode for the exit() Syscall 38 Injectable Shellcode 42 Spawning a Shell 44 Conclusion 53 Chapter 4 Introduction to Format String Bugs 55 Prerequisites 55 What Is a Format String? 56 What Is a Format String Bug? 57 Format String Exploits 62 Crashing Services 63 Information Leakage 64 Controlling Execution for Exploitation 69 Why Did This Happen? 79 Format String Technique Roundup 79 Conclusion 82 Chapter 5 Introduction to Heap Overflows 83 What Is a Heap? 84 How a Heap Works 85 Finding Heap Overflows 86 Basic Heap Overflows 87 Intermediate Heap Overflows 93 Advanced Heap Overflow Exploitation 99 What to Overwrite 100 Conclusion 101 Part 2 Exploiting More Platforms: Windows, Solaris, andtru Chapter 6 The Wild World of Windows 105 How Does Windows Differ from Linux? 105 Win32 API and PE-COFF 106 Heaps 108 Threading 109 The Genius and Idiocy of the Distributed Common Object Model and DCE-RPC HO Recon 112 Exploitation 114 Tokens and Impersonation 114 Exception Handling under Win Debugging Windows 118 Bugs in Win Writing Windows Shellcode 119 A Hacker 's Guide to the Win32 API 119 A Windows Family Tree from the Hacker's Perspective 120 Conclusion 121

4 Contents xv Chapter 7 Chapter 8 Windows Shellcode Syntax and Filters Setting Up Parsing the PEB Heapoverflow.c Analysis Searching with Windows Exception Handling Popping a Shell Why You Should Never Pop a Shell on Windows Conclusion Windows Overflows Stack-Based Buffer Overflows Frame-Based Exception Handlers Abusing Frame-Based Exception Handling on Windows 2003 Server Abusing an Existine Handler Find a block of code in an address not associated with a module that will get us back to our buffer 158 Find a block of code in the address space of a module that does not have a Load Configuration Directory 159 A Final Note about Frame-Based Handler Overwrites 160 Stack Protection and Windows 2003 Server 161 Heap-Based Buffer Overflows 167 The Process Heap 167 Dynamic Heaps 167 Working with the Heap 168 How the Heap Works 168 Exploiting Heap-Based Overflows 172 Overwrite Pointer to RtlEnterCriticalSection in the PEB 172 Overwrite Pointer to First Vectored Handler at 77FC Overwrite Pointer to Unhandled Exception Filter 178 Overwrite Pointer to Exception Handler in Thread Environment Block 184 Repairing the Heap 185 Other Aspects of Heap-Based Overflows 187 COM Objects and the Heap 187 Overflowing Logic Program Control Data 188 Wrapping Up the Heap 188 Other Overflows 188.data section overflows 188 TEB/PEB Overflows 190 Exploiting Buffer Overflows and Non-Executable Stacks 191 Conclusion 196

5 xvi Contents Chapter 9 Overcoming Filters 197 Writing Exploits for Use with an Alphanumeric Filter 197 Writing Exploits for Use with a Unicode Filter 201 What Is Unicode? 202 Converting from ASCII to Unicode 202 Exploiting Unicode-Based Vulnerabilities 203 The Available Instruction Set in Unicode Exploits 204 The Venetian Method 205 An ASCII Venetian Implementation 207 Decoder and Decoding 210 The Decoder Code 211 Getting a Fix on the Buffer Address 212 Conclusion 213 Chapter 10 Introduction to Solaris Exploitation 215 Introduction to the SPARC Architecture 216 Registers and Register Windows 216 The Delay Slot 219 Synthetic Instructions 219 Solaris/SPARC Shellcode Basics 220 Self-Location Determination and SPARC Shellcode 220 Simple SPARC exec Shellcode 221 Useful System Calls on Solaris 222 NOP and Padding Instructions 222 Solaris/SPARC Stack Frame Introduction 223 Stack-Based Overflow Methodologies 224 Arbitrary Size Overflow 224 Register Windows and Stack Overflow Complications 225 Other Complicating Factors 225 Possible Solutions 225 Off-By-One Stack Overflow Vulnerabilities 226 Shellcode Locations 227 Stack Overflow Exploitation In Action 228 The Vulnerable Program 228 The Exploit 230 Heap-Based Overflows on Solaris/SPARC 233 Solaris System V Heap Introduction 234 Heap Tree Structure 234 Basic Exploit Methodology (t_delete) 254 Standard Heap Overflow Limitations 257 Targets for Overwrite 258 The Bottom Chunk 259 Small Chunk Corruption 260 Other Heap-Related Vulnerabilities 261 Off-by-One Overflows 261 Double Free Vulnerabilities 261 Arbitrary Free Vulnerabilities 262

6 Contents xvii Heap Overflow Example 262 The Vulnerable Program 262 Other Solaris Exploitation Techniques 266 Static Data Overflows 267 Bypassing the Non-Executable Stack Protection 267 Conclusion 268 Chapter 11 Advanced Solaris Exploitation 269 Single Stepping the Dynamic Linker 271 Various Style Tricks for Solaris SPARC Heap Overflows 286 Advanced Solaris/SPARC Shellcode 288 Conclusion 300 Chapter 12 HP Tru64 Unix Exploitation 301 The Alpha Architecture 302 Alpha Registers 302 Instruction Set 303 Calling Conventions 305 Retrieving the Program Counter (GetPC) 306 System Call Invocation 308 XOR Decoder for Shellcode 308.end main setuid + execve Shellcode 310 Code the setuid(o) + execve("/bin/sh",...) systemcalls 310 Compile the Assembly Code and Extract the Main Function 311 Encode the Extracted opcodes with the XOR Key 312 Plug the Encoded Code into the XOR Decoder 313 Compile and Extract the Final Shellcode 314 Connect-Back Shellcode 316 Find-Socket Shellcode 317 Bind-Socket Shellcode 319 Stack Overflow Exploitation 320 Defeating the Non-Executable Stack 321 Exploiting rpc.ttdbserver 322 Conclusion 330 Part 3 Vulnerability Discovery 331 Chapter 13 Establishing a Working Environment 333 What You Need for Reference 334 What You Need for Code 334 gcc 334 gdb 335 NASM 335 WinDbg 335 OllyDbg 335 SoftICE 335 Visual C Python 336

7 xviii Contents What You Need for Investigation 336 Useful Custom Scripts/Tools 336 An Offset Finder 336 Generic Fuzzers 337 The Debug Trick 337 All Platforms 338 Unix 338 ltrace 339 strace 339 fstat (BSD) 339 tcpdump 339 Ethereal 339 Windows 339 IDA Pro Disassembler 340 What You Need to Know 340 Paper Archives 343 Optimizing Shellcode Development 343 Plan the Exploit 343 Write the Shellcode in Inline Assembler 344 Maintain a Shellcode Library 345 Make It Continue Nicely 346 Make the Exploit Stable 347 Make It Steal the Connection 347 Conclusion 348 Chapter 14 Fault Injection 349 Design Overview 350 Input Generation 351 Manual Generation 352 Automated Generation 352 Live Capture 353 "Fuzz" Generation 353 Fault Injection 354 Modification Engines 354 Delimiting Logic 355 Getting around Input Sanitization 357 Fault Delivery 358 Nagel Algorithm 359 Timing 359 Heuristics 359 Stateless versus State-Based Protocols 360 Fault Monitoring 360 Using a Debugger 360 FaultMon 361 Putting It Together 361 Conclusion 362

8 Contents xix Chapter 15 Chapter 16 The Art of Fuzzing General Theory of Fuzzing Statte Analysis versus Fuzzing Fuzzing Is Scalable Weaknesses in Fuzzers Modeling Arbitrary Network Protocols Other Fuzzer Possibilities Bit Flipping Modifying Open Source Programs Fuzzing with Dynamic Analysis SPIKE What Is a Spike? Why Use the SPIKE Data Structure to Model Network Protocols? Various Programs Included with SPIKE SPIKE Example: dtlogin Other Fuzzers Conclusion Source Code Auditing: Finding Vulnerabilities in C-Based Languages Tools Cscope Ctags Editors Cbrowser Automated Source Code Analysis Tools Methodology Top-Down (Specific) Approach Bottom-Up Approach Selective Approach Vulnerability Classes Generic Logic Errors (Almost) Extinct Bug Classes Format Strings Generic Incorrect Bounds-Checking Loop Constructs Off-by-One Vulnerabilities Non-Null Termination Issues Skipping Null-Termination Issues Signed Comparison Vulnerabilities Integer-Related Vulnerabilities Different-Sized Integer Conversions Double Free Vulnerabilities Out-of-Scope Memory Usage Vulnerabilities Uninitialized Variable Usage

9 Contents Use After Free Vulnerabilities 401 Multithreaded Issues and Re-Entrant Safe Code 402 Beyond Recognition: A Real Vulnerability versus a Bug 402 Conclusion 403 Chapter 17 Instrumented Investigation: A Manual Approach 405 Philosophy 405 Oracle extproc Overflow 406 Common Architectural Failures 410 Problems Happen at Boundaries 410 A Process Calling into an External Process on the Same Host 410 A Process Calling into an External, Dynamically Loaded Library 410 A Process Calling into a Function on a Remote Host 411 Problems Happen When Data Is Translated 411 Problems Cluster in Areas of Asymmetry 413 Problems Occur When Authentication and Authorization Are Confused 414 Problems Occur in the Dumbest Places 414 Bypassing Input Validation and Attack Detection 415 Stripping Bad Data 415 Using Alternate Encodings 415 Using File-Handling Features 416 Required String Is Present in Path 416 Prohibited String Not Present in Path 417 Incorrect Behavior Based on File Extension 417 Evading Attack Signatures 419 Defeating Length Limitations 419 Sea Monkey Data 419 Harmful Truncation Severing Escape Characters 420 Multiple Attempts 421 Context-Free Length Limits 421 Windows 2000 SNMP DOS 421 Finding DOS Attacks 422 SQL-UDP 423 Conclusion 424 Chapter 18 Tracing for Vulnerabilities 427 Overview 428 A Vulnerable Program 429 Component Design 431 Process Injection 432 Machine-Code Analysis 432 Function Hooking 436 Data Collection 439

10 Contents xxi Building VulnTrace 440 VTInject 440 VulnTrace.dll 443 Using VulnTrace 445 Advanced Techniques 448 Fingerprint Systems 448 More Vulnerability Classes 449 Conclusion 450 Chapter 19 Binary Auditing: Hacking Closed Source Software 451 Binary versus Source-Code Auditing: The Obvious Differences 452 IDA Pro The Tool of the Trade 452 Features: A Quick Crash Course 453 Debugging Symbols 454 Binary Auditing Introduction 454 Stack Frames 454 Traditional BP-Based Stack Frames 455 Functions without a Frame Pointer 455 Non-Traditional BP-Based Stack Frames 456 Calling Conventions 456 The C Calling Convention 457 The Stdcall Calling Convention 457 Compiler-Generated Code 458 Function Layouts 458 If Statements 458 For and While Loops 459 Switch Statements 460 memcpy-like Code Constructs 462 strlen-like Code Constructs 462 C++ Code Constructs 463 The this Pointer 463 Reconstructing Class Definitions 464 vtables 465 Quick but Useful Tidbits 465 Manual Binary Analysis 466 Quick Examination of Library Calls 466 Suspicious Loops and Write Instructions 466 Higher-Level Understanding and Logic Bugs 467 Graphical Analysis of Binaries 468 Manual Decompilation 468 Binary Vulnerability Examples 468 Microsoft SQL Server Bugs 469 LSD's RPC-DCOM Vulnerability 469 IIS WebDAV Vulnerability 470 Conclusion 472

11 xxii Contents Part 4 Advanced Materials 473 Chapter 20 Alternative Payload Strategies 475 Modifying the Program 476 The SQL Server 3-Byte Patch 477 The MySQL 1-Bit Patch 481 OpenSSH RS A Authentication Patch 483 Other Runtime Patching Ideas 484 GPG Randomness Patch 485 Upload and Run (or Proglet Server) 486 Syscall Proxies 486 Problems with Syscall Proxies 489 Conclusion 498 Chapter 21 Writing Exploits that Work in the Wild 499 Factors in Unreliability 499 Magic Numbers 499 Versioning 500 Shellcode Problems 501 Network Related 501 Privilege Related 501 Configuration Related 502 Host IDS Related 502 Thread Related 502 Countermeasures 503 Preparation 504 Brüte Forcing 504 Local Exploits 505 OS/Application Fingerprinting 505 Information Leaks 507 Conclusion 508 Chapter 22 Attacking Database Software 509 Network Layer Attacks 510 Application Layer Attacks 520 Running Operating System Commands 521 Microsoft SQL Server 521 Oracle 522 IBM DB2 523 Exploiting Overruns at the SQL Level 525 SQL Functions 526 Using the CHR/CHAR Function 526 Conclusion 528 Chapter 23 Kernel Overflows 529 Kernel Vulnerability Types 529 Oday Kernel Vulnerabilities 538 OpenBSD exec_ibcs2_coff_prep_zmagic() Stack Overflow 538 The Vulnerability 540

12 Contents xxiii Solaris vfs_getvfssw() Loadable Kernel Module Traversal Vulnerability The sysfs() System Call The mount() System Call Conclusion Chapter 24 Exploiting Kernel Vulnerabilities The exec_ibcs2_coff_prep_zmagic() Vulnerability Calculating Offsets and Breakpoints Overwriting the Return Address and Redirecting Execution Locating the Process Descriptor (or the Proc Structure) Stack Lookup sysctl() Syscall Kernel Mode Payload Creation p_cred and u_cred Breaking chroot Returning Back from Kernel Payload Return to User Mode: iret Technique Return to Kernel Code: sidt Technique and _kernel_text Search Getting root (uid=0) Solaris vfs_getvfssw() Loadable Kernel Module Path Traversal Exploit Crafting the Exploit The Kernel Module to Load Getting root (uid=0) Conclusion Index 581

The Shellcoder's Handbook Discovering and Exploiting Security Holes Second Edition

The Shellcoder's Handbook Discovering and Exploiting Security Holes Second Edition The Shellcoder's Handbook Discovering and Exploiting Security Holes Second Edition Chris Anley John Heasman Felix "FX" Linder Gerardo Richarte The Shellcoder's Handbook: Discovering and Exploiting Security

More information

CNIT 127: Exploit Development. Ch 18: Source Code Auditing. Updated

CNIT 127: Exploit Development. Ch 18: Source Code Auditing. Updated CNIT 127: Exploit Development Ch 18: Source Code Auditing Updated 4-10-17 Why Audit Source Code? Best way to discover vulnerabilities Can be done with just source code and grep Specialized tools make it

More information

1.1 For Fun and Profit. 1.2 Common Techniques. My Preferred Techniques

1.1 For Fun and Profit. 1.2 Common Techniques. My Preferred Techniques 1 Bug Hunting Bug hunting is the process of finding bugs in software or hardware. In this book, however, the term bug hunting will be used specifically to describe the process of finding security-critical

More information

Foreword by Katie Moussouris... Acknowledgments... xvii. Introduction...xix. Chapter 1: The Basics of Networking... 1

Foreword by Katie Moussouris... Acknowledgments... xvii. Introduction...xix. Chapter 1: The Basics of Networking... 1 Brief Contents Foreword by Katie Moussouris.... xv Acknowledgments... xvii Introduction...xix Chapter 1: The Basics of Networking... 1 Chapter 2: Capturing Application Traffic... 11 Chapter 3: Network

More information

CNIT 127: Exploit Development. Ch 3: Shellcode. Updated

CNIT 127: Exploit Development. Ch 3: Shellcode. Updated CNIT 127: Exploit Development Ch 3: Shellcode Updated 1-30-17 Topics Protection rings Syscalls Shellcode nasm Assembler ld GNU Linker objdump to see contents of object files strace System Call Tracer Removing

More information

Hunting Security Bugs

Hunting Security Bugs Microsoft Hunting Security Bugs * Tom Gallagher Bryan Jeffries Lawrence Landauer Contents at a Glance 1 General Approach to Security Testing 1 2 Using Threat Models for Security Testing 11 3 Finding Entry

More information

Penetration Testing with Kali Linux

Penetration Testing with Kali Linux Penetration Testing with Kali Linux PWK Copyright Offensive Security Ltd. All rights reserved. Page 1 of 11 All rights reserved to Offensive Security No part of this publication, in whole or in part, may

More information

Buffer overflow background

Buffer overflow background and heap buffer background Comp Sci 3600 Security Heap Outline and heap buffer Heap 1 and heap 2 3 buffer 4 5 Heap Outline and heap buffer Heap 1 and heap 2 3 buffer 4 5 Heap Address Space and heap buffer

More information

SQL Injection Attacks and Defense

SQL Injection Attacks and Defense SQL Injection Attacks and Defense Justin Clarke Lead Author and Technical Editor Rodrigo Marcos Alvarez Dave Hartley Joseph Hemler Alexander Kornbrust Haroon Meer Gary O'Leary-Steele Alberto Revelli Marco

More information

20: Exploits and Containment

20: Exploits and Containment 20: Exploits and Containment Mark Handley Andrea Bittau What is an exploit? Programs contain bugs. These bugs could have security implications (vulnerabilities) An exploit is a tool which exploits a vulnerability

More information

CNIT 127: Exploit Development. Ch 14: Protection Mechanisms. Updated

CNIT 127: Exploit Development. Ch 14: Protection Mechanisms. Updated CNIT 127: Exploit Development Ch 14: Protection Mechanisms Updated 3-25-17 Topics Non-Executable Stack W^X (Either Writable or Executable Memory) Stack Data Protection Canaries Ideal Stack Layout AAAS:

More information

CONTENTS IN DETAIL. FOREWORD by HD Moore ACKNOWLEDGMENTS INTRODUCTION 1 THE ABSOLUTE BASICS OF PENETRATION TESTING 1 2 METASPLOIT BASICS 7

CONTENTS IN DETAIL. FOREWORD by HD Moore ACKNOWLEDGMENTS INTRODUCTION 1 THE ABSOLUTE BASICS OF PENETRATION TESTING 1 2 METASPLOIT BASICS 7 CONTENTS IN DETAIL FOREWORD by HD Moore xiii PREFACE xvii ACKNOWLEDGMENTS xix Special Thanks... xx INTRODUCTION xxi Why Do A Penetration Test?... xxii Why Metasploit?... xxii A Brief History of Metasploit...

More information

Is stack overflow still a problem?

Is stack overflow still a problem? Morris Worm (1998) Code Red (2001) Secure Programming Lecture 4: Memory Corruption II (Stack Overflows) David Aspinall, Informatics @ Edinburgh 31st January 2017 Memory corruption Buffer overflow remains

More information

C O N t E N t s I N D E ta I l FORewORd by dr. Jared demott acknowledgments xvii introduction xix PaRT 1 TOOLS OF THe TRade

C O N t E N t s I N D E ta I l FORewORd by dr. Jared demott acknowledgments xvii introduction xix PaRT 1 TOOLS OF THe TRade Foreword by Dr. Jared DeMott xv Acknowledgments xvii Introduction Prerequisites for the Reader...xx A Brief Game Hacking History....xx Why Hack Games?... xxi How This Book Is Organized...xxii About the

More information

Buffer overflow is still one of the most common vulnerabilities being discovered and exploited in commodity software.

Buffer overflow is still one of the most common vulnerabilities being discovered and exploited in commodity software. Outline Morris Worm (1998) Infamous attacks Secure Programming Lecture 4: Memory Corruption II (Stack Overflows) David Aspinall, Informatics @ Edinburgh 23rd January 2014 Recap Simple overflow exploit

More information

Università Ca Foscari Venezia

Università Ca Foscari Venezia Stack Overflow Security 1 2018-19 Università Ca Foscari Venezia www.dais.unive.it/~focardi secgroup.dais.unive.it Introduction Buffer overflow is due to careless programming in unsafe languages like C

More information

Other array problems. Integer overflow. Outline. Integer overflow example. Signed and unsigned

Other array problems. Integer overflow. Outline. Integer overflow example. Signed and unsigned Other array problems CSci 5271 Introduction to Computer Security Day 4: Low-level attacks Stephen McCamant University of Minnesota, Computer Science & Engineering Missing/wrong bounds check One unsigned

More information

Bypassing Browser Memory Protections

Bypassing Browser Memory Protections Bypassing Browser Memory Protections Network Security Instructor: Dr. Shishir Nagaraja September 10, 2011. 1 Introduction to the topic A number of memory protection mechanisms like GS, SafeSEH, DEP and

More information

ECE 471 Embedded Systems Lecture 22

ECE 471 Embedded Systems Lecture 22 ECE 471 Embedded Systems Lecture 22 Vince Weaver http://www.eece.maine.edu/~vweaver vincent.weaver@maine.edu 31 October 2018 Don t forget HW#7 Announcements 1 Computer Security and why it matters for embedded

More information

Vivisection of an Exploit: What To Do When It Isn't Easy. Dave Aitel Immunity, Inc

Vivisection of an Exploit: What To Do When It Isn't Easy. Dave Aitel Immunity, Inc Vivisection of an Exploit: What To Do When It Isn't Easy Dave Aitel Immunity, Inc http://www.immunitysec.com Who am I? Founder, Immunity, Inc. NYC based consulting and products company CANVAS: Exploitation

More information

Identifying Memory Corruption Bugs with Compiler Instrumentations. 이병영 ( 조지아공과대학교

Identifying Memory Corruption Bugs with Compiler Instrumentations. 이병영 ( 조지아공과대학교 Identifying Memory Corruption Bugs with Compiler Instrumentations 이병영 ( 조지아공과대학교 ) blee@gatech.edu @POC2014 How to find bugs Source code auditing Fuzzing Source Code Auditing Focusing on specific vulnerability

More information

Hack in the Box Trends and Tools. H D Moore

Hack in the Box Trends and Tools. H D Moore Hack in the Box 2003 Advanced Exploit Development Trends and Tools H D Moore 1 Who Who am I? Co-founder of Digital Defense Security researcher (5+ years) Projects DigitalOffense.net Metasploit.com 2 What

More information

A program execution is memory safe so long as memory access errors never occur:

A program execution is memory safe so long as memory access errors never occur: A program execution is memory safe so long as memory access errors never occur: Buffer overflows, null pointer dereference, use after free, use of uninitialized memory, illegal free Memory safety categories

More information

CS 642 Homework #4. Due Date: 11:59 p.m. on Tuesday, May 1, Warning!

CS 642 Homework #4. Due Date: 11:59 p.m. on Tuesday, May 1, Warning! CS 642 Homework #4 Due Date: 11:59 p.m. on Tuesday, May 1, 2007 Warning! In this assignment, you will construct and launch attacks against a vulnerable computer on the CS network. The network administrators

More information

MSRPC Heap Overflow Part II

MSRPC Heap Overflow Part II MSRPC Heap Overflow Part II Dave Aitel So a new approach is needed. As with any heap overflow, you get to chose a where and a what value, subject to certain constraints. If you chose a what value that

More information

A Security Microcosm Attacking and Defending Shiva

A Security Microcosm Attacking and Defending Shiva A Security Microcosm Attacking and Defending Shiva Shiva written by Neel Mehta and Shaun Clowes Presented by Shaun Clowes shaun@securereality.com.au What is Shiva? Shiva is an executable encryptor Encrypted

More information

Software Security II: Memory Errors - Attacks & Defenses

Software Security II: Memory Errors - Attacks & Defenses 1 Software Security II: Memory Errors - Attacks & Defenses Chengyu Song Slides modified from Dawn Song 2 Administrivia Lab1 Writeup 3 Buffer overflow Out-of-bound memory writes (mostly sequential) Allow

More information

Play with FILE Structure Yet Another Binary Exploitation Technique. Abstract

Play with FILE Structure Yet Another Binary Exploitation Technique. Abstract Play with FILE Structure Yet Another Binary Exploitation Technique An-Jie Yang (Angelboy) angelboy@chroot.org Abstract To fight against prevalent cyber threat, more mechanisms to protect operating systems

More information

Secure Software Programming and Vulnerability Analysis

Secure Software Programming and Vulnerability Analysis Secure Software Programming and Vulnerability Analysis Christopher Kruegel chris@auto.tuwien.ac.at http://www.auto.tuwien.ac.at/~chris Race Conditions Secure Software Programming 2 Overview Parallel execution

More information

Beyond Stack Smashing: Recent Advances in Exploiting. Jonathan Pincus(MSR) and Brandon Baker (MS)

Beyond Stack Smashing: Recent Advances in Exploiting. Jonathan Pincus(MSR) and Brandon Baker (MS) Beyond Stack Smashing: Recent Advances in Exploiting Buffer Overruns Jonathan Pincus(MSR) and Brandon Baker (MS) Buffer Overflows and How they Occur Buffer is a contiguous segment of memory of a fixed

More information

Documentation for exploit entitled nginx 1.3.9/1.4.0 x86 Brute Force Remote Exploit

Documentation for exploit entitled nginx 1.3.9/1.4.0 x86 Brute Force Remote Exploit Documentation for exploit entitled nginx 1.3.9/1.4.0 x86 Brute Force Remote Exploit about a generic way to exploit Linux targets written by Kingcope Introduction In May 2013 a security advisory was announced

More information

Buffer Overflows Defending against arbitrary code insertion and execution

Buffer Overflows Defending against arbitrary code insertion and execution www.harmonysecurity.com info@harmonysecurity.com Buffer Overflows Defending against arbitrary code insertion and execution By Stephen Fewer Contents 1 Introduction 2 1.1 Where does the problem lie? 2 1.1.1

More information

Offensive Security My First Buffer Overflow: Tutorial

Offensive Security My First Buffer Overflow: Tutorial Offensive Security My First Buffer Overflow: Tutorial César Bernardini University of Trento cesar.bernardini@unitn.it October 12, 2015 2 Cesar Bernardini Postdoctoral Fellow at UNITN PhD Student at INRIA-LORIA

More information

ECS 153 Discussion Section. April 6, 2015

ECS 153 Discussion Section. April 6, 2015 ECS 153 Discussion Section April 6, 2015 1 What We ll Cover Goal: To discuss buffer overflows in detail Stack- based buffer overflows Smashing the stack : execution from the stack ARC (or return- to- libc)

More information

TABLE OF CONTENT 1. Abstract: Terminology Introduction Basic Shellcoding Solving The Addressing Problem Hash API

TABLE OF CONTENT 1. Abstract: Terminology Introduction Basic Shellcoding Solving The Addressing Problem Hash API SECURITY PAPER Preparation Date: 11 Dec 2016 Art of Anti Detection 3 Shellcode Alchemy Prepared by: Ege BALCI Penetration Tester ege.balciinvictuseurope.com TABLE OF CONTENT 1. Abstract:...3 2. Terminology...

More information

Security and Privacy in Computer Systems. Lecture 5: Application Program Security

Security and Privacy in Computer Systems. Lecture 5: Application Program Security CS 645 Security and Privacy in Computer Systems Lecture 5: Application Program Security Buffer overflow exploits More effective buffer overflow attacks Preventing buffer overflow attacks Announcement Project

More information

Shellbased Wargaming

Shellbased Wargaming Shellbased Wargaming Abstract Wargaming is a hands-on way to learn about computer security and common programming mistakes. This document is intended for readers new to the subject and who are interested

More information

Exploits and gdb. Tutorial 5

Exploits and gdb. Tutorial 5 Exploits and gdb Tutorial 5 Exploits and gdb 1. Buffer Vulnerabilities 2. Code Injection 3. Integer Attacks 4. Advanced Exploitation 5. GNU Debugger (gdb) Buffer Vulnerabilities Basic Idea Overflow or

More information

Confinement (Running Untrusted Programs)

Confinement (Running Untrusted Programs) Confinement (Running Untrusted Programs) Chester Rebeiro Indian Institute of Technology Madras Untrusted Programs Untrusted Application Entire Application untrusted Part of application untrusted Modules

More information

(In columns, of course.)

(In columns, of course.) CPS 310 first midterm exam, 10/9/2013 Your name please: Part 1. Fun with forks (a) What is the output generated by this program? In fact the output is not uniquely defined, i.e., it is not always the same.

More information

Homework 1 CS 642: Information Security

Homework 1 CS 642: Information Security Homework 1 CS 642: Information Security September 22, 2012 This homework assignment tasks you with understanding vulnerabilities in five target programs. You may (optionally) work with a partner. It is

More information

C and C++ Secure Coding 4-day course. Syllabus

C and C++ Secure Coding 4-day course. Syllabus C and C++ Secure Coding 4-day course Syllabus C and C++ Secure Coding 4-Day Course Course description Secure Programming is the last line of defense against attacks targeted toward our systems. This course

More information

CSC 405 Computer Security Shellcode

CSC 405 Computer Security Shellcode CSC 405 Computer Security Shellcode Alexandros Kapravelos akaprav@ncsu.edu Attack plan Attack code Vulnerable code xor ebx, ebx xor eax, eax mov ebx,edi mov eax,edx sub eax,0x388 Vulnerable code xor ebx,

More information

Security Workshop HTS. LSE Team. February 3rd, 2016 EPITA / 40

Security Workshop HTS. LSE Team. February 3rd, 2016 EPITA / 40 Security Workshop HTS LSE Team EPITA 2018 February 3rd, 2016 1 / 40 Introduction What is this talk about? Presentation of some basic memory corruption bugs Presentation of some simple protections Writing

More information

Runtime Process Insemination

Runtime Process Insemination Runtime Process Insemination Shawn lattera Webb SoldierX https://www.soldierx.com/ Who Am I? Just another blogger Professional Security Analyst Twelve-year C89 programmer Member of SoldierX, BinRev, and

More information

Return-orientated Programming

Return-orientated Programming Return-orientated Programming or The Geometry of Innocent Flesh on the Bone: Return-into-libc without Function Calls (on the x86) Hovav Shacham, CCS '07 Return-Oriented oriented Programming programming

More information

SOME ASSEMBLY REQUIRED

SOME ASSEMBLY REQUIRED SOME ASSEMBLY REQUIRED Assembly Language Programming with the AVR Microcontroller TIMOTHY S. MARGUSH CRC Press Taylor & Francis Group CRC Press is an imprint of the Taylor & Francis Croup an Informa business

More information

TH IRD EDITION. Python Cookbook. David Beazley and Brian K. Jones. O'REILLY. Beijing Cambridge Farnham Köln Sebastopol Tokyo

TH IRD EDITION. Python Cookbook. David Beazley and Brian K. Jones. O'REILLY. Beijing Cambridge Farnham Köln Sebastopol Tokyo TH IRD EDITION Python Cookbook David Beazley and Brian K. Jones O'REILLY. Beijing Cambridge Farnham Köln Sebastopol Tokyo Table of Contents Preface xi 1. Data Structures and Algorithms 1 1.1. Unpacking

More information

Secure Software Development: Theory and Practice

Secure Software Development: Theory and Practice Secure Software Development: Theory and Practice Suman Jana MW 2:40-3:55pm 415 Schapiro [SCEP] *Some slides are borrowed from Dan Boneh and John Mitchell Software Security is a major problem! Why writing

More information

12 th January MWR InfoSecurity Security Advisory. WebSphere MQ xcsgetmem Heap Overflow Vulnerability. Contents

12 th January MWR InfoSecurity Security Advisory. WebSphere MQ xcsgetmem Heap Overflow Vulnerability. Contents Contents MWR InfoSecurity Security Advisory WebSphere MQ xcsgetmem Heap Overflow Vulnerability 12 th January 2009 2009-01-05 Page 1 of 9 Contents Contents 1 Detailed Vulnerability Description...5 1.1 Introduction...5

More information

Module: Program Vulnerabilities. Professor Trent Jaeger. CSE543 - Introduction to Computer and Network Security

Module: Program Vulnerabilities. Professor Trent Jaeger. CSE543 - Introduction to Computer and Network Security CSE543 - Introduction to Computer and Network Security Module: Program Vulnerabilities Professor Trent Jaeger 1 1 Programming Why do we write programs? Function What functions do we enable via our programs?

More information

Shellcode Analysis. Chapter 19

Shellcode Analysis. Chapter 19 Shellcode Analysis Chapter 19 What is Shellcode Shellcode a payload of raw executable code, attackers use this code to obtain interactive shell access. A binary chunk of data Can be generally referred

More information

(Early) Memory Corruption Attacks

(Early) Memory Corruption Attacks (Early) Memory Corruption Attacks CS-576 Systems Security Instructor: Georgios Portokalidis Fall 2018 Fall 2018 Stevens Institute of Technology 1 Memory Corruption Memory corruption occurs in a computer

More information

Linux Kernel Architecture

Linux Kernel Architecture Professional Linux Kernel Architecture Wolf gang Mauerer WILEY Wiley Publishing, Inc. Introduction xxvii Chapter 1: Introduction and Overview 1 Tasks of the Kernel v -- 2 Implementation Strategies 3 Elements

More information

Why bother? Default configurations Buffer overflows Authentication mechanisms Reverse engineering Questions?

Why bother? Default configurations Buffer overflows Authentication mechanisms Reverse engineering Questions? Jeroen van Beek 1 Why bother? Default configurations Buffer overflows Authentication mechanisms Reverse engineering Questions? 2 Inadequate OS and application security: Data abuse Stolen information Bandwidth

More information

CS 161 Computer Security

CS 161 Computer Security Paxson Spring 2017 CS 161 Computer Security Discussion 2 Question 1 Software Vulnerabilities (15 min) For the following code, assume an attacker can control the value of basket passed into eval basket.

More information

General Pr0ken File System

General Pr0ken File System General Pr0ken File System Hacking IBM s GPFS Felix Wilhelm & Florian Grunow 11/2/2015 GPFS Felix Wilhelm && Florian Grunow #2 Agenda Technology Overview Digging in the Guts of GPFS Remote View Getting

More information

Module: Program Vulnerabilities. Professor Trent Jaeger. CSE543 - Introduction to Computer and Network Security

Module: Program Vulnerabilities. Professor Trent Jaeger. CSE543 - Introduction to Computer and Network Security CSE543 - Introduction to Computer and Network Security Module: Program Vulnerabilities Professor Trent Jaeger 1 Programming Why do we write programs? Function What functions do we enable via our programs?

More information

Hackveda Training - Ethical Hacking, Networking & Security

Hackveda Training - Ethical Hacking, Networking & Security Hackveda Training - Ethical Hacking, Networking & Security Day1: Hacking windows 7 / 8 system and security Part1 a.) Windows Login Password Bypass manually without CD / DVD b.) Windows Login Password Bypass

More information

Module: Program Vulnerabilities. Professor Trent Jaeger. CSE543 - Introduction to Computer and Network Security

Module: Program Vulnerabilities. Professor Trent Jaeger. CSE543 - Introduction to Computer and Network Security CSE543 - Introduction to Computer and Network Security Module: Program Vulnerabilities Professor Trent Jaeger 1 Programming Why do we write programs? Function What functions do we enable via our programs?

More information

Foundations of Python

Foundations of Python Foundations of Python Network Programming The comprehensive guide to building network applications with Python Second Edition Brandon Rhodes John Goerzen Apress Contents Contents at a Glance About the

More information

Secure Systems Engineering

Secure Systems Engineering Secure Systems Engineering Chester Rebeiro Indian Institute of Technology Madras Flaws that would allow an attacker access the OS flaw Bugs in the OS The Human factor Chester Rebeiro, IITM 2 Program Bugs

More information

Fundamentals of Linux Platform Security

Fundamentals of Linux Platform Security Fundamentals of Linux Platform Security Security Training Course Dr. Charles J. Antonelli The University of Michigan 2012 Linux Platform Security Module 8 Arbitrary Code Execution: Threats & Countermeasures

More information

Lab 2: Buffer Overflows

Lab 2: Buffer Overflows Department of Computer Science: Cyber Security Practice Lab 2: Buffer Overflows Introduction In this lab, you will learn how buffer overflows and other memory vulnerabilities are used to takeover vulnerable

More information

CS155: Computer Security Spring Project #1

CS155: Computer Security Spring Project #1 CS155: Computer Security Spring 2018 Project #1 Due: Part 1: Thursday, April 12-11:59pm, Parts 2 and 3: Thursday, April 19-11:59pm. The goal of this assignment is to gain hands-on experience finding vulnerabilities

More information

Lecture 4 Processes. Dynamic Analysis. GDB

Lecture 4 Processes. Dynamic Analysis. GDB Lecture 4 Processes. Dynamic Analysis. GDB Computer and Network Security 23th of October 2017 Computer Science and Engineering Department CSE Dep, ACS, UPB Lecture 4, Processes. Dynamic Analysis. GDB 1/45

More information

Lecture 4 September Required reading materials for this class

Lecture 4 September Required reading materials for this class EECS 261: Computer Security Fall 2007 Lecture 4 September 6 Lecturer: David Wagner Scribe: DK Moon 4.1 Required reading materials for this class Beyond Stack Smashing: Recent Advances in Exploiting Buffer

More information

Agenda. The Mindset Finding vulnerabilities Writing exploits Exploiting non-standard stuff

Agenda. The Mindset Finding vulnerabilities Writing exploits Exploiting non-standard stuff Agenda The Mindset Finding vulnerabilities Writing exploits Exploiting non-standard stuff Mindset 1. Understand John von Neumann! For any given computer today, there is no difference between data and code.

More information

Exercise 6: Buffer Overflow and return-into-libc Attacks

Exercise 6: Buffer Overflow and return-into-libc Attacks Technische Universität Darmstadt Fachbereich Informatik System Security Lab Prof. Dr.-Ing. Ahmad-Reza Sadeghi M.Sc. David Gens Exercise 6: Buffer Overflow and return-into-libc Attacks Course Secure, Trusted

More information

CMSC 414 Computer and Network Security

CMSC 414 Computer and Network Security CMSC 414 Computer and Network Security Buffer Overflows Dr. Michael Marsh August 30, 2017 Trust and Trustworthiness You read: Reflections on Trusting Trust (Ken Thompson), 1984 Smashing the Stack for Fun

More information

Hacking Blind BROP. Presented by: Brooke Stinnett. Article written by: Andrea Bittau, Adam Belay, Ali Mashtizadeh, David Mazie`res, Dan Boneh

Hacking Blind BROP. Presented by: Brooke Stinnett. Article written by: Andrea Bittau, Adam Belay, Ali Mashtizadeh, David Mazie`res, Dan Boneh Hacking Blind BROP Presented by: Brooke Stinnett Article written by: Andrea Bittau, Adam Belay, Ali Mashtizadeh, David Mazie`res, Dan Boneh Overview Objectives Introduction to BROP ROP recap BROP key phases

More information

Copyright 2015 MathEmbedded Ltd.r. Finding security vulnerabilities by fuzzing and dynamic code analysis

Copyright 2015 MathEmbedded Ltd.r. Finding security vulnerabilities by fuzzing and dynamic code analysis Finding security vulnerabilities by fuzzing and dynamic code analysis Security Vulnerabilities Top code security vulnerabilities don t change much: Security Vulnerabilities Top code security vulnerabilities

More information

Malware

Malware reloaded Malware Research Team @ @xabiugarte Motivation Design principles / architecture Features Use cases Future work Dynamic Binary Instrumentation Techniques to trace the execution of a binary (or

More information

Runtime Defenses against Memory Corruption

Runtime Defenses against Memory Corruption CS 380S Runtime Defenses against Memory Corruption Vitaly Shmatikov slide 1 Reading Assignment Cowan et al. Buffer overflows: Attacks and defenses for the vulnerability of the decade (DISCEX 2000). Avijit,

More information

CSE 565 Computer Security Fall 2018

CSE 565 Computer Security Fall 2018 CSE 565 Computer Security Fall 2018 Lecture 14: Software Security Department of Computer Science and Engineering University at Buffalo 1 Software Security Exploiting software vulnerabilities is paramount

More information

2 Sadeghi, Davi TU Darmstadt 2012 Secure, Trusted, and Trustworthy Computing Chapter 6: Runtime Attacks

2 Sadeghi, Davi TU Darmstadt 2012 Secure, Trusted, and Trustworthy Computing Chapter 6: Runtime Attacks Runtime attacks are major threats to today's applications Control-flow of an application is compromised at runtime Typically, runtime attacks include injection of malicious code Reasons for runtime attacks

More information

Process Dump Analyses

Process Dump Analyses Process Dump Analyses 1 Process Dump Analyses Forensical acquisition and analyses of volatile data Tobias Klein tk@trapkit.de Version 1.0, 2006/07/22. Process Dump Analyses 2 1 Overview There is a general

More information

CSC 591 Systems Attacks and Defenses Stack Canaries & ASLR

CSC 591 Systems Attacks and Defenses Stack Canaries & ASLR CSC 591 Systems Attacks and Defenses Stack Canaries & ASLR Alexandros Kapravelos akaprav@ncsu.edu How can we prevent a buffer overflow? Check bounds Programmer Language Stack canaries [...more ] Buffer

More information

Advances in Linux process forensics with ECFS

Advances in Linux process forensics with ECFS Advances in Linux process forensics with ECFS Quick history Wanted to design a process snapshot format native to VMA Vudu http://www.bitlackeys.org/#vmavudu ECFS proved useful for other projects as well

More information

Why bother? Default configurations Buffer overflows Authentication mechanisms Reverse engineering Questions?

Why bother? Default configurations Buffer overflows Authentication mechanisms Reverse engineering Questions? Jeroen van Beek 1 Why bother? Default configurations Buffer overflows Authentication mechanisms Reverse engineering Questions? 2 Inadequate OS and application security: Data abuse Stolen information Bandwidth

More information

In-Memory Fuzzing in JAVA

In-Memory Fuzzing in JAVA Your texte here. In-Memory Fuzzing in JAVA 2012.12.17 Xavier ROUSSEL Summary I. What is Fuzzing? Your texte here. Introduction Fuzzing process Targets Inputs vectors Data generation Target monitoring Advantages

More information

Managed. Code Rootkits. Hooking. into Runtime. Environments. Erez Metula ELSEVIER. Syngress is an imprint of Elsevier SYNGRESS

Managed. Code Rootkits. Hooking. into Runtime. Environments. Erez Metula ELSEVIER. Syngress is an imprint of Elsevier SYNGRESS Managed Code Rootkits Hooking into Runtime Environments Erez Metula ELSEVIER AMSTERDAM BOSTON HEIDELBERG LONDON NEWYORK OXFORD PARIS SAN DIEGO SAN FRANCISCO SINGAPORE SYDNEY TOKYO Syngress is an imprint

More information

Stack-Based Buffer Overflow Explained. Marc Koser. East Carolina University. ICTN 4040: Enterprise Information Security

Stack-Based Buffer Overflow Explained. Marc Koser. East Carolina University. ICTN 4040: Enterprise Information Security Running Head: BUFFER OVERFLOW 1 Stack-Based Buffer Overflow Explained Marc Koser East Carolina University ICTN 4040: Enterprise Information Security Instructor: Dr. Philip Lunsford 03-17-2015 Prepared

More information

Buffer Overflow Defenses

Buffer Overflow Defenses Buffer Overflow Defenses Some examples, pros, and cons of various defenses against buffer overflows. Caveats: 1. Not intended to be a complete list of products that defend against buffer overflows. 2.

More information

Lecture 08 Control-flow Hijacking Defenses

Lecture 08 Control-flow Hijacking Defenses Lecture 08 Control-flow Hijacking Defenses Stephen Checkoway University of Illinois at Chicago CS 487 Fall 2017 Slides adapted from Miller, Bailey, and Brumley Control Flow Hijack: Always control + computation

More information

CS 550 Operating Systems Spring System Call

CS 550 Operating Systems Spring System Call CS 550 Operating Systems Spring 2018 System Call 1 Recap: The need for protection When running user processes, the OS needs to protect itself and other system components For reliability: buggy programs

More information

CS 161 Computer Security

CS 161 Computer Security Paxson Spring 2011 CS 161 Computer Security Discussion 1 January 26, 2011 Question 1 Buffer Overflow Mitigations Buffer overflow mitigations generally fall into two categories: (i) eliminating the cause

More information

Software Vulnerability

Software Vulnerability Software Vulnerability Refers to a weakness in a system allowing an attacker to violate the integrity, confidentiality, access control, availability, consistency or audit mechanism of the system or the

More information

Ethical Hacking: Preventing & Writing Buffer Overflow Exploits

Ethical Hacking: Preventing & Writing Buffer Overflow Exploits Ethical Hacking: Preventing & Writing Buffer Overflow Exploits Rochester Security Summit 2014 Rochester OWASP Chapter Lead Ralph Durkee - Durkee Consulting, Inc. info@rd1.net Ralph Durkee Background Founder

More information

Outline. Format string attack layout. Null pointer dereference

Outline. Format string attack layout. Null pointer dereference CSci 5271 Introduction to Computer Security Day 5: Low-level defenses and counterattacks Stephen McCamant University of Minnesota, Computer Science & Engineering Null pointer dereference Format string

More information

Computer Systems A Programmer s Perspective 1 (Beta Draft)

Computer Systems A Programmer s Perspective 1 (Beta Draft) Computer Systems A Programmer s Perspective 1 (Beta Draft) Randal E. Bryant David R. O Hallaron August 1, 2001 1 Copyright c 2001, R. E. Bryant, D. R. O Hallaron. All rights reserved. 2 Contents Preface

More information

Hacking Blind. Andrea Bittau, Adam Belay, Ali Mashtizadeh, David Mazières, Dan Boneh. Stanford University

Hacking Blind. Andrea Bittau, Adam Belay, Ali Mashtizadeh, David Mazières, Dan Boneh. Stanford University Hacking Blind Andrea Bittau, Adam Belay, Ali Mashtizadeh, David Mazières, Dan Boneh Stanford University Hacking 101 Exploit GET /0xDEAD HTTP/1.0 shell $ cat /etc/passwd root:x:0:0:::/bin/sh sorbo:x:6:9:pac:/bin/sh

More information

Language Security. Lecture 40

Language Security. Lecture 40 Language Security Lecture 40 (from notes by G. Necula) Prof. Hilfinger CS 164 Lecture 40 1 Lecture Outline Beyond compilers Looking at other issues in programming language design and tools C Arrays Exploiting

More information

It was a dark and stormy night. Seriously. There was a rain storm in Wisconsin, and the line noise dialing into the Unix machines was bad enough to

It was a dark and stormy night. Seriously. There was a rain storm in Wisconsin, and the line noise dialing into the Unix machines was bad enough to 1 2 It was a dark and stormy night. Seriously. There was a rain storm in Wisconsin, and the line noise dialing into the Unix machines was bad enough to keep putting garbage characters into the command

More information

Defeat Exploit Mitigation Heap Attacks. compass-security.com 1

Defeat Exploit Mitigation Heap Attacks. compass-security.com 1 Defeat Exploit Mitigation Heap Attacks compass-security.com 1 ASCII Armor Arbitrary Write Overflow Local Vars Exploit Mitigations Stack Canary ASLR PIE Heap Overflows Brute Force Partial RIP Overwrite

More information

Basic Buffer Overflows

Basic Buffer Overflows Operating Systems Security Basic Buffer Overflows (Stack Smashing) Computer Security & OS lab. Cho, Seong-je ( 조성제 ) Fall, 2018 sjcho at dankook.ac.kr Chapter 10 Buffer Overflow 2 Contents Virtual Memory

More information

The cross-page overwrite and it s application in heap overflows. By Greg Hoglund 2003 HBGary, LLC

The cross-page overwrite and it s application in heap overflows. By Greg Hoglund 2003 HBGary, LLC ABSTRACT The cross-page overwrite and it s application in heap overflows By Greg Hoglund 2003 HBGary, LLC Buffer overflows remain the backbone of subversive code attacks. As stack protection finds more

More information

Engineering Your Software For Attack

Engineering Your Software For Attack Engineering Your Software For Attack Robert A. Martin Senior Principal Engineer Cyber Security Center Center for National Security The MITRE Corporation 2013 The MITRE Corporation. All rights reserved.

More information

Encyclopedia of Crash Dump Analysis Patterns

Encyclopedia of Crash Dump Analysis Patterns Encyclopedia of Crash Dump Analysis Patterns Detecting Abnormal Software Structure and Behavior in Computer Memory Dmitry Vostokov Software Diagnostics Institute OpenTask 2 Published by OpenTask, Republic

More information

Buffer Overflow and Protection Technology. Department of Computer Science,

Buffer Overflow and Protection Technology. Department of Computer Science, Buffer Overflow and Protection Technology Department of Computer Science, Lorenzo Cavallaro Andrea Lanzi Table of Contents Introduction

More information