Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def xor(key, data):
- return bytes(x ^ y for x, y in zip(key * len(data), data))
- def viscrypt(data):
- return xor(data, data[1:] + b"\xaa")
- def round(key, rawdata):
- return viscrypt(xor(key, rawdata))
- cipher_hex="5e904cfb42a18e054f9b04a057ab81421b9c18b046a59b1f48914de312e58b011dc25bfe15e6d75f54941cb04abc8112569534"
- cipher=bytes.fromhex(cipher_hex)
- def get_key(original,shifted,number,cipher):
- return(ord(chr(ord(original)^ord(shifted)^number^cipher)))
- expected8="srdnlen{"
- left_shift_expected8="rdnlen{"
- key=[0]*8
- key[2]=ord(chr(cipher[50]^170^ord('}')))
- key[1]=get_key('r','d',key[2],cipher[1])
- key[0]=get_key('s','r',key[1],cipher[0])
- key[3]=get_key('d','n',key[2],cipher[2])
- key[4]=get_key('n','l',key[3],cipher[3])
- key[5]=get_key('l','e',key[4],cipher[4])
- key[6]=get_key('e','n',key[5],cipher[5])
- key[7]=get_key('n','{',key[6],cipher[6])
- print(key)
- #key=[58,101,227,165,92,23,189,38]
- quasi_output=[]
- for i in range(0,len(cipher)):
- quasi_output.append(cipher[i] ^ key[(i+1)%8] ^ key[(i)%8])
- last=ord('}') #quasi_output[-1]^key[3]^170
- print(chr (last))
- quasi_output[-1]=last
- for i in range(49,0,-1):
- quasi_output[i]^=quasi_output[i+1]
- print(quasi_output)
- output=""
- for i in range(0,len(quasi_output)):
- output+=chr(quasi_output[i])
- print(output)
Advertisement
Add Comment
Please, Sign In to add comment