From 647a5e8fc82f8d9eb1524241b75bd56a23979817 Mon Sep 17 00:00:00 2001 From: cedricbonhomme Date: Thu, 24 Mar 2011 12:32:46 +0100 Subject: [PATCH] Added command line for exif-header.py. --- basic.py | 6 ++--- exif-header.py | 53 +++++++++++++++++++++++++++++++++----- lsb-s.py | 2 +- steganalysis-statistics.py | 4 +-- 4 files changed, 53 insertions(+), 12 deletions(-) diff --git a/basic.py b/basic.py index aa0d48c..88569fe 100755 --- a/basic.py +++ b/basic.py @@ -85,11 +85,11 @@ if __name__ == '__main__': usage = "usage: %prog hide|reveal [options]" parser = OptionParser(usage) parser.add_option("-i", "--input", dest="input_image_file", - help="Image file") + help="Image file.") parser.add_option("-o", "--output", dest="output_image_file", - help="Image file") + help="Image file.") parser.add_option("-s", "--secret", dest="secret", - help="Your secret (Message, Image, Music or any binary file.)") + help="Your secret (Message, Image, Music or any binary file).") parser.set_defaults(input_image_file = './pictures/Lenna.png', output_image_file = './pictures/Lenna_enc.png', secret = 'Hello World!') diff --git a/exif-header.py b/exif-header.py index 656330d..7d84cfd 100644 --- a/exif-header.py +++ b/exif-header.py @@ -26,7 +26,8 @@ __license__ = "GPLv3" # Thanks to: http://www.julesberman.info/spec2img.htm -def hide(img, img_enc, copyright="http://bitbucket.org/cedricbonhomme/stegano"): +def hide(img, img_enc, copyright="http://bitbucket.org/cedricbonhomme/stegano", \ + secret_message = None, secret_file = None): """ """ import shutil @@ -36,12 +37,16 @@ def hide(img, img_enc, copyright="http://bitbucket.org/cedricbonhomme/stegano"): from base64 import b64encode from exif.minimal_exif_writer import MinimalExifWriter - file = open("lorem_ipsum.txt", "r") + if secret_file != None: + with open(secret_file, "r") as f: + secret_file_content = f.read() text = "\nImage annotation date: " text = text + str(datetime.date.today()) text = text + "\nImage description:\n" - text = compress(b64encode(text + file.read())) - file.close() + if secret_file != None: + text = compress(b64encode(text + secret_file_content)) + else: + text = compress(b64encode(text + secret_message)) try: shutil.copy(img, img_enc) @@ -73,5 +78,41 @@ def reveal(img): if __name__ == "__main__": - hide(img='./pictures/Elisha-Cuthbert.jpg', img_enc='./pictures/Elisha-Cuthbert_enc.jpg') - reveal(img='./pictures/Elisha-Cuthbert_enc.jpg') \ No newline at end of file + # Point of entry in execution mode. + from optparse import OptionParser + parser = OptionParser(version=__version__) + parser.add_option('--hide', action='store_true', default=False, + help="Hides a message in an image.") + parser.add_option('--reveal', action='store_true', default=False, + help="Reveals the message hided in an image.") + # Original image + parser.add_option("-i", "--input", dest="input_image_file", + help="Input image file.") + # Image containing the secret + parser.add_option("-o", "--output", dest="output_image_file", + help="Output image containing the secret.") + + # Secret raw message to hide + parser.add_option("-m", "--secret-message", dest="secret_message", + help="Your raw secret message to hide.") + + # Secret text file to hide. + parser.add_option("-f", "--secret-file", dest="secret_file", + help="Your secret textt file to hide.") + + parser.set_defaults(input_image_file = './pictures/Elisha-Cuthbert.jpg', + output_image_file = './pictures/Elisha-Cuthbert_enc.jpg', + secret_message = '', secret_file = '') + + (options, args) = parser.parse_args() + + if options.hide: + if options.secret_message != "" and options.secret_file == "": + hide(img=options.input_image_file, img_enc=options.output_image_file, \ + secret_message=options.secret_message) + elif options.secret_message == "" and options.secret_file != "": + hide(img=options.input_image_file, img_enc=options.output_image_file, \ + secret_file=options.secret_file) + + elif options.reveal: + reveal(img=options.input_image_file) \ No newline at end of file diff --git a/lsb-s.py b/lsb-s.py index 4c6af4a..a9a2e1e 100755 --- a/lsb-s.py +++ b/lsb-s.py @@ -106,7 +106,7 @@ if __name__ == '__main__': help="Reveals the message hided in an image.") # Original image parser.add_option("-i", "--input", dest="input_image_file", - help="Input image fil.e") + help="Input image file.") # Image containing the secret parser.add_option("-o", "--output", dest="output_image_file", help="Output image containing the secret.") diff --git a/steganalysis-statistics.py b/steganalysis-statistics.py index 4fd3d05..59df801 100644 --- a/steganalysis-statistics.py +++ b/steganalysis-statistics.py @@ -58,9 +58,9 @@ if __name__ == '__main__': from optparse import OptionParser parser = OptionParser() parser.add_option("-i", "--input", dest="input_image_file", - help="Image file") + help="Image file.") parser.add_option("-o", "--output", dest="output_image_file", - help="Image file") + help="Image file.") parser.set_defaults(input_image_file = './pictures/Lenna.png', output_image_file = './pictures/Lenna_steganalysed.png') (options, args) = parser.parse_args()