Advertisement
nicoviale_

Untitled

Mar 19th, 2024
446
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.32 KB | None | 0 0
  1. from pwn import *
  2. from pymd5 import md5
  3.  
  4. def int_to_hex_litte_endian(n):
  5.     return str(n.to_bytes(8, byteorder='little').hex())
  6.  
  7. io=remote('how-are-you-mister.chall.srdnlen.it', 443, ssl=True)
  8.  
  9. def sign_message(message):
  10.     io.recvuntil(b"> ")
  11.     io.sendline(b'1')
  12.  
  13.     io.recvuntil(b"Insert your name (hex format)? ")
  14.     io.sendline(message.hex())
  15.     return bytearray.fromhex(io.recvline().decode().removesuffix('\n'))
  16.  
  17.  
  18. hash=sign_message(b"")
  19. print("hash:", hash)
  20.  
  21. h = md5(state=hash, count=512)
  22. print("hash without admin: ", h.hexdigest())
  23.  
  24. h.update(b'admin')
  25. new_hash_with_admin=h.hexdigest()
  26. print("new_hash_with_admin:", new_hash_with_admin)
  27.  
  28. for i in range(20,1,-1):
  29.     print("lunghezza corrente: ", i)
  30.  
  31.     #calcolo new_name_to_send
  32.     new_name_to_send = b'\x80' + b'\x00' * 7 + b'\x00'*(48-i)+ bytes.fromhex(int_to_hex_litte_endian(8*i)) +b'admin'
  33.  
  34.     print("new_name_to_send: ", new_name_to_send)
  35.     print("new hash with admin:", new_hash_with_admin)
  36.  
  37.     #invio new_name_to_send
  38.     io.recvuntil(b"> ")
  39.     io.sendline(b'2')
  40.  
  41.     io.recvuntil(b"Insert your name (hex format)? ")
  42.     io.sendline(new_name_to_send)
  43.    
  44.  
  45.     #invio relative_signature
  46.     io.recvuntil(b"Insert relative signature ")
  47.     io.sendline(new_hash_with_admin)
  48.  
  49.     #print what I received
  50.    
  51. io.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement