9
Introduction to Information Security Reverse Engineering and Binary Patching

Introduction to Information Security · IDA - lump Search View Options Windows Help T ext 0101 0101 0101 Hex Vien-A Exports Imports Names Functions Structures Enums Names window Name

  • Upload
    others

  • View
    12

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Introduction to Information Security · IDA - lump Search View Options Windows Help T ext 0101 0101 0101 Hex Vien-A Exports Imports Names Functions Structures Enums Names window Name

Introduction to Information SecurityReverse Engineering and Binary Patching

Page 2: Introduction to Information Security · IDA - lump Search View Options Windows Help T ext 0101 0101 0101 Hex Vien-A Exports Imports Names Functions Structures Enums Names window Name

Reverse Engineering• Restructuring the execution flow of a binary file

• What for?

• Understanding proprietary code

• ReactOS

• Cryptographic algorithms

• Looking for exploits

Page 3: Introduction to Information Security · IDA - lump Search View Options Windows Help T ext 0101 0101 0101 Hex Vien-A Exports Imports Names Functions Structures Enums Names window Name

Reverse Engineering• The problem

• Compilation is like a one-way function: comments, names and some structure are lost

• Solutions

• Look for anchors: constants (especially strings), standard library functions, etc.

• Somewhat of an art form

• Most of the code is inessential

• Programmers are pretty predictable

• Compilers are also pretty predictable

Page 4: Introduction to Information Security · IDA - lump Search View Options Windows Help T ext 0101 0101 0101 Hex Vien-A Exports Imports Names Functions Structures Enums Names window Name

IDA• Interactive DisAssembler

• Navigation

• Strings

• Standard library functions

• Cross references (xrefs)

• Documentation

• Comments

• Variable and function names

Page 5: Introduction to Information Security · IDA - lump Search View Options Windows Help T ext 0101 0101 0101 Hex Vien-A Exports Imports Names Functions Structures Enums Names window Name

IDAclick n ; x

Page 6: Introduction to Information Security · IDA - lump Search View Options Windows Help T ext 0101 0101 0101 Hex Vien-A Exports Imports Names Functions Structures Enums Names window Name

Patching• Changing the execution flow of a binary file

• What for?

• Small changes

• Big changes, when recompilation is not possible (no source code or build environment)

• How?

• Changing instructions to other instructions

• Chaining instructions to redirect to "Dead Zones", and adding more instructions there

Page 7: Introduction to Information Security · IDA - lump Search View Options Windows Help T ext 0101 0101 0101 Hex Vien-A Exports Imports Names Functions Structures Enums Names window Name

Patching

if (!auth)return -1;

...

MOV EAX, [EBP-4]CMP EAX, 0JNE _AUTHMOV EAX, -1RET_AUTH:...

8b 44 24 fc 83 f8 00 75 06 b8 ff ff ff ff c374

JE

Page 8: Introduction to Information Security · IDA - lump Search View Options Windows Help T ext 0101 0101 0101 Hex Vien-A Exports Imports Names Functions Structures Enums Names window Name

Dead Zones

function

Dead ZoneDead Zone

function

Dead ZoneDead Zone

Page 9: Introduction to Information Security · IDA - lump Search View Options Windows Help T ext 0101 0101 0101 Hex Vien-A Exports Imports Names Functions Structures Enums Names window Name

IDA• Shows offsets

• Shows virtual addresses