r/crypto•
Kiwitheme

Known-plaintext BF-ecb file edit - Uni Assignment

So I'm doing a first year Cybersecurity fundamentals paper and we have our first assignment. I've finished all questions bar this one in particular and need some push in the right direction.

We have a small "payroll/ann salary" file that we need to edit. And make "our" salary equal to the higher salaries.

We know employee names, know the length of each line, and also that it is sorted alphabetically.

After quite a bit of reading I'm concluding that I'm stumped. After decryption I still don't have the key to re-encrypt, editing the file will change its hash, making it obvious that it has been edited.

What are the typical steps to approach something like this? Is there any appropriate documents that would be of help?

Thanks

Posted Apr 25, 2019, 10:17 PM UTC

56
Natanael_LTrusted third party•

Have you looked at the differences between ECB mode and other modes like CTR and CBC? You might notice that each block in ECB is always encrypted the same way no matter where it is or what's around it. Blocks gets scrambled in CTR and CBC mode if you randomly move them. But what do you get in ECB mode? And for example, what happens to the ciphertext if the same plaintext repeats for a while, like a bunch of zeroes? And vice versa.

You mentioned a hash. Is that something that's actually being verified? Is there any authentication tag? Because if it isn't validated, the hash means nothing. If there's an unkeyed hash on the ciphertext, stored next to the ciphertext, you can trivially replace it. You'd be in trouble if it was keyed (like HMAC) or stored in a system you can't access.

2
KiwithemeOP•

We haven't covered CTR yet, mostly AES/DES ECB and CBC. So I should just keep attempting decrypts with bad passwords? We honestly haven't covered methods for this, so a little lost.

From what I read it's salted, and it uses non-alphabetic ciphertext, but isn't ending in Base64 (I presume due to the lack of ending in "==") And the goal is to edit "my" salary utilising openssl command lines.

I've overthought the hash. Which doesn't need to be addressed. After re-reading the question.

1
Natanael_LTrusted third party•

Have you considered ciphertext malleability? Google the term, and see if you can figure out what to do on your own. You might not need the key!

3
KiwithemeOP•

Ahhh! I'll definitely read up on this one, hope it may help! Thankies

1
poindexter_one•

What else do you know about the structure of the data file? Are the names padded to a known length? Do you know the key length? The “trick”to ECB is that each block of 8 bytes with identical contents will encrypt to the same 8bute cipher text value.

Given this is 1st year, I think your going to find 8byte blocks containing salary info and all you have to do is replace the right target block with another one that has the desired salary.

Break the ciphertext into 8byte blocks and look for repeated blocks, see where that gets you.

Edit: by the way, the 8-byte figure I used pertains to BF as you indicated. Different ciphers can have different values. AES-128 will be 16 bytes, etc. BF also has a 128-bit/16-byte version.

2
KiwithemeOP•

Will give this a try also, thanks for advice on a place to start :)

1