Fork Join

18
Fork/Join framework Rainbow attack example Philip Savkin [email protected] Twitter: philipsavkin

Transcript of Fork Join

Page 1: Fork Join

Fork/Join framework

Rainbow attack example

Philip Savkin [email protected]

Twitter: philipsavkin

Page 2: Fork Join

Fork Join Framework

Java framework for supporting a style of parallel

programming in which problems are solved by

(recursively) splitting them into subtasks that are

solved in parallel, waiting for them to complete,

and then composing results.

http://gee.cs.oswego.edu/dl/papers/fj.pdf

Page 3: Fork Join

Algorithm

Result solve(Problem problem) {

if (problem is small)

directly solve problem

else {

split problem into independent parts

fork new subtasks to solve each part

join all subtasks

compose result from subresults

}

}

Page 4: Fork Join

Core classes

Page 5: Fork Join

Differences from

ThreadPoolExecutor

Suited for recursive tasks and “divide and

conquer” algorithms

Work stealing

Page 6: Fork Join

Work Stealing

Wait for all threads to complete their tasks

Initial state

Page 7: Fork Join

Work Stealing

Wait for all threads to complete their tasks

Other threads are idle until the first thread finished

Page 8: Fork Join

Part II

Page 9: Fork Join

Practical example

Passwords are rarely kept in cleartext

nowadays

The problem: restore passwords from a list

of password hashes with Rainbow attack

Page 10: Fork Join

Rainbow attack

http://en.wikipedia.org/wiki/Rainbow_attack

Build a Rainbow table using the list of

possible passwords

Lookup passwords in the table

Page 11: Fork Join

The algorithm

Load top 2000 english words

Add all case permutations

Add numbers 0-9

Results in 6 000 000 combinations

Compute hashes

Lookup hashes in the table

Page 12: Fork Join

How ForkJoin can help?

CPU intensive tasks

Generate the list of all possible passwords

Compute hashes

Page 13: Fork Join

Let’s see some code!

Page 14: Fork Join

Test results

Tested on Amazon EC2 Extra Large

instance running 64 bit AMI Linux

15 Gb RAM, 4 processors

Rainbow table size: 6 041 508

Input: list of 1000 MD5 hashes

Found all 10 passwords

Page 15: Fork Join

Test results

Sequential 2 threads 4 threads 8 threads

Threads 1 2 4 8

Run 1 10967 7278 5465 5451

Run 2 9176 7195 5687 5646

Run 3 8083 5270 4338 4025

Run 4 9244 6515 5507 5005

Run 5 9279 7265 6497 5650

Avg 9350 6705 5499 5155

Speedup 0% 28% 41% 45%

0%

10%

20%

30%

40%

50%

1 2 4 8

Page 16: Fork Join

Bonus slide - Offtopic

Never keep passwords in cleartext!

MD5 is a bad choice

Always add “salt” to passwords

The right way: use Bcrypt!

Page 17: Fork Join

More offtopic

The “pastebin” experiment

http://pastebin.com/1iL2P0G5

Found one password “a1”

Page 18: Fork Join

Questions

Thank you!