mirror of
https://github.com/cedricbonhomme/Stegano.git
synced 2025-05-13 01:18:31 +02:00
'hide' and 'reveal' are now sub-parameter of the command line.
This commit is contained in:
parent
1879197624
commit
d3d03c2f74
2 changed files with 51 additions and 42 deletions
50
bin/lsb
50
bin/lsb
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env python3.5
|
#!/usr/bin/env python
|
||||||
#-*- coding: utf-8 -*-
|
#-*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Stéganô - Stéganô is a basic Python Steganography module.
|
# Stéganô - Stéganô is a basic Python Steganography module.
|
||||||
|
@ -32,18 +32,16 @@ except:
|
||||||
from stegano import tools
|
from stegano import tools
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
parser = argparse.ArgumentParser(prog='Stegano')
|
parser = argparse.ArgumentParser(prog='lsb')
|
||||||
group_method = parser.add_mutually_exclusive_group(required=True)
|
subparsers = parser.add_subparsers(help='sub-command help', dest='command')
|
||||||
group_method.add_argument('--hide', action='store_true', default=False,
|
|
||||||
help='Hides a message in an image.')
|
|
||||||
group_method.add_argument('--reveal', action='store_true', default=False,
|
|
||||||
help='Reveals the message hided in an image.')
|
|
||||||
|
|
||||||
|
# Subparser: Hide
|
||||||
|
parser_hide = subparsers.add_parser('hide', help='hide help')
|
||||||
# Original image
|
# Original image
|
||||||
parser.add_argument("-i", "--input", dest="input_image_file",
|
parser_hide.add_argument("-i", "--input", dest="input_image_file",
|
||||||
help="Input image file.")
|
required=True, help="Input image file.")
|
||||||
|
|
||||||
group_secret = parser.add_mutually_exclusive_group()
|
group_secret = parser_hide.add_mutually_exclusive_group(required=True)
|
||||||
# Non binary secret message to hide
|
# Non binary secret message to hide
|
||||||
group_secret.add_argument("-m", dest="secret_message",
|
group_secret.add_argument("-m", dest="secret_message",
|
||||||
help="Your secret message to hide (non binary).")
|
help="Your secret message to hide (non binary).")
|
||||||
|
@ -52,20 +50,26 @@ group_secret.add_argument("-f", dest="secret_file",
|
||||||
help="Your secret to hide (Text or any binary file).")
|
help="Your secret to hide (Text or any binary file).")
|
||||||
|
|
||||||
# Image containing the secret
|
# Image containing the secret
|
||||||
group_output = parser.add_mutually_exclusive_group()
|
parser_hide.add_argument("-o", "--output", dest="output_image_file",
|
||||||
group_output.add_argument("-o", "--output", dest="output_image_file",
|
required=True, help="Output image containing the secret.")
|
||||||
help="Output image containing the secret.")
|
|
||||||
group_output.add_argument("-b", "--binary", dest="secret_binary",
|
|
||||||
|
# Subparser: Reveal
|
||||||
|
parser_reveal = subparsers.add_parser('reveal', help='reveal help')
|
||||||
|
parser_reveal.add_argument("-i", "--input", dest="input_image_file",
|
||||||
|
required=True, help="Input image file.")
|
||||||
|
parser_reveal.add_argument("-o", dest="secret_binary",
|
||||||
help="Output for the binary secret (Text or any binary file).")
|
help="Output for the binary secret (Text or any binary file).")
|
||||||
|
|
||||||
|
|
||||||
arguments = parser.parse_args()
|
arguments = parser.parse_args()
|
||||||
|
|
||||||
if arguments.hide:
|
|
||||||
#parser.parse_args(['--hide'])
|
if arguments.command == 'hide':
|
||||||
if arguments.secret_message != None:
|
if arguments.secret_message != None:
|
||||||
secret = arguments.secret_message
|
secret = arguments.secret_message
|
||||||
elif arguments.secret_file != None:
|
elif arguments.secret_file != None:
|
||||||
secret = tools.binary2base64(options.secret_file)
|
secret = tools.binary2base64(arguments.secret_file)
|
||||||
|
|
||||||
img_encoded = lsb.hide(arguments.input_image_file, secret)
|
img_encoded = lsb.hide(arguments.input_image_file, secret)
|
||||||
try:
|
try:
|
||||||
|
@ -74,18 +78,18 @@ if arguments.hide:
|
||||||
# If hide() returns an error (Too long message).
|
# If hide() returns an error (Too long message).
|
||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
elif arguments.reveal:
|
elif arguments.command == 'reveal':
|
||||||
secret = lsb.reveal(arguments.input_image_file)
|
secret = lsb.reveal(arguments.input_image_file)
|
||||||
if arguments.secret_binary != None:
|
if arguments.secret_binary != None:
|
||||||
data = tools.base642binary(bytes(secret, "utf-8"))
|
"""data = tools.base642binary(secret)
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
import io
|
import io
|
||||||
file_like = io.BytesIO(data)
|
file_like = io.BytesIO(data)
|
||||||
file_like.seek(0)
|
file_like.seek(0)
|
||||||
image = Image.open(file_like)
|
image = Image.open(file_like)
|
||||||
image.save(options.secret_binary)
|
image.save(arguments.secret_binary)"""
|
||||||
"""data = tools.base642binary(bytes(secret, "utf-8)"))
|
data = tools.base642binary(secret)
|
||||||
with open(options.secret_binary, "wb") as f:
|
with open(arguments.secret_binary, "wb") as f:
|
||||||
f.write(data)"""
|
f.write(data)
|
||||||
else:
|
else:
|
||||||
print(secret)
|
print(secret)
|
||||||
|
|
43
bin/lsb-set
43
bin/lsb-set
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env python3.5
|
#!/usr/bin/env python
|
||||||
#-*- coding: utf-8 -*-
|
#-*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Stéganô - Stéganô is a basic Python Steganography module.
|
# Stéganô - Stéganô is a basic Python Steganography module.
|
||||||
|
@ -34,23 +34,20 @@ except:
|
||||||
from stegano import tools
|
from stegano import tools
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
parser = argparse.ArgumentParser(prog='Stegano')
|
parser = argparse.ArgumentParser(prog='lsb-set')
|
||||||
group_method = parser.add_mutually_exclusive_group(required=True)
|
subparsers = parser.add_subparsers(help='sub-command help', dest='command')
|
||||||
group_method.add_argument('--hide', action='store_true', default=False,
|
|
||||||
help='Hides a message in an image.')
|
|
||||||
group_method.add_argument('--reveal', action='store_true', default=False,
|
|
||||||
help='Reveals the message hided in an image.')
|
|
||||||
|
|
||||||
|
# Subparser: Hide
|
||||||
|
parser_hide = subparsers.add_parser('hide', help='hide help')
|
||||||
# Original image
|
# Original image
|
||||||
parser.add_argument("-i", "--input", dest="input_image_file",
|
parser_hide.add_argument("-i", "--input", dest="input_image_file",
|
||||||
help="Input image file.")
|
required=True, help="Input image file.")
|
||||||
|
|
||||||
# Generator
|
# Generator
|
||||||
parser.add_argument("-g", "--generator", dest="generator_function",
|
parser_hide.add_argument("-g", "--generator", dest="generator_function",
|
||||||
help="Generator")
|
required=True, help="Generator")
|
||||||
|
|
||||||
group_secret = parser.add_mutually_exclusive_group()
|
|
||||||
|
|
||||||
|
group_secret = parser_hide.add_mutually_exclusive_group(required=True)
|
||||||
# Non binary secret message to hide
|
# Non binary secret message to hide
|
||||||
group_secret.add_argument("-m", dest="secret_message",
|
group_secret.add_argument("-m", dest="secret_message",
|
||||||
help="Your secret message to hide (non binary).")
|
help="Your secret message to hide (non binary).")
|
||||||
|
@ -59,12 +56,20 @@ group_secret.add_argument("-f", dest="secret_file",
|
||||||
help="Your secret to hide (Text or any binary file).")
|
help="Your secret to hide (Text or any binary file).")
|
||||||
|
|
||||||
# Image containing the secret
|
# Image containing the secret
|
||||||
group_output = parser.add_mutually_exclusive_group()
|
parser_hide.add_argument("-o", "--output", dest="output_image_file",
|
||||||
group_output.add_argument("-o", "--output", dest="output_image_file",
|
required=True, help="Output image containing the secret.")
|
||||||
help="Output image containing the secret.")
|
|
||||||
group_output.add_argument("-b", "--binary", dest="secret_binary",
|
|
||||||
|
# Subparser: Reveal
|
||||||
|
parser_reveal = subparsers.add_parser('reveal', help='reveal help')
|
||||||
|
parser_reveal.add_argument("-i", "--input", dest="input_image_file",
|
||||||
|
required=True, help="Input image file.")
|
||||||
|
parser_reveal.add_argument("-g", "--generator", dest="generator_function",
|
||||||
|
required=True, help="Generator")
|
||||||
|
parser_reveal.add_argument("-o", dest="secret_binary",
|
||||||
help="Output for the binary secret (Text or any binary file).")
|
help="Output for the binary secret (Text or any binary file).")
|
||||||
|
|
||||||
|
|
||||||
arguments = parser.parse_args()
|
arguments = parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
@ -74,7 +79,7 @@ except AttributeError as e:
|
||||||
print("Unknown generator: {}".format(arguments.generator_function))
|
print("Unknown generator: {}".format(arguments.generator_function))
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
if arguments.hide:
|
if arguments.command == 'hide':
|
||||||
if arguments.secret_message != None:
|
if arguments.secret_message != None:
|
||||||
secret = arguments.secret_message
|
secret = arguments.secret_message
|
||||||
elif arguments.secret_file != "":
|
elif arguments.secret_file != "":
|
||||||
|
@ -87,7 +92,7 @@ if arguments.hide:
|
||||||
# If hide() returns an error (Too long message).
|
# If hide() returns an error (Too long message).
|
||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
elif arguments.reveal:
|
elif arguments.command == 'reveal':
|
||||||
try:
|
try:
|
||||||
secret = lsbset.reveal(arguments.input_image_file, generator)
|
secret = lsbset.reveal(arguments.input_image_file, generator)
|
||||||
except IndexError:
|
except IndexError:
|
||||||
|
|
Loading…
Add table
Reference in a new issue