The byte_test Keyword
The byte_test
keyword tests the specified byte segment against the Value
argument and its operator.
The following table describes the required arguments for the
byte_test
keyword.
Argument |
Description |
---|---|
Bytes |
The number of bytes to calculate from the packet. If used without DCE/RPC, the allowed values are 1 to 10. However, if you specify a number of bytes other than 1, 2, or 4, you must specify a Number Type (hexadecimal, octal, or decimal.). If used with DCE/RPC, allowed values are 1, 2, and 4. |
Value |
Value to test, including its operator. Supported operators: <, >, =, !, &, ^, !>, !<, !=, !&, or !^. For example, if you specify
Note that ! and != are equivalent. You can also use an
existing |
Offset |
The number of bytes into the payload to start processing. The
You can use an
existing |
You can further define how the system uses
byte_test
arguments with the arguments described in the
following table.
Argument |
Description |
---|---|
Bitmask |
Applies the specified hexadecimal bitmask using the AND operator to the bytes extracted from the Bytes argument. A bitmask can be 1 to 4 bytes. The result will be right-shifted by the number of bits equal to the number of trailing zeros in the mask. |
Relative |
Makes the offset relative to the last successful pattern match. |
You can specify only one of DCE/RPC, Endian, or Number Type.
To define how the
byte_test
keyword calculates the bytes it tests, choose from the
arguments in the following table. If you do not select a byte-ordering argument, the
rules engine uses big endian byte order.
Argument |
Description |
---|---|
Big Endian |
Processes data in big endian byte order, which is the default network byte order. |
Little Endian |
Processes data in little endian byte order. |
DCE/RPC |
Specifies a
The DCE/RPC preprocessor determines big endian or little endian byte order, and the Number Type and Endian arguments do not apply. When you enable this argument, you can also use
|
You can define how the system views string data in a packet by using one of the arguments in the following table.
Argument |
Description |
---|---|
Hexadecimal String |
Represents converted string data in hexadecimal format. |
Decimal String |
Represents converted string data in decimal format. |
Octal String |
Represents converted string data in octal format. |
For example, if the value for
byte_test
is specified as the following:
-
Bytes = 4
-
Operator and Value > 128
-
Offset = 8
-
Relative enabled
The rules engine calculates the number described in the four bytes that appear 9 bytes away from (relative to) the last successful content match, and, if the calculated number is larger than 128 bytes, the rule is triggered.