예제 #1
0
    def generateValue(self, negative, dictionary):

        variable = dictionary.getVariableByID(self.idVar)
        (binValue, strValue) = variable.getValue(negative, dictionary)

        self.log.debug("GENERATE VALUE of size : " + str(binValue))
        nb_letter = TypeConvertor.bin2int(binValue)
        self.strVal = ''.join(random.choice(string.ascii_letters) for x in range(nb_letter))
        self.binVal = TypeConvertor.string2bin(self.strVal, 'big')
        self.log.debug("Generated value = " + self.strVal)
        self.log.debug("Generated value = " + str(self.binVal))
예제 #2
0
    def generateValue(self, negative, dictionary):

        variable = dictionary.getVariableByID(self.idVar)
        (binValue, strValue) = variable.getValue(negative, dictionary)

        self.log.debug("GENERATE VALUE of size : " + str(binValue))
        nb_letter = TypeConvertor.bin2int(binValue)
        self.strVal = ''.join(random.choice(string.ascii_letters) for x in range(nb_letter))
        self.binVal = TypeConvertor.string2bin(self.strVal, 'big')
        self.log.debug("Generated value = " + self.strVal)
        self.log.debug("Generated value = " + str(self.binVal))
예제 #3
0
    def learn(self, val, indice, isForced, dictionary):
        self.log.debug("LEARN")
        variable = dictionary.getVariableByID(self.idVar)
        (binValue, strValue) = variable.getValue(False, dictionary)
        nb_letter = TypeConvertor.bin2int(binValue) * 8
        self.log.debug("nb_letter = " + str(nb_letter))
        tmp = val[indice:]
        self.log.debug("tmp size : " + str(len(tmp)))
        if (len(tmp) >= nb_letter):
            self.binVal = tmp[:nb_letter]
            self.strVal = TypeConvertor.bin2string(self.binVal)
            self.log.debug("Value learnt : " + self.strVal)
            return indice + nb_letter

        return -1
예제 #4
0
    def learn(self, val, indice, isForced, dictionary):
        self.log.debug("LEARN")
        variable = dictionary.getVariableByID(self.idVar)
        (binValue, strValue) = variable.getValue(False, dictionary)
        nb_letter = TypeConvertor.bin2int(binValue) * 8
        self.log.debug("nb_letter = " + str(nb_letter))
        tmp = val[indice:]
        self.log.debug("tmp size : " + str(len(tmp)))
        if (len(tmp) >= nb_letter):
            self.binVal = tmp[:nb_letter]
            self.strVal = TypeConvertor.bin2string(self.binVal)
            self.log.debug("Value learnt : " + self.strVal)
            return indice + nb_letter

        return -1
예제 #5
0
    def learn(self, val, indice, isForced, dictionary):
        self.log.debug("Learn on " + str(indice) + " : " + str(val[indice:]))
        if self.binValue != None and not isForced:
            self.log.debug("Won't learn the hex value (" + self.name + ") since it already has one is not forced to (return " + str(len(self.binValue)) + ")")
            return indice + len(self.binValue)

        tmp = val[indice:]
        self.log.debug("Learn hex given its size : " + str(self.size) + " from " + str(tmp))
        if len(tmp) >= self.size:

            self.binValueBeforeLearning = self.binValue
            self.strValueBeforeLearning = self.strValue

            self.binValue = val[indice:indice + self.size]
            self.strValue = str(TypeConvertor.bin2int(self.binValue))

            self.log.debug("learning value : " + str(self.binValue))
            self.log.debug("learning value : " + self.strValue)

            return indice + self.size
        else:
            return -1
예제 #6
0
    def learn(self, val, indice, isForced, dictionary):
        self.log.debug("Learn on " + str(indice) + " : " + str(val[indice:]))
        if self.binValue is not None and not isForced:
            self.log.debug("Won't learn the hex value (" + self.name + ") since it already has one is not forced to (return " + str(len(self.binValue)) + ")")
            return indice + len(self.binValue)

        tmp = val[indice:]
        self.log.debug("Learn hex given its size: " + str(self.size) + " from " + str(tmp))
        if len(tmp) >= self.size:

            self.binValueBeforeLearning = self.binValue
            self.strValueBeforeLearning = self.strValue

            self.binValue = val[indice:indice + self.size]
            self.strValue = str(TypeConvertor.bin2int(self.binValue))

            self.log.debug("learning value: " + str(self.binValue))
            self.log.debug("learning value: " + self.strValue)

            return indice + self.size
        else:
            return -1