Skip to content

Commit a73ad2e

Browse files
removed module dependency on struct
1 parent 28e9230 commit a73ad2e

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

paddingoracle.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
Padding Oracle Exploit API
44
~~~~~~~~~~~~~~~~~~~~~~~~~~
55
'''
6-
76
from itertools import izip, cycle
87
import logging
98

@@ -223,13 +222,11 @@ def test():
223222

224223
class PadBuster(PaddingOracle):
225224
def oracle(self, ctext):
226-
import struct
227-
228225
cipher = AES.new(key, AES.MODE_CBC, str(bytearray(AES.block_size)))
229226
ptext = cipher.decrypt(str(ctext))
230-
plen = struct.unpack("B", ptext[-1])[0]
227+
plen = ord(ptext[-1])
231228

232-
padding_is_good = (ptext[-plen:] == struct.pack("B", plen) * plen)
229+
padding_is_good = (ptext[-plen:] == chr(plen) * plen)
233230

234231
if padding_is_good:
235232
return

0 commit comments

Comments
 (0)