mirror of
https://github.com/cedricbonhomme/Stegano.git
synced 2025-05-12 17:18:30 +02:00
Reorganization of all modules.
This commit is contained in:
parent
e0bed8ba52
commit
872a5546fc
23 changed files with 77 additions and 43 deletions
|
@ -25,7 +25,7 @@ __date__ = "$Date: 2016/03/18 $"
|
||||||
__license__ = "GPLv3"
|
__license__ = "GPLv3"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from stegano import slsb
|
from stegano import lsb
|
||||||
except:
|
except:
|
||||||
print("Install Stegano: sudo pip install Stegano")
|
print("Install Stegano: sudo pip install Stegano")
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ if options.hide:
|
||||||
elif options.secret_message == "" and options.secret_file != "":
|
elif options.secret_message == "" and options.secret_file != "":
|
||||||
secret = tools.binary2base64(options.secret_file)
|
secret = tools.binary2base64(options.secret_file)
|
||||||
|
|
||||||
img_encoded = slsb.hide(options.input_image_file, secret)
|
img_encoded = lsb.hide(options.input_image_file, secret)
|
||||||
try:
|
try:
|
||||||
img_encoded.save(options.output_image_file)
|
img_encoded.save(options.output_image_file)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -76,7 +76,7 @@ if options.hide:
|
||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
elif options.reveal:
|
elif options.reveal:
|
||||||
secret = slsb.reveal(options.input_image_file)
|
secret = lsb.reveal(options.input_image_file)
|
||||||
if options.secret_binary != "":
|
if options.secret_binary != "":
|
||||||
data = tools.base642binary(secret)
|
data = tools.base642binary(secret)
|
||||||
with open(options.secret_binary, "w") as f:
|
with open(options.secret_binary, "w") as f:
|
|
@ -25,7 +25,7 @@ __date__ = "$Date: 2016/03/18 $"
|
||||||
__license__ = "GPLv3"
|
__license__ = "GPLv3"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from stegano import slsbset
|
from stegano import lsbset
|
||||||
except:
|
except:
|
||||||
print("Install stegano: sudo pip install Stegano")
|
print("Install stegano: sudo pip install Stegano")
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ if options.hide:
|
||||||
elif options.secret_message == "" and options.secret_file != "":
|
elif options.secret_message == "" and options.secret_file != "":
|
||||||
secret = tools.binary2base64(options.secret_file)
|
secret = tools.binary2base64(options.secret_file)
|
||||||
|
|
||||||
img_encoded = slsbset.hide(options.input_image_file, secret, options.generator_function)
|
img_encoded = lsbset.hide(options.input_image_file, secret, options.generator_function)
|
||||||
try:
|
try:
|
||||||
img_encoded.save(options.output_image_file)
|
img_encoded.save(options.output_image_file)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -83,7 +83,7 @@ if options.hide:
|
||||||
|
|
||||||
elif options.reveal:
|
elif options.reveal:
|
||||||
try:
|
try:
|
||||||
secret = slsbset.reveal(options.input_image_file, options.generator_function)
|
secret = lsbset.reveal(options.input_image_file, options.generator_function)
|
||||||
except IndexError:
|
except IndexError:
|
||||||
print("Impossible to detect message.")
|
print("Impossible to detect message.")
|
||||||
exit(0)
|
exit(0)
|
|
@ -46,7 +46,7 @@ Turorial
|
||||||
|
|
||||||
tutorial
|
tutorial
|
||||||
|
|
||||||
You can also take a look at the
|
You can also have a look at the
|
||||||
`unit tests <https://github.com/cedricbonhomme/Stegano/tree/master/tests>`_.
|
`unit tests <https://github.com/cedricbonhomme/Stegano/tree/master/tests>`_.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
wget http://www.gnu.org/music/free-software-song.ogg
|
wget http://www.gnu.org/music/free-software-song.ogg
|
||||||
slsb --hide -i ./pictures/Montenach.png -o ./pictures/Montenach_enc.png -f ./free-software-song.ogg
|
lsb --hide -i ./pictures/Montenach.png -o ./pictures/Montenach_enc.png -f ./free-software-song.ogg
|
||||||
rm free-software-song.ogg
|
rm free-software-song.ogg
|
||||||
slsb --reveal -i ./pictures/Montenach_enc.png -b ./zik.ogg
|
lsb --reveal -i ./pictures/Montenach_enc.png -b ./zik.ogg
|
||||||
|
|
|
@ -7,20 +7,20 @@
|
||||||
echo "We're going to test a little Stéganô..."
|
echo "We're going to test a little Stéganô..."
|
||||||
|
|
||||||
echo "Hide the message with the Sieve of Eratosthenes..."
|
echo "Hide the message with the Sieve of Eratosthenes..."
|
||||||
slsb-set --hide -i ./pictures/Montenach.png -o ./surprise.png --generator eratosthenes -m 'Joyeux Noël!'
|
lsb-set --hide -i ./pictures/Montenach.png -o ./surprise.png --generator eratosthenes -m 'Joyeux Noël!'
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
echo "Try to reveal with Mersenne numbers..."
|
echo "Try to reveal with Mersenne numbers..."
|
||||||
slsb-set --reveal --generator mersenne -i ./surprise.png
|
lsb-set --reveal --generator mersenne -i ./surprise.png
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
echo "Try to reveal with fermat numbers..."
|
echo "Try to reveal with fermat numbers..."
|
||||||
slsb-set --reveal --generator fermat -i ./surprise.png
|
lsb-set --reveal --generator fermat -i ./surprise.png
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
echo "Try to reveal with carmichael numbers..."
|
echo "Try to reveal with carmichael numbers..."
|
||||||
slsb-set --reveal --generator carmichael -i ./surprise.png
|
lsb-set --reveal --generator carmichael -i ./surprise.png
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
echo "Try to reveal with Sieve of Eratosthenes..."
|
echo "Try to reveal with Sieve of Eratosthenes..."
|
||||||
slsb-set --reveal --generator eratosthenes -i ./surprise.png
|
lsb-set --reveal --generator eratosthenes -i ./surprise.png
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
|
|
||||||
|
|
||||||
# Hide the message - LSB with a set defined by the identity function (f(x) = x).
|
# Hide the message - LSB with a set defined by the identity function (f(x) = x).
|
||||||
slsb-set --hide -i examples/pictures/Montenach.png -o ~/enc-identity.png --generator identity -m 'I like steganography.'
|
lsb-set --hide -i examples/pictures/Montenach.png -o ~/enc-identity.png --generator identity -m 'I like steganography.'
|
||||||
|
|
||||||
# Hide the message - LSB only.
|
# Hide the message - LSB only.
|
||||||
slsb --hide -i examples/pictures/Montenach.png -o ~/enc.png -m 'I like steganography.'
|
lsb --hide -i examples/pictures/Montenach.png -o ~/enc.png -m 'I like steganography.'
|
||||||
|
|
||||||
|
|
||||||
# Check if the two generated files are the same.
|
# Check if the two generated files are the same.
|
||||||
|
@ -16,7 +16,7 @@ sha1sum ~/enc-identity.png ~/enc.png
|
||||||
|
|
||||||
|
|
||||||
# The output of slsb is given to slsb-set.
|
# The output of slsb is given to slsb-set.
|
||||||
slsb-set --reveal -i ~/enc.png --generator identity
|
lsb-set --reveal -i ~/enc.png --generator identity
|
||||||
|
|
||||||
# The output of slsb-set is given to slsb.
|
# The output of slsb-set is given to slsb.
|
||||||
slsb --reveal -i ~/enc-identity.png
|
lsb --reveal -i ~/enc-identity.png
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
|
|
||||||
echo "Hide the message with Sieve of Eratosthenes..."
|
echo "Hide the message with Sieve of Eratosthenes..."
|
||||||
slsb-set --hide -i ./pictures/Ginnifer-Goodwin.png -o ./surprise.png --generator eratosthenes -m 'Probably the most beautiful woman in the world.'
|
lsb-set --hide -i ./pictures/Ginnifer-Goodwin.png -o ./surprise.png --generator eratosthenes -m 'Probably the most beautiful woman in the world.'
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
echo "Steganalysis of the original photo..."
|
echo "Steganalysis of the original photo..."
|
||||||
|
@ -18,4 +18,4 @@ echo ""
|
||||||
|
|
||||||
echo "Reveal with Sieve of Eratosthenes..."
|
echo "Reveal with Sieve of Eratosthenes..."
|
||||||
echo "The secret is:"
|
echo "The secret is:"
|
||||||
slsb-set --reveal --generator eratosthenes -i ./surprise.png
|
lsb-set --reveal --generator eratosthenes -i ./surprise.png
|
||||||
|
|
9
setup.py
9
setup.py
|
@ -11,7 +11,12 @@ except ImportError:
|
||||||
from distutils.core import setup
|
from distutils.core import setup
|
||||||
|
|
||||||
packages = [
|
packages = [
|
||||||
'stegano'
|
'stegano',
|
||||||
|
'stegano.red',
|
||||||
|
'stegano.exifHeader',
|
||||||
|
'stegano.lsb',
|
||||||
|
'stegano.lsbset',
|
||||||
|
'stegano.steganalysis'
|
||||||
]
|
]
|
||||||
|
|
||||||
requires = ['pillow', 'piexif']
|
requires = ['pillow', 'piexif']
|
||||||
|
@ -28,7 +33,7 @@ setup(
|
||||||
author_email='cedric@cedricbonhomme.org',
|
author_email='cedric@cedricbonhomme.org',
|
||||||
packages=packages,
|
packages=packages,
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
scripts=['bin/slsb', 'bin/slsb-set', 'bin/steganalysis-parity'],
|
scripts=['bin/lsb', 'bin/lsb-set', 'bin/steganalysis-parity'],
|
||||||
url='https://github.com/cedricbonhomme/Stegano',
|
url='https://github.com/cedricbonhomme/Stegano',
|
||||||
description='A Python Steganography module.',
|
description='A Python Steganography module.',
|
||||||
long_description=readme + '\n\n' + changelog,
|
long_description=readme + '\n\n' + changelog,
|
||||||
|
|
|
@ -1 +1,9 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from . import red
|
||||||
|
from . import exifHeader
|
||||||
|
from . import lsb
|
||||||
|
from . import lsbset
|
||||||
|
|
||||||
|
from . import steganalysis
|
||||||
|
|
4
stegano/exifHeader/__init__.py
Normal file
4
stegano/exifHeader/__init__.py
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
#-*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from .exifHeader import *
|
4
stegano/lsb/__init__.py
Normal file
4
stegano/lsb/__init__.py
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
#-*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from .lsb import *
|
|
@ -28,7 +28,7 @@ import sys
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
from . import tools
|
from stegano import tools
|
||||||
|
|
||||||
try:
|
try:
|
||||||
input = raw_input
|
input = raw_input
|
4
stegano/lsbset/__init__.py
Normal file
4
stegano/lsbset/__init__.py
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
#-*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from .lsbset import *
|
|
@ -28,7 +28,7 @@ import sys
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
from . import tools
|
from stegano import tools
|
||||||
from . import generators
|
from . import generators
|
||||||
|
|
||||||
try:
|
try:
|
4
stegano/red/__init__.py
Normal file
4
stegano/red/__init__.py
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
#-*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from .red import *
|
5
stegano/steganalysis/__init__.py
Normal file
5
stegano/steganalysis/__init__.py
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
#-*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from .steganalysisParity import *
|
||||||
|
from .steganalysisStatistics import *
|
|
@ -27,18 +27,18 @@ __license__ = "GPLv3"
|
||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from stegano import slsb
|
from stegano import lsb
|
||||||
|
|
||||||
class TestSLSB(unittest.TestCase):
|
class TestLSB(unittest.TestCase):
|
||||||
|
|
||||||
def test_hide_empty_message(self):
|
def test_hide_empty_message(self):
|
||||||
"""
|
"""
|
||||||
Test hiding the empty string.
|
Test hiding the empty string.
|
||||||
"""
|
"""
|
||||||
secret = slsb.hide("./examples/pictures/Lenna.png", "")
|
secret = lsb.hide("./examples/pictures/Lenna.png", "")
|
||||||
secret.save("./image.png")
|
secret.save("./image.png")
|
||||||
|
|
||||||
clear_message = slsb.reveal("./image.png")
|
clear_message = lsb.reveal("./image.png")
|
||||||
|
|
||||||
self.assertEqual("", clear_message)
|
self.assertEqual("", clear_message)
|
||||||
|
|
||||||
|
@ -46,20 +46,20 @@ class TestSLSB(unittest.TestCase):
|
||||||
messages_to_hide = ["a", "foo", "Hello World!", ":Python:"]
|
messages_to_hide = ["a", "foo", "Hello World!", ":Python:"]
|
||||||
|
|
||||||
for message in messages_to_hide:
|
for message in messages_to_hide:
|
||||||
secret = slsb.hide("./examples/pictures/Lenna.png", message)
|
secret = lsb.hide("./examples/pictures/Lenna.png", message)
|
||||||
secret.save("./image.png")
|
secret.save("./image.png")
|
||||||
|
|
||||||
clear_message = slsb.reveal("./image.png")
|
clear_message = lsb.reveal("./image.png")
|
||||||
|
|
||||||
self.assertEqual(message, clear_message)
|
self.assertEqual(message, clear_message)
|
||||||
|
|
||||||
def test_with_long_message(self):
|
def test_with_long_message(self):
|
||||||
with open("./examples/lorem_ipsum.txt") as f:
|
with open("./examples/lorem_ipsum.txt") as f:
|
||||||
message = f.read()
|
message = f.read()
|
||||||
secret = slsb.hide("./examples/pictures/Lenna.png", message)
|
secret = lsb.hide("./examples/pictures/Lenna.png", message)
|
||||||
secret.save("./image.png")
|
secret.save("./image.png")
|
||||||
|
|
||||||
clear_message = slsb.reveal("./image.png")
|
clear_message = lsb.reveal("./image.png")
|
||||||
self.assertEqual(message, clear_message)
|
self.assertEqual(message, clear_message)
|
||||||
|
|
||||||
def test_with_too_long_message(self):
|
def test_with_too_long_message(self):
|
||||||
|
@ -67,7 +67,7 @@ class TestSLSB(unittest.TestCase):
|
||||||
message = f.read()
|
message = f.read()
|
||||||
message += message*2
|
message += message*2
|
||||||
with self.assertRaises(Exception):
|
with self.assertRaises(Exception):
|
||||||
slsb.hide("./examples/pictures/Lenna.png", message)
|
lsb.hide("./examples/pictures/Lenna.png", message)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
try:
|
try:
|
|
@ -27,19 +27,19 @@ __license__ = "GPLv3"
|
||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from stegano import slsbset
|
from stegano import lsbset
|
||||||
|
|
||||||
class TestSLSBSet(unittest.TestCase):
|
class TestLSBSet(unittest.TestCase):
|
||||||
|
|
||||||
def test_hide_empty_message(self):
|
def test_hide_empty_message(self):
|
||||||
"""
|
"""
|
||||||
Test hiding the empty string.
|
Test hiding the empty string.
|
||||||
"""
|
"""
|
||||||
secret = slsbset.hide("./examples/pictures/Lenna.png", "",
|
secret = lsbset.hide("./examples/pictures/Lenna.png", "",
|
||||||
"eratosthenes")
|
"eratosthenes")
|
||||||
secret.save("./image.png")
|
secret.save("./image.png")
|
||||||
|
|
||||||
clear_message = slsbset.reveal("./image.png", "eratosthenes")
|
clear_message = lsbset.reveal("./image.png", "eratosthenes")
|
||||||
|
|
||||||
self.assertEqual("", clear_message)
|
self.assertEqual("", clear_message)
|
||||||
|
|
||||||
|
@ -47,23 +47,23 @@ class TestSLSBSet(unittest.TestCase):
|
||||||
messages_to_hide = ["a", "foo", "Hello World!", ":Python:"]
|
messages_to_hide = ["a", "foo", "Hello World!", ":Python:"]
|
||||||
|
|
||||||
for message in messages_to_hide:
|
for message in messages_to_hide:
|
||||||
secret = slsbset.hide("./examples/pictures/Lenna.png", message,
|
secret = lsbset.hide("./examples/pictures/Lenna.png", message,
|
||||||
"eratosthenes")
|
"eratosthenes")
|
||||||
secret.save("./image.png")
|
secret.save("./image.png")
|
||||||
|
|
||||||
clear_message = slsbset.reveal("./image.png", "eratosthenes")
|
clear_message = lsbset.reveal("./image.png", "eratosthenes")
|
||||||
|
|
||||||
self.assertEqual(message, clear_message)
|
self.assertEqual(message, clear_message)
|
||||||
|
|
||||||
def test_hide_and_reveal_with_bad_generator(self):
|
def test_hide_and_reveal_with_bad_generator(self):
|
||||||
message_to_hide = "Hello World!"
|
message_to_hide = "Hello World!"
|
||||||
|
|
||||||
secret = slsbset.hide("./examples/pictures/Lenna.png", message_to_hide,
|
secret = lsbset.hide("./examples/pictures/Lenna.png", message_to_hide,
|
||||||
"eratosthenes")
|
"eratosthenes")
|
||||||
secret.save("./image.png")
|
secret.save("./image.png")
|
||||||
|
|
||||||
with self.assertRaises(IndexError):
|
with self.assertRaises(IndexError):
|
||||||
clear_message = slsbset.reveal("./image.png", "identity")
|
clear_message = lsbset.reveal("./image.png", "identity")
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
try:
|
try:
|
Loading…
Add table
Reference in a new issue