Goals: To gain an understanding of assembly To get your hands dirty in GDB.

Slides:



Advertisements
Similar presentations
Fabián E. Bustamante, Spring 2007 Machine-Level Programming II: Control Flow Today Condition codes Control flow structures Next time Procedures.
Advertisements

Gnu Debugger (GDB) Topics Overview Quick Reference Card Readings: Quick Reference Card February 7, 2012 CSCE 212Honors Computer Organization.
The art of exploitation
Utilizing the GDB debugger to analyze programs Background and application.
Debugging What can debuggers do? Run programs Make the program stops on specified places or on specified conditions Give information about current variables’
PC hardware and x86 3/3/08 Frans Kaashoek MIT
1 Function Calls Professor Jennifer Rexford COS 217 Reading: Chapter 4 of “Programming From the Ground Up” (available online from the course Web site)
1 Homework Reading –PAL, pp , Machine Projects –Finish mp2warmup Questions? –Start mp2 as soon as possible Labs –Continue labs with your.
September 22, 2014 Pengju (Jimmy) Jin Section E
C Prog. To Object Code text text binary binary Code in files p1.c p2.c
Memory & Storage Architecture Seoul National University Computer Architecture “ Bomb Lab Hints” 2nd semester, 2014 Modified version : The original.
OllyDbg Debuger.
Recitation 2: Assembly & gdb Andrew Faulring Section A 16 September 2002.
Recitation: Bomb Lab June 5, 2015 Dipayan Bhattacharya.
Gdb is the GNU debugger on our CS machines. gdb is most effective when it is debugging a program that has debugging symbols linked in to it. With gcc and.
Introduction to InfoSec – Recitation 2 Nir Krakowski (nirkrako at post.tau.ac.il) Itamar Gilad (itamargi at post.tau.ac.il)
Memory & Storage Architecture Seoul National University GDB commands Hyeon-gyu School of Computer Science and Engineering.
6.828: PC hardware and x86 Frans Kaashoek
Assembly Questions תרגול 12.
1 Carnegie Mellon Stacks : Introduction to Computer Systems Recitation 5: September 24, 2012 Joon-Sup Han Section F.
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.
Carnegie Mellon Recitation: Bomb Lab 21 Sep 2015 Monil Shah, Shelton D’Souza.
Introduction to InfoSec – Recitation 2 Nir Krakowski (nirkrako at post.tau.ac.il) Itamar Gilad (itamargi at post.tau.ac.il)
Assembly and Bomb Lab : Introduction to Computer Systems Recitation 4: Monday, Sept. 16, 2013 Marjorie Carlson Section A.
1 Carnegie Mellon Assembly and Bomb Lab : Introduction to Computer Systems Recitation 4, Sept. 17, 2012.
Low Level Programming Lecturer: Duncan Smeed The Interface Between High-Level and Low-Level Languages.
Unit - V. Debugging GNU Debugger helps you in getting information about the following: 1.If a core dump happened, then what statement or expression did.
University of Amsterdam Computer Systems – the instruction set architecture Arnoud Visser 1 Computer Systems The instruction set architecture.
Introduction to Intel IA-32 and IA-64 Instruction Set Architectures.
1 Assembly Language: Function Calls Jennifer Rexford.
Linking I Topics Assembly and symbol resolution Static linking Systems I.
OUTLINE 2 Pre-requisite Bomb! Pre-requisite Bomb! 3.
GDB Introduction And Lab 2
Gnu Debugger (GDB) Topics Overview Quick Reference Card Readings: Quick Reference Card February 4, 2010 CSCE 212Honors Computer Organization.
Reading Condition Codes (Cont.)
Instruction Set Architecture
Static and dynamic analysis of binaries
Credits and Disclaimers
IA32 Processors Evolutionary Design
Recitation: Bomb Lab _______________ 18 Sep 2017.
More GDB, Intro to x86 Calling Conventions, Control Flow, & Lab 2
Dynamic Analysis ddaa.
Conditional Branch Example
CSCE 212Honors Computer Organization
Debugging with gdb gdb is the GNU debugger on our CS machines.
Homework Reading Machine Projects Labs PAL, pp ,
Recitation: Bomb Lab _______________ 06 Feb 2017.
Aaron Miller David Cohen Spring 2011
Homework In-line Assembly Code Machine Language
gdb gdb is the GNU debugger on our CS machines.
Introduction to Computer Systems
Assembly Language Programming V: In-line Assembly Code
Machine-Level Programming 1 Introduction
Computer Architecture “Bomb Lab Hints”
Computer Architecture and Assembly Language
C Prog. To Object Code text text binary binary Code in files p1.c p2.c
Introduction to Intel IA-32 and IA-64 Instruction Set Architectures
Assembly Language Programming II: C Compiler Calling Sequences
Machine-Level Programming 2 Control Flow
Machine-Level Programming III: Procedures Sept 18, 2001
Machine-Level Programming: Introduction
Machine-Level Programming I: Basics Comp 21000: Introduction to Computer Organization & Systems Instructor: John Barr * Modified slides from the book.
02/02/10 20:53 Assembly Questions תרגול 12 1.
CSCE 212Honors Computer Organization
Debugging.
Credits and Disclaimers
Computer Architecture and System Programming Laboratory
Computer Architecture and System Programming Laboratory
By Hugues Leger / Intro to GDB debugger By Hugues Leger / 11/16/2019.
Presentation transcript:

Goals: To gain an understanding of assembly To get your hands dirty in GDB

C program compilation Overview of the Binary Bomb Lab Assembly basics GDB basics GDB “bug” GDB demo Assembly/C comparison practice

Steps to building an executable file from a C source code file: 1.Preprocessing: the preprocessor takes a C source code file and replaces preprocessor directives with source code For example, #include and #define precede preprocessor directives 2.Compilation: the compiler produces an object file based on the output of the preprocessor 3.Assembling: conversion from assembly to machine instructions 4.Linking: the linker takes the object files produced by the compiler and combines them to produce a library or an executable file If one is available, running the Makefile (using the command “make”) can do these steps for you Alternatively, you could use the “gcc” command

Dr. Evil has created a series of so-called “binary bombs” for you to defuse by determining the password needed to prevent an “explosion” from occurring You will only be given your bomb’s.o file because giving you the source code would make this lab far too easy You will be expected to look at the assembly dump of this file to help you determine the passwords It may be useful to learn how to set breakpoints to prevent explosions Each time you allow the bomb to explode, you will lose ¼ point Capped at 10 points lost Each phase is worth 10 points out of a total of 60 points

movl Souce, Destination Ex: can move immediate value to a register or to memory, can move a register value to another register or to memory, can move memory to a register CANNOT move memory to memory leal Souce, Destination Commonly used for computing arithmetic expressions Ex: leal (%eax, %eax, 2), %eax would be the assembly version of C code that looks something like the following: x = x + x*2 cmpl Reg1, Reg2: Reg2 “relation” Reg1 j mpl Label Could be of the form j “relation” (Ex: j le or j g or j e) addl Souce, Destination: Dest = Dest + Src subl Souce, Destination: Dest = Dest - Src

%esp: stack pointer %ebp: stack base pointer %eax: function return value %ebx, %ecx, %edx: general-purpose registers %eip: instruction pointer (program counter)

0x8(%edx) => 0x8+%edx (%edx, %ecx) => %edx + %ecx (%edx, %ecx, 4) => %edx + 4*%ecx 0x8(, %edx, 2) => 2*%edx + 0x8

Command line debugging tool Available on many different platforms Useful outside of classroom setting Allows you to trace a program in execution and set breakpoints along the way Gives you a chance to inspect register contents and the assembly breakdown of your executable

When setting a breakpoint, GDB replaces the instruction at which you are breaking with the expression “int3” as an indicator of a system interrupt so that the program will pause at that point when it is running As a quick fix, please do the following: Within GDB: (gdb) set code-cache off As a permanent fix, please do the following: Command line: $ echo "set code-cache off" >> ~/.gdbinit

break: sets break point at specified location print: prints a specified variable or register’s value stepi: steps through one instruction in assembly nexti: steps through one instruction, including function calls disas: show the disassembly of the current code continue: continues execution after stopping at a break point quit: exit gdb

disas [function] disas *address info break info registers x/* address: display contents of memory x/ 4x address: display 4 32-bit hex numbers starting at address

(Practice problem was adapted from Professor Mohamed Zahran’s practice exam)