0

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?

  • 1
    Does this answer your question? [Can't write to a .txt file in Python](https://stackoverflow.com/questions/44582905/cant-write-to-a-txt-file-in-python) – PCM Sep 10 '21 at 09:13

0 Answers0