title: Read each four bytes (DWORD) and XOR with 0xBABEBABE with Python
body: <p>I have a malware sample to analyze for a school project. The payload is encoded by XORing every 4 bytes (DWORD) with 0xBABEBABE. I knew that because XORing the first 4 bytes with it gave me 0x4D5A9000 (MZ header). I want a script that can automate the process so that I can decode the file.</p>
  
  <p>Here's what I have tried so far:</p>
  
  <pre><code>xor_key = 0xfe
  result = bytearray('')
  with open("myfile.bin","rb") as encoded_file:
      for one_byte in encoded_file.read():
          result.append(one_byte^xor_key)
  </code></pre>
  
  <p>But this only works for 1byte data at a time. </p>
  
  <p>Thank you</p>