I am trying to do the Insomni'hack teaser 2018 Rule86 CTF challenge. When I try to write to the super_cipher.py file, the file is empty. But I am able to print.
def xor(a,b):
return bytes([(i ^ j) for (i, j) in zip(a, b)])
txt = open('rule86.txt', 'rb').read()
txtenc = open('rule86.txt.enc', 'rb').read()
pyenc = open('super_cipher.py.enc', 'rb').read()
py = open('super_cipher.py','w')
keystream=xor(txt,txtenc)
print(xor(pyenc,keystream).decode())
py.write(xor(pyenc,keystream).decode())
Also, doing python test.py > super_cipher.py in cmd works.
Why does the write command not work?