defrand(): global state state = (state * 1103515425 + 54321) & 0x3fffffff return state defsrand(seed): global state state = seed defencrypt(data,key): srand(key) cipher = "" for c in data: cipher += pack("i",(ord(c)<<22) + rand()) return cipher
defdecrypt(data,key): srand(key) plain = "" for i inrange(0,len(data),4): temp = unpack("i",data[i:i+4])[0] - rand() plain += chr(temp >> 22) return plain
defmain(): f1 = open("plaintext","rb") f2 = open("ciphertext","wb") data = f1.read() from secretfile import secretkey data = encrypt(data,secretkey) f2.write(data)
from Crypto.Util.number import* from struct import pack from struct import unpack
state = 0
defrand(): global state state = (state * 1103515425 + 54321) & 0x3fffffff return state defsrand(seed): global state state = seed defencrypt(data,key): srand(key) cipher = "" for c in data: cipher += pack("i",(ord(c)<<22) + rand()) return cipher
defdecrypt(data): plain = [] for i inrange(0,len(data),4): temp = unpack("i",data[i:i+4])[0] plain.append(temp) return plain
defmain(): f1 = open("ciphertext","rb") data = decrypt(f1.read()) for j inrange(256): print("j =",j,":",end = " ") key = ((data[0] - (j<<22)) - 54321) * inverse(1103515425,(0x3fffffff + 1)) print(key,end = " ") srand(key) for i in data[0:40]: try: print(chr((i - rand()) >> 22),end = "") except: print("",end = "") print()
... +0lpfzK92vRhs6zyLUYE20n65i9s9GHFfw04XTb2BqKed1d35nuQX1hD5JRsou3m7dEEKGBIJCxUeAjPDgeixlQrAoZzFAlt541yJoyXxuEMGwaAqTXQlF+7pB/5S4vnZ85Lap2siP8q/jFYp87z7PXHmJ20opxy8yxnBsRPoWEs8glONXf1H+h4kkdTcCg+HfwGXqYrf0jyFBgAAAABJRU5ErkJggg==|flag is hidden in the above data It is a picture and you should base64decode it.