INFORMATION SECURITY - PRACTICAL ASSESSMENT - BASICS IN BUFFER EXPLOITATION

Size: px
Start display at page:

Download "INFORMATION SECURITY - PRACTICAL ASSESSMENT - BASICS IN BUFFER EXPLOITATION"

Transcription

1 INFORMATION SECURITY - PRACTICAL ASSESSMENT - BASICS IN BUFFER EXPLOITATION GRENOBLE INP ENSIMAG COMPUTER SCIENCE 3RD YEAR IF-MMIS - 1ST SEMESTER, 2011 Lecturers: Fabien Duchene - Karim Hossen firstname.lastname [ at ] imag.fr NOTE: Practical assessment regarding the course we had on Thu. 22th, September 2011 and regarding the chapter 1.1. They are due for Tuesday 27th, September pm59. This practical assessment will give you some methods used by security professionals to exploit vulnerabilities. This is an introduction to such exploitation techniques. The second part will then focus on x86 binary exploitation. functionalities, you will have to exploit two vulnerabilities. After a brief exploration of the debugger Goals: Inspect a program thanks to a debugger (in that case the Immunity Debugger) Obtain a basic knowledge in buffer exploitation 1 Requirements: hypervisor and virtual machine image Download the hypervisor for your platform from Install it on your laptop Download the virtual machine image from import it into VirtualBox (follow the instructions at VirtualBox-) save a snapshot of the virtual machine (in its turned off state) launch the virtual machine log-on using those credentials (username / password): user / user (for TP1-application exploitation.7z) or user / empty password (for TP1 - Exploitation.ova) 2 Binary exploitation 2.1 Let us discover the Immunity Debugger Launch the debugger

2 2 Open ex0.exe and eventually make the CPU view visible. Check the window title to see if you are in the ex0.exe module. If not, open the view executable modules, and choose ex0.exe. 1. (a) Describe in few lines the content of each 5 part of the CPU view (b) One instruction is selected, what is it and how it is generally called? (c) Where does the debugger find his address? 2. (a) Lets run the program (F9 keyboard shortcut). What just happened? (Hint : status bar) (b) What is the purpose of the first instructions block at the beginning of the program? Is that block our main function? 3. (a) Now we want to set a breakpoint. Use Right click > Search for > All intermodular call > printf to find the printf. The main function, for little program without a lot of libraries is often located few instructions after the entry point. Alternatively you also can scroll down till you see the printf call. At which address is the printf located? (b) Set the breakpoint (F2), restart and run the program (Ctrl+F2). The program is now stopped at the printf. How many arguments a printf function is supposed to have? (c) Locate and describe them on the stack part of the CPU view. (d) A debugger has a control on the control flow of a program it has loaded. It also is able to manage the data flow. Now let us modify the text to be printed. Find two ways to modify the text which will be printed and briefly describe them. Use at least one of these methods to change the text. (e) It is also possible to run the program step-by-step using Step into (F7) and Step over (F8) function. What is the difference between these functions? 4. Step over until the instruction at the address 0x What is this instruction? What is its purpose? Resume the execution of the program by pressing F9 and let it terminated. You are now sufficiently familiar with that debugger to perform the very next sections. 2.2 Bin100 - It is sometimes too small In order to help you for your first exploitation, we did provide you some few hints regarding the vulnerability you will exploit for this exercise. It is a classic simple - and unfortunately still possible in several today softwares - stack overflow assuming that DEP and ASLR are not activated. This is the perfect example your always have been dreaming of to exploit! Controlling the flow 5. (a) Briefly remember ( 4 lines) what is a stack-based overflow and how can we exploit it. (b) Run the program (standalone, without the debugger attached) and play with it. Explain what is the purpose of that executable. (c) Open (in text editor) the script sendstring.py. What is the use of it? With the script, trigger an overflow. What happened when the overflow occured?

3 3 6. Now, we need more detailed information/impact about the overflow on the program. Run Immunity Debugger, open ex1.exe and run it. Trigger the overflow. The program will throw an exception and the debugger will catch it. Now the execution is paused at the instruction that triggered that overflow. (a) What is that instruction? (b) Describe the purpose of that instruction and why an overflow could happen here. (c) Now, have a look the registers which partly describe the state of the program (because the memory state is also important). What do you notice? What is the purpose of that (these) register(s) on which you just noticed something? (d) What is the content of that register? Change the string you send to the program, and restart it and see if the content of the register have changed. We seem to control the register. What does it mean? (e) To have a stable control on that register, we should know how many bytes we must send to overwrite the register. Some people already thought about it and produced 2 small and useful ruby scripts : pattern create and pattern offset These scripts are available in Metasploit. Open the system console of Metasploit. 1 >ruby t o o l s \ p a t t e r n c r e a t e. rb Usage : p a t t e r n c r e a t e. rb length [ set a ] [ set b ] [ set c ] (f) By reading and testing these two scripts, describe in what extend they could be useful. (g) Using pattern offset, how many bytes are necessary before overwriting the register? Let s call this value OFFSET EIP. We will have to send something following this format [padding][value of register] with size([padding]) = OFFSET EIP Test with aaaaa...aaaaabcd and check with the debugger if there is an attempt to execute instruction at the address ABCD (h) Now we really control the control flow because we almost be able to put any value in this register. Explain why the word almost is used in the previous sentence? Controlling the flow to our code To prove that we control the control flow, you should be able to execute arbitrary codes. This code will be in the string that you send to the program. Codes are in string?? Don t forget that there are no type notions here, your string will be in memory, and a string is set of bytes like instructions. This kind of code is called shellcode because, most of time we use it to have a shell (terminal) on the victim system. There are a lot of shellcodes, to do a lot of things, show a messagebox, run an executable, download and execute something... We will use the simple messagebox shellcode. Technics to write a shellcode are out of the scope of this practical assesment, we will use Metasploit to generate one for us. Thanks to it :) Open the Metasploit system console. We use the S option to display a summary (or help). > ruby msfpayload windows/ messagebox S 2 Name : Windows MessageBox Module : payload / windows/ messagebox 4 Version : l a t f o r m : Windows 6 Arch : x86 Needs Admin : No 8 Total size : 270 Rank : Normal 10...

4 4 7. (a) What are the options we have for the message box? Metasploit can output the shellcode with different format, R for raw, C, P for Perl... As we use Python, we can take the C format which is closed to Python. This is an example : >ruby msfpayload windows/ messagebox EXITFUNC=p r o c e s s ICON=INFORMATION TEXT= Blabla TITLE= H e l l o C 2... OK, we have our shellcode, in C format. Now we have to redirect the control flow to our shellcode. Our shellcode will be located in memory because it will be in the string you send to the program. Copy your shellcode at the beginning of the string. Now, we can consider the string as a payload, so call it payload. Your payload should follow this format above [shellcode][padding][value of register] with size([shellcode][padding]) = OFFSET EIP From now, we will use the script exploit.py to send the string. Set padding to : \x90 xoffset EIP Set jmp to : abcd Set shellcode to : your shellcode previously generated 8. (a) Send your payload to the program under the debugger, it will stop at the exception. Locate your shellcode. Where is it? (b) Jumping to a fix address in the stack could be problematic, because the two first bytes of stack address can change. Look the register. Do you find something interesting? Why? So we need to jump to the address in this register. Let find a jmp esp instruction. Open the view executable modules. What we can find in this view? (don t answer executable modules :)) Choose the module kernel32.dll, go to the CPU view. You should see the instruction of kernel32.dll. (c) Now, we will use the debugger to find a jmp esp. Right click in the instruction panel > Search for > Command : jmp esp What is the address of the jmp esp? Now, you should have a good payload following this format : [shellcode][padding][@jmp esp] Encoding the shellcode 9. (a) Test your previously created payload. Does it works?... ok. Let us find the problem. Use the debugger to locate your shellcode in the stack. Compare it from the original shellcode. (b) The beginning of the shellcode is correctly copied but there is an error after few bytes. What bytes was not copied successfully? In fact, the program can modify some byte of the strings and most of time its special character like \r, \n and space. Of course, there is a technic to bypass these modifications. We just need to avoid this character in our shellcode :) For that, there are encoders which encode the shellcode in a format which doesn t have chosen characters. And again, its module is available in Metasploit. To use it, you will send the raw shellcode to the encoder and tell him to output C again and removing some characters. The command become : > 2 ruby msfpayload windows/ messagebox EXITFUNC=p r o c e s s ICON=INFORMATION TEXT= Blabla TITLE= H e l l o R ruby msfencode a x86 b \ x00 \ x0a \ x0d t c Now retry your payload. If it work : \o/

5 With DEP? 10. Active DEP and test your payload again. It should work. What?? Indeed, you just activated a thing called by Microsoft Software DEP. it is a good memory protection mechanism but not the real DEP With DEP 11. To active the real DEP, you have to modify the configuration of the virtual machine to enable the PAE mode (cf. course) Now test your payload again. It should lead to an application crash, with a message from windows. That s the real DEP. Well done for those who successfully finished this part. It is however is not yet the end :) 2.3 Bin200 - Where are my parameters?! For your second exploitation, you have to exploit a vulnerability in the format string Reminders 12. (a) Briefly describe what a format string vulnerability is and compare it to stack based buffer overflow. Which one is the most powerful? Why? (b) Locate the vulnerable function and start playing with its parameters Print the content of the first 40 bytes on the stack. Why the printed result doesn t have 80 bytes exactly? Use the debugger to check Control WHERE you want to write (ECX) Let s call the string the content of input.txt. In order to exploit, we first need to reach the end of our string. From now, we will use the script exploit.py to build the input.txt. Set address to : abcd => This is where we will write. We use abcd because we don t yet where to write. Set write to : %x => Use to print (%x) the address or write (%n) to the address Set moves to : %x *30 => Use to moves on the stack (30*4 bytes) We know that %x read 4 bytes, but if we want to control where we are on the stack accurately, we need something else to move at the byte scale. This is the goal of the padding value. 13. (a) Now play with the number of moves until you recognize the address. Remember you are printing bytes in hexadecimal and in Little-endian. Remember after hexadecimal stuff, you should see the abcd string of course. (We put it in the printf) (b) How abcd should be printed? Let s call it AABBCCDD You should see :...AABBCCDDabcd... AABBCCDD will be replaced later by the address to overwrite. Now replace the write by an %n and check in the debugger if there is an attempt to write at the address AABBCCDD. Now we control where we want to write. You can replace AABBCCDD by something else to check. Note the value of EAX register, we will need it in the next part.

6 Control WHAT you write (EAX register) 14. (a) Remember what the function of %n in printf is The register EAX is used to store this number. Let s call EAX the value of EAX register. We will need to write 1000 (3e8 in hexadecimal) at the address of target to pass the test. We just have to write 3e8-EAX bytes before the %n. (b) We can put a lot of padding in the string to do that. Why it is not a good way? (c) Use the printf reference to find how we can print a lot of bytes using a short string (Think simple) Set write to : %x, we are still testing, no need to write. Set value to : %#x replacing the # by the result of 3e8-EAX But the length of the string have changed again, we need to adjust the padding or moves. Set moves to : 32 Set padding to : m, m or another character except \x00 You should see : abcd... again. Now we are ready to exploit! Exploitation 15. (a) What is the address of the target variable? (b) There is a null byte in it and we use fgets. Is it a problem? Why? Replace the address (abcd) by target address in little-endian with this syntax \ x6c \ x f f \ x22 Remember that since the new address contains 1 character less than abcd, we need to increment that value by 1. You should see Well done! :)

WRITING YOUR FIRST EXPLOIT LECTURE NOTES

WRITING YOUR FIRST EXPLOIT LECTURE NOTES WRITING YOUR FIRST EXPLOIT LECTURE NOTES Robert Olson Lecturer Dept. of Computing & Info Sciences SUNY at Fredonia olsonr@fredonia.edu @nerdprof https://github.com/nerdprof/writing-your-first-exploit 1.

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

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

Exploit Development. License. Contents. General notes about the labs. General notes about the labs. Preparation. Introduction to exploit development

Exploit Development. License. Contents. General notes about the labs. General notes about the labs. Preparation. Introduction to exploit development Exploit Development License This work by Z. Cliffe Schreuders at Leeds Metropolitan University is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License. All included software source

More information

Bypassing DEP with WPM & ROP Case Study : Audio Converter by D.R Software Exploit and Document by Sud0 sud0.x90 [ at ] gmail.com sud0 [at] corelan.

Bypassing DEP with WPM & ROP Case Study : Audio Converter by D.R Software Exploit and Document by Sud0 sud0.x90 [ at ] gmail.com sud0 [at] corelan. Bypassing DEP with WPM & ROP Case Study : Audio Converter by D.R Software Exploit and Document by Sud0 sud0.x90 [ at ] gmail.com sud0 [at] corelan.be (May 2010) Introduction : For this first tutorial,

More information

Remote Buffer Overflow Exploits

Remote Buffer Overflow Exploits We work in the dark we do what we can we give what we have. Our doubt is our passion and our passion is our task. The rest is the madness of art. Henry James 2010 Remote Buffer Overflow Exploits 2010 DZZ

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

Assignment 4 Buffer Overflows

Assignment 4 Buffer Overflows LEIC/MEIC - IST Alameda LEIC/MEIC/MERC IST Taguspark DEASegInf Network and Computer Security 2012/2013 Assignment 4 Buffer Overflows Goal Exploit buffer overflow vulnerabilities. 1. Introduction Log in

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

Advanced Buffer Overflow

Advanced Buffer Overflow Pattern Recognition and Applications Lab Advanced Buffer Overflow Ing. Davide Maiorca, Ph.D. davide.maiorca@diee.unica.it Computer Security A.Y. 2016/2017 Department of Electrical and Electronic Engineering

More information

Exploiting Stack Buffer Overflows Learning how blackhats smash the stack for fun and profit so we can prevent it

Exploiting Stack Buffer Overflows Learning how blackhats smash the stack for fun and profit so we can prevent it Exploiting Stack Buffer Overflows Learning how blackhats smash the stack for fun and profit so we can prevent it 29.11.2012 Secure Software Engineering Andreas Follner 1 Andreas Follner Graduated earlier

More information

Lecture Notes for 04/04/06: UNTRUSTED CODE Fatima Zarinni.

Lecture Notes for 04/04/06: UNTRUSTED CODE Fatima Zarinni. Lecture Notes for 04/04/06 UNTRUSTED CODE Fatima Zarinni. Last class we started to talk about the different System Solutions for Stack Overflow. We are going to continue the subject. Stages of Stack Overflow

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

Writing your first windows exploit in less than one hour

Writing your first windows exploit in less than one hour Writing your first windows exploit in less than one hour Klaus Gebeshuber klaus.gebeshuber@fh-joanneum.at http://www.fh-joanneum.at/ims AGENDA Workshop 10.00 13.00 Memory & stack basics, function calling

More information

Advanced Buffer Overflow

Advanced Buffer Overflow Pattern Recognition and Applications Lab Advanced Buffer Overflow Ing. Davide Maiorca, Ph.D. davide.maiorca@diee.unica.it Computer Security A.Y. 2017/2018 Department of Electrical and Electronic Engineering

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

Project 4: Application Security

Project 4: Application Security CS461/ECE422 October 23, 2015 Computer Security I Project 4: Application Security Project 4: Application Security This project is split into two parts, with the first checkpoint due on Friday, October

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

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

4. Jump to *RA 4. StackGuard 5. Execute code 5. Instruction Set Randomization 6. Make system call 6. System call Randomization

4. Jump to *RA 4. StackGuard 5. Execute code 5. Instruction Set Randomization 6. Make system call 6. System call Randomization 04/04/06 Lecture Notes Untrusted Beili Wang Stages of Static Overflow Solution 1. Find bug in 1. Static Analysis 2. Send overflowing input 2. CCured 3. Overwrite return address 3. Address Space Randomization

More information

Stack overflow exploitation

Stack overflow exploitation Stack overflow exploitation In order to illustrate how the stack overflow exploitation goes I m going to use the following c code: #include #include #include static void

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

CNIT 127: Exploit Development. Ch 1: Before you begin. Updated

CNIT 127: Exploit Development. Ch 1: Before you begin. Updated CNIT 127: Exploit Development Ch 1: Before you begin Updated 1-14-16 Basic Concepts Vulnerability A flaw in a system that allows an attacker to do something the designer did not intend, such as Denial

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

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

CS 392/681 Lab 6 Experiencing Buffer Overflows and Format String Vulnerabilities

CS 392/681 Lab 6 Experiencing Buffer Overflows and Format String Vulnerabilities CS 392/681 Lab 6 Experiencing Buffer Overflows and Format String Vulnerabilities Given: November 13, 2003 Due: November 20, 2003 1 Motivation Buffer overflows and format string vulnerabilities are widespread

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

Practical Malware Analysis

Practical Malware Analysis Practical Malware Analysis Ch 4: A Crash Course in x86 Disassembly Revised 1-16-7 Basic Techniques Basic static analysis Looks at malware from the outside Basic dynamic analysis Only shows you how the

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

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

buffer overflow exploitation

buffer overflow exploitation buffer overflow exploitation Samuele Andreoli, Nicolò Fornari, Giuseppe Vitto May 11, 2016 University of Trento Introduction 1 introduction A Buffer Overflow is an anomaly where a program, while writing

More information

Lecture 9: Buffer Overflow* CS 392/6813: Computer Security Fall Nitesh Saxena

Lecture 9: Buffer Overflow* CS 392/6813: Computer Security Fall Nitesh Saxena Lecture 9: Buffer Overflow* CS 392/6813: Computer Security Fall 2007 Nitesh Saxena *Adopted from a previous lecture by Aleph One (Smashing the Stack for Fun and Profit) and Stanislav Nurilov Course Admin

More information

Black Box Debugging of Embedded Systems

Black Box Debugging of Embedded Systems Black Box Debugging of Embedded Systems Introduction: Alexandru Ariciu Background in hacking Worked as a hacker for my whole life Worked in corporate security before (Pentester) Currently an ICS Penetration

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

Lecture 09 Code reuse attacks. Stephen Checkoway University of Illinois at Chicago CS 487 Fall 2017

Lecture 09 Code reuse attacks. Stephen Checkoway University of Illinois at Chicago CS 487 Fall 2017 Lecture 09 Code reuse attacks Stephen Checkoway University of Illinois at Chicago CS 487 Fall 2017 Last time No good reason for stack/heap/static data to be executable No good reason for code to be writable

More information

Exploiting the MSRPC Heap Overflow Part I

Exploiting the MSRPC Heap Overflow Part I Exploiting the MSRPC Heap Overflow Part I Dave Aitel Sep 11, 2003 Illustration 1Polyphemus Moth This little documentary chronicles the last moments of another beautiful moth, stuck somewhere between the

More information

Buffer-Overflow Attacks on the Stack

Buffer-Overflow Attacks on the Stack Computer Systems Buffer-Overflow Attacks on the Stack Introduction A buffer overflow occurs when a program, while writing data to a buffer, overruns the buffer's boundary and overwrites memory in adjacent

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

Representation of Information

Representation of Information Representation of Information CS61, Lecture 2 Prof. Stephen Chong September 6, 2011 Announcements Assignment 1 released Posted on http://cs61.seas.harvard.edu/ Due one week from today, Tuesday 13 Sept

More information

This time. Defenses and other memory safety vulnerabilities. Everything you ve always wanted to know about gdb but were too afraid to ask

This time. Defenses and other memory safety vulnerabilities. Everything you ve always wanted to know about gdb but were too afraid to ask This time We will continue Buffer overflows By looking at Overflow Defenses and other memory safety vulnerabilities Everything you ve always wanted to know about gdb but were too afraid to ask Overflow

More information

Analysis of MS Multiple Excel Vulnerabilities

Analysis of MS Multiple Excel Vulnerabilities Analysis of MS-07-036 Multiple Excel Vulnerabilities I. Introduction This research was conducted using the Office 2003 Excel Viewer application and the corresponding security patch for MS-07-036 - Vulnerabilities

More information

Lecture 6: Buffer Overflow. CS 436/636/736 Spring Nitesh Saxena

Lecture 6: Buffer Overflow. CS 436/636/736 Spring Nitesh Saxena Lecture 6: Buffer Overflow CS 436/636/736 Spring 2016 Nitesh Saxena *Adopted from a previous lecture by Aleph One (Smashing the Stack for Fun and Profit) HW3 submitted Course Admin Being graded Solution

More information

Lecture 10 Return-oriented programming. Stephen Checkoway University of Illinois at Chicago Based on slides by Bailey, Brumley, and Miller

Lecture 10 Return-oriented programming. Stephen Checkoway University of Illinois at Chicago Based on slides by Bailey, Brumley, and Miller Lecture 10 Return-oriented programming Stephen Checkoway University of Illinois at Chicago Based on slides by Bailey, Brumley, and Miller ROP Overview Idea: We forge shellcode out of existing application

More information

CS 161 Computer Security. Week of January 22, 2018: GDB and x86 assembly

CS 161 Computer Security. Week of January 22, 2018: GDB and x86 assembly Raluca Popa Spring 2018 CS 161 Computer Security Discussion 1 Week of January 22, 2018: GDB and x86 assembly Objective: Studying memory vulnerabilities requires being able to read assembly and step through

More information

EXPLOITING BUFFER OVERFLOWS ON MIPS ARCHITECTURES

EXPLOITING BUFFER OVERFLOWS ON MIPS ARCHITECTURES EXPLOITING BUFFER OVERFLOWS ON MIPS ARCHITECTURES A Walkthrough by Lyon Yang @l0op3r Editing and Support: Bernhard Mueller PUBLIC VERSION Table of Contents 1.! Introduction,...,3! 2.! Triggering,and,Debugging,the,Exploit,...,3!

More information

Secure Programming I. Steven M. Bellovin September 28,

Secure Programming I. Steven M. Bellovin September 28, Secure Programming I Steven M. Bellovin September 28, 2014 1 If our software is buggy, what does that say about its security? Robert H. Morris Steven M. Bellovin September 28, 2014 2 The Heart of the Problem

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

HW 8 CS681 & CS392 Computer Security Understanding and Experimenting with Memory Corruption Vulnerabilities DUE 12/18/2005

HW 8 CS681 & CS392 Computer Security Understanding and Experimenting with Memory Corruption Vulnerabilities DUE 12/18/2005 HW 8 CS681 & CS392 Computer Security Understanding and Experimenting with Memory Corruption Vulnerabilities 1 Motivation DUE 12/18/2005 Memory corruption vulnerabilities to change program execution flow

More information

Post exploitation techniques on OSX and Iphone. Vincenzo Iozzo

Post exploitation techniques on OSX and Iphone. Vincenzo Iozzo Post exploitation techniques on OSX and Iphone Vincenzo Iozzo vincenzo.iozzo@zynamics.com Who I am Student at Politecnico di Milano Security Consultant at Secure Network srl Reverse Engineer at zynamics

More information

War Industries Presents: An Introduction to Programming for Hackers Part III - Advanced Variables & Flow Control.

War Industries Presents: An Introduction to Programming for Hackers Part III - Advanced Variables & Flow Control. War Industries Presents: An Introduction to Programming for Hackers Part III - Advanced Variables & Flow Control By Lovepump, 2004 Visit: www.warindustries.com Part II Programs 101 Goals: At the end of

More information

CSE 361S Intro to Systems Software Lab Assignment #4

CSE 361S Intro to Systems Software Lab Assignment #4 Due: Thursday, October 23, 2008. CSE 361S Intro to Systems Software Lab Assignment #4 In this lab, you will mount a buffer overflow attack on your own program. As stated in class, we do not condone using

More information

Buffer-Overflow Attacks on the Stack

Buffer-Overflow Attacks on the Stack Computer Systems Buffer-Overflow Attacks on the Stack Introduction A buffer overflow occurs when a program, while writing data to a buffer, overruns the buffer's boundary and overwrites memory in adjacent

More information

CS 161 Computer Security

CS 161 Computer Security Popa & Wagner Spring 2016 CS 161 Computer Security Homework 2 Due: Monday, February 22nd, at 11:59pm Instructions. This homework is due Monday, February 22nd, at 11:59pm. It must be submitted electronically

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

BUFFER OVERFLOW DEFENSES & COUNTERMEASURES

BUFFER OVERFLOW DEFENSES & COUNTERMEASURES BUFFER OVERFLOW DEFENSES & COUNTERMEASURES CMSC 414 FEB 01 2018 RECALL OUR CHALLENGES How can we make these even more difficult? Putting code into the memory (no zeroes) Finding the return address (guess

More information

CSCI0330 Intro Computer Systems Doeppner. Lab 02 - Tools Lab. Due: Sunday, September 23, 2018 at 6:00 PM. 1 Introduction 0.

CSCI0330 Intro Computer Systems Doeppner. Lab 02 - Tools Lab. Due: Sunday, September 23, 2018 at 6:00 PM. 1 Introduction 0. CSCI0330 Intro Computer Systems Doeppner Lab 02 - Tools Lab Due: Sunday, September 23, 2018 at 6:00 PM 1 Introduction 0 2 Assignment 0 3 gdb 1 3.1 Setting a Breakpoint 2 3.2 Setting a Watchpoint on Local

More information

What the CPU Sees Basic Flow Control Conditional Flow Control Structured Flow Control Functions and Scope. C Flow Control.

What the CPU Sees Basic Flow Control Conditional Flow Control Structured Flow Control Functions and Scope. C Flow Control. C Flow Control David Chisnall February 1, 2011 Outline What the CPU Sees Basic Flow Control Conditional Flow Control Structured Flow Control Functions and Scope Disclaimer! These slides contain a lot of

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

Introduction to Reverse Engineering. Alan Padilla, Ricardo Alanis, Stephen Ballenger, Luke Castro, Jake Rawlins

Introduction to Reverse Engineering. Alan Padilla, Ricardo Alanis, Stephen Ballenger, Luke Castro, Jake Rawlins Introduction to Reverse Engineering Alan Padilla, Ricardo Alanis, Stephen Ballenger, Luke Castro, Jake Rawlins Reverse Engineering (of Software) What is it? What is it for? Binary exploitation (the cool

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

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

Win32 Stack BufferOverFlow Real Life Vuln-Dev Process

Win32 Stack BufferOverFlow Real Life Vuln-Dev Process Win32 Stack BufferOverFlow Real Life Vuln-Dev Process by Sergio Alvarez Security Research & Development IT Security Consulting shadown@g-con.org shadown@gmail.com September, 5 2004 INTRODUCTION Many times

More information

Biography. Background

Biography. Background From Over ow to Shell An Introduction to low-level exploitation Carl Svensson @ KTH, January 2019 1 / 28 Biography MSc in Computer Science, KTH Head of Security, KRY/LIVI CTF: HackingForSoju E-mail: calle.svensson@zeta-two.com

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

Autodesk AutoCAD DWG-AC1021 Heap Corruption

Autodesk AutoCAD DWG-AC1021 Heap Corruption security research Autodesk AutoCAD DWG-AC1021 Heap Corruption Mar 2013 AutoCAD is a software for computer-aided design (CAD) and technical drawing in 2D/3D, being one of the worlds leading CAD design tools.

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

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

Heaps of Heap-based Memory Attacks

Heaps of Heap-based Memory Attacks Heaps of Heap-based Memory Attacks Kevin Leach kleach2@gmu.edu Center for Secure Information Systems 3 October 2012 K. Leach (CSIS) Heaps of Heap-based Memory Attacks 3 October 2012 1 / 23 Goals During

More information

ISA 564, Laboratory I: Buffer Overflows

ISA 564, Laboratory I: Buffer Overflows ISA 564, Laboratory I: Buffer Overflows Lab Submission Instructions To complete the lab, you need to submit the compressed files (either tar or zip) using the GMU Blackboard system. Please make sure that

More information

Project 1 Notes and Demo

Project 1 Notes and Demo Project 1 Notes and Demo Overview You ll be given the source code for 7 short buggy programs (target[1-7].c). These programs will be installed with setuid root Your job is to write exploits (sploit[1-7].c)

More information

CSE 127: Computer Security Control Flow Hijacking. Kirill Levchenko

CSE 127: Computer Security Control Flow Hijacking. Kirill Levchenko CSE 127: Computer Security Control Flow Hijacking Kirill Levchenko October 17, 2017 Control Flow Hijacking Defenses Avoid unsafe functions Stack canary Separate control stack Address Space Layout Randomization

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

APPM 2460 Matlab Basics

APPM 2460 Matlab Basics APPM 2460 Matlab Basics 1 Introduction In this lab we ll get acquainted with the basics of Matlab. This will be review if you ve done any sort of programming before; the goal here is to get everyone on

More information

Writing Exploits. Nethemba s.r.o.

Writing Exploits. Nethemba s.r.o. Writing Exploits Nethemba s.r.o. norbert.szetei@nethemba.com Motivation Basic code injection W^X (DEP), ASLR, Canary (Armoring) Return Oriented Programming (ROP) Tools of the Trade Metasploit A Brief History

More information

GDB Tutorial. A Walkthrough with Examples. CMSC Spring Last modified March 22, GDB Tutorial

GDB Tutorial. A Walkthrough with Examples. CMSC Spring Last modified March 22, GDB Tutorial A Walkthrough with Examples CMSC 212 - Spring 2009 Last modified March 22, 2009 What is gdb? GNU Debugger A debugger for several languages, including C and C++ It allows you to inspect what the program

More information

Buffer Overflow Attack (AskCypert CLaaS)

Buffer Overflow Attack (AskCypert CLaaS) Buffer Overflow Attack (AskCypert CLaaS) ---------------------- BufferOverflow.c code 1. int main(int arg c, char** argv) 2. { 3. char name[64]; 4. printf( Addr;%p\n, name); 5. strcpy(name, argv[1]); 6.

More information

Memory Safety (cont d) Software Security

Memory Safety (cont d) Software Security Memory Safety (cont d) Software Security CS 161: Computer Security Prof. Raluca Ada Popa January 17, 2016 Some slides credit to David Wagner and Nick Weaver Announcements Discussion sections and office

More information

Fastbin_dup into stack exploitation

Fastbin_dup into stack exploitation Fastbin_dup into stack exploitation This tutorial is about the fastbin_dup into stack heap exploitation. First we re going to analyze what is fastbin and how to exploit the heap by double freeing and reallocating

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

Return oriented programming

Return oriented programming Return oriented programming TOOR - Computer Security Hallgrímur H. Gunnarsson Reykjavík University 2012-05-04 Introduction Many countermeasures have been introduced to foil EIP hijacking: W X: Prevent

More information

Robust Shell Code Return Oriented Programming and HeapSpray. Zhiqiang Lin

Robust Shell Code Return Oriented Programming and HeapSpray. Zhiqiang Lin CS 6V81-05: System Security and Malicious Code Analysis Robust Shell Code Return Oriented Programming and HeapSpray Zhiqiang Lin Department of Computer Science University of Texas at Dallas April 16 th,

More information

Creating User-Friendly Exploits

Creating User-Friendly Exploits 1 Creating User-Friendly Exploits Skylar Rampersaud skylar@immunityinc.com Security Research 2 What is a User-Friendly Exploit? An exploit that causes no distress to the user of the exploited program i.e.,

More information

Introduction. Overview and Getting Started. CS 161 Computer Security Lab 1 Buffer Overflows v.01 Due Date: September 17, 2012 by 11:59pm

Introduction. Overview and Getting Started. CS 161 Computer Security Lab 1 Buffer Overflows v.01 Due Date: September 17, 2012 by 11:59pm Dawn Song Fall 2012 CS 161 Computer Security Lab 1 Buffer Overflows v.01 Due Date: September 17, 2012 by 11:59pm Introduction In this lab, you will get a hands-on approach to circumventing user permissions

More information

Reversing. Time to get with the program

Reversing. Time to get with the program Reversing Time to get with the program This guide is a brief introduction to C, Assembly Language, and Python that will be helpful for solving Reversing challenges. Writing a C Program C is one of the

More information

United States Naval Academy Electrical and Computer Engineering Department EC310-6 Week Midterm Spring 2015

United States Naval Academy Electrical and Computer Engineering Department EC310-6 Week Midterm Spring 2015 United States Naval Academy Electrical and Computer Engineering Department EC310-6 Week Midterm Spring 2015 1. Do a page check: you should have 8 pages including this cover sheet. 2. You have 50 minutes

More information

Exercises 6 - Virtual vs. Physical Memory, Cache

Exercises 6 - Virtual vs. Physical Memory, Cache Questions 1. Consider a (very old!) computer with a hard disk of only 1 GB, main memory of 16 MB, and a cache with 512 blocks of 8 words each. Suppose the hard disk and main memory are partitioned into

More information

INSIDE THE ULTIMA ONLINE CLIENT - INSERTING A SLEEP

INSIDE THE ULTIMA ONLINE CLIENT - INSERTING A SLEEP INSIDE THE ULTIMA ONLINE CLIENT - INSERTING A SLEEP GOAL The Ultima Online client utilizes too much CPU power when it s not doing anything useful. For example, when we are at the logon screen or when we

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

Week 5, continued. This is CS50. Harvard University. Fall Cheng Gong

Week 5, continued. This is CS50. Harvard University. Fall Cheng Gong This is CS50. Harvard University. Fall 2014. Cheng Gong Table of Contents News... 1 Buffer Overflow... 1 Malloc... 6 Linked Lists... 7 Searching... 13 Inserting... 16 Removing... 19 News Good news everyone!

More information

Project 4: Application Security

Project 4: Application Security EECS 388 October 25, 2018 Intro to Computer Security Project 4: Application Security Project 4: Application Security This project is due on November 15, 2018 at 6 p.m. and counts for 8% of your course

More information

Homework 4 CS161 Computer Security, Spring 2008 Assigned 4/14/08 Due 4/21/08

Homework 4 CS161 Computer Security, Spring 2008 Assigned 4/14/08 Due 4/21/08 Homework 4 CS161 Computer Security, Spring 2008 Assigned 4/14/08 Due 4/21/08 NOTE: Questions 1-3 are based on real-world systems, and present a fair amount of background material. Although the question

More information

CS 33 (Week 4) Section 1G, Spring 2015 Professor Eggert (TA: Eric Kim) v1.0

CS 33 (Week 4) Section 1G, Spring 2015 Professor Eggert (TA: Eric Kim) v1.0 CS 33 (Week 4) Section 1G, Spring 2015 Professor Eggert (TA: Eric Kim) v1.0 Announcements Midterm 1 was yesterday. It's over! Don't stress out too much. We'll go over the midterm next week Homework 3 due

More information

Chapter 1 Getting Started

Chapter 1 Getting Started Chapter 1 Getting Started The C# class Just like all object oriented programming languages, C# supports the concept of a class. A class is a little like a data structure in that it aggregates different

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

System Security Class Notes 09/23/2013

System Security Class Notes 09/23/2013 System Security Class Notes 09/23/2013 1 Format String Exploits a Format String bugs The printf family consists of functions with variable arguments i printf (char* format, ) ii sprint (char* dest, char*

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

ROP It Like It s Hot!

ROP It Like It s Hot! Wednesday, December 3, 14 2014 Red Canari, Inc. All rights reserved. 1 I N F O R M AT I O N S E C U R I T Y ROP It Like It s Hot! A 101 on Buffer Overflows, Return Oriented Programming, & Shell- code Development

More information

CS61 Section Solutions 3

CS61 Section Solutions 3 CS61 Section Solutions 3 (Week of 10/1-10/5) 1. Assembly Operand Specifiers 2. Condition Codes 3. Jumps 4. Control Flow Loops 5. Procedure Calls 1. Assembly Operand Specifiers Q1 Operand Value %eax 0x104

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

INFORMATION SECURITY - PRACTICAL ASSESSMENT - TP3 - CRYPTOGRAPHY AND APPLICATIONS. GRENOBLE INP ENSIMAG

INFORMATION SECURITY - PRACTICAL ASSESSMENT - TP3 - CRYPTOGRAPHY AND APPLICATIONS. GRENOBLE INP ENSIMAG INFORMATION SECURITY - PRACTICAL ASSESSMENT - TP3 - CRYPTOGRAPHY AND APPLICATIONS GRENOBLE INP ENSIMAG http://www.ensimag.fr COMPUTER SCIENCE 3RD YEAR SIF-LOAD - 1ST SEMESTER, 2011 Lecturers: Fabien Duchene

More information