Fork Join

1,186 views
1,080 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,186
On SlideShare
0
From Embeds
0
Number of Embeds
140
Actions
Shares
0
Downloads
15
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Fork Join

  1. 1. Fork/Join framework<br />Rainbow attack example<br />Philip Savkinphilip.savkin@gmail.com<br />Twitter: philipsavkin<br />
  2. 2. Fork Join Framework<br />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.<br />http://gee.cs.oswego.edu/dl/papers/fj.pdf<br />
  3. 3. Algorithm<br />Result solve(Problem problem) {<br /> if (problem is small)<br /> directly solve problem<br /> else {<br /> split problem into independent parts<br /> fork new subtasks to solve each part<br /> join all subtasks<br /> compose result from subresults<br /> }<br />}<br />
  4. 4. Core classes<br />
  5. 5. Differences from ThreadPoolExecutor<br />Suited for recursive tasks and “divide and conquer” algorithms<br />Work stealing<br />
  6. 6. Work Stealing<br />Initial state<br />Wait for all threads to complete their tasks<br />
  7. 7. Work Stealing<br />Other threads are idle until the first thread finished<br />Wait for all threads to complete their tasks<br />
  8. 8. Part II<br />
  9. 9. Practical example<br />Passwords are rarely kept in cleartext nowadays<br />The problem: restore passwords from a list of password hashes with Rainbow attack<br />
  10. 10. Rainbow attack<br />http://en.wikipedia.org/wiki/Rainbow_attack<br />Build a Rainbow table using the list of possible passwords<br />Lookup passwords in the table<br />
  11. 11. The algorithm<br />Load top 2000 english words<br />Add all case permutations<br />Add numbers 0-9<br />Results in 6 000 000 combinations<br />Compute hashes<br />Lookup hashes in the table<br />
  12. 12. How ForkJoin can help?<br />CPU intensive tasks<br />Generate the list of all possible passwords<br />Compute hashes<br />
  13. 13. Let’s see some code!<br />
  14. 14. Test results<br />Tested on Amazon EC2 Extra Large instance running 64 bit AMI Linux<br />15 Gb RAM, 4 processors<br />Rainbow table size: 6 041 508<br />Input: list of 1000 MD5 hashes<br />Found all 10 passwords<br />
  15. 15. Test results<br />
  16. 16. Bonus slide - Offtopic<br />Never keep passwords in cleartext!<br />MD5 is a bad choice<br />Always add “salt” to passwords<br />The right way: use Bcrypt!<br />
  17. 17. More offtopic<br />The “pastebin” experiment<br />http://pastebin.com/1iL2P0G5<br />Found one password “a1”<br />
  18. 18. Questions<br />Thank you!<br />

×