Malware and Software Vulnerability Analysis Q&A of Fuzzing Programming Project 2 Cliff Zou University of Central Florida.

Slides:



Advertisements
Similar presentations
R4 Dynamically loading processes. Overview R4 is closely related to R3, much of what you have written for R3 applies to R4 In R3, we executed procedures.
Advertisements

What is a pointer? First of all, it is a variable, just like other variables you studied So it has type, storage etc. Difference: it can only store the.
CSSE221: Software Dev. Honors Day 28 Announcements Announcements Simulation grades coming back Simulation grades coming back All C Projects due Friday.
Homework Reading Programming Assignments
Topics Introduction Hardware and Software How Computers Store Data
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2011.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
CP104 Introduction to Programming File I/O Lecture 33 __ 1 File Input/Output Text file and binary files File Input/output File input / output functions.
File Handling Spring 2013Programming and Data Structure1.
Testing and Debugging Version 1.0. All kinds of things can go wrong when you are developing a program. The compiler discovers syntax errors in your code.
22. FILE INPUT/OUTPUT. File Pointers and Streams Declarations of functions that perform file I/O appear in. Each function requires a file pointer as a.
Automatic Diagnosis and Response to Memory Corruption Vulnerabilities Presenter: Jianyong Dai Jun Xu, Peng Ning, Chongkyung Kil, Yan Zhai, Chris Bookhot.
Topics 1.File Basics 2.Output Formatting 3.Passing File Stream Objects to Functions 4.More Detailed Error Testing 5.Member Functions for Reading and 6.Writing.
File IO and command line input CSE 2451 Rong Shi.
Chapter 8 File-Oriented Input and Output. 8.1 INTRODUCTION a file can also be designed to store data. We can easily update files, A data file as input.
Overflow Examples 01/13/2012. ACKNOWLEDGEMENTS These slides where compiled from the Malware and Software Vulnerabilities class taught by Dr Cliff Zou.
1 File Handling. 2 Storage seen so far All variables stored in memory Problem: the contents of memory are wiped out when the computer is powered off Example:
Introduction to Systems Programming (CS 0449) C Preprocessing Makefile File I/O.
Objective Explain basic fuzzing with concrete coding example
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Lucas Bang Lecture 11: Pointers.
Files A collection of related data treated as a unit. Two types Text
CSC Programming for Science Lecture 18: More Data Files.
Connecting to Files In order to read or write to a file, we need to make a connection to it. There are several functions for doing this. fopen() – makes.
C Programming Day 2. 2 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/LA07/003 Version No. 1.0 Union –mechanism to create user defined data types.
Process Related System Calls By Neha Hulkoti & Kavya Bhat.
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2014.
Hank Childs, University of Oregon April 15 th, 2016 CIS 330: _ _ _ _ ______ _ _____ / / / /___ (_) __ ____ _____ ____/ / / ____/ _/_/ ____/__ __ / / /
Winter 2009 Tutorial #6 Arrays Part 2, Structures, Debugger
User-Written Functions
Input from STDIN STDIN, standard input, comes from the keyboard.
Topics Introduction Hardware and Software How Computers Store Data
© 2016 Pearson Education, Ltd. All rights reserved.
Chapter 22 – part a Stream refer to any source of input or any destination for output. Many small programs, obtain all their input from one stream usually.
Command Line Arguments
CSC215 Lecture Input and Output.
Week 7 Part 2 Kyle Dewey.
CS111 Computer Programming
Hank Childs, University of Oregon
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Hank Childs, University of Oregon
Lecture 8b: Strings BJ Furman 15OCT2012.
Objective Explain basic fuzzing with concrete coding example
Lecture 13 Input/Output Files.
Basic File I/O and Stream Objects
Python Lessons 13 & 14 Mr. Kalmes.
Handling Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
Topics Introduction Hardware and Software How Computers Store Data
File I/O in C Lecture 7 Narrator: Lecture 7: File I/O in C.
Text and Binary File Processing
File Handling.
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2015.
CNT4704: Analysis of Computer Communication Network Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Fall 2011.
Handling Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
Line at a time I/O with fgets() and fputs()
Handling Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
Homework Reading Programming Assignments Finish K&R Chapter 1
Functions continued.
C Preprocessing File I/O
Homework Continue with K&R Chapter 5 Skipping sections for now
Malware and Software Vulnerability Analysis Fuzzing Test Example Cliff Zou University of Central Florida.
Python Lessons 13 & 14 Mr. Husch.
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2016.
Block I/O fread and fwrite functions are the most efficient way to read or write large amounts of data. fread() – reads a specified number of bytes from.
CSc 352 File I/O Saumya Debray Dept. of Computer Science
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2013.
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2010.
Professor Jodi Neely-Ritz University of Florida
I/O CS580U - Fall 2018.
SPL – PS1 Introduction to C++.
Professor Jodi Neely-Ritz University of Florida
Presentation transcript:

Malware and Software Vulnerability Analysis Q&A of Fuzzing Programming Project 2 Cliff Zou University of Central Florida

Manual Bugs Added Original code is a C++ code: ‘jpg2bmp.cpp’ All 8 bugs are segmentation fault (11) or illegal instruction fault (6) added manually by me with the following code: int (*foo)(void);   /* function pointer definition */ ....      fprintf(stderr, "Bug #2 triggered.\n");      int (*foo)(void) = (int (*)(void))0xbffbffff;      foo();  /* this will trigger illegal instruction fault */    They are added in places where the program processes the image parameters

Input Processing Question: I understand the concept of fuzzing and I am clear about the example program discussed in class. However the project assignment is totally different in that the input needs to be a file instead of argv[], and we need to record down modified image file that causes crash instead of simply printf() in the example. I am not clear as to how to do that !

Input Processing Answer: Your fuzzer program needs to use the given 'cross.jpg' image file to generate a mutated jpg file, say 'test.jpg‘, to feed it to jpg2bmp for execution: Open & read the 'cross.jpg' file as binary format file In C code it could be:  fin = fopen("./cross.jpg", "rb"); fout = fopen("./test.jpg", "wb");  Read the 'cross.jpg' file as byte stream into a character array variable buff[] you defined. Make sure the char array variable has enough space to hold the image file.

Input Processing Modify this character array variable buff[] in whatever way you want (mutation). You don't need to know the structure of JPEG format since we are doing mutation-based fuzzing, which does not assume you to know any format of the input Write this character array variable back to the ‘test.jpg’ file.   Execute jpg2bmp to process the ‘test.jpg’ file, such as: char comBuf[200]; sprintf(comBuf, "./jpg2bmp test.jpg temp.bmp"); ret = system(comBuf); In C code, the reading/writing file can use fread(), fwrite() functions, or any other C file operation functions.

Automatic File Name Creation Question: I am looking for a way in which I could save each input image that triggers each bug, instead of just saving the last one crashing image. So how can I read from the command prompt to check for the Bug number? Question: If I generated 10,000 mutated image files for the fuzzing test, will I need to save all of them? How do I just save image files that cause crash? How do I know which bug is triggered by each crashing image?

Automatic File Name Creation Answer: All "Bug #x triggered" messages are printed out in Stderr, which is hard to read as the fuzzer keeps running and generating Stderr output. A simpler, not intelligent way is:  keep a counter variable n to increase by 1 when a crash (segmentation fault) happens, then save the image file which causes this crash with the file name as fileName = 'crashed-n.jpg' and fprintf(stderr, "file %s is generated\n", fileName);  so that this crash number appeared right after the system output print of "Bug #x triggered“ in stderr.   So after fuzzing test produces, for example, 1000 crashes,  my fuzzer has produced 1000 crashed-x.jpg image files under the current directory. Then I can check the Stderr output (redirected and saved to a text file) to see which Bug number produces which crashed-n.jpg.

Automatic File Name Creation It is easy to generate a variable file name. Such as: char fileName[30]; int n; .... sprintf(fileName, "crashed-%d.jpg", n); fout = fopen(fileName, "wb");

Unlabeled Bugs Besides the 8 manually added bug, the original code has an additional segmentation fault bug This is a real bug in the original code! But this bug will not be counted as one of the 7 out of 8 bugs required to be discovered.

Completeness Question: Hi Professor, Can you give any hints for how to find Bugs 3 and 6? I found all others multiple times but not these two? Answer: You can modify your fuzzer code with different ways in mutating the cross.jpg file, and then test the new fuzzer code with another round of, for example, 1000 mutated image files. Mutation Ways: Change one byte at a random location to a random value. Change m consecutive bytes at a random location to all zero. Change m bytes at m random locations to value 255. …….