nicoviale_

Untitled

Mar 11th, 2024
858
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1. from pwn import *
  2.  
  3. def oracle_decrypt(ct):
  4.     io.sendline(ct.hex())
  5.     response = io.recvline()
  6.     if b"Padding is incorrect" in response:
  7.         return False
  8.     return True
  9.  
  10. io=remote("padding-oracle.chall.srdnlen.it", 443, ssl=True)
  11.  
  12. io.recvuntil(b"flag")
  13. iv_and_flag=io.recvuntil(b"What do you want to decrypt (in hex)?").decode().strip()
  14. iv_and_flag=iv_and_flag[:192]
  15. array = [iv_and_flag[i:i+2] for i in range(0, len(iv_and_flag), 2)]
  16. orig_arr_80=array[79]
  17.  
  18. print(array)
  19.  
  20. for i in range(0, 256):
  21.     array[80] = hex(i)[2:4].zfill(2)
  22.     #print(array)
  23.     if oracle_decrypt(bytes.fromhex("".join(array))):
  24.         t1=int(array[79], 16)
  25.         print(int(array[79], 16))
  26.         break
  27.        
  28. x1 = t1 ^ 1
  29.  
  30. p1 = x1 ^ int(orig_arr_80, 16)
  31.  
  32. print(p1)
  33.  
  34.  
  35. io.close()
  36.  
Advertisement
Add Comment
Please, Sign In to add comment