Пример #1
0
 def __init__(self, id, name, init, id_var):
     Variable.__init__(self, id, name, "MD5")
     self.log = logging.getLogger('netzob.Common.MMSTD.Dictionary.Variables.HexVariable.py')
     self.init = init
     self.id_var = id_var
     self.binVal = None
     self.strVal = None
Пример #2
0
 def __init__(self, id, name, init, id_var):
     Variable.__init__(self, id, name, "MD5")
     self.log = logging.getLogger(
         'netzob.Common.MMSTD.Dictionary.Variables.HexVariable.py')
     self.init = init
     self.id_var = id_var
     self.binVal = None
     self.strVal = None
Пример #3
0
 def __init__(self, id, name, variableID):
     """Constructor of a ReferencedVariable:
             @type variableID: string
             @param variableID: id of the pointed variable.
     """
     Variable.__init__(self, "ReferencedVariable", id, name)
     self.log = logging.getLogger('netzob.Common.MMSTD.Dictionary.Variables.ReferencedVariable.py')
     self.varID = variableID
Пример #4
0
 def __init__(self, id, name, defaultVar):
     Variable.__init__(self, id, name, "IP")
     self.log = logging.getLogger('netzob.Common.MMSTD.Dictionary.Variables.IPVariable.py')
     if defaultVar == "" or defaultVar is None:
         self.binVal = None
         self.strVal = None
     else:
         self.strVal = defaultVar
         self.binVal = self.string2bin(self.strVal)
Пример #5
0
 def __init__(self, idVar, name, children):
     """Constructor of AlternateVariable:
             @type children: netzob.Common.MMSTD.Dictionary.Variable.Variable List
             @param children: the list of all its children.
     """
     Variable.__init__(self, "Alternate", idVar, name)
     self.log = logging.getLogger('netzob.Common.MMSTD.Dictionary.Variables.AlternativeVariable.py')
     self.children = []
     if children is not None:
         self.children.extend(children)
Пример #6
0
 def __init__(self, id, name, defaultVar):
     Variable.__init__(self, id, name, "IP")
     self.log = logging.getLogger(
         'netzob.Common.MMSTD.Dictionary.Variables.IPVariable.py')
     if defaultVar == "" or defaultVar is None:
         self.binVal = None
         self.strVal = None
     else:
         self.strVal = defaultVar
         self.binVal = self.string2bin(self.strVal)
Пример #7
0
    def __init__(self, id, name, originalValue):
        """Constructor of DecimalWordVariable:
                @type originalValue: string
                @param originalValue: a decimal ASCII word (set of characters in string.numbers) which will be the originalValue of this variable.
        """
        Variable.__init__(self, "DecimalWord", id, name)
        self.log = logging.getLogger("netzob.Common.MMSTD.Dictionary.Variables.DecimalVariable.py")
        self.originalValue = originalValue

        # Set the original value (in bitarray)
        self.computeCurrentValue(self.originalValue)
Пример #8
0
 def __init__(self, idVar, name, children=None):
     """Constructor of AggregateVariable:
             @type children: netzob.Common.MMSTD.Dictionary.Variable.Variable List
             @param children: the list of all its children.
     """
     Variable.__init__(self, "Aggregate", idVar, name)
     self.log = logging.getLogger(
         'netzob.Common.MMSTD.Dictionary.Variables.AggregateVariable.py')
     self.children = []
     if children is not None:
         self.children.extend(children)
Пример #9
0
    def __init__(self, id, name, originalValue):
        """Constructor of WordVariable:

                @type originalValue: string
                @param originalValue: ASCII word (set of string.lowercase and string.uppercase) which will be the initial value of this variable.
        """
        Variable.__init__(self, "Word", id, name)
        self.log = logging.getLogger('netzob.Common.MMSTD.Dictionary.Variables.WordVariable.py')
        self.originalValue = originalValue

        # Set the original value (in bitarray)
        self.computeCurrentValue(self.originalValue)
Пример #10
0
    def __init__(self, id, name, originalValue):
        """Constructor of DecimalWordVariable:
                @type originalValue: string
                @param originalValue: a decimal ASCII word (set of characters in string.numbers) which will be the originalValue of this variable.
        """
        Variable.__init__(self, "DecimalWord", id, name)
        self.log = logging.getLogger(
            'netzob.Common.MMSTD.Dictionary.Variables.DecimalVariable.py')
        self.originalValue = originalValue

        # Set the original value (in bitarray)
        self.computeCurrentValue(self.originalValue)
Пример #11
0
    def __init__(self, id, name, originalValue):
        """Constructor of WordVariable:

                @type originalValue: string
                @param originalValue: ASCII word (set of string.lowercase and string.uppercase) which will be the initial value of this variable.
        """
        Variable.__init__(self, "Word", id, name)
        self.log = logging.getLogger(
            'netzob.Common.MMSTD.Dictionary.Variables.WordVariable.py')
        self.originalValue = originalValue

        # Set the original value (in bitarray)
        self.computeCurrentValue(self.originalValue)
Пример #12
0
    def __init__(self, id, name, originalValue, minBits, maxBits):
        """Constructor of BinaryVariable:

                @type originalValue: bitarray.bitarray
                @param originalValue: the initial value of this variable.
                @type minBits: integer
                @param minBits: the minimum number of bits in the variable value.
                @type maxBits: integer
                @param maxBits: the maximum number of bits in the variable value.
        """
        Variable.__init__(self, BinaryVariable.TYPE, id, name)
        self.log = logging.getLogger('netzob.Common.MMSTD.Dictionary.Variables.BinaryVariable.py')
        self.originalValue = originalValue
        self.minBits = minBits
        self.maxBits = maxBits

        # Set the current value
        self.computeCurrentValue(self.originalValue)
Пример #13
0
    def __init__(self, id, name, originalValue, minHex, maxHex):
        """Constructor of HexVariable:

                @type originalValue: string
                @param originalValue: hexadecimal word describing the initial value of the variable (e5f026...).
                @type minHex: integer
                @param minHex: number minimum of hexadecimal character.
                @type maxHex: integer
                @param maxHex: number maximum of hexadecimal character.
        """
        Variable.__init__(self, "Hexadecimal", id, name)
        self.log = logging.getLogger('netzob.Common.MMSTD.Dictionary.Variables.HexVariable.py')
        self.originalValue = originalValue
        self.minHex = minHex
        self.maxHex = maxHex

        # Set the current value
        self.computeCurrentValue(self.originalValue)
Пример #14
0
    def __init__(self, id, name, originalValue, minHex, maxHex):
        """Constructor of HexVariable:

                @type originalValue: string
                @param originalValue: hexadecimal word describing the initial value of the variable (e5f026...).
                @type minHex: integer
                @param minHex: number minimum of hexadecimal character.
                @type maxHex: integer
                @param maxHex: number maximum of hexadecimal character.
        """
        Variable.__init__(self, "Hexadecimal", id, name)
        self.log = logging.getLogger(
            'netzob.Common.MMSTD.Dictionary.Variables.HexVariable.py')
        self.originalValue = originalValue
        self.minHex = minHex
        self.maxHex = maxHex

        # Set the current value
        self.computeCurrentValue(self.originalValue)
Пример #15
0
    def __init__(self, id, name, originalValue, minBits, maxBits):
        """Constructor of BinaryVariable:

                @type originalValue: bitarray.bitarray
                @param originalValue: the initial value of this variable.
                @type minBits: integer
                @param minBits: the minimum number of bits in the variable value.
                @type maxBits: integer
                @param maxBits: the maximum number of bits in the variable value.
        """
        Variable.__init__(self, BinaryVariable.TYPE, id, name)
        self.log = logging.getLogger(
            'netzob.Common.MMSTD.Dictionary.Variables.BinaryVariable.py')
        self.originalValue = originalValue
        self.minBits = minBits
        self.maxBits = maxBits

        # Set the current value
        self.computeCurrentValue(self.originalValue)
Пример #16
0
    def __init__(self, id, name, size, value):
        Variable.__init__(self, id, name, "INT")
        self.log = logging.getLogger('netzob.Common.MMSTD.Dictionary.Variables.HexVariable.py')
        self.value = value

        self.size = size
        self.min = -1
        self.max = -1
        self.reset = "normal"
        if self.value is not None:
            self.binValue = TypeConvertor.int2bin(self.value, self.size)
            self.strValue = TypeConvertor.int2string(self.value)
        else:
            self.binValue = None
            self.strValue = None

        self.binValueBeforeLearning = None
        self.strValueBeforeLearning = None

        self.log.debug("Bin-value = " + str(self.binValue) + ", str-value = " + str(self.strValue))
Пример #17
0
    def __init__(self, id, name, originalValue, startValue, endValue, format):
        """Constructor of IPv4Variable:

            @type originalValue: string
            @param originalValue: the original value of the variable, must be a "real" ip address declared in ASCII like : "192.168.0.10".
            @type startValue: string
            @param startValue: the first value of the IP range contained by the variable, must be a "real" ip address declared in ASCII like : "192.168.0.10"
            @type endValue: string
            @param endValue: the last value of the IP range contained by the variable, must be a "real" ip address declared in ASCII like : "192.168.0.10"
            @type format: string
            @param format: the format of the given IO, either "hex" or "ascii".
        """
        Variable.__init__(self, "IPv4Variable", id, name)
        self.log = logging.getLogger("netzob.Common.MMSTD.Dictionary.Variables.IP4Variable.py")

        # Save initial informations
        self.format = format
        self.startValue = startValue
        self.endValue = endValue
        self.originalValue = originalValue

        # Set the current value
        self.computeCurrentValue(self.originalValue)
Пример #18
0
    def __init__(self, id, name, originalValue, startValue, endValue, format):
        """Constructor of IPv4Variable:

            @type originalValue: string
            @param originalValue: the original value of the variable, must be a "real" ip address declared in ASCII like : "192.168.0.10".
            @type startValue: string
            @param startValue: the first value of the IP range contained by the variable, must be a "real" ip address declared in ASCII like : "192.168.0.10"
            @type endValue: string
            @param endValue: the last value of the IP range contained by the variable, must be a "real" ip address declared in ASCII like : "192.168.0.10"
            @type format: string
            @param format: the format of the given IO, either "hex" or "ascii".
        """
        Variable.__init__(self, "IPv4Variable", id, name)
        self.log = logging.getLogger(
            'netzob.Common.MMSTD.Dictionary.Variables.IP4Variable.py')

        # Save initial informations
        self.format = format
        self.startValue = startValue
        self.endValue = endValue
        self.originalValue = originalValue

        # Set the current value
        self.computeCurrentValue(self.originalValue)
Пример #19
0
 def __init__(self, id, name, idVar):
     Variable.__init__(self, id, name, "DynLenString")
     self.log = logging.getLogger('netzob.Common.MMSTD.Dictionary.Variables.WordVariable.py')
     self.idVar = idVar
     self.binVal = None
     self.strVal = None