Introduction to Information Security ROP – Recitation 5.

Slides:



Advertisements
Similar presentations
Practical Malware Analysis
Advertisements

Smashing the Stack for Fun and Profit
David Brumley Carnegie Mellon University Credit: Some slides from Ed Schwartz.
Introduction to Information Security ROP – Recitation 5 nirkrako at post.tau.ac.il itamarg at post.tau.ac.il.
ITEC 352 Lecture 27 Memory(4). Review Questions? Cache control –L1/L2  Main memory example –Formulas for hits.
CMSC 414 Computer and Network Security Lecture 22 Jonathan Katz.
Review: Software Security David Brumley Carnegie Mellon University.
English Shellcode J. Mason, S. Small, F. Monrose, G. MacManus CCS ’09 Presented by: Eugenie Lee EE515/IS523: Security101: Think Like an Adversary.
TK 2633 Microprocessor & Interfacing Lecture 3: Introduction to 8085 Assembly Language Programming (2) 1 Prepared By: Associate Prof. Dr Masri Ayob.
Buffer Overflow. Process Memory Organization.
Assembly תרגול 8 פונקציות והתקפת buffer.. Procedures (Functions) A procedure call involves passing both data and control from one part of the code to.
Andrea Bittau, Adam Belay, Ali Mashtizadeh, David Maziéres, Dan Boneh
OllyDbg Debuger.
CMSC 414 Computer and Network Security Lecture 20 Jonathan Katz.
Security Exploiting Overflows. Introduction r See the following link for more info: operating-systems-and-applications-in-
Introduction to InfoSec – Recitation 2 Nir Krakowski (nirkrako at post.tau.ac.il) Itamar Gilad (itamargi at post.tau.ac.il)
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2011.
Lecture 6: Buffer Overflow CS 436/636/736 Spring 2014 Nitesh Saxena *Adopted from a previous lecture by Aleph One (Smashing the Stack for Fun and Profit)
Carnegie Mellon Introduction to Computer Systems /18-243, spring 2009 Recitation, Jan. 14 th.
Introduction: Exploiting Linux. Basic Concepts Vulnerability A flaw in a system that allows an attacker to do something the designer did not intend,
Mitigation of Buffer Overflow Attacks
CNIT 127: Exploit Development Ch 4: Introduction to Format String Bugs.
Introduction to Information Security מרצים : Dr. Eran Tromer: Prof. Avishai Wool: מתרגלים : Itamar Gilad
Buffer Overflow CS461/ECE422 Spring Reading Material Based on Chapter 11 of the text.
Introduction to InfoSec – Recitation 2 Nir Krakowski (nirkrako at post.tau.ac.il) Itamar Gilad (itamargi at post.tau.ac.il)
Exploitation possibilities of memory related vulnerabilities
Lecture 8: Buffer Overflow CS 436/636/736 Spring 2013 Nitesh Saxena *Adopted from a previous lecture by Aleph One (Smashing the Stack for Fun and Profit)
Lecture 9: Buffer Ovefflows and ROP EEN 312: Processors: Hardware, Software, and Interfacing Department of Electrical and Computer Engineering Spring 2014,
CNIT 127: Exploit Development Ch 1: Before you begin.
Shellcode Development -Femi Oloyede -Pallavi Murudkar.
CS 155 Section 1 PP1 Eu-Jin Goh. Setting up Environment Demo.
Buffer Overflow Attack- proofing of Code Binaries Ramya Reguramalingam Gopal Gupta Gopal Gupta Department of Computer Science University of Texas at Dallas.
Reminder Bomb lab is due tomorrow! Attack lab is released tomorrow!!
Information Security - 2. A Stack Frame. Pushed to stack on function CALL The return address is copied to the CPU Instruction Pointer when the function.
Security Attacks Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
EXPLOITATION CRASH COURSE – FALL 2013 UTD Computer Security Group – Andrew Folloder csg.utdallas.edu (credit: Scott Hand)
1 Assembly Language: Function Calls Jennifer Rexford.
Introduction to InfoSec – Recitation 3 Nir Krakowski (nirkrako at post.tau.ac.il) Itamar Gilad (infosec15 at modprobe.net)
ROP Exploit. ROP Return Oriented Programming (ROP): is a hacking exploit technique where you exploit buffer overflow to inject a chain of gadgets. Each.
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2014.
1 Introduction to Information Security , Spring 2016 Lecture 2: Control Hijacking (2/2) Avishai Wool.
Section 5: Procedures & Stacks
Introduction to Information Security
Shellcode COSC 480 Presentation Alison Buben.
Mitigation against Buffer Overflow Attacks
Jump-Oriented Programming
Introduction to Information Security
Recitation: Attack Lab
Introduction to Information Security
Exploiting & Defense Day 2 Recap
Homework In-line Assembly Code Machine Language
CSC 495/583 Topics of Software Security Return-oriented programming
Assembly Language Programming V: In-line Assembly Code
Recitation: Attack Lab
CMSC 414 Computer and Network Security Lecture 21
Summary by - Bo Zhang and Shuang Guo [Date: 03/31/2014]
Recitation: Attack Lab
Assembly Language Programming II: C Compiler Calling Sequences
Lecture 9: Buffer Overflow*
Smashing the Stack for Fun and Profit
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2015.
Week 2: Buffer Overflow Part 1.
Week 2: Buffer Overflow Part 2.
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2016.
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2013.
System and Cyber Security
Several Tips on Project 1
Computer Architecture and System Programming Laboratory
Return-to-libc Attacks
Presentation transcript:

Introduction to Information Security ROP – Recitation 5

We’ll start by overviewing the last lecture before the long holiday. We’ll continue with a short summary, and how to use the tools needed to complete the exercise faster

Return Oriented Programming Return oriented programming is a different way to control the flow of EIP in a program Motivation: Write or Execute: as a result of overflows, the first prevention technique is to make: o Executable memory segments read-only o Writeable memory segments Non-Executable. Most slides in this presentation were taken as is from: Return-oriented Programming: Exploitation without Code Injection By Erik Buchanan, Ryan Roemer, Stefan Savage, Hovav Shacham from the University of California, San Diego

Getting started Need control of memory around %esp Rewrite stack: o Buffer overflow on stack o Format string vuln to rewrite stack contents Move stack: o Overwrite saved frame pointer on stack; on leave/ret, move %esp to area under attacker control o Overflow function pointer to a register spring for %esp: o set or modify %esp from an attacker-controlled register o then return

Schematic: return to libc Control hijacking without executing code Avishai Wool, lecture args ret-addr sfp local buf stack exec() printf() “/bin/sh” libc.so

Returning to Code Chunks (aka Gadgets) Instead of working with small “opcodes” and %eip, we now use larger chunks of code and %esp All the “larger chunks” do multiple register manipulations, and we must consider the effect of all of them. Not everything we want is possible directly, so we have to be creative and work around the problem. All chunks end with 0xc3 (RET) We are effectively using a new ‘language’ to code.

Chunk guidelines All chunk ends with 0xc3 Chunks should be as minimal as possible, containing minimum amount of data Chunks are better if they appear in more “stable” and common libraries such as: libc. (and can then be reused for different binaries). Chunks can not contain Junks. o If the CPU can not interpret the junk in the chunk, it will stop the program with illegal instruction exception.

ROP – Machine level Stack pointer (%esp) determines which instruction sequence to fetch & execute o Processor doesn’t automatically increment %esp; — but the “ret” at end of each instruction sequence does

No-op equivalent No-op instruction does nothing but advance %eip o Return-oriented equivalent: o point to return instruction o advances %esp o Useful in nop sled

Loading Immediates Instructions can encode constants Return-oriented equivalent: o Store on the stack; o Pop into register to use

Control flow Ordinary programming: o (Conditionally) set %eip to new value Return-oriented equivalent: o (Conditionally) set %esp to new value

Multiple instruction sequence Sometimes more than one instruction sequence needed o to encode logical unit Example: load from memory into register: o Load address of source word into %eax o Load memory at (%eax) into %ebx

Gadget summary We can write complex shellcode by returning to relevant gadgets. All gadgets end with ret. (0xc3) Gadgets can not contain junk (everything must be interpretable) “JMP” is analogous to finding code that modifies the ESP. We don’t have to maintain the original alignment of code (on x86). Example: o MOV EAX, 0x5DC3 o This is interpreted into: B8 5D C3 o However, o POP EBP o RETN o This is interpreted into: o 5D C3 Using rop_ptrace.py we debug the executable and are able to locate relevant gadgets To have we everything flowing correctly and make sure we are aware of where ESP and EIP are pointing to at all times.

Infosec ROP Tools./rop_ptrace.py./memmap.py./disas_at_va.py

./rop_ptrace.py./rop_ptrace.py o Usage:./rop_ptrace.py [filename] [depth] “OPCODE” rop_ptrace.py helps you by loading the binary into memory, therefore causing the creation of all linked shared objects (SO). The list of libraries can also be shown via shell command ‘ldd filename’. After loading the binary and waiting for the SOs to load it will search for code chunks ending with ROP and then look back until [depth] bytes. rop_ptrace.py then codes and disassembles the chunk rop_ptrace.py uses distorm3 to disassemble and python- ptrace library to debug the executable.

./rop_ptrace.py cont. [rop_ptrace.py example]

./memmap.py Usage:./memmap.py [filename] o Prints the libraries, memories mapped to, and their permissions. Usage:./memmap.py [filename] [string] o Attempts to locate the string within the mapped memory sections. memmap.py uses python-ptrace

./memmap.py cont. [memmap.py example]

./disas_at_va.py cont. disas_at_va.py [filename] [va] [length] o Disassembles [length] number of bytes at virtual address [va] after loading the binary [filename] to memory. Uses python-ptrace and distorm3.