예제 #1
0
def testString(inputValue):
    # Test the serialization function itself
    try:
        print(
            "\n{}Testing direct serialization and deserialization...{}".format(
                Color.BOLD, Color.END))
        serialized = Message.serializeByteArray(inputValue)
        deserialized = Message.deserializeByteArray(serialized)
        print("\tSerialized: {0}".format(serialized))
        print("\tBefore: {0}".format(str(inputValue)))
        print("\t After: {0}".format(str(deserialized)))
    except Exception as e:
        print("Caught exception running test: {}".format(str(e)))
        deserialized = ""
    printResult("Direct Serialization Test", inputValue == deserialized)

    # Also go a step further and test the inbound/outbound etc parsing
    try:
        print(
            "\n{}Testing full serialization with inbound/outbound lines...{}".
            format(Color.BOLD, Color.END))
        message = Message()
        message.direction = Message.Direction.Outbound
        message.setMessageFrom(Message.Format.Raw, bytearray(inputValue),
                               False)
        serialized = message.getSerialized()
        message.setFromSerialized(serialized)
        deserialized = message.getOriginalMessage()
        print("\tSerialized: {0}".format(serialized))
        print("\tBefore: {0}".format(str(inputValue)))
        print("\t After: {0}".format(str(deserialized)))
    except Exception as e:
        print("Caught exception running test: {}".format(str(e)))
        deserialized = ""
    printResult("Full Serialization Test", inputValue == deserialized)
예제 #2
0
                 if not askedToCombinePackets:
                     if prompt(
                             "There are multiple packets from client to server or server to client back-to-back - combine payloads into single messages?"
                     ):
                         isCombiningPackets = True
                     askedToCombinePackets = True
                 if isCombiningPackets:
                     message.appendMessageFrom(Message.Format.Raw,
                                               bytearray(tempMessageData),
                                               False)
                     print("\tMessage #%d - Added %d new bytes %s" %
                           (j, len(tempMessageData), message.direction))
                     continue
             # Either direction isn't the same or we're not combining packets
             message = Message()
             message.direction = newMessageDirection
             lastMessageDirection = newMessageDirection
             message.setMessageFrom(Message.Format.Raw,
                                    bytearray(tempMessageData), False)
             fuzzerData.messageCollection.addMessage(message)
             j += 1
             print(
                 "\tMessage #%d - Processed %d bytes %s" %
                 (j, len(message.getOriginalMessage()), message.direction))
         except AttributeError:
             # No payload, keep going (different from empty payload)
             continue
 except Exception as rdpcap_e:
     print(str(rdpcap_e))
     print("Processing as c_array...")
     try: