Guest

Untitled

By: a guest on Jan 16th, 2011  |  syntax: Python  |  size: 0.42 KB  |  hits: 121  |  expires: Never
download  |  raw  |  embed  |  report abuse
Copied
  1. #WILL `CORRUPT` A BMP
  2.  
  3. import struct
  4.  
  5. string = "SECRET MESSAGE"
  6.  
  7. stdin = open("YourBMPhere.bmp","r")
  8.  
  9. x = stdin.read()
  10.  
  11. stdin.close()
  12.  
  13. offset = struct.unpack("<I",x[10:14])[0]
  14.  
  15. x,y = x[:offset],x[offset:]
  16.  
  17. z = ''
  18.  
  19. for char in y:
  20.     z+=(chr(ord(char)^2))
  21.  
  22. new_offset = offset+len(string)
  23.  
  24. x = x+struct.pack("<I",new_offset)+string+z
  25.  
  26. stdout = open("result.bmp","w+")
  27.  
  28. stdout.write(x)
  29.  
  30. stdout.close()