Added padding oracle attack vector
This commit is contained in:
parent
09d4c52043
commit
6365e737df
8 changed files with 412 additions and 0 deletions
42
crack.py
Normal file
42
crack.py
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import requests
|
||||
|
||||
from imp.constants import PRINTABLE
|
||||
from imp.attacks.paddingoracle import paddingoracle
|
||||
|
||||
NIBBLESET = [n.to_bytes() for n in range(256)]
|
||||
|
||||
HOST = 'https://aes.cryptohack.org'
|
||||
ENDPOINT = '/ecb_oracle/encrypt/{0}/'
|
||||
URI = HOST + ENDPOINT
|
||||
|
||||
# CHARSET = [c.encode() for c in string.printable]
|
||||
CHARSET = NIBBLESET # OVERRIDE
|
||||
|
||||
FLAG_LEN = 26 # flag length, calculated by hand
|
||||
SPACER = b'\x0f' # arbitrary spacing character
|
||||
|
||||
BLOCK_BYTES = 16
|
||||
BLOCK_NIBBLES = 32 # measured in nibbles
|
||||
|
||||
|
||||
def mkreq(hextext: str) -> dict[str, str]:
|
||||
resp = requests.get(URI.format(hextext))
|
||||
if resp.status_code != 200:
|
||||
raise Exception(f'[!] resp failed! {resp} : {resp.text}')
|
||||
return resp.json()
|
||||
|
||||
def encrypt(b: bytes) -> bytes:
|
||||
resp = mkreq(b.hex())
|
||||
return bytes.fromhex(resp['ciphertext'])
|
||||
|
||||
def main() -> None:
|
||||
paddingoracle(encrypt, NIBBLESET, 64, batch_size=16, debug=True)
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
main()
|
||||
except (KeyboardInterrupt, EOFError):
|
||||
print('\n[!] Interrupt')
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue