RC4 is the encryption algorithm used to cipher the data sent. It consists of :
First part of the encryption process.
Assume N = 256//Determines how strong the encryption is.K[] = Secrete Key array//Is unscrambled.Initialization://Used to fill the empty State (S[]) array with values 0 to 255.For i = 0 to N - 1 S[i] = ij = 0//Is used to hold a value during the scrambling process.Scrambling://Starts the scrambling process that transforms S into a pseudo random arrayFor i = 0 to N - 1 j = j + S[i] + K[i]//Merge the properties of the secret key with the state
array (S[]) to create a pseudo random number Swap(S[i], S[j])Outputs a streaming key based on the KSA's pseudo random state array. This streaming key is then merged with the plaintext data to create a stream of data that is encrypted.
Initializationi = 0 j = 0Generation Loop: //Starts the stream-generation process : will continue until there is no more data i = i + 1 j = j + S[i] Swap(S[i], S[j]) Output z = S[S[i] + S[j]]// Output XORed with data//| A | B | A XOR B |
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
Recap :
Furthermore :
The captured weak IV is 3, 255, 7. The pre-shared password is 22222.
The key array: K[0]=3 K[1]=255 K[2]=7 K[3]=? K[4]=? K[5]=? K[6]=? K[7]=?
i=0 j=0 S[0]=0 S[1]=1 S[2]=2 S[3]=3j=j + S[i] + K[i mod l] = 0 + S[0] + K[0] = 0 + 0 + 3 = 3 : j = 3Swap (S[i], S[j]) = Swap (S[0] , S[3]) : finally S[0] = 3 , S[3] = 0 i=1 j=3 S[0]=3 S[1]=1 S[2]=2 S[3]=0 j=j + S[i] + K[i mod l] = 3 + S[1] + K[1 mod 8] = 3 + 1 + 255 = 259 mod 256 = 3 j = 3Swap(S[i], S[j]) = Swap (S[1] , S[3]) : finally S[1]=0 , S[3]=1 i=2 j=3 S[0]=3 S[1]=0 S[2]=2 S[3]=1 j=j + S[i] + K[i mod l] = 3 + S[2] + K[2] = 3 + 2 + 7 = 12 j = 12Swap(S[i], S[j]) = Swap (S[2] , S[12]) : finally S[2]=12 , S[12]=2i=3 j=12 S[0]=3 S[1]=0 S[2]=12 S[3]=1 S[12]=2 j=j + S[i] + K[i mod l] = 12 + S[3] + K[3] = 12 + 1 + ? = ? j = ??We can deduce the first byte of the PRGA if we XOR the first byte of the encrypted data with the first byte of plaintext. We know in advance that it will be the SNAP header (170 in decimal).
In the example, the captured encrypted byte value is 165 in decimal.
z = 0xAA(SNAP) XOR Ciphertext byte1 = 170 (Dec) XOR 165 (Dec) = 15 : z = 15 Swap (S[i], S[j]) = Swap (S[1] , S[0]) finally S[1]=3 , S[0]=0 z = S[S[i] + S[j]] = S[S[1] + S[0]] = S[3 + 0] = S[3] = ? S[3]=15 , S[15]=S[3]t-1 : S[3]=15 , S[15]=1 j=j + S[i] + K[i mod 256] = 12 + S[3] + K[3] = 12 + 1 + K[3] = 15K[3] = 15 - 12 - 1 = 2 We found the first character of the secret key.
These are dedicated to cracking WEP keys:
But you might also need: