diff --git a/break_script/automated_attack.py b/break_script/automated_attack.py index 6e13ed9..e940937 100755 --- a/break_script/automated_attack.py +++ b/break_script/automated_attack.py @@ -9,6 +9,7 @@ import threading from Crypto.Cipher import AES #context.log_level = "debug" +max_measurements = 20000 allowed_chars = string.ascii_letters + string.digits + string.punctuation @@ -104,7 +105,11 @@ key = [] # We keep gathering measurements until we are certain enoguh which key the correct one is while len(key) < 16: - measurements.update(gather_measurements(remotes, 1000)) + if len(measurements) < max_measurements: + measurements.update(gather_measurements(remotes, 1000)) + else: + log.failure("Unable to restore key after using the maximum configured number of measurements. This can mean one of two things: Either we just got very unlucky with the random numbers and this error will not occur again during the next run. In this case this error can be ignored. If this error keeps occuring the challange is broken.") + sys.exit(1) log.info("Total number of unique measurements gathered: {}".format(len(measurements))) # This attack allows us to test each aes key byte independently