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())
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())
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())
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())
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())
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())
def test_StegInject(self): jt65data = [ 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 ]), np.array([ 1, 22, 21, 42, 33, 8, 40, 58, 13, 54, 19, 19, 58, 6, 5, 10, 29, 24, 34, 1, 53, 33, 30, 43, 17, 51, 29, 38, 52, 58, 55, 9, 49, 50, 24, 61, 0, 52, 51, 20, 25, 58, 15, 41, 53, 48, 6, 57, 10, 25, 11, 30, 16, 20, 47, 6, 0, 43, 6, 18, 38, 3, 29 ]) ] cipherdata = [ 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.steginject(jt65data, 0, cipherdata, hidekey, False) expectedresult = [ 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 ]) ] self.assertEqual(len(expectedresult), len(result)) for i in range(len(expectedresult)): self.assertEqual(result[i].tolist(), expectedresult[i].tolist())
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())
# 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 elif args.decode: stegpresent = False # Process input to JT numpy arrays
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 elif args.decode: stegpresent = False