reverse engineering (evo 2008)

54
Reverse Engineering Tudor Gîrba www.tudorgirba.com

Upload: tudor-girba

Post on 03-Jul-2015

2.189 views

Category:

Education


5 download

DESCRIPTION

This set of slides accompanied my lecture on reverse engineering held at the University of Bern. More information at: scglectures.unibe.ch/evo2008

TRANSCRIPT

Page 1: Reverse Engineering (EVO 2008)

Reverse Engineering

Tudor Gîrbawww.tudorgirba.com

Page 2: Reverse Engineering (EVO 2008)

Chikofky & Cross, 90

Reverse engineering is analyzing a subject system to:

identify components and their relationships, andcreate more abstract representations.

Page 3: Reverse Engineering (EVO 2008)

Why reverse engineer?

Page 4: Reverse Engineering (EVO 2008)

The B29 bomber

Page 5: Reverse Engineering (EVO 2008)

In 1944, 3 B29s had to land in Russia

Page 6: Reverse Engineering (EVO 2008)

Requirement: Copy everything, fast!

Page 7: Reverse Engineering (EVO 2008)
Page 8: Reverse Engineering (EVO 2008)
Page 9: Reverse Engineering (EVO 2008)
Page 10: Reverse Engineering (EVO 2008)
Page 11: Reverse Engineering (EVO 2008)

Disassemble

Page 12: Reverse Engineering (EVO 2008)

Disassemble Run

Page 13: Reverse Engineering (EVO 2008)

Disassemble Run

Test and compare

Page 14: Reverse Engineering (EVO 2008)
Page 15: Reverse Engineering (EVO 2008)

Tupolev TU-4: 105,000 pieces assembled in 2 years

Page 16: Reverse Engineering (EVO 2008)

Why reverse engineer software?

Page 17: Reverse Engineering (EVO 2008)

forward engineering

actual development }

{

}

{

}

{

}

{}

{

}

{

}

{}

{

}

{

Page 18: Reverse Engineering (EVO 2008)

reve

rse

engin

eerin

gforward engineering

}

{

}

{

}

{

}

{}

{

}

{

}

{}

{

}

{

actual development

Page 19: Reverse Engineering (EVO 2008)

program transformation

reve

rse

engin

eerin

gforward engineering

}

{

}

{

}

{

}

{}

{

}

{

}

{}

{

}

{

Page 20: Reverse Engineering (EVO 2008)

program transformation

reve

rse

engin

eerin

gforward engineering

}

{

}

{

}

{

}

{}

{

}

{

}

{}

{

}

{

Reengineering life cycle

Page 21: Reverse Engineering (EVO 2008)

reve

rse

engin

eerin

g

}

{

}

{

}

{}

{

}

{Setting direction

First contact

Initial understanding

Detailed model capture

Page 22: Reverse Engineering (EVO 2008)

reve

rse

engin

eerin

g

}

{

}

{

}

{}

{

}

{Setting direction

First contact

Initial understanding

Detailed model capture

patterns

patterns

patterns

patterns

Page 23: Reverse Engineering (EVO 2008)

short intermezzo

What are patterns?

Page 24: Reverse Engineering (EVO 2008)

reve

rse

engin

eerin

g

}

{

}

{

}

{}

{

}

{

Setting directionFirst contact

Initial understanding

Detailed model capture

Page 25: Reverse Engineering (EVO 2008)

Yogi Berra

You got to be careful if you don't know where you're going, because you might not get there.

Page 26: Reverse Engineering (EVO 2008)

Setting direction patterns

Agreeon maxims

Appointa navigator

Speak to theround table

Most valuablefirst

If it ain’t brokedon’t fix it

Whereto start

Whatto do

Fix problemsnot symptoms

Keep it simple

What notto do

How to do

Setdirection

Maintain direction

Coordinate direction

Page 27: Reverse Engineering (EVO 2008)

reve

rse

engin

eerin

g

}

{

}

{

}

{}

{

}

{Setting direction

First contactInitial understanding

Detailed model capture

Page 28: Reverse Engineering (EVO 2008)

Interview during demo Chat with maintainers

What is the usage?

What are the bugs?

What do you like?

What is the history?

What is the process?

What are the problems?

Page 29: Reverse Engineering (EVO 2008)

Interview during demo Chat with maintainers

Remember that they are all humans:

they complain

they are enthusiastic

they protect their jobs

What is the usage?

What are the bugs?

What do you like?

What is the history?

What is the process?

What are the problems?

Page 30: Reverse Engineering (EVO 2008)
Page 31: Reverse Engineering (EVO 2008)

Read all code in one hour

Page 32: Reverse Engineering (EVO 2008)

Read all code in one hour ?

Page 33: Reverse Engineering (EVO 2008)

Read all code in one hour 100’000 lines of code

?

Page 34: Reverse Engineering (EVO 2008)

Read all code in one hour 100’000 lines of code

* 2 = 200’000 seconds

?

Page 35: Reverse Engineering (EVO 2008)

Read all code in one hour 100’000 lines of code

* 2 = 200’000 seconds

/ 3600 = 56 hours

?

Page 36: Reverse Engineering (EVO 2008)

Read all code in one hour 100’000 lines of code

* 2 = 200’000 seconds

/ 3600 = 56 hours

/ 8 = 7 days

?

Page 37: Reverse Engineering (EVO 2008)

ArgoUML

Page 38: Reverse Engineering (EVO 2008)

Moose

Page 39: Reverse Engineering (EVO 2008)

Woody Allen

I took a course in speed reading and read “War and Peace” in twenty minutes.

It’s about Russia.

Page 40: Reverse Engineering (EVO 2008)
Page 41: Reverse Engineering (EVO 2008)

First contact patterns

Chat withmaintainers

Interview during demo

Talk withdevelopers

Talk withusers

Read all codein one hour

Skimdocumentation

Do a mockinstallation

Readthe code

Compilethe code

Read about the code

Talk about it

Verify what you hear

Page 42: Reverse Engineering (EVO 2008)

reve

rse

engin

eerin

g

}

{

}

{

}

{}

{

}

{Setting direction

First contact

Initial understandingDetailed model capture

Page 43: Reverse Engineering (EVO 2008)

Speculate about design

Graph

Layout

EdgeNode

Abstract

Item

Page 44: Reverse Engineering (EVO 2008)

Identify exceptional entities

Page 45: Reverse Engineering (EVO 2008)

Identify exceptional entities

for i in $( ls ); do echo `wc -l $i` >> tempdonesort -nr temp | head -10

Page 46: Reverse Engineering (EVO 2008)

Initial understanding patterns

Speculateabout design

Analyzepersistent data

Studyexceptional entities

Bottom up

Top down

Iteration

Recoverdatabase

Identifyproblems

Recoverdesign

Page 47: Reverse Engineering (EVO 2008)

reve

rse

engin

eerin

g

}

{

}

{

}

{}

{

}

{Setting direction

First contact

Initial understanding

Detailed model capture

Page 48: Reverse Engineering (EVO 2008)

To understand: refactor

Page 49: Reverse Engineering (EVO 2008)

To understand: refactorwrite tests

Page 50: Reverse Engineering (EVO 2008)

To understand: refactorwrite testsstep through execution

Page 51: Reverse Engineering (EVO 2008)

Learn from the past

Page 52: Reverse Engineering (EVO 2008)

Detailed model capture patternsTie code and

questions

Exposecontracts

Refactorto understand

Step throughexecution

Look forthe contracts

Write teststo understand

Learn fromthe past

Exposedesign

Track yourunderstanding

Encodeassumptions

Exposecollaborations

Exposeevolution

Page 53: Reverse Engineering (EVO 2008)

reve

rse

engin

eerin

g

}

{

}

{

}

{}

{

}

{Setting direction

First contact

Initial understanding

Detailed model capture