Esempio n. 1
0
    def test_NoCipher_WithSteg_WAV(self):
        for i in range(MAX_COVER_NOISE):
            # Encode
            jt65msgs = ["KB2BBC KA1AAB DD44", "KA1AAB KB2BBC DD44"]
            jt65data = jts.jt65encodemessages(jt65msgs, False)
            stegmsg = "BEACON FTW AND DEF CON 22"
            key = ''.join(random.choice(string.ascii_letters + string.digits)
                          for n in xrange(random.randint(10, 30)))
            hidekey = jts.getnoisekey(key)
            cipherdata = jts.createciphermsgs(
                len(jt65data), stegmsg, "none", "", "", "", False)
            finalmsgs = jts.steginject(jt65data, i, cipherdata, hidekey, False)
            for index, value in enumerate(finalmsgs):
                tones = jt65sound.toneswithsync(value)
                jt65sound.outputwavfile(
                    "test_output-00" + str(index) + ".wav", tones)

            # Decode
            result1 = jt65sound.inputwavfile("test_output-000.wav")
            result2 = jt65sound.inputwavfile("test_output-001.wav")
            symbols1, confidence1, wavmsg1, s2db, freq, a1, a2 = result1[0]
            symbols2, confidence2, wavmsg2, s2db, freq, a1, a2 = result2[0]
            os.remove("test_output-000.wav")
            os.remove("test_output-001.wav")
            finalresultmsgs = [symbols1, symbols2]
            stegdata = jts.retrievesteg(finalresultmsgs, hidekey, False)
            resultstegmsg = jts.deciphersteg(stegdata, "none", "", "", False)
            decodedjt65msgs = jts.decodemessages(finalresultmsgs, False)
            self.assertEqual(len(result1), 1)
            self.assertEqual(len(result2), 1)
            self.assertEqual(len(decodedjt65msgs), len(jt65msgs))
            for i in range(len(jt65msgs)):
                self.assertEqual(
                    jt65msgs[i].rstrip(), decodedjt65msgs[i].rstrip())
            self.assertEqual(stegmsg.rstrip(), resultstegmsg.rstrip())
Esempio n. 2
0
    def test_NoCipher_WithSteg_Extra(self):
        for i in range(MAX_COVER_NOISE):
            # Encode with more JT65 msgs than necessary
            jt65msgs = [
                "KB2BBC KA1AAB DD44", "KA1AAB KB2BBC DD44",
                "KB2BBC KA1AAB DD44", "KA1AAB KB2BBC DD44"
            ]
            jt65data = jts.jt65encodemessages(jt65msgs, False)
            stegmsg = "BEACON FTW AND DEF CON 22"
            key = ''.join(
                random.choice(string.ascii_letters + string.digits)
                for n in xrange(random.randint(10, 30)))
            hidekey = jts.getnoisekey(key)
            cipherdata = jts.createciphermsgs(len(jt65data), stegmsg, "none",
                                              "", "", "", False)
            finalmsgs = jts.steginject(jt65data, i, cipherdata, hidekey, False)

            # Decode
            finalresultmsgs = list(finalmsgs)
            stegdata = jts.retrievesteg(finalmsgs, hidekey, False)
            resultstegmsg = jts.deciphersteg(stegdata, "none", "", "", False)
            decodedjt65msgs = jts.decodemessages(finalmsgs, False)
            self.assertEqual(len(decodedjt65msgs), len(jt65msgs))
            for i in range(len(jt65msgs)):
                self.assertEqual(jt65msgs[i].rstrip(),
                                 decodedjt65msgs[i].rstrip())
            self.assertEqual(stegmsg.rstrip(), resultstegmsg.rstrip())
Esempio n. 3
0
    def test_AES_CFB(self):
        for i in range(MAX_COVER_NOISE):
            # Encode
            jt65msgs = [
                "KB2BBC KA1AAB DD44", "KA1AAB KB2BBC DD44",
                "KB2BBC KA1AAB DD44", "KA1AAB KB2BBC DD44"
            ]
            jt65data = jts.jt65encodemessages(jt65msgs, False)
            stegmsg = "DEF CON 22"
            key = ''.join(
                random.choice(string.ascii_letters + string.digits)
                for n in xrange(random.randint(10, 30)))
            hidekey = jts.getnoisekey(key)
            cipherdata = jts.createciphermsgs(
                len(jt65data), stegmsg, "AES",
                "AES is totes secure, right? Yeah", "", "CFB", False)
            finalmsgs = jts.steginject(jt65data, i, cipherdata, hidekey, False)

            # Decode
            finalresultmsgs = list(finalmsgs)
            stegdata = jts.retrievesteg(finalmsgs, hidekey, False)
            resultstegmsg = jts.deciphersteg(
                stegdata, "AES", "AES is totes secure, right? Yeah", "CFB",
                False)
            decodedjt65msgs = jts.decodemessages(finalmsgs, False)
            self.assertEqual(len(decodedjt65msgs), len(jt65msgs))
            for i in range(len(jt65msgs)):
                self.assertEqual(jt65msgs[i].rstrip(),
                                 decodedjt65msgs[i].rstrip())
            self.assertEqual(stegmsg.rstrip(), resultstegmsg.rstrip())
Esempio n. 4
0
    def test_OTP_Extra(self):
        for i in range(MAX_COVER_NOISE):
            # Encode with more JT65 msgs than necessary
            jt65msgs = [
                "KB2BBC KA1AAB DD44", "KA1AAB KB2BBC DD44", "KB2BBC KA1AAB DD44",
                "KA1AAB KB2BBC DD44", "KB2BBC KA1AAB DD44", "KA1AAB KB2BBC DD44"]
            jt65data = jts.jt65encodemessages(jt65msgs, False)
            stegmsg = "BEACON FTW AND DEF CON 22"
            key = ''.join(random.choice(string.ascii_letters + string.digits)
                          for n in xrange(random.randint(10, 30)))
            hidekey = jts.getnoisekey(key)
            cipherdata = jts.createciphermsgs(
                len(jt65data), stegmsg, "OTP", "I LOVE SECURITY AND STUFF", "", "", False)
            finalmsgs = jts.steginject(jt65data, i, cipherdata, hidekey, False)

            # Decode
            finalmsgscopy = copy.deepcopy(finalmsgs)
            jt65stegmsgs = []
            decodedjt65msgs = jts.decodemessages(finalmsgs, False)

            for i in range(len(finalmsgscopy)):
                if jts.validatesteg(decodedjt65msgs[i], finalmsgscopy[i], hidekey, STEG_DETECTION_ERROR_THRESHOLD, False):
                    jt65stegmsgs.append(finalmsgscopy[i])
            stegdata = jts.retrievesteg(jt65stegmsgs, hidekey, False)
            resultstegmsg = jts.deciphersteg(
                stegdata, "OTP", "I LOVE SECURITY AND STUFF", "", False)

            self.assertEqual(len(decodedjt65msgs), len(jt65msgs))
            for i in range(len(jt65msgs)):
                self.assertEqual(
                    jt65msgs[i].rstrip(), decodedjt65msgs[i].rstrip())
            self.assertEqual(stegmsg.rstrip(), resultstegmsg.rstrip())
Esempio n. 5
0
    def test_OTP(self):
        for i in range(MAX_COVER_NOISE):
            # Encode
            jt65msgs = ["KB2BBC KA1AAB DD44", "KA1AAB KB2BBC DD44",
                        "KB2BBC KA1AAB DD44", "KA1AAB KB2BBC DD44"]
            jt65data = jts.jt65encodemessages(jt65msgs, False)
            stegmsg = "BEACON FTW AND DEF CON 22"
            key = ''.join(random.choice(string.ascii_letters + string.digits)
                          for n in xrange(random.randint(10, 30)))
            hidekey = jts.getnoisekey(key)
            cipherdata = jts.createciphermsgs(
                len(jt65data), stegmsg, "OTP", "I LOVE SECURITY AND STUFF", "", "", False)
            finalmsgs = jts.steginject(jt65data, i, cipherdata, hidekey, False)

            # Decode
            finalresultmsgs = list(finalmsgs)
            stegdata = jts.retrievesteg(finalmsgs, hidekey, False)
            resultstegmsg = jts.deciphersteg(
                stegdata, "OTP", "I LOVE SECURITY AND STUFF", "", False)
            decodedjt65msgs = jts.decodemessages(finalmsgs, False)
            self.assertEqual(len(decodedjt65msgs), len(jt65msgs))
            for i in range(len(jt65msgs)):
                self.assertEqual(
                    jt65msgs[i].rstrip(), decodedjt65msgs[i].rstrip())
            self.assertEqual(stegmsg.rstrip(), resultstegmsg.rstrip())
Esempio n. 6
0
 def test_RetrieveSteg(self):
     jt65data = [
         np.array([
             39, 21, 16, 1, 29, 49, 58, 39, 13, 27, 20, 56, 17, 17, 25, 45,
             46, 19, 29, 51, 56, 0, 11, 26, 39, 6, 7, 17, 26, 52, 17, 4, 21,
             31, 30, 15, 46, 42, 15, 35, 14, 26, 12, 7, 5, 8, 42, 41, 37,
             19, 16, 35, 63, 20, 3, 12, 38, 26, 8, 37, 22, 23, 29
         ]),
         np.array([
             1, 35, 21, 61, 33, 28, 40, 27, 13, 11, 19, 39, 58, 49, 5, 15,
             29, 48, 34, 50, 53, 9, 30, 23, 17, 39, 29, 26, 52, 55, 55, 61,
             49, 62, 24, 15, 0, 56, 51, 28, 25, 58, 15, 41, 53, 48, 6, 57,
             10, 25, 11, 30, 16, 20, 47, 6, 0, 43, 6, 18, 38, 3, 29
         ])
     ]
     expectedresult = [
         np.array([
             21, 1, 49, 39, 27, 56, 17, 45, 19, 51, 0, 26, 6, 17, 52, 4, 31,
             15, 42, 35
         ]),
         np.array([
             35, 61, 28, 27, 11, 39, 49, 15, 48, 50, 9, 23, 39, 26, 55, 61,
             62, 15, 56, 28
         ])
     ]
     result = jts.retrievesteg(jt65data, hidekey, False)
     self.assertEqual(len(expectedresult), len(result))
     for i in range(len(expectedresult)):
         self.assertEqual(result[i].tolist(), expectedresult[i].tolist())
Esempio n. 7
0
    def test_AES_CFB_WAV(self):
        for i in range(MAX_COVER_NOISE):
            # Encode
            jt65msgs = [
                "KB2BBC KA1AAB DD44", "KA1AAB KB2BBC DD44",
                "KB2BBC KA1AAB DD44", "KA1AAB KB2BBC DD44"
            ]
            jt65data = jts.jt65encodemessages(jt65msgs, False)
            stegmsg = "DEF CON 22"
            key = ''.join(
                random.choice(string.ascii_letters + string.digits)
                for n in xrange(random.randint(10, 30)))
            hidekey = jts.getnoisekey(key)
            cipherdata = jts.createciphermsgs(
                len(jt65data), stegmsg, "AES",
                "AES is totes secure, right? Yeah", "", "CFB", False)
            finalmsgs = jts.steginject(jt65data, i, cipherdata, hidekey, False)
            for index, value in enumerate(finalmsgs):
                tones = jt65sound.toneswithsync(value)
                jt65sound.outputwavfile("test_output-00" + str(index) + ".wav",
                                        tones)

            # Decode
            result1 = jt65sound.inputwavfile("test_output-000.wav")
            result2 = jt65sound.inputwavfile("test_output-001.wav")
            result3 = jt65sound.inputwavfile("test_output-002.wav")
            result4 = jt65sound.inputwavfile("test_output-003.wav")
            symbols1, confidence1, wavmsg1, s2db, freq, a1, a2 = result1[0]
            symbols2, confidence2, wavmsg2, s2db, freq, a1, a2 = result2[0]
            symbols3, confidence3, wavmsg3, s2db, freq, a1, a2 = result3[0]
            symbols4, confidence4, wavmsg4, s2db, freq, a1, a2 = result4[0]
            os.remove("test_output-000.wav")
            os.remove("test_output-001.wav")
            os.remove("test_output-002.wav")
            os.remove("test_output-003.wav")
            finalresultmsgs = [symbols1, symbols2, symbols3, symbols4]
            stegdata = jts.retrievesteg(finalresultmsgs, hidekey, False)
            resultstegmsg = jts.deciphersteg(
                stegdata, "AES", "AES is totes secure, right? Yeah", "CFB",
                False)
            decodedjt65msgs = jts.decodemessages(finalresultmsgs, False)
            self.assertEqual(len(result1), 1)
            self.assertEqual(len(result2), 1)
            self.assertEqual(len(result3), 1)
            self.assertEqual(len(result4), 1)
            self.assertEqual(len(decodedjt65msgs), len(jt65msgs))
            for i in range(len(jt65msgs)):
                self.assertEqual(jt65msgs[i].rstrip(),
                                 decodedjt65msgs[i].rstrip())
            self.assertEqual(stegmsg.rstrip(), resultstegmsg.rstrip())
Esempio n. 8
0
def performwavdecode(filename, stegcollection):
    # Decode a single wav file
    containssteg = False
    messages = jt65sound.inputwavfile(filename, verbose=args.verbose)

    for currentmsg in messages:
        symbols, confidence, msg, s2db, freq, a1, a2 = currentmsg
        numpymsg = np.array(symbols)
        jt65data = []
        jt65data.append(numpymsg)
        jt65datacopy = copy.deepcopy(
            jt65data
        )  # Necessary on some version of Python due to 'unprepmsg' not preserving list

        # Retrieve JT65 valid messages
        jt65msgs = jts.decodemessages(jt65data, args.verbose)

        if STEG_ENABLED:
            containssteg = jts.validatesteg(jt65msgs[0], symbols, hidekey,
                                            STEG_DETECTION_ERROR_THRESHOLD,
                                            args.verbose)

        if containssteg:
            # Retrieve steg message
            stegdata = jts.retrievesteg(
                jt65datacopy, hidekey, args.verbose,
                True)  # Unprep the steg to get actual bytes
            stegcollection.append(stegdata[0])

            # Determine if we have a steg result
            containsstegresult, stegstatus, resetcollection, stegmsg = getstegresult(
                stegcollection, args.cipher, args.key, args.aesmode,
                args.verbose)

            if resetcollection:
                stegcollection[:] = [
                ]  # Reset the steg collection for the next incoming message

        # Print result
        for index, value in enumerate(jt65msgs):
            print "\nDecoded JT65 message " + str(
                index
            ) + " : " + colorama.Fore.BLUE + value + colorama.Fore.RESET

        if containssteg and containsstegresult:
            print "\nHidden message : " + colorama.Fore.RED + stegmsg + colorama.Fore.RESET

        elif containssteg:
            print "\n" + colorama.Fore.RED + "Steg detected! " + colorama.Fore.YELLOW + stegstatus + colorama.Fore.RESET
Esempio n. 9
0
def performwavdecode(filename, stegcollection):
    # Decode a single wav file
    containssteg = False
    messages = jt65sound.inputwavfile(filename, verbose=args.verbose)

    for currentmsg in messages:
        symbols, confidence, msg, s2db, freq, a1, a2 = currentmsg
        numpymsg = np.array(symbols)
        jt65data = []
        jt65data.append(numpymsg)
        jt65datacopy = copy.deepcopy(
            jt65data
        )  # Necessary on some version of Python due to 'unprepmsg' not preserving list

        # Retrieve JT65 valid messages
        jt65msgs = jts.decodemessages(jt65data, args.verbose)

        if STEG_ENABLED:
            containssteg = jts.validatesteg(jt65msgs[0], symbols, hidekey, STEG_DETECTION_ERROR_THRESHOLD, args.verbose)

        if containssteg:
            # Retrieve steg message
            stegdata = jts.retrievesteg(
                jt65datacopy, hidekey, args.verbose, True
            )  # Unprep the steg to get actual bytes
            stegcollection.append(stegdata[0])

            # Determine if we have a steg result
            containsstegresult, stegstatus, resetcollection, stegmsg = getstegresult(
                stegcollection, args.cipher, args.key, args.aesmode, args.verbose
            )

            if resetcollection:
                stegcollection[:] = []  # Reset the steg collection for the next incoming message

        # Print result
        for index, value in enumerate(jt65msgs):
            print "\nDecoded JT65 message " + str(index) + " : " + colorama.Fore.BLUE + value + colorama.Fore.RESET

        if containssteg and containsstegresult:
            print "\nHidden message : " + colorama.Fore.RED + stegmsg + colorama.Fore.RESET

        elif containssteg:
            print "\n" + colorama.Fore.RED + "Steg detected! " + colorama.Fore.YELLOW + stegstatus + colorama.Fore.RESET
Esempio n. 10
0
    def test_OTP_Extra(self):
        for i in range(MAX_COVER_NOISE):
            # Encode with more JT65 msgs than necessary
            jt65msgs = [
                "KB2BBC KA1AAB DD44", "KA1AAB KB2BBC DD44",
                "KB2BBC KA1AAB DD44", "KA1AAB KB2BBC DD44",
                "KB2BBC KA1AAB DD44", "KA1AAB KB2BBC DD44"
            ]
            jt65data = jts.jt65encodemessages(jt65msgs, False)
            stegmsg = "BEACON FTW AND DEF CON 22"
            key = ''.join(
                random.choice(string.ascii_letters + string.digits)
                for n in xrange(random.randint(10, 30)))
            hidekey = jts.getnoisekey(key)
            cipherdata = jts.createciphermsgs(len(jt65data), stegmsg, "OTP",
                                              "I LOVE SECURITY AND STUFF", "",
                                              "", False)
            finalmsgs = jts.steginject(jt65data, i, cipherdata, hidekey, False)

            # Decode
            finalmsgscopy = copy.deepcopy(finalmsgs)
            jt65stegmsgs = []
            decodedjt65msgs = jts.decodemessages(finalmsgs, False)

            for i in range(len(finalmsgscopy)):
                if jts.validatesteg(decodedjt65msgs[i], finalmsgscopy[i],
                                    hidekey, STEG_DETECTION_ERROR_THRESHOLD,
                                    False):
                    jt65stegmsgs.append(finalmsgscopy[i])
            stegdata = jts.retrievesteg(jt65stegmsgs, hidekey, False)
            resultstegmsg = jts.deciphersteg(stegdata, "OTP",
                                             "I LOVE SECURITY AND STUFF", "",
                                             False)

            self.assertEqual(len(decodedjt65msgs), len(jt65msgs))
            for i in range(len(jt65msgs)):
                self.assertEqual(jt65msgs[i].rstrip(),
                                 decodedjt65msgs[i].rstrip())
            self.assertEqual(stegmsg.rstrip(), resultstegmsg.rstrip())
Esempio n. 11
0
    # Process input to JT numpy arrays
    jt65data = processinput(args.stdin, args.wavin, args.verbose)
    jt65datacopy = copy.deepcopy(jt65data)
    jt65stegmsgs = []

    # Retrieve JT65 valid messages
    jt65msgs = jts.decodemessages(jt65data, args.verbose)

    if STEG_ENABLED:
        for i in range(len(jt65datacopy)):
            if jts.validatesteg(jt65msgs[i], jt65datacopy[i], hidekey, STEG_DETECTION_ERROR_THRESHOLD, args.verbose):
                jt65stegmsgs.append(jt65datacopy[i])
                stegpresent = True

    # Retrieve steg message
    stegdata = jts.retrievesteg(jt65stegmsgs, hidekey, args.verbose)

    # Decipher steg message
    stegmsg = jts.deciphersteg(stegdata, args.cipher, args.key, args.aesmode, args.verbose)

    # Print result
    for index, value in enumerate(jt65msgs):
        print "\nDecoded JT65 message " + str(index) + " : " + colorama.Fore.BLUE + value + colorama.Fore.RESET
    if stegpresent:
        print "\nHidden message : " + colorama.Fore.RED + stegmsg + colorama.Fore.RESET

# Interactive - Just listening for now
elif args.interactive:
    stegcollection = []

    while True:
Esempio n. 12
0
    jt65data = processinput(args.stdin, args.wavin, args.verbose)
    jt65datacopy = copy.deepcopy(jt65data)
    jt65stegmsgs = []

    # Retrieve JT65 valid messages
    jt65msgs = jts.decodemessages(jt65data, args.verbose)

    if STEG_ENABLED:
        for i in range(len(jt65datacopy)):
            if jts.validatesteg(jt65msgs[i], jt65datacopy[i], hidekey,
                                STEG_DETECTION_ERROR_THRESHOLD, args.verbose):
                jt65stegmsgs.append(jt65datacopy[i])
                stegpresent = True

    # Retrieve steg message
    stegdata = jts.retrievesteg(jt65stegmsgs, hidekey, args.verbose)

    # Decipher steg message
    stegmsg = jts.deciphersteg(stegdata, args.cipher, args.key, args.aesmode,
                               args.verbose)

    # Print result
    for index, value in enumerate(jt65msgs):
        print "\nDecoded JT65 message " + str(
            index) + " : " + colorama.Fore.BLUE + value + colorama.Fore.RESET
    if stegpresent:
        print "\nHidden message : " + colorama.Fore.RED + stegmsg + colorama.Fore.RESET

# Interactive - Just listening for now
elif args.interactive:
    stegcollection = []