An introduction to Reverse engineering, the tools and assembly

Slides:



Advertisements
Similar presentations
Chapter 2: Data Manipulation
Advertisements

Microprocessors Typical microprocessor controlled devices: Camera, mobile phone, stereo, mp3 player, electronic toys… High-level microprocessor controlled.
Machine Instructions Operations
The 8051 Microcontroller and Embedded Systems
Chapter 10- Instruction set architectures
 Suppose for a moment that you were asked to perform a task and were given the following list of instructions to perform:
Project Testing; Processor Examples. Project Testing --thorough, efficient, hierarchical --done by “independent tester” --well-documented, repeatable.
TK 2633 Microprocessor & Interfacing Lecture 3: Introduction to 8085 Assembly Language Programming (2) 1 Prepared By: Associate Prof. Dr Masri Ayob.
1 ICS 51 Introductory Computer Organization Fall 2006 updated: Oct. 2, 2006.
CSC 200 Spring 2006 Instructor: Matt Kayala. What is a “Computer”? We all use them for all kinds of tasks: –Games –Word Processing Good at repetitive.
Stored Program Concept: The Hardware View
CS 300 – Lecture 19 Intro to Computer Architecture / Assembly Language C Coding & The Simulator Caches.
Recap – Our First Computer WR System Bus 8 ALU Carry output A B S C OUT F 8 8 To registers’ input/output and clock inputs Sequence of control signal combinations.
ECE 382 Lesson 2 Readings Lesson Outline Admin Assembler Linker
Implementation of a Stored Program Computer
ARM C Language & Assembler. Using C instead of Java (or Python, or your other favorite language)? C is the de facto standard for embedded systems because.
Activity 1 - WBs 5 mins Go online and spend a moment trying to find out the difference between: HIGH LEVEL programming languages and LOW LEVEL programming.
CHAPTER 4: INTRODUCTION TO COMPUTER ORGANIZATION AND PROGRAMMING DESIGN Lec. Ghader Kurdi.
Georgia Institute of Technology Student Computer Simulation Barbara Ericson Georgia Tech Sept 2005.
Levels of Architecture & Language CHAPTER 1 © copyright Bobby Hoggard / material may not be redistributed without permission.
COMP2011 Assembly Language Programming and Introduction to WRAMP.
1 A Simple but Realistic Assembly Language for a Course in Computer Organization Eric Larson Moon Ok Kim Seattle University October 25, 2008.
Chapter 4 - Implementing Standard Program Structures in 8086 Assembly Language from Microprocessors and Interfacing by Douglas Hall.
December 8, 2003Other ISA's1 Other ISAs Next, we discuss some alternative instruction set designs. – Different ways of specifying memory addresses – Different.
Assembly Language A Brief Introduction. Unit Learning Goals CPU architecture. Basic Assembler Commands High level Programming  Assembler  Machine Language.
Basic of Programming Language Skill Area Computer System Computer Program Programming Language Programmer Translators.
COMPUTER ORGANIZATION AND ASSEMBLY LANGUAGE Lecture 21 & 22 Processor Organization Register Organization Course Instructor: Engr. Aisha Danish.
Computer Systems – Machine & Assembly code. Objectives Machine Code Assembly Language Op-code Operand Instruction Set.
Department of Electronic & Electrical Engineering Lecture 2. PIC16F84A Architecture / Instructions Memory. Program/Data (Harvard) File Registers (Data).
Structure and Role of a Processor
1 EKT 225 MICROCONTROLLER I CHAPTER ASSEMBLY LANGUAGE PROGRAMMING.
Microprocessor Fundamentals Week 2 Mount Druitt College of TAFE Dept. Electrical Engineering 2008.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
Recap – Our First Computer WR System Bus 8 ALU Carry output A B S C OUT F 8 8 To registers’ read/write and clock inputs Sequence of control signal combinations.
Datapath and control Dr. ir. A.B.J. Kokkeler 1. What is programming ? “Programming is instructing a computer to do something for you with the help of.
F453 Module 8: Low Level Languages 8.1: Use of Computer Architecture.
The Little man computer
Component 1.6.
Overview of Instruction Set Architectures
Gunjeet Kaur Dronacharya Group of institutions
Assembly Language Programming of 8085
Assembly Language Assembly Language
3.Instruction Set of 8085 Consists of 74 operation codes, e.g. MOV
1. Introduction A microprocessor executes instructions given by the user Instructions should be in a language known to the microprocessor Microprocessor.
The 8051 Microcontroller and Embedded Systems
TRANSLATORS AND IDEs Key Revision Points.
Teaching Computing to GCSE
Introduction to Assembly Language
Hmmm Assembly Language
Instruction set architectures
Computer Architecture
The University of Adelaide, School of Computer Science
Instruction encoding We’ve already seen some important aspects of processor design. A datapath contains an ALU, registers and memory. Programmers and compilers.
Two questions Four registers isn’t a lot. What if we need more storage? Who exactly decides which registers are read and written and which ALU function.
Introduction to Programming Part 2
Functions in Hmmm Assembly
Instruction set architectures
Other ISAs Next, we’ll first we look at a longer example program, starting with some C code and translating it into our assembly language. Then we discuss.
Other ISAs Next, we’ll first we look at a longer example program, starting with some C code and translating it into our assembly language. Then we discuss.
Mastering Memory Modes
Lecture 6: Assembly Programs
Introduction to Computer Systems
ECE 352 Digital System Fundamentals
Instructions in Machine Language
Addressing mode summary
8051 ASSEMBLY LANGUAGE PROGRAMMING
Program Execution.
Reversing an Executable
Hmmm Assembly Language
Computer Architecture and System Programming Laboratory
Presentation transcript:

An introduction to Reverse engineering, the tools and assembly Chris Estes

What is Reverse Engineering? When you take a final product (e.g. a compiled program) and attempt to break it down and understand what it’s doing, and possibly modifying it for a new purpose. This involves the use of specialized tools such as debuggers and disassemblers Debuggers allow you monitor things live as they happen Disassemblers attempt to analyze the program and show you what it looks like in assembly

Why would you need to reverse engineer something? When you have a program that you don’t have the source code for but what to find out how it does things Improving/modifying something you don’t have the source code for This may not be legal for every program out there, so exercise it with caution

We’ll be looking at reverse engineering through “romhacking”

Why romhacking? It’s in a bit of a grey area, however, many hobbyists have written highly specialized and useful debuggers/emulators that can help one learn this process A game is a good way to break into reverse engineering (and by extension assembly) It’ll be easier to work with gameplay concepts as things we want to find/alter

Why does it have to be in assembly? There is no real way to convert something back from a compiled format to the original source code The best we can manage is turning it back into assembly Don’t be scared of assembly! It is daunting at first but it’s a good skill to have High Level Language Compiler Executable File (Machine Code /Assembly)

The CPU Registers – storage locations, values move around here Processor Status/Flag Register – keeps track of flags that are set during calculations Program Counter – address of current instruction Stack Pointer – keeps track of call stack

Assembly Basics A very basic example. Basic operators: add, sub, mul*, div* mov (move): copies value from source and puts it into the destination. You will probably see this instruction a lot. jmp (jump) and other conditional jumps: used to hop to certain addresses nop: no operation (I believe it’s used for when you need to wait) *older, simpler CPUs might not have those luxuries, you may have to do your multiplication/division through bit-shifting A very basic example. I highly recommend keeping a reference document up while working on assembly to make it simpler.

Basic approach to reverse engineering Task we want to accomplish -> hunt for relevant info (such as RAM addresses & values) -> set breakpoints (freeze CPU during a certain action) -> slowly trace through instructions and attempting to figure things out -> modify (test & check) OR document how it works

Our Target: The GameBoy The Specs CPU : Sharp LR35902 @ 4.19 MHz Display: 2.6” LCD Resolution: 160x144px Media: ROM Cartridges A Gameboy cartridge PCB.

Metroid II Changing bomb timers DDX0 – Bomb State, DDX1 – Bomb Timer

After searching we find that setting the timer is quite simple.

This one (thankfully) was quite simple and very easy to modify.

Super Mario Land Score is stored at RAM values C0A0 – C0A2 How does the score update? Score is stored at RAM values C0A0 – C0A2

After a lot of searching, we stumble upon this routine.

Basically HL points to location in ram, point value is loaded from register D, then moved to register A, and score is tabulated and stored back to target RAM Location.

Things to remember: Assembly can be a valuable asset, it’s quite confusing at first but debugging a program (that you have source code access to or not) is an invaluable tool for fixing problems! Reverse Engineering is a challenging process but you’ll learn quite a lot about a program and the architecture it’s designed for Don’t ever be afraid to dive into assembly, it may look scary but given enough time you can figure things out and will learn a lot of useful info

THE END!