0

I'm trying to programming the brute force attack, the idea is that:

  • I already have the Cipher text After the encryption
  • I have the first 4 letter of the plain text ( which is 41 character )
  • I have the first 12 character of the secret key

What I need is to find the 4 missing characters

Let's assume I have the key :

 "ABCDEFGHIJ????"

How can I apply brute force attack to find the missing character ?

ʰᵈˑ
  • 10,738
  • 2
  • 20
  • 45
Katio
  • 29
  • 1
  • 1
    Do you know the encryption mode? http://stackoverflow.com/questions/1220751/how-to-choose-an-aes-encryption-mode-cbc-ecb-ctr-ocb-cfb – ʰᵈˑ Mar 07 '17 at 15:55

1 Answers1

0

There are 2^32 possibilities for the missing 4 key bytes. That fits into an unsigned 32-bit int. So, loop over all possibilities for this unsigned int, taking your four missing bytes from the integer value. In C, something like this:

unsigned int i = 0;

do {
    first candidate missing byte for key = i&255;
    second candidate missing byte for key = (i>>8)&255;
    third candidate missing byte for key = (i>>16)&255;
    fourth candidate missing byte for key = (i>>24)i&255;
    /* here: try the candidate with your AES encryption, break if it works */
    ++i;
} while (i != 0);
TheGreatContini
  • 5,791
  • 1
  • 18
  • 25