From 28ba1e54cf4be69be3d2c89c63f1176ce9a608b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Bonhomme?= Date: Tue, 6 Oct 2015 07:49:11 +0200 Subject: [PATCH] Fixed some bugs. --- bin/slsb | 8 ++++---- bin/slsb-set | 10 +++++----- bin/steganalysis-parity | 4 ++-- setup.py | 18 +++--------------- stegano/slsb.py | 2 +- stegano/slsbset.py | 16 ++++++++-------- 6 files changed, 23 insertions(+), 35 deletions(-) diff --git a/bin/slsb b/bin/slsb index 73e661b..72de135 100755 --- a/bin/slsb +++ b/bin/slsb @@ -27,7 +27,7 @@ __license__ = "GPLv3" try: from stegano import slsb except: - print "Install stegano: python setup.py install" + print("Install Stegano: sudo pip install Stegano") from stegano import tools @@ -71,9 +71,9 @@ if options.hide: img_encoded = slsb.hide(options.input_image_file, secret) try: img_encoded.save(options.output_image_file) - except Exception, e: + except Exception as e: # If hide() returns an error (Too long message). - print e + print(e) elif options.reveal: secret = slsb.reveal(options.input_image_file) @@ -82,4 +82,4 @@ elif options.reveal: with open(options.secret_binary, "w") as f: f.write(data) else: - print secret \ No newline at end of file + print(secret) diff --git a/bin/slsb-set b/bin/slsb-set index 2afef7c..1265c32 100755 --- a/bin/slsb-set +++ b/bin/slsb-set @@ -27,7 +27,7 @@ __license__ = "GPLv3" try: from stegano import slsbset except: - print "Install stegano: python setup.py install" + print("Install stegano: sudo pip install Stegano") from stegano import tools @@ -77,19 +77,19 @@ if options.hide: img_encoded = slsbset.hide(options.input_image_file, secret, options.generator_function) try: img_encoded.save(options.output_image_file) - except Exception, e: + except Exception as e: # If hide() returns an error (Too long message). - print e + print(e) elif options.reveal: try: secret = slsbset.reveal(options.input_image_file, options.generator_function) except IndexError: - print "Impossible to detect message." + print("Impossible to detect message.") exit(0) if options.secret_binary != "": data = tools.base642binary(secret) with open(options.secret_binary, "w") as f: f.write(data) else: - print secret \ No newline at end of file + print(secret) diff --git a/bin/steganalysis-parity b/bin/steganalysis-parity index 1a7a1a0..59f691f 100644 --- a/bin/steganalysis-parity +++ b/bin/steganalysis-parity @@ -27,7 +27,7 @@ __license__ = "GPLv3" try: from stegano import steganalysisParity except: - print "Install stegano: python setup.py install" + print("Install Stegano: sudo pip install Stegano") from PIL import Image @@ -43,4 +43,4 @@ parser.set_defaults(input_image_file = './pictures/Lenna.png', input_image_file = Image.open(options.input_image_file) output_image = steganalysisParity.steganalyse(input_image_file) -output_image.save(options.output_image_file) \ No newline at end of file +output_image.save(options.output_image_file) diff --git a/setup.py b/setup.py index 2783272..74f6600 100644 --- a/setup.py +++ b/setup.py @@ -12,8 +12,7 @@ except ImportError: packages = [ 'stegano', - 'stegano.exif', - 'bin' + 'stegano.exif' ] requires = ['pillow'] @@ -23,12 +22,12 @@ with open('README.md', 'r') as f: setup( name='Stegano', - version='0.4.2', + version='0.4.3', author='Cédric Bonhomme', author_email='cedric@cedricbonhomme.org', packages=packages, include_package_data=True, - #scripts=[''], + scripts=['bin/slsb', 'bin/slsb-set', 'bin/steganalysis-parity'], url='https://bitbucket.org/cedricbonhomme/stegano', description='A Python Steganography module.', long_description=readme, @@ -46,14 +45,3 @@ setup( "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)" ] ) - -if sys.argv[-1] == "install": - print("Installing binaries") - shutil.copy2("./bin/slsb-set", "/bin/slsb-set") - shutil.copymode("./bin/slsb-set", "/bin/slsb-set") - - shutil.copy2("./bin/slsb", "/bin/slsb") - shutil.copymode("./bin/slsb", "/bin/slsb") - - shutil.copy2("./bin/steganalysis-parity", "/bin/steganalysis-parity") - shutil.copymode("./bin/steganalysis-parity", "/bin/steganalysis-parity") diff --git a/stegano/slsb.py b/stegano/slsb.py index 7ca12c0..4073e3f 100755 --- a/stegano/slsb.py +++ b/stegano/slsb.py @@ -28,7 +28,7 @@ import sys from PIL import Image -import tools +from . import tools def hide(input_image_file, message): """ diff --git a/stegano/slsbset.py b/stegano/slsbset.py index da8024d..9788100 100644 --- a/stegano/slsbset.py +++ b/stegano/slsbset.py @@ -28,8 +28,8 @@ import sys from PIL import Image -import tools -import generators +from . import tools +from . import generators def hide(input_image_file, message, generator_function): """ @@ -50,7 +50,7 @@ def hide(input_image_file, message, generator_function): raise Exception("""The message you want to hide is too long (%s > %s).""" % (len(message_bits), npixels * 3)) generator = getattr(generators, generator_function)() - + while index + 3 <= len(message_bits) : generated_number = next(generator) (r, g, b) = img_list[generated_number] @@ -62,17 +62,17 @@ def hide(input_image_file, message, generator_function): # Save the new pixel img_list[generated_number] = (r, g , b) - + index += 3 # create empty new image of appropriate format encoded = Image.new('RGB', (img.size)) - + # insert saved data into the image encoded.putdata(img_list) - + return encoded - + def reveal(input_image_file, generator_function): @@ -132,7 +132,7 @@ if __name__ == '__main__': # Generator parser.add_option("-g", "--generator", dest="generator_function", help="Generator") - + # Image containing the secret parser.add_option("-o", "--output", dest="output_image_file", help="Output image containing the secret.")