Пример #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())
Пример #2
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())
Пример #3
0
 def test_DecodeWav(self):
     expectedresult = "KB2BBC KA1AAB DD44"
     msg = np.array(
         [39, 19, 16, 44, 29, 13, 58, 19, 13, 14, 20, 44, 17, 20, 25, 31, 46, 2, 29, 35, 56, 17, 11, 20, 39,
          51, 7, 30, 26, 11, 17, 27, 21, 11, 30, 34, 46, 48, 15, 53, 14, 26, 12, 7, 5, 8, 42, 41, 37, 19,
          16, 35, 63, 20, 3, 12, 38, 26, 8, 37, 22, 23, 29])
     tones = jt65sound.toneswithsync(msg)
     jt65sound.outputwavfile("test_output.wav", tones)
     result = jt.decodewav("test_output.wav")
     symbols, confidence, jt65result, s2db, freq, a1, a2 = result[0]
     os.remove("test_output.wav")  # Cleanup!
     self.assertEqual(len(result), 1)
     self.assertEqual(symbols, msg.tolist())
     self.assertEqual(
         confidence, [255] * 63)  # 63 symbols with 100% confidence
     self.assertEqual(jt65result, expectedresult)
Пример #4
0
def processoutput(finalmsgs, stdout, wavout, wsjt, freq, mode, verbose):
    # Send JT65 messages to output specified by user
    if stdout:
        np.set_printoptions(linewidth=300)

        for msg in finalmsgs:
            print msg

    if wavout:
        wavmode = 1  # Set mode to WSJT-X
        offset = freq - 1270.5
        jt65mode = 1

        if wsjt:
            wavmode = 0

        if mode == 'B':
            jt65mode = 2

        elif mode == 'C':
            jt65mode = 4

        if wavout.endswith('.wav'):
            wavout = wavout[:-4]

        for index, value in enumerate(finalmsgs):
            filename = wavout + "-" + \
                str(index).zfill(3) + ".wav"  # Creates -000.wav, -001.wav, etc

            if verbose:
                print "Generating audio file " + str(index) + " : " + filename

            if wavmode == 1 and freq == 1270.5 and mode == 'A':
                jt65sound.outputwavfilequick(filename, value)

            else:
                tones = jt65sound.toneswithsync(value, jt65mode, offset)
                jt65sound.outputwavfile(filename, tones, wavmode)
Пример #5
0
    def test_NoCipher_NoSteg_WAV(self):
        # Encode
        jt65msgs = ["KB2BBC KA1AAB DD44", "KA1AAB KB2BBC DD44"]
        jt65data = jts.jt65encodemessages(jt65msgs, False)
        for index, value in enumerate(jt65data):
            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")
        resultjt65data = [symbols1, symbols2]
        decodedjt65msgs = jts.decodemessages(resultjt65data, 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())
Пример #6
0
    def test_NoCipher_NoSteg_WAV(self):
        # Encode
        jt65msgs = ["KB2BBC KA1AAB DD44", "KA1AAB KB2BBC DD44"]
        jt65data = jts.jt65encodemessages(jt65msgs, False)
        for index, value in enumerate(jt65data):
            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")
        resultjt65data = [symbols1, symbols2]
        decodedjt65msgs = jts.decodemessages(resultjt65data, 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())
Пример #7
0
def processoutput(finalmsgs, stdout, wavout, wsjt, freq, mode, verbose):
    # Send JT65 messages to output specified by user
    if stdout:
        np.set_printoptions(linewidth=300)

        for msg in finalmsgs:
            print msg

    if wavout:
        wavmode = 1  # Set mode to WSJT-X
        offset = freq - 1270.5
        jt65mode = 1

        if wsjt:
            wavmode = 0

        if mode == "B":
            jt65mode = 2

        elif mode == "C":
            jt65mode = 4

        if wavout.endswith(".wav"):
            wavout = wavout[:-4]

        for index, value in enumerate(finalmsgs):
            filename = wavout + "-" + str(index).zfill(3) + ".wav"  # Creates -000.wav, -001.wav, etc

            if verbose:
                print "Generating audio file " + str(index) + " : " + filename

            if wavmode == 1 and freq == 1270.5 and mode == "A":
                jt65sound.outputwavfilequick(filename, value)

            else:
                tones = jt65sound.toneswithsync(value, jt65mode, offset)
                jt65sound.outputwavfile(filename, tones, wavmode)