nicoviale_

Untitled

Mar 5th, 2024 (edited)
1,023
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.34 KB | None | 0 0
  1. def xor(key, data):
  2.     return bytes(x ^ y for x, y in zip(key * len(data), data))
  3.  
  4.  
  5. def viscrypt(data):
  6.     return xor(data, data[1:] + b"\xaa")
  7.  
  8.  
  9. def round(key, rawdata):
  10.     return viscrypt(xor(key, rawdata))
  11.  
  12. cipher_hex="5e904cfb42a18e054f9b04a057ab81421b9c18b046a59b1f48914de312e58b011dc25bfe15e6d75f54941cb04abc8112569534"
  13.  
  14. cipher=bytes.fromhex(cipher_hex)
  15.  
  16. def get_key(original,shifted,number,cipher):
  17.     return(ord(chr(ord(original)^ord(shifted)^number^cipher)))
  18.  
  19.  
  20. expected8="srdnlen{"
  21. left_shift_expected8="rdnlen{"
  22.  
  23. key=[0]*8
  24.  
  25. key[2]=ord(chr(cipher[50]^170^ord('}')))
  26.  
  27. key[1]=get_key('r','d',key[2],cipher[1])
  28. key[0]=get_key('s','r',key[1],cipher[0])
  29. key[3]=get_key('d','n',key[2],cipher[2])
  30. key[4]=get_key('n','l',key[3],cipher[3])
  31. key[5]=get_key('l','e',key[4],cipher[4])
  32. key[6]=get_key('e','n',key[5],cipher[5])
  33. key[7]=get_key('n','{',key[6],cipher[6])
  34.  
  35.  
  36. print(key)
  37.  
  38. #key=[58,101,227,165,92,23,189,38]
  39.  
  40. quasi_output=[]
  41.  
  42. for i in range(0,len(cipher)):
  43.     quasi_output.append(cipher[i] ^ key[(i+1)%8] ^ key[(i)%8])
  44.  
  45. last=ord('}') #quasi_output[-1]^key[3]^170
  46.  
  47. print(chr (last))
  48.  
  49. quasi_output[-1]=last  
  50.  
  51. for i in range(49,0,-1):
  52.     quasi_output[i]^=quasi_output[i+1]
  53.  
  54. print(quasi_output)
  55.  
  56. output=""
  57. for i in range(0,len(quasi_output)):
  58.     output+=chr(quasi_output[i])
  59.  
  60. print(output)
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
Advertisement
Add Comment
Please, Sign In to add comment