示例#1
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())
示例#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())
示例#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())
示例#4
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())
示例#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())
示例#6
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())
示例#7
0
 def test_CreateCipher_XOR(self):
     result = jts.createciphermsgs(2, "DEF CON 22", "XOR",
                                   "XOR rox and all that jazz", "", "",
                                   False)
     expectedresult = [
         np.array([
             27, 20, 48, 2, 31, 48, 33, 42, 0, 9, 48, 10, 5, 0, 0, 49, 8,
             11, 24, 0
         ]),
         np.array([
             55, 48, 18, 20, 31, 6, 56, 34, 27, 37, 13, 28, 20, 49, 52, 41,
             15, 13, 46, 27
         ])
     ]
     self.assertEqual(len(expectedresult), len(result))
     self.assertEqual(result[0].tolist(), expectedresult[0].tolist())
示例#8
0
 def test_CreateCipher_None(self):
     result = jts.createciphermsgs(2, "BEACON FTW AND DEF CON 22", "none",
                                   "", "", "", False)
     expectedresult = [
         np.array([
             47, 44, 14, 33, 4, 58, 19, 6, 16, 52, 50, 11, 6, 13, 41, 26,
             39, 15, 39, 11
         ]),
         np.array([
             22, 29, 9, 53, 17, 23, 57, 14, 20, 36, 39, 11, 59, 23, 28, 16,
             53, 8, 57, 0
         ])
     ]
     self.assertEqual(len(expectedresult), len(result))
     for i in range(len(expectedresult)):
         self.assertEqual(result[i].tolist(), expectedresult[i].tolist())
示例#9
0
 def test_CreateCipher_AES_ECB(self):
     result = jts.createciphermsgs(2, "DEF CON 22", "AES",
                                   "AES is totes secure, right? Yeah", "",
                                   "ECB", False)
     expectedresult = [
         np.array([
             36, 4, 41, 24, 13, 59, 33, 52, 61, 58, 34, 51, 24, 42, 33, 50,
             5, 13, 40, 61
         ]),
         np.array([
             21, 19, 6, 19, 31, 6, 40, 34, 11, 4, 26, 16, 4, 8, 4, 62, 44,
             32, 25, 61
         ])
     ]
     self.assertEqual(len(expectedresult), len(result))
     for i in range(len(expectedresult)):
         self.assertEqual(result[i].tolist(), expectedresult[i].tolist())
示例#10
0
 def test_CreateCipher_ARC4(self):
     result = jts.createciphermsgs(
         2, "DEF CON 22", "ARC4",
         "RC4 is the most secure algorithm in the world", "", "", False)
     expectedresult = [
         np.array([
             1, 19, 25, 35, 19, 32, 46, 12, 62, 60, 24, 53, 21, 33, 29, 1,
             1, 11, 38, 47
         ]),
         np.array([
             60, 22, 15, 21, 4, 42, 5, 24, 16, 48, 46, 5, 14, 48, 32, 50, 5,
             17, 27, 41
         ])
     ]
     self.assertEqual(len(expectedresult), len(result))
     for i in range(len(expectedresult)):
         self.assertEqual(result[i].tolist(), expectedresult[i].tolist())
示例#11
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())
示例#12
0
    STEG_ENABLED = False
else:
    hidekey = jts.getnoisekey(args.key)

# Batch encode
if args.encode:
    # Create array of your valid JT65 text
    jt65msgs = args.jt65msg.split(",")

    # Create array of valid JT65 data
    jt65data = jts.jt65encodemessages(jt65msgs, args.verbose)

    if args.stegmsg != "" and STEG_ENABLED:
        # Create array of cipher data to hide
        cipherdata = jts.createciphermsgs(
            len(jt65data), args.stegmsg, args.cipher, args.key, args.recipient, args.aesmode, args.verbose
        )

        # Embed steg data in JT65 messages
        finalmsgs = jts.steginject(jt65data, args.noise, cipherdata, hidekey, args.verbose)

    else:
        # No steg data to hide, just add cover noise if specified
        finalmsgs = []
        for msg in jt65data:
            finalmsgs.append(jts.randomcover(msg, [], args.noise, args.verbose))

    # Send to output
    processoutput(finalmsgs, args.stdout, args.wavout, args.wsjt, args.freq, args.mode, args.verbose)

# Decode
示例#13
0
    STEG_ENABLED = False
else:
    hidekey = jts.getnoisekey(args.key)

# Batch encode
if args.encode:
    # Create array of your valid JT65 text
    jt65msgs = args.jt65msg.split(',')

    # Create array of valid JT65 data
    jt65data = jts.jt65encodemessages(jt65msgs, args.verbose)

    if args.stegmsg != "" and STEG_ENABLED:
        # Create array of cipher data to hide
        cipherdata = jts.createciphermsgs(len(jt65data), args.stegmsg,
                                          args.cipher, args.key,
                                          args.recipient, args.aesmode,
                                          args.verbose)

        # Embed steg data in JT65 messages
        finalmsgs = jts.steginject(jt65data, args.noise, cipherdata, hidekey,
                                   args.verbose)

    else:
        # No steg data to hide, just add cover noise if specified
        finalmsgs = []
        for msg in jt65data:
            finalmsgs.append(jts.randomcover(msg, [], args.noise,
                                             args.verbose))

    # Send to output
    processoutput(finalmsgs, args.stdout, args.wavout, args.wsjt, args.freq,