Example #1
0
    def cluster(self, messages):
        if messages is None:
            raise TypeError("Messages cannot be None")
        if len(messages) == 0:
            raise TypeError("There should be at least one message.")

        for m in messages:
            if not isinstance(m, AbstractMessage):
                raise TypeError(
                    "At least one message ({0}) is not an AbstractMessage.".
                    format(str(m)))

        self._logger.debug(
            "Identify similar messages following their alignment (min_equivalence={0})"
            .format(self.minEquivalence))

        self._logger.debug(
            "Initiating the clustering by alignment on {0} messages...".format(
                len(messages)))
        symbols = self._processUPGMA(messages, self.recomputeMatrixThreshold)
        self._logger.debug("Clustering completed, computing final alignment.")

        # Retrieve the alignment of each symbol and the build the associated regular expression
        for symbol in symbols:
            self._logger.debug("Align messages from symbol {0}".format(
                symbol.name))
            from netzob.Inference.Vocabulary.Format import Format
            Format.splitAligned(symbol, useSemantic=False)

        return symbols
Example #2
0
    def cluster(self, messages):
        if messages is None:
            raise TypeError("Messages cannot be None")
        if len(messages) == 0:
            raise TypeError("There should be at least one message.")

        for m in messages:
            if not isinstance(m, AbstractMessage):
                raise TypeError(
                    "At least one message ({0}) is not an AbstractMessage.".
                    format(str(m)))

        self._logger.debug(
            "Identify similar messages following their alignment (min_equivalence={0})".
            format(self.minEquivalence))

        self._logger.debug(
            "Initiating the clustering by alignment on {0} messages...".format(
                len(messages)))
        symbols = self._processUPGMA(messages, self.recomputeMatrixThreshold)
        self._logger.debug("Clustering completed, computing final alignment.")

        # Retrieve the alignment of each symbol and the build the associated regular expression
        for symbol in symbols:
            self._logger.debug(
                "Align messages from symbol {0}".format(symbol.name))
            from netzob.Inference.Vocabulary.Format import Format
            Format.splitAligned(symbol, useSemantic=False)

        return symbols