Beispiel #1
0
    def __init__(self, pattern):
        """
        Class constructor.

        @type  pattern: str
        @param pattern:
            Hexadecimal pattern matching with wildcards.

            Hex patterns must be in this form::
                "68 65 6c 6c 6f 20 77 6f 72 6c 64"  # "hello world"

            Spaces are optional. Capitalization of hex digits doesn't matter.
            This is exactly equivalent to the previous example::
                "68656C6C6F20776F726C64"            # "hello world"

            Wildcards are allowed, in the form of a C{?} sign in any hex digit::
                "5? 5? c3"          # pop register / pop register / ret
                "b8 ?? ?? ?? ??"    # mov eax, immediate value
        """
        super(HexPattern, self).__init__(pattern)
        if not HexInput.is_pattern(pattern):
            raise ValueError("Invalid hexadecimal pattern: %r" % pattern)
        self.length = HexInput.get_pattern_length(pattern)
        self.compiled = re.compile(HexInput.pattern(pattern), re.DOTALL)
Beispiel #2
0
    def __init__(self, pattern):
        """
        Class constructor.

        @type  pattern: str
        @param pattern:
            Hexadecimal pattern matching with wildcards.

            Hex patterns must be in this form::
                "68 65 6c 6c 6f 20 77 6f 72 6c 64"  # "hello world"

            Spaces are optional. Capitalization of hex digits doesn't matter.
            This is exactly equivalent to the previous example::
                "68656C6C6F20776F726C64"            # "hello world"

            Wildcards are allowed, in the form of a C{?} sign in any hex digit::
                "5? 5? c3"          # pop register / pop register / ret
                "b8 ?? ?? ?? ??"    # mov eax, immediate value
        """
        super(HexPattern, self).__init__(pattern)
        if not HexInput.is_pattern(pattern):
            raise ValueError("Invalid hexadecimal pattern: %r" % pattern)
        self.length   = HexInput.get_pattern_length(pattern)
        self.compiled = re.compile( HexInput.pattern(pattern), re.DOTALL )