commit 5b428137a6bf2c2278e8a6b9494d1a4c19b65d0c
parent c9e57ef52d3801acdfb743f3d352e3eb64145353
Author: mpizzzle <michael.770211@gmail.com>
Date: Tue, 31 Oct 2017 19:33:41 +0000
renaming some methods
Diffstat:
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/set3/cbc_padding_oracle.py b/set3/cbc_padding_oracle.py
@@ -10,7 +10,7 @@ def encryption_oracle():
plaintext = f.read().splitlines()[random.randint(0, 9)]
pad_len = AES.block_size - (len(plaintext) % AES.block_size)
- return AES.new(key, AES.MODE_CBC, iv).encrypt(plaintext + ''.join([chr(pad_len) for i in range(pad_len)]))
+ return iv + AES.new(key, AES.MODE_CBC, iv).encrypt(plaintext + ''.join([chr(pad_len) for i in range(pad_len)]))
def pkcs7_padding_validation(msg, strip_mode):
len_pad = ord(msg[len(msg) - 1])
@@ -27,7 +27,7 @@ def pkcs7_padding_validation(msg, strip_mode):
def padding_oracle(ciphertext):
return pkcs7_padding_validation(AES.new(key, AES.MODE_CBC, iv).decrypt(ciphertext), False)
-ciphertext = iv + encryption_oracle()
+ciphertext = encryption_oracle()
plaintext = ""
for b_idx in reversed(range((len(ciphertext) / AES.block_size) - 1)):