Skip to content

Commit bd869c3

Browse files
committed
Must only record the last byte, not the others
1 parent f8d998c commit bd869c3

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

paddingoracle.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,11 @@ def bust(self, block, block_size=8, **kwargs):
180180

181181
self.history = []
182182

183-
# Break on first value that returns and oracle, otherwise if we
183+
# Break on first value that returns an oracle, otherwise if we
184184
# don't find a good value it means we have a false positive
185-
# value for the last byte and we need to start all over again from the last byte.
186-
# We can resume where we left off for the last byte though.
185+
# value for the last byte and we need to start all over again
186+
# from the last byte. We can resume where we left off for the
187+
# last byte though.
187188

188189
r = 256
189190
if byte_num == block_size-1 and last_ok > 0:
@@ -202,7 +203,9 @@ def bust(self, block, block_size=8, **kwargs):
202203
try:
203204
self.attempts += 1
204205
self.oracle(test_bytes[:], **kwargs)
205-
last_ok = i
206+
207+
if byte_num == block_size-1:
208+
last_ok = i
206209

207210
except BadPaddingException:
208211

0 commit comments

Comments
 (0)