



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




A few notes on these exercises.
Given the following victim encryption script, with a six-digit non-zero integer flag:
import datetime flag = "XXXXXX" # Redacted while True:
minutes = datetime.datetime.now().minute cipher = str (minutes * int (flag)) send_to_server_z(cipher)
Here is the script to crack the cipher [students would normally submit this via AutoLab].
origCipher = cipher = netcatread(s) while cipher == origCipher: time.sleep(30) cipher = netcatread(s) if cipher == 0: #origCipher was minute 59 print (origCipher / 59) else : print (cipher - origCipher)
which gives us a secret flag of 123456. The vulnerability in the program is two-fold: first, it uses a bad source of randomness. Although current local time is actually a fairly decent source of randomness in general, it relies on there being a lot of precision, and thus being difficult to duplicate, rather than a predictable state like the current minute. The second is in how the randomness is applied: the script performs a simple multiplication, which allows for no secrecy at all (due to associativity, having an easy inverse, etc). Even without the obvious trick, we could take two successive reads, and subtract one from the other and be done. The fact that minute 0 is recognizable with probability 1, and the following minute does not âencryptâ the flag at all, just makes it worse. So, our script uses the predictable progression of minutes to its advantage. It gets an initial reading from the server, then keeps reading until it gets a different reading, which will be the following minute. There are two cases: if the second reading is 0, we know the first reading had to be 59 minutes in, so dividing our original result by 59 will invert the âcipherâ and give us the flag. Otherwise, we know
cipher = minutes (^) * flag = (lastMinute + 1) * flag = (lastMinute (^) * flag) + flag
and lastMinute * flag is just oldCipher, meaning subtracting that out from our current cipher gives us the flag directly.
Another Python script is running on the Evil Corp server. This script encrypts a more complex secret (using both numbers and letters), using AES with a null initialization vector, random key, and 16-byte block. The script sends the encrypted text to the user in a hex format, and attempts to decrypt user input in the same hex format using the same key. Note that the key is newly generated for each session. Given this setup, your goal is to determine the value of the flag (assuming that you have polynomial time bounded computation resources).
Notes and Tips
While working as a secret agent for the 330 hacking group, you were able to intercept a message between Elaine, the Chairwoman of Evil Corp, and one of her employees, Bob. Youâd love to get Bob to send your favorite professor some Bitcoin, but unfortunately, the CEO has applied a MAC to her message, and you do not know her secret key. However, it seems as though Elaine hasnât taken 15 / 18 â 330 , so maybe there is still a way for you to alter the message and still get it to verify...
Your goal in this problem is to implement a length-extension attack, which allows an attacker to calculate the MAC of a maliciously-chosen message without access to a secret key. Provided in merkle_damgard_utils.py are the value msg which is the message that you intercepted between Elaine and Bob. You can simulate a MAC by calculating MAC(key, msg) locally. Here is a description of the MAC that Eve uses to calculate MAC(key, msg) (where key is a 32-byte secret key, and msg is the message to MAC):
To verify, Bob simply calculates the value of MAC(key, msg) and confirms whether it matches the received value. If it matches, Bob can remove the padding values 0x12 to retrieve the message. Your goal is to generate a pair of values msgâ and MAC(key, msgâ˛), where msgâ˛^ contains the following phrase:
Please send ten thousand Bitcoins to Bryan.
and MAC(key, msgâ˛) is a valid MAC for the new message. Note this means that Bob accepts the altered message even though you never learn the secret key directly.
Notes and Tips
You were eating a Caesar salad at a restaurant, when you overheard two Evil Corp employees talking about a secret plan to crash a satellite to Earth. Being the good citizen that you are, you tried to intercept their exact plans. Unfortunately, all you were able to gather is one message, which appears to be complete gibberish:
kyzj zj r kvjk fw fli kfg jvtivk lesivrbrscv vetipgkzfe jtyvdv
The only helpful information you picked up from the Evil Corp employees was that the most common letter in this message is an âeâ and that all employees have an irrational hatred of capital letters. Your mission, should you choose to accept it, is to somehow decrypt this message and figure out what their evil plan is. We expect that you donât just brute force this problem, but write a Python code to do all the work for you. In your write up, provide a description of how your algorithm to decode this message works. Thereâs no autolab for this problem, but please still place your code named âcaesar sol.pyâ in the .tar file for submission and include the decoded message in your writeup.