Esempio n. 1
0
def create_cpt_parameter(password, size_x, size_y):
    """This functions gets parameter
    password
    size_x
    size_y
    and with them produces and returns a new cpt parameter
    using libstegofile's types.h.
    """
    para = libstegofile.cpt_parameter()
    para.block_width = size_x
    para.block_height = size_y
    para.passwd = password
    para.pwlen = len(password)
    return para
Esempio n. 2
0
def cptExtract(q):
    post, filename = q.get()
    rgb_data = libstegofile.rgb_data_t()
    png_struct = libstegofile.png_internal_data_t()
    retcode = libstegofile.io_png_read(filename, rgb_data, png_struct)
    if retcode == 0:
        pass
    else:
        return -1
    para = libstegofile.cpt_parameter()
    para.password = str(post["pw"])
    para.pwlen = len(para.password)
    para.block_width = int((post["width"]))
    para.block_height = int((post["height"]))
    stegomsg = libstego.new_charp()
    stegolen = libstego.new_intp()
    libstego.cpt_extract(rgb_data, stegomsg, stegolen, para)
    q.put(str(libstego.charp_value(stegomsg)))
Esempio n. 3
0
def cptEmbed(q):
    post, filename = q.get()
    rgb_data = libstegofile.rgb_data_t()
    stego_data = libstegofile.rgb_data_t()
    png_struct = libstegofile.png_internal_data_t()
    retcode = libstegofile.io_png_read(filename, rgb_data, png_struct)
    if retcode == 0:
        pass
    else:
        q.put(-1)
        return -1
    para = libstegofile.cpt_parameter()
    message = str(post["message"])
    para.password = str(post["pw"])
    para.pwlen = len(para.password)
    para.block_width = int(post["width"])
    para.block_height = int(post["height"])
    retcode = libstego.cpt_embed(rgb_data, stego_data, message, len(message), para)
    libstegofile.io_png_integrate(png_struct, stego_data)
    libstegofile.io_png_write(filename, png_struct)
    q.put(filename)
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 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. 6
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