Advertisement
nicoviale_

Untitled

Mar 11th, 2024 (edited)
560
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.     #print(response)
  7.     if b"adding is incorrect" in response:
  8.         return False
  9.     return True
  10.  
  11. io=remote("padding-oracle.chall.srdnlen.it", 443, ssl=True)
  12.  
  13. io.recvuntil(b"flag")
  14. iv_and_flag=io.recvuntil(b"What do you want to decrypt (in hex)?").decode().strip()
  15. iv_and_flag=iv_and_flag[:192]
  16.  
  17. iv_and_flag=bytes.fromhex(iv_and_flag) #ora è di 96
  18.  
  19. array = [iv_and_flag[i] for i in range(0, len(iv_and_flag))]
  20.  
  21. print(array)
  22.  
  23. orig_arr_80=array[79]
  24.  
  25. for i in range(0, 256):
  26.     if i == orig_arr_80:
  27.         continue
  28.  
  29.     array[79] = i
  30.  
  31.     if oracle_decrypt(bytes(array)):
  32.         t1=i
  33.         print(i)
  34.  
  35. x1 = (t1) ^ 1
  36.  
  37. p1 = x1 ^ orig_arr_80
  38.  
  39. print(p1)
  40.  
  41.  
  42.  
  43.  
  44. io.close()
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement