from random import randint, seed from itertools import chain seed(a = 10489, version=2) flag = "IGCTF{RealEncryptionWouldHaveBeenABetterChoice}" positions = [] while len(positions) < len(flag): pos = randint(0, 65536) if pos in positions: continue positions.append(pos) size = max(positions) buff = [ randint(0, 255) for _ in range(0, size+1) ] for char, pos in zip(flag, positions): buff[pos] = ord(char) with open("memory.bin", "wb") as f: print("Writing number of characters to the file") # Write the number of characters first v = len(flag).to_bytes(4, "little") f.write(v) print("Writing the positions to the file") # Write the positions as bytes to the file for n in positions: v = n.to_bytes(4, "little") f.write(v) print("Writing the data to the file") # Write the data to the file for b in buff: f.write(b.to_bytes(1, "little")) print("Done")