Hide your ASSets the Python way
Some of you may have seen the “trick” of using the command prompt to hide archives in images. Example: “C:>copy /b image1.jpg + stuff.zip newimage.jpg” This will hide stuff.zip in the picture image.jpg and output the merged file as newimage.jpg
As far as I know, this only works with jpeg’s. That’s cool and all, but how does it do that? And how can I do the same with python?
Well, it works by opening each file as it’s binary state and merges the two binaries into one. To view the image, just open it like normal. To view the archive, open it with an archive viewer like 7zip.
Now that we know how it works, lets try and do the same with python.
#open the image a=append, b=open as binary
image = open("test.jpg", "ab")
#open the archive as a binary
archive = open("test.zip","rb")
#write the archive data after a newline
#to our image
image.write("\n"+archive.read())
#close handles
image.close()
archive.close()
As you can see, it only took 5 lines of code. You can view the image as a regular image, or open as a zip file. Alliteratively, you could os.popen() or os.system() with the cmd version as well, but I like to do things the python way.
Short, sweet, and to the point.
Like this:
This entry was posted on November 5, 2011 at 12:46 am and is filed under Uncategorized with tags archive, hide, hide files, image, python, python hide files, zip. You can follow any responses to this entry through the RSS 2.0 feed You can leave a response, or trackback from your own site.