©2002, Ed Skoudis Format String Stack View main() { char user_input[100]; char buffer[100]; int x; … /*get user_input*/ … snprintf(buffer, sizeof buffer,

Slides:



Advertisements
Similar presentations
Slide: 1 CAMP 06: Maturing Minds Programming in C Recap Camp 06 Maturing Minds.
Advertisements

Incomplete Structs struct B; struct A { struct B * partner; // other declarations… }; struct B { struct A * partner; // other declarations… };
Dynamic Allocation and Linked Lists. Dynamic memory allocation in C C uses the functions malloc() and free() to implement dynamic allocation. malloc is.
Monday, Jan 20, 2002Kate Gregory with material from Deitel and Deitel Week 3 Questions from Last Week Hand in Lab 1 Arrays Pointers Strings Lab 2.
For(int i = 1; i
Senem Kumova Metin Spring2009 STACKS AND QUEUES Chapter 10 in A Book on C.
Dynamic Memory Allocation in C.  What is Memory What is Memory  Memory Allocation in C Memory Allocation in C  Difference b\w static memory allocation.
Buffer Overflow Prabhaker Mateti Wright State University.
Carnegie Mellon 1 Dynamic Memory Allocation: Basic Concepts : Introduction to Computer Systems 17 th Lecture, Oct. 21, 2010 Instructors: Randy Bryant.
Chapter 6 Structures By C. Shing ITEC Dept Radford University.
David Notkin Autumn 2009 CSE303 Lecture 13 This space for rent.
Def f(n): if (n == 0): return else: print(“*”) return f(n-1) f(3)
Strings Input/Output scanf and printf sscanf and sprintf gets and puts.
Character String Manipulation. Overview Character string functions sscanf() function snprintf() function.
Array_strcpy void array_strcpy(char dest[], char src[]) { int i = 0; while (src[i] != '\0') { dest[i] = src[i]; i++; } dest[i] = '\0'; }
Network Security Attack Analysis. cs490ns - cotter2 Outline Types of Attacks Vulnerabilities Exploited Network Attack Phases Attack Detection Tools.
By Senem Kumova Metin 1 POINTERS + ARRAYS + STRINGS REVIEW.
Memory allocation CSE 2451 Matt Boggus. sizeof The sizeof unary operator will return the number of bytes reserved for a variable or data type. Determine:
Stack-Based Buffer Overflows Attacker – Can take over a system remotely across a network. local malicious users – To elevate their privileges and gain.
Software and Software Vulnerabilities. Synopsis Array overflows Stack overflows String problems Pointer clobbering. Dynamic memory management Integer.
Exploiting Format String Vulnerabilities
CS 240: Data Structures Supplemental: Command Line Input.
Command line arguments. – main can take two arguments conventionally called argc and argv. – Information regarding command line arguments are passed to.
University of Washington CSE 351 : The Hardware/Software Interface Section 5 Structs as parameters, buffer overflows, and lab 3.
1 - buttons Click “Step Forward” to execute one line of the program. Click “Reset” to start over. “Play,” “Stop,” and “Step Back” are disabled in this.
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2011.
Chapter 9 Character Strings 9.1 Character String Constants A character string constant is a sequence of characters enclosed in double quotation mark. Examples.
February 11, 2005 More Pointers Dynamic Memory Allocation.
CS 1031 Linked Lists Definition of Linked Lists Examples of Linked Lists Operations on Linked Lists Linked List as a Class Linked Lists as Implementations.
STARTING OUT WITH STARTING OUT WITH Class 9 Honors.
Chapter 7 Formatted input and output. 7.1 introduction Tax: This result is correct; but it would be better Maybe as $13, Make formatting.
Chapter 7 Pointers: Java does not have pointers. Used for dynamic memory allocation.
 Structures are like arrays except that they allow many variables of different types grouped together under the same name. For example you can create.
What is exactly Exploit writing?  Writing a piece of code which is capable of exploit the vulnerability in the target software.
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.
Arrays, Strings, and Memory. Command Line Arguments #include int main(int argc, char *argv[]) { int i; printf("Arg# Contents\n"); for (i = 0; i < argc;
Department of Electronic & Electrical Engineering IO reading and writing variables scanf printf format strings "%d %c %f"
C Programming Chapters 11, . . .
C++ Programming Lecture 14 Arrays – Part I The Hashemite University Computer Engineering Department (Adapted from the textbook slides)
 Memory setup  Pointer declaration  Address operator  Indirection  Printing addresses or pointers.
Announcements There is a Quiz today. There were problems with grading assignment 2, but they should be worked out today The web page for correcting the.
CS426Fall 2010/Lecture 141 Computer Security CS 426 Lecture 14 Software Vulnerabilities: Format String and Integer Overflow Vulnerabilities.
Files A collection of related data treated as a unit. Two types Text
IO revisited CSE 2451 Rong Shi. stdio.h Functions – printf – scanf(normally stops at whitespace) – fgets – sscanf Standard streams – stdin(defaults to.
CS 140 Lecture Notes: Virtual MemorySlide 1 Load-Time Relocation Process 1 0 ∞ Process 3 Operating System Process 6.
CSC 482/582: Computer Security
Pointers and Classes.
CS 140 Lecture Notes: Virtual Memory
Popping Items Off a Stack Using a Function Lesson xx
5.13 Recursion Recursive functions Functions that call themselves
Command Line Arguments
File Input/Output.
CS-401 Computer Architecture & Assembly Language Programming
CSC 253 Lecture 8.
CS 140 Lecture Notes: Virtual Memory
CSC 253 Lecture 8.
Arrays & pointers C How to Program, 8/e.
CS 140 Lecture Notes: Virtual Memory
Review & Lab assignments
Dynamic Memory A whole heap of fun….
CNT4704: Analysis of Computer Communication Network Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Fall 2011.
Programming Assignment 1
Chien-Chung Shen CIS/UD
Buffer Overflows.
Chapter 9: Pointers and String
The Stack.
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2016.
CS 140 Lecture Notes: Virtual Memory
How Memory Leaks Work with Memory Diagram
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2010.
Presentation transcript:

©2002, Ed Skoudis Format String Stack View main() { char user_input[100]; char buffer[100]; int x; … /*get user_input*/ … snprintf(buffer, sizeof buffer, user_input); }

©2002, Ed Skoudis Format String Stack View main() { char user_input[100]; char buffer[100]; int x; … /*get user_input*/ … snprintf(buffer, sizeof buffer, user_input); } Top of Memory Bottom of Memory Fill Direction Value to Change

©2002, Ed Skoudis Format String Stack View main() { char user_input[100]; char buffer[100]; int x; … /*get user_input*/ … snprintf(buffer, sizeof buffer, user_input); } Top of Memory Bottom of Memory int x Fill Direction Buffer (100 char) Value to Change

©2002, Ed Skoudis Format String Stack View main() { char user_input[100]; char buffer[100]; int x; … /*get user_input*/ … snprintf(buffer, sizeof buffer, user_input); } Top of Memory Bottom of Memory int x Return Pointer Fill Direction Buffer (100 char) Pointer to user_input sizeof buffer Pointer to Buffer Value to Change

©2002, Ed Skoudis Format String Stack View main() { char user_input[100]; char buffer[100]; int x; … /*get user_input*/ … snprintf(buffer, sizeof buffer, user_input); } Top of Memory Bottom of Memory int x Return Pointer Fill Direction Buffer (100 char) Pointer to user_input sizeof buffer Pointer to Buffer c0faffbf%d%n Value to Change

©2002, Ed Skoudis Format String Stack View main() { char user_input[100]; char buffer[100]; int x; … /*get user_input*/ … snprintf(buffer, sizeof buffer, user_input); } Top of Memory Bottom of Memory int x Return Pointer Fill Direction Buffer (100 char) Pointer to user_input sizeof buffer Pointer to Buffer c0faffbf%d%n c0faffbf Value to Change

©2002, Ed Skoudis Format String Stack View main() { char user_input[100]; char buffer[100]; int x; … /*get user_input*/ … snprintf(buffer, sizeof buffer, user_input); } Top of Memory Bottom of Memory int x Return Pointer Fill Direction Buffer (100 char) Pointer to user_input sizeof buffer Pointer to Buffer c0faffbf%d%n c0faffbf value of x Value to Change

©2002, Ed Skoudis Format String Stack View main() { char user_input[100]; char buffer[100]; int x; … /*get user_input*/ … snprintf(buffer, sizeof buffer, user_input); } Top of Memory Bottom of Memory int x Return Pointer Fill Direction Buffer (100 char) Pointer to user_input sizeof buffer Pointer to Buffer c0faffbf%d%n c0faffbf value of x Value to Change

©2002, Ed Skoudis Format String Stack View main() { char user_input[100]; char buffer[100]; int x; … /*get user_input*/ … snprintf(buffer, sizeof buffer, user_input); } Top of Memory Bottom of Memory int x Return Pointer Fill Direction Buffer (100 char) Pointer to user_input sizeof buffer Pointer to Buffer c0faffbf%d%n c0faffbf value of x 5

©2002, Ed Skoudis Format String Stack View main() { char user_input[100]; char buffer[100]; int x; … /*get user_input*/ … snprintf(buffer, sizeof buffer, user_input); } Top of Memory Bottom of Memory int x Return Pointer Fill Direction Buffer (100 char) Pointer to user_input sizeof buffer Pointer to Buffer c0faffbf%.255d%n c0faffbf value of x 259