Disassembly תרגול 9 ניתוח קוד. How to - Disassembly of code Compilation of code:  gcc code.c  We get the file: a.out Disassembly:  objdump -d a.out.

Slides:



Advertisements
Similar presentations
Chapter 11 Introduction to Programming in C
Advertisements

SPARC Architecture & Assembly Language
I/O: SPARC Assembly Department of Computer Science Georgia State University Georgia State University Updated Spring 2014.
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.
1 ICS103 Programming in C Lecture 3: Introduction to C (2)
C Programming Language 4 Developed in 1972 by Dennis Ritchie at AT&T Bell Laboratories 4 Used to rewrite the UNIX operating system 4 Widely used on UNIX.
C Prog. To Object Code text text binary binary Code in files p1.c p2.c
Chapter 3: Introduction to C Programming Language C development environment A simple program example Characters and tokens Structure of a C program –comment.
CMSC 104, Version 8/061L18Functions1.ppt Functions, Part 1 of 4 Topics Using Predefined Functions Programmer-Defined Functions Using Input Parameters Function.
1 uClinux course Day 3 of 5 The uclinux toolchain, elf format and ripping a “hello world”
Ping Zhang 10/08/2010.  You can get data from the user (input) and display information to the user (output).  However, you must include the library.
Input/Output  Input/Output operations are performed using input/output functions  Common input/output functions are provided as part of C’s standard.
Homework Reading Programming Assignments
CNG 140 C Programming (Lecture set 9) Spring Chapter 9 Character Strings.
MODULE 1.3 VERILOG BASICS UNIT 1 : INTRODUCTION TO VERILOG TOPIC : System Tasks and Compiler directive.
Files Working with Files in C ATS 315. Files Misunderstandings about “files” In Windows and on Macs, we tend to think of files as “containing something”.
Programming I Introduction Introduction The only way to learn a new programming language is by writing programs in it. The first program to.
C++ Basics Structure of a Program. C++ Source Code Plain text file Typical file extension .CPP Must compile the C++ source code without errors before.
Compiling & Debugging Quick tutorial. What is gcc? Gcc is the GNU Project C compiler A command-line program Gcc takes C source files as input Outputs.
CNIT 127: Exploit Development Ch 4: Introduction to Format String Bugs.
1 Programming in C Hello World! Soon I will control the world! Soon I will control the world!
Structure of a C program Preprocessor directive (header file) Program statement } Preprocessor directive Global variable declaration Comments Local variable.
Chapter 3: Formatted Input/Output Copyright © 2008 W. W. Norton & Company. All rights reserved. 1 Chapter 3 Formatted Input/Output.
Chapter 3: Formatted Input/Output Copyright © 2008 W. W. Norton & Company. All rights reserved. 1 Chapter 3 Formatted Input/Output.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room , Chris Hill, Room ,
Chapter 0 Getting Started. Objectives Understand the basic structure of a C++ program including: – Comments – Preprocessor instructions – Main function.
Algorithms  Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
Lecture 1 cis208 January 14 rd, Compiling %> gcc helloworld.c returns a.out %> gcc –o helloworld helloworld.c returns helloworld.
Chapter 1 Introduction. Chapter 1 - Introduction 2 The Goal of Chapter 1 Introduce different forms of language translators Give a high level overview.
Lexical Elements, Operators, and the C Cystem. C overview recap functions –structured programming –return value is typed –arguments(parameters) pointers.
1 Printing in Python Every program needs to do some output This is usually to the screen (shell window) Later we’ll see graphics windows and external files.
First Compilation Rudra Dutta CSC Spring 2007, Section 001.
CMPE13Cyrus Bazeghi 1 Chapter 11 Introduction to Programming in C.
Announcements Assignment 1 due Wednesday at 11:59PM Quiz 1 on Thursday 1.
1 Structure of Simple C++ Program Chapter 1 09/09/13.
LECTURE 3 Translation. PROCESS MEMORY There are four general areas of memory in a process. The text area contains the instructions for the application.
Chapter 3: Formatted Input/Output 1 Chapter 3 Formatted Input/Output.
Nested Loops CS303E: Elements of Computers and Programming.
1 CS 192 Lecture 4 Winter 2003 December 8-9, 2003 Dr. Shafay Shamail.
Chapter 5: Preparing C Programs
Programs – Preprocessing, Compilation and Linking
Lecture 3 Translation.
ECE Application Programming
A bit of C programming Lecture 3 Uli Raich.
Command Line Arguments
ICS103 Programming in C Lecture 3: Introduction to C (2)
Debugging with gdb gdb is the GNU debugger on our CS machines.
Input/Output Input/Output operations are performed using input/output functions Common input/output functions are provided as part of C’s standard input/output.
Lexical Elements, Operators, and the C Cystem
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Ken D. Nguyen Department of Computer Science Georgia State University
CS 2308 Exam I Review.
Chapter 11 Introduction to Programming in C
C Prog. To Object Code text text binary binary Code in files p1.c p2.c
Lexical Elements, Operators, and the C Cystem
Chapter 11 Introduction to Programming in C
Govt. Polytechnic,Dhangar
Homework Applied for cs240? (If not, keep at it!) 8/10 Done with HW1?
Chapter 11 Introduction to Programming in C
C Programming Getting started Variables Basic C operators Conditionals
Program Execution in Linux
Chapter 11 Programming in C
Disassembly תרגול 7 ניתוח קוד.
Ken D. Nguyen Department of Computer Science Georgia State University
Introduction to C Programming
Debugging.
Exploitation Part 1.
By Hugues Leger / Intro to GDB debugger By Hugues Leger / 11/16/2019.
Introduction to C CS 3410.
Presentation transcript:

Disassembly תרגול 9 ניתוח קוד

How to - Disassembly of code Compilation of code:  gcc code.c  We get the file: a.out Disassembly:  objdump -d a.out  We get an assembly-like code that represents the c code appeared in file code.c  Objdump –t a.out  This will print out the symbol table of the file. The symbol table includes the names of all functions and global variables in the file, the names of all the functions being called by the file, and their addresses.

Basic: Many times we work with an executive file and we are interested in the code that behind it. We can use the disassembly option or the debugger option in order to analyze the executive file, and understand what is does. Some time we will want to use both options. Disassembly enable us to get an assembly-like file that represent the activity of the executive file.

Important aspects In disassembly we only get the code of the functions in the files and functions that were used by the files. We don’t get the code of the system’s functions (printf, scanf…). We don’t get the values of global constants or strings. Many times there are optimizations or nops added by the compiler – what make is harder to understand. While using dissembler there are many global general functions added (init, start) usually we don’t care about them.

An example Show disass.asm

main:

hello: Address 0x does not appear in the disassembly code we can see. What does that tell us? How can we find out what is its value?

hello: Function “puts” is a simplified version of the printf() function. It doesn’t have all printf formats and it always put the newline character in the end of its strings.

main:

even: What kind of a loop is it?

main: Cleaning up the stack!

The C code: