Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Information Security מרצים : Dr. Eran Tromer: Prof. Avishai Wool: מתרגלים : Itamar Gilad

Similar presentations


Presentation on theme: "Introduction to Information Security מרצים : Dr. Eran Tromer: Prof. Avishai Wool: מתרגלים : Itamar Gilad"— Presentation transcript:

1 Introduction to Information Security מרצים : Dr. Eran Tromer: tromer@cs.tau.ac.il Prof. Avishai Wool: yash@eng.tau.ac.il מתרגלים : Itamar Gilad (itamargi@post.tau.ac.il) Nir Krakowski (nirkrako@post.tau.ac.il)

2 Today Reverse Engineering 101 IDA (!) Binary patching 101 More tools

3 Reverse Engineering What does the following code do: o LEA EDX, [address to “Hello, world!”] o MOV ECX, 12 MYLOOP: o PUSH EDX o CALL printf o ADD ESP, 4 o LOOP MYLOOP

4 Reverse Engineering What is it? o Using the binary to recreate any knowledge needed Why? o Recreating lost platforms (ReactOS) o ‘Secret’ algorithms (Encryption, trade secrets, etc.) o Hidden features (and hidden backdoors) o Internal structures & implementation details o Bugs / Vulnerabilities that only exist in the binary o you name it!

5 So, what’s the problem? o Compiling is like a one-way function. o Information is lost, and we *often* loose access to – Variable and function names Comments o What do we still have - Import and export names (relations between modules) Structure of parameters to functions. Starting point Hard-coded strings Constants

6 RE Process Our objectives – o Find the most interesting piece of code in the least amount of time o Understand what it does and how o Find weaknesses and figure out how to exploit them Use leads – o Strings, UI o Dynamic debugging, breakpoints. o Library and system functions Interpret the assembled code by using intelligent guesses – o Context-based o Code is written by people using regular code conventions o Code is written in an upper level language, and compilers are usually pretty predictable

7 IDA The Interactive Dis-Assembler ( IDA ) is the most popular reverse engineering tool o Version 5.0 is free-ware and that is what we’ll use. IDA does several things automatically: o Disassemble x86 binary code into human readable format o Identifies ELF headers (executable file formats) o Signature based recognition for library functions and compiler tricks o Creates code graph by basic blocks o Code and data xrefs (references to memory addresses, functions) Provides a good environment for research: o Adding comments (‘;’) o Renaming labels: code blocks, variables, function names, structures. (‘n’) o Change interpretation of binary data (code->data, data->code, data type change, etc.) https://www.hex-rays.com/products/ida/support/freefiles/IDA_Pro_Shortcuts.pdf

8 IDA Options

9 IDA Demo [Helllo World]

10 IDA Demo [stricmp]

11 Binary patching What? o Changing instructions/data/metadata in the “production” binary Why? o You lost the source code o You never had the source code o Small changes that would be easier to test on their own o Hot patching o And many more

12 Binary patching example int verify_login(char * username, char * password) { if ((0 == strcmp(username, “root”)) && (0 == strcmp(password, “my_pass”)) { return 0; } else { return 1; }

13 Patch Layout Patch area (NOPs) Function body Function prolog Function Epilog

14 Execution Layout Patch area (CODE) Function body Function prolog Function Epilog

15 Patch Layout Patch area (NOPs) Function body Function prolog Function Epilog Divert execution around patch area

16 Patch Layout Patch area (NOPs) Function body Function prolog Function Epilog Jump into patch area

17 Patch Layout Patch area (NOPs) Function body Function prolog Function Epilog Jump back into original code

18 Patch Layout Patch area (CODE) Function body Function prolog Function Epilog

19 New tools! va_to_offset.py – A tool to map a virtual address (as you see in IDA) to a file offset patch_util_gcc.py – A script that lets you patch a binary by using simple text files with (bare) assembly instructions

20 This week’s exercise First reverse engineering task First binary patching task It isn’t hard – but please start early and contact us if you have any trouble with the setup


Download ppt "Introduction to Information Security מרצים : Dr. Eran Tromer: Prof. Avishai Wool: מתרגלים : Itamar Gilad"

Similar presentations


Ads by Google