예제 #1
0
def calibration(filename):

    if not utils.which("convert"):
        print("Error: 'convert' tool not found, please install it.\n")
        sys.exit(0)

    tmpdir = tempfile.mkdtemp()
    predfile = os.path.join(tempfile.mkdtemp(), 'pred.jpg')
    os.system("convert -chop 2x2 " + filename + " " + predfile)

    im_jpeg = JPEG(filename)
    impred_jpeg = JPEG(predfile)
    found = False
    for i in range(im_jpeg.components()):
        dct = np.abs(im_jpeg.coeffs(i).flatten())
        dctpred = np.abs(impred_jpeg.coeffs(i).flatten())
        Hs0 = sum(dct == 0)
        Hs1 = sum(dct == 1)
        Hp0 = sum(dctpred == 0)
        Hp1 = sum(dctpred == 1)
        Hp2 = sum(dctpred == 2)

        beta = (Hp1 * (Hs0 - Hp0) + (Hs1 - Hp1) *
                (Hp2 - Hp1)) / (Hp1**2 + (Hp2 - Hp1)**2)
        # XXX: Incomplete implementation. Check http://www.ws.binghamton.edu/fridrich/Research/mms100.pdf

        if beta > 0.05:
            print("Hiden data found in channel " + str(i) + ":", beta)
            found = True

    if not found:
        print("No hidden data found")

    shutil.rmtree(tmpdir)
예제 #2
0
def print_dct_diffs(cover, stego):
    def print_list(l, ln):
        for i in range(0, len(l), ln):
            print(l[i:i + ln])

    C_jpeg = JPEG(cover)
    S_jpeg = JPEG(stego)
    for i in range(C_jpeg.components()):
        C = C_jpeg.coeffs(i)
        S = S_jpeg.coeffs(i)
        D = S - C
        print("\nChannel " + str(i) + ":")
        pairs = list(zip(C.ravel(), S.ravel(), D.ravel()))
        pairs_diff = [p for p in pairs if p[2] != 0]
        print_list(pairs_diff, 5)
예제 #3
0
def print_dct_diffs(cover, stego):
    def print_list(l, ln):
        mooc = 0
        for i in range(0, len(l), ln):
            #print(l[i:i+ln])
            v = l[i:i + ln][0][2]
            if np.abs(v) > 1:
                mooc += 1
        print("mooc:", mooc)

    C_jpeg = JPEG(cover)
    S_jpeg = JPEG(stego)
    for i in range(C_jpeg.components()):
        C = C_jpeg.coeffs(i)
        S = S_jpeg.coeffs(i)
        D = S - C
        print("\nChannel " + str(i) + ":")
        pairs = list(zip(C.ravel(), S.ravel(), D.ravel()))
        pairs_diff = [p for p in pairs if p[2] != 0]
        #print_list(pairs_diff, 5)
        print_list(pairs_diff, 1)
예제 #4
0
def calibration_f5_octave_jpeg(filename):
    """ It uses JPEG from octave """
    tmpdir = tempfile.mkdtemp()
    predfile = os.path.join(tmpdir, 'img.jpg')
    os.system("convert -chop 4x4 "+filename+" "+predfile)

    im_jpeg = JPEG(filename)
    impred_jpeg = JPEG(predfile)
    for i in range(im_jpeg.components()):
        dct_b = im_jpeg.coeffs(i)
        dct_0 = impred_jpeg.coeffs(i)
        b01 = beta_kl(dct_0, dct_b, 0, 1)   
        b10 = beta_kl(dct_0, dct_b, 1, 0)   
        b11 = beta_kl(dct_0, dct_b, 1, 1)
        beta = (b01+b10+b11)/3
        if beta > 0.05:
            print("Hidden data found in channel "+str(i)+":", beta)
        else:
            print("No hidden data found in channel "+str(i))

    shutil.rmtree(tmpdir)
예제 #5
0
def calibration(filename):
    tmpdir = tempfile.mkdtemp()
    predfile = os.path.join(tmpdir, 'img.jpg')
    os.system("convert -chop 4x4 " + filename + " " + predfile)

    im_jpeg = JPEG(filename)
    impred_jpeg = JPEG(predfile)
    found = False
    for i in range(im_jpeg.components()):
        dct_b = im_jpeg.coeffs(i)
        dct_0 = impred_jpeg.coeffs(i)
        b01 = beta_kl(dct_0, dct_b, 0, 1)
        b10 = beta_kl(dct_0, dct_b, 1, 0)
        b11 = beta_kl(dct_0, dct_b, 1, 1)
        beta = (b01 + b10 + b11) / 3
        if beta > 0.02:
            print("Hidden data found in channel " + str(i) + ":", beta)
            found = True

    if not found:
        print("No hidden data found", beta)

    shutil.rmtree(tmpdir)