|
| 1 | +.. _rules-integer-keywords: |
| 2 | + |
| 3 | +Integer Keywords |
| 4 | +================ |
| 5 | + |
| 6 | +Many keywords will match on an integer value on the network traffic. |
| 7 | +These are unsigned integers that can be 8, 16, 32 or 64 bits. |
| 8 | + |
| 9 | +Simple example:: |
| 10 | + |
| 11 | + bsize:integer value; |
| 12 | + |
| 13 | +The integer value can be written as base-10 like ``100`` or as |
| 14 | +an hexadecimal value like ``0x64``. |
| 15 | + |
| 16 | +The most direct exemple is to match for equality, but there are |
| 17 | +different modes. |
| 18 | + |
| 19 | +Comparison modes |
| 20 | +---------------- |
| 21 | + |
| 22 | +Integers can be matched for |
| 23 | +* Equality |
| 24 | +* Inequality |
| 25 | +* Greater than |
| 26 | +* Less than |
| 27 | +* Range |
| 28 | +* Negated range |
| 29 | +* Bitmask |
| 30 | +* Negated Bitmask |
| 31 | + |
| 32 | +Comparisons are strict by default. Ranges are thus exclusive. |
| 33 | +That means a range between 1 and 4 will match 2 and 3, but neither 1 nor 4. |
| 34 | +Negated range !1-4 will match for 1 or below and for 4 or above. |
| 35 | + |
| 36 | +Examples:: |
| 37 | + |
| 38 | + bsize:19; # equality |
| 39 | + bsize:=0x13; # equality |
| 40 | + bsize:!0x14; # inequality |
| 41 | + bsize:!=20; # inequality |
| 42 | + bsize:>21; # greater than |
| 43 | + bsize:>=21; # greater than or equal |
| 44 | + bsize:<22; # lesser than |
| 45 | + bsize:<=22; # lesser than or equal |
| 46 | + bsize:19-22; # range between value1 and value2 |
| 47 | + bsize:!19-22; # negated range between value1 and value2 |
| 48 | + bsize:&0xc0=0x80; # bitmask mask is compared to value for equality |
| 49 | + bsize:&0xc0!=0; # bitmask mask is compared to value for inequality |
| 50 | + |
| 51 | +Enumerations |
| 52 | +------------ |
| 53 | + |
| 54 | +Some integers on the wire represent an enumeration, that is, some values |
| 55 | +have a string/meaning associated to it. |
| 56 | +Rules can be written using one of these strings to check for equality. |
| 57 | +This is meant to make rules more human-readable and equivalent for matching. |
| 58 | + |
| 59 | +Examples:: |
| 60 | + |
| 61 | + websocket.opcode:text; |
| 62 | + websocket.opcode:1; # behaves the same |
| 63 | + |
| 64 | +Bitmasks |
| 65 | +-------- |
| 66 | + |
| 67 | +Some integers on the wire represent multiple bits. |
| 68 | +Some of these bits have a string/meaning associated to it. |
| 69 | +Rules can be written using a list (comma-separated) of these strings, |
| 70 | +where each item can be negated. |
| 71 | + |
| 72 | +Examples:: |
| 73 | + |
| 74 | + websocket.flags:fin,!comp; |
| 75 | + websocket.flags:&0xc0=0x80; # behaves the same |
0 commit comments