RC4 cracker

Problem: decrypt the cipher.

Tool: crytool

cipher: '1834e1b2170c2ac5212677e3ae48ed42c32810400afca21defab111bc7'
which encrypted by 4-characters password


How RC4 works?

RC4 is a stream cipher and variable length key algorithm. 
Plaintext does XOR with key stream to get the cipher, so that the key stream has the same length as the plaintext.
So how to get the key stream?
First, initial array:

  • Initial state vector S, s[0..255]. 
  • A key which is a password, like 'KEY', it should repeat many times to fill T with size 256. T[K,E,Y,K,E,Y,...].
  • Initial permuted vector S, s[0..255].

Second, do calculate and swap to get a new Permuted vector S. Every element should be produced with the previous one.

Third, get the key stream with as  the same length as plaintext. It also contains some calculation and swap.

Last, make plaintext and key stream do XOR to get the cipher.


Crack RC4 with brute force:
It should be a forward-direction which means we should list all the password and do the encryption to get the key stream, and make it XOR with our cipher, then we can get different plaintexts. These plaintexts should be list by the entropy, so we can find the most readable plaintext. 

Step 1: Copy the cipher in the txt, then choose the analysis  RC4:





Step 2 : Choose the length of the password, 4 characters is 32 bits:



Step 3: the consequence is ordered by entropy:


Popular posts from this blog

Phonebook - Hack the box Write up -- Web LDAP injection

wafwaf -- Hack The Box -- Web SQL injection

Cheat sheet for security+