import sys, zlib, os from Crypto.Cipher import AES import png with open("logo11w.png", "rb") as f: c = png.read(f) # a PNG with appended data contents = png.make(c) + os.urandom(64 * 1024) with open("appendeddata.png", "wb") as f: f.write(contents) # a PNG with a standard text chunk c1 = list(c) c1.insert(1, ["tEXt", "sans commentaire!"]) with open("text-chunk.png", "wb") as f: f.write(png.make(c1)) # a PNG with a custom chunk c2 = list(c) c2.insert(1, ["bing", "extra chunk"]) with open("custom-chunk.png", "wb") as f: f.write(png.make(c2)) # a PNG with a custom chunk FIRST c2 = list(c) c2.insert(0, ["brin", "Do no evil, Sergey ;)"]) with open("custom-first.png", "wb") as f:
# appends data at PNG format level import sys, png, os fn = sys.argv[1] with open(fn, "rb") as f: chunks = png.read(f) for chunk in chunks: if chunk[0] == "IDAT": chunk[1] += os.urandom(1024 * 1024) with open("app_%s" % fn, "wb") as f: f.write(png.make(chunks))
#appends data at PNG format level import sys, png, os fn = sys.argv[1] with open(fn, "rb") as f: chunks = png.read(f) for chunk in chunks: if chunk[0] == "IDAT": chunk[1] += os.urandom(1024 * 1024) with open("app_%s" % fn, "wb") as f: f.write(png.make(chunks))
import sys, zlib, os from Crypto.Cipher import AES import png with open("logo11w.png", "rb") as f: c = png.read(f) #a PNG with appended data contents = png.make(c) + os.urandom(64 * 1024) with open("appendeddata.png", "wb") as f: f.write(contents) #a PNG with a standard text chunk c1 = list(c) c1.insert(1, ["tEXt", "sans commentaire!"]) with open("text-chunk.png", "wb") as f: f.write(png.make(c1)) #a PNG with a custom chunk c2 = list(c) c2.insert(1, ["bing", "extra chunk"]) with open("custom-chunk.png", "wb") as f: f.write(png.make(c2)) #a PNG with a custom chunk FIRST c2 = list(c) c2.insert(0, ["brin", "Do no evil, Sergey ;)"]) with open("custom-first.png", "wb") as f: