Question: Implement the rainbow table attack based on the following hash function and reduce functions. Let p (for PIN) be an integer between 0000 and 9999

Implement the rainbow table attack based on the following hash function and reduce functions. Let p (for PIN) be an integer between 0000 and 9999 inclusive.

hash(p) = b((p+25) mod 10000)2 100 c mod 10000

reduce(h) = h Run your attack against all 10000 possible PINs.

What is the success rate of your rainbow attack?

This is what I have so far is this properly measuring my success rate?

import java.io.IOException; import java.util.Random;

public class RainbowAttack { public static void main(String[] args) throws IOException { int RainbowTable[][] = new int [100][2]; int[] pins = new Random().ints(0,9999).distinct().limit(100).toArray(); //System.out.print(pins); for(int i = 0; i < 100; ++i){ int hash; hash = pins[i]; RainbowTable[i][0] = hash; for(int j = 0; j < 100; j++) { hash = RainbowTable[i][0]; hash = hash(hash); hash = reduce(hash); } RainbowTable[i][1] = hash; } double count = 0; boolean found = false; int j = 0; int hash; for(int i = 0; i < 10000; i++){ hash = hash(i); found = false; for(j = 0; j< 100; ++j){ if(hash == RainbowTable[j][1]){ hash = RainbowTable[j][0]; for(int k = 0; k < 100; ++k){ hash = hash(hash); if(i == hash){ found = true; count++; break; } } if(found) break; } } }

double percent = (count/10000)*100; System.out.println(percent); }

static int hash(int p){ double h = ((p + 25) % 10000) * ((p + 25) % 10000); h /= 100; h %= 10000; if(h > (int)h) h = (int)h; return (int)h; }

public static int reduce(int hash){ return hash; } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!