Advertisement
diliupg

import an icon hidden in a pyfile

Oct 22nd, 2015
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.13 KB | None | 0 0
  1. ## import the icon file from the icopy.py file
  2. import os
  3. import string
  4. import base64
  5. from itertools import cycle, izip
  6. import ctypes
  7. from icopy import icopydata
  8.  
  9. key = "QZY0r[CIlVwq1O#SxBt_2eij%b;3$vJK4,FN&TG5PHdzDER+@k7pcm!LX8gufh=y9A^UaMsn-oW6"
  10. #----------------------------------------------------------------------
  11. def XOR(message):
  12.  
  13.     cryptedMessage = ''.join(chr(ord(c)^ord(k)) for c,k in izip(message, cycle(key)))
  14.  
  15.     return cryptedMessage
  16.  
  17. #----------------------------------------------------------------------
  18. def main(filename):
  19.     """get image,sound from the encrypted picklefile in the img.py file"""
  20.     file2get = filename
  21.  
  22.     ## check if file in directory. If not return null
  23.     if file2get in icopydata.keys():
  24.         ## get file from the objectstore, decrypt and return it
  25.         strA = base64.b64decode(icopydata[file2get])
  26.         datastr = XOR(strA)
  27.         ## now write it to disk
  28.         with open("dg.ico", "wb") as outfile:
  29.             outfile.write(datastr)
  30.         ## read the file from disk
  31.         image = "dg.ico"
  32.  
  33.         return image
  34.  
  35. if __name__=='__main__':
  36.  
  37.     main(filename)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement