Esempio n. 1
0
def create_sortunsort_parameter(password):
    """This functions gets parameter
    password
    and with it produces and returns a new sortunsort parameter
    using libstegofile's types.h.
    """
    para = libstegofile.sortunsort_parameter()
    para.password = password
    para.pwlen = len(password)
    return para
Esempio n. 2
0
import libstego
import libstegofile

palette_data = libstegofile.palette_data_t()
stego_data = libstegofile.palette_data_t()
gif_struct = libstegofile.gif_internal_data_t()
gif_struct.SrcFilename = ""
bla = libstegofile.io_gif_read("test.gif",palette_data, gif_struct)
# TODO: uint8_t is not a good return type for functions!
# Python with SWIG interpretes them as char so "return 0" is weird for it.
if bla == 0:
    print "Gif file read successful."
else:
    print "Gif file could not be read."
para = libstegofile.sortunsort_parameter()
message = "hi"
para.password = "******"
sort_unsort_capacity = 0
cap = libstego.sortunsort_check_capacity(palette_data,para)[0]
print "sort unsort capacity: "+str(cap)
if cap == 28:
    print "Capacity is correct."
else:
    print "Capacity is wrong!"
libstego.sortunsort_embed(palette_data, stego_data, message, len(message), para)
#libstegofile.io_gif_cleanup_data(palette_data)
print "Test done."
Esempio n. 3
0
def get_algorithm(filename, msglen, password):
    if filename.endswith("jpeg") or filename.endswith("jpg"):
        # PQ, F5, LSB
        jpeg_data = libstegofile.jpeg_data_t()
        jpeg_int = libstegofile.jpeg_internal_data_t()
        err = libstegofile.io_jpeg_read(filename,jpeg_data, jpeg_int)
#TODO: ERROR (everywhere)

        para = libstegofile.pq_parameter()
        para.header_size = 0
        para.quality = 0

        if libstego.pq_check_capacity(jpeg_data, para) >= msglen:
            libstegofile.jpeg_cleanup_data(jpeg_data)
            libstegofile.io_jpeg_cleanup_internal(jpg_int)
            return ["PQ",para]

        para = libstegofile.f5_parameter()


        if libstego.f5_check_capacity(jpeg_data, para) >= msglen:
            libstegofile.jpeg_cleanup_data(jpeg_data)
            libstegofile.io_jpeg_cleanup_internal(jpg_int)
            return ["F5",para]

        para = libstegofile.lsb_parameter()


#        if libstego.lsb_check_capacity(jpeg_data, para) >= msglen:
#            libstegofile.jpeg_cleanup_data(jpeg_data)
#            libstegofile.io_jpeg_cleanup_internal(jpg_int)
#            return ["LSB",para]

        libstegofile.jpeg_cleanup_data(jpeg_data)
        libstegofile.io_jpeg_cleanup_internal(jpg_int)
        return

    elif filename.endswith("gif"):
        # AdvGifshuffle, Gifshuffle, Frirui, Sort/Unsort, LSB
        palette_data = libstegofile.palette_data_t()
        gif_int = libstegofile.gif_internal_data_t()
        err = libstegofile.io_gif_read(filename, palette_data, gif_int)

        para = libstegofile.gifshuffle_parameter()
        if libstego.gifshuffle_check_capacity(palette_data, para) >= msglen:
            return ["Adv. Gifshuffle", para]
# no elif gifshuffle since it has the same capacity that adv gusfhuffle has

        para = libstegofile.frirui_parameter()

        para.method = 0;
        para.size = 100;
        para.password = password
        para.pwlen = len(password)

        #para.method = 1;
        #para.threshold = 574;
        #para.password = password
        #para.pwlen = len(password)

        #para.method = 1;
        #para.threshold = 1148;
        #para.password = password
        #para.pwlen = len(password)

        #para.method = 2;
        #para.password = password
        #para.pwlen = len(password)

        #para.method = 1;
        #para.threshold = 2295;
        #para.password = password
        #para.pwlen = len(password)

        #para.method = 0;
        #para.size = 6;
        #para.password = password
        #para.pwlen = len(password)


        # DONE: multiple parameter sets for frirui from Matthias here!
        if libstego.frirui_check_capacity(palette_data, para) >= msglen:
            return ["Frirui", para]

        para = libstegofile.sortunsort_parameter()
        if libstego.sortunsort_check_capacity(palette_data, para) >= msglen:
            return ["Sort/Unsort", para]

        """para = libstegofile_lsb_parameter_t()
        #TODO: LSB Wrappers for structs like palette_data -> Jan ?
        if libstego.lsb_check_capacity(palette_data, para) >= msglen:
            return ["LSB", para]"""


    elif filename.endswith("png"):
        # CPT, Battlesteg, LSB
        rgb_data = libstegofile.rgb_data_t()
        png_int = libstegofile.png_internal_data_t()
        err = libstegofile.io_png_read(filename, rgb_data, png_int)

        for i in [2,4,6,8]:
            para = libstegofile.cpt_parameter()
            para.block_width = i;
            para.block_height = i;
            para.password = password
            para.pwlen = len(password)

            if libstegofile.cpt_check_capacity(rgb_data, para) >= msglen:
                return ["CPT", para]

        para = libstegofile.battlesteg_parameter()
        para.startbit = 7
        para.move_away = 3
        para.range = 5
        para.password = password
        para.pwlen = len(password)

        # parameter set "capacity"
        #para = libstegofile.battlesteg_parameter()
        #para.startbit = 6
        #para.move_away = 3
        #para.range = 5
        #para.password = "******"
        #para.pwlen = 8

        if libstegofile.battlesteg_check_capacity(rgb_data, para) >= msglen:
            return ["BattleSteg", para]

        """para = libstegofile.lsb_parameter()
        para.password = password
        para.pwlen = len(password)
        para.select_mode = 2


        if libstegofile.lsb_check_capacity(rgb_data, para) >= msglen:
            return ["LSB", para]"""

    elif filename.endswith("wav"):
        # Phase Coding, Echo Hiding, LSB
        pass

    elif filename.endswith("svg"):
        # SVGSteg

        svg_data = libstegofile.svg_data_t()
        svg_int = libstegofile.svg_internal_data_t()
        err = libstegofile.io_svg_read(filename, svg_data, svg_int)

        if err != 0:
            return None

        para = libstegofile.svg_parameter_t()
        para.password = password
        para.pwlen = len(password)
        para.first_embed_digit = 3

        fits = False
        if libstego.svg_check_capacity(svg_dat, para) >= msglen:
            fits = True

        libstegofile.svg_cleanup_data(svg_dat)
        libstegofile.svg_cleanup_internal(svg_int)

        if fits == True:
            return ["SVG", para]
Esempio n. 4
0
def setup_methods(password, filetype):
    # Add all parameter sets for your algorithms here
    # Order them from the most secure to the least secure

    global num_methods
    global method_to_algo
    global methods

    num_methods = 0

    """JPEG params"""
    if filetype in ["JPEG", "JPG"]:
        # PQ
        #~ para = libstegofile.pq_parameter()
        #~ para.header_size = 0
        #~ para.quality = 0
        #~ para.password = password
        #~ para.pwlen = len(password)
        #~ methods[num_methods] = para
        #~ method_to_algo[num_methods] = "PQ"
        #~ num_methods += 1

        # F5
        para = libstegofile.f5_parameter()
        methods[num_methods] = para
        method_to_algo[num_methods] = "F5"
        num_methods += 1

        """GIF params"""
    elif filetype == "GIF":
        # Adv. Gifshuffle
        para = libstegofile.gifshuffle_parameter()
        para.method = 1
        para.password = password
        para.pwlen = len(password)
        methods[num_methods] = para
        method_to_algo[num_methods] = "Adv. Gifshuffle"
        num_methods += 1

        # Gifshuffle
        # TODO add Gifshuffle parameter set(s) here

        # Frirui
        para = libstegofile.frirui_parameter()
        para.method = 0
        para.size = 100
        para.password = password
        para.pwlen = len(password)
        methods[num_methods] = para
        method_to_algo[num_methods] = "Frirui"
        num_methods += 1

        # Sort/Unsort
        para = libstegofile.sortunsort_parameter()
        para.password = password
        para.pwlen = len(password)
        methods[num_methods] = para
        method_to_algo[num_methods] = "Sort/Unsort"
        num_methods += 1


        """PNG params"""
    elif filetype == "PNG":
        # CPT
        for i in [8,6,4,2]:
            para = libstegofile.cpt_parameter()
            para.block_width = i;
            para.block_height = i;
            para.password = password
            para.pwlen = len(password)
            methods[num_methods] = para
            method_to_algo[num_methods] = "CPT"
            num_methods += 1

        # Battlesteg
        para = libstegofile.battlesteg_parameter()
        para.startbit = 7
        para.move_away = 3
        para.range = 5
        para.password = password
        para.pwlen = len(password)
        methods[num_methods] = para
        method_to_algo[num_methods] = "Battlesteg"
        num_methods += 1


        """SVG Params"""
    elif filetype == "SVG":
        # SVG Steg
        for i in [6,4,2,0]:
            para = libstegofile.svg_parameter_t()
            para.password = password
            para.pwlen = len(password)
            para.first_embed_digit = i
            methods[num_methods] = para
            method_to_algo[num_methods] = "SVG Steg"
            num_methods += 1


        """WAV Params"""
    elif filetype == "WAV":
        # Echo Hiding
        para = libstegofile.eh_parameter()
        para.amplitude = 0.4;
        para.zero_offset = 900;
        para.one_offset = 2700;
        para.block_size = 80000;
        methods[num_methods] = para
        method_to_algo[num_methods] = "Echo Hiding"
        num_methods += 1

        # Phase Coding
        # TODO: add Phase Coding parameter set(s) here


    """LSB"""
    # LSB isn't dependant on a certain filetype
    para = libstegofile.lsb_parameter_t()
    para.password = password
    para.pwlen = len(password)
    para.select_mode = 2
    para.use_msb = 0
    methods[num_methods] = para
    method_to_algo[num_methods] = "LSB"
    num_methods += 1
Esempio n. 5
0
def setup_methods(password):
    # Add all parameter sets for your algorithms here
    # Order them from the most secure to the least secure

    num_methods = 0

    """JPEG params"""
    # PQ
    para = libstegofile.pq_parameter()
    para.header_size = 0
    para.quality = 0
    methods[num_methods] = para
    method_to_algo[num_methods] = "PQ"
    num_methods += 1

    # F5
    para = libstegofile.f5_parameter()
    methods[num_methods] = para
    method_to_algo[num_methods] = "F5"
    num_methods += 1

    """GIF params"""
    # Adv. Gifshuffle
    para = libstegofile.gifshuffle_parameter()
    methods[num_methods] = para
    method_to_algo[num_methods] = "Adv. Gifshuffle"
    num_methods += 1

    # Gifshuffle
    # TODO add Gifshuffle parameter set(s) here

    # Frirui
    para = libstegofile.frirui_parameter()
    para.method = 0
    para.size = 100
    para.password = password
    para.pwlen = len(password)
    methods[num_methods] = para
    method_to_algo[num_methods] = "Frirui"
    num_methods += 1

    # Sort/Unsort
    para = libstegofile.sortunsort_parameter()
    methods[num_methods] = para
    method_to_algo[num_methods] = "Sort/Unsort"
    num_methods += 1


    """PNG params"""
    # CPT
    for i in [2,4,6,8]:
        para = libstegofile.cpt_parameter()
        para.block_width = i;
        para.block_height = i;
        para.password = password
        para.pwlen = len(password)
        methods[num_methods] = para
        method_to_algo[num_methods] = "CPT"
        num_methods += 1

    # Battlesteg
    para = libstegofile.battlesteg_parameter()
    para.startbit = 7
    para.move_away = 3
    para.range = 5
    para.password = password
    para.pwlen = len(password)
    methods[num_methods] = para
    method_to_algo[num_methods] = "Battlesteg"
    num_methods += 1


    """SVG Params"""
    # SVG Steg
    for i in [6,4,2,0]:
        para = libstegofile.svg_parameter_t()
        para.password = password
        para.pwlen = len(password)
        para.first_embed_digit = i
        methods[num_methods] = para
        method_to_algo[num_methods] = "SVG Steg"
        num_methods += 1


    """WAV Params"""
    # Echo Hiding
    # TODO: add Echo Hiding parameter set(s) here

    # Phase Coding
    # TODO: add Phase Coding parameter set(s) here

    """LSB"""
    para = libstegofile.lsb_parameter_t()
    para.password = password
    para.pwlen = len(password)
    para.select_mode = 2
    para.use_msb = 0
    methods[num_methods] = para
    method_to_algo[num_methods] = "LSB"
    num_methods += 1