Skip to content

Commit cd32edc

Browse files
committed
doc: integer keywords
Ticket: 6628 Document the generic detection capabilities for integer keywords. and make every integer keyword pointing to this section.
1 parent f27ea82 commit cd32edc

13 files changed

Lines changed: 128 additions & 0 deletions

‎doc/userguide/rules/dhcp-keywords.rst‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ dhcp.leasetime
66

77
DHCP lease time (integer).
88

9+
dhcp.leasetime uses an :ref:`unsigned 64-bits integer <rules-integer-keywords>`.
10+
911
Syntax::
1012

1113
dhcp.leasetime:[op]<number>
@@ -25,6 +27,8 @@ dhcp.rebinding_time
2527

2628
DHCP rebinding time (integer).
2729

30+
dhcp.rebinding_time uses an :ref:`unsigned 64-bits integer <rules-integer-keywords>`.
31+
2832
Syntax::
2933

3034
dhcp.rebinding_time:[op]<number>
@@ -44,6 +48,8 @@ dhcp.renewal_time
4448

4549
DHCP renewal time (integer).
4650

51+
dhcp.renewal_time uses an :ref:`unsigned 64-bits integer <rules-integer-keywords>`.
52+
4753
Syntax::
4854

4955
dhcp.renewal_time:[op]<number>

‎doc/userguide/rules/file-keywords.rst‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ filesize
244244

245245
Match on the size of the file as it is being transferred.
246246

247+
filesize uses an :ref:`unsigned 64-bits integer <rules-integer-keywords>`.
248+
247249
Syntax::
248250

249251
filesize:<value>;

‎doc/userguide/rules/flow-keywords.rst‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,8 @@ flow.age
292292
Flow age in seconds (integer)
293293
This keyword does not wait for the end of the flow, but will be checked at each packet.
294294

295+
flow.age uses an :ref:`unsigned 32-bits integer <rules-integer-keywords>`.
296+
295297
Syntax::
296298

297299
flow.age: [op]<number>
@@ -314,6 +316,8 @@ flow.pkts_toclient
314316
Flow number of packets to client (integer)
315317
This keyword does not wait for the end of the flow, but will be checked at each packet.
316318

319+
flow.pkts_toclient uses an :ref:`unsigned 32-bits integer <rules-integer-keywords>`.
320+
317321
Syntax::
318322

319323
flow.pkts_toclient: [op]<number>
@@ -334,6 +338,8 @@ flow.pkts_toserver
334338
Flow number of packets to server (integer)
335339
This keyword does not wait for the end of the flow, but will be checked at each packet.
336340

341+
flow.pkts_toserver uses an :ref:`unsigned 32-bits integer <rules-integer-keywords>`.
342+
337343
Syntax::
338344

339345
flow.pkts_toserver: [op]<number>
@@ -354,6 +360,8 @@ flow.bytes_toclient
354360
Flow number of bytes to client (integer)
355361
This keyword does not wait for the end of the flow, but will be checked at each packet.
356362

363+
flow.bytes_toclient uses an :ref:`unsigned 64-bits integer <rules-integer-keywords>`.
364+
357365
Syntax::
358366

359367
flow.bytes_toclient: [op]<number>
@@ -374,6 +382,8 @@ flow.bytes_toserver
374382
Flow number of bytes to server (integer)
375383
This keyword does not wait for the end of the flow, but will be checked at each packet.
376384

385+
flow.bytes_toserver uses an :ref:`unsigned 64-bits integer <rules-integer-keywords>`.
386+
377387
Syntax::
378388

379389
flow.bytes_toserver: [op]<number>

‎doc/userguide/rules/header-keywords.rst‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ For example::
1515

1616
ttl:10;
1717

18+
ttl uses an :ref:`unsigned 8-bits integer <rules-integer-keywords>`.
19+
1820
At the end of the ttl keyword you can enter the value on which you
1921
want to match. The Time-to-live value determines the maximal amount
2022
of time a packet can be in the Internet-system. If this field is set
@@ -431,6 +433,8 @@ tcp.mss
431433
Match on the TCP MSS option value. Will not match if the option is not
432434
present.
433435

436+
tcp.mss uses an :ref:`unsigned 16-bits integer <rules-integer-keywords>`.
437+
434438
The format of the keyword::
435439

436440
tcp.mss:<min>-<max>;
@@ -506,6 +510,8 @@ messages. The different messages are distinct by different names, but
506510
more important by numeric values. For more information see the table
507511
with message-types and codes.
508512

513+
itype uses an :ref:`unsigned 8-bits integer <rules-integer-keywords>`.
514+
509515
The format of the itype keyword::
510516

511517
itype:min<>max;
@@ -565,6 +571,8 @@ code of a ICMP message clarifies the message. Together with the
565571
ICMP-type it indicates with what kind of problem you are dealing with.
566572
A code has a different purpose with every ICMP-type.
567573

574+
icode uses an :ref:`unsigned 8-bits integer <rules-integer-keywords>`.
575+
568576
The format of the icode keyword::
569577

570578
icode:min<>max;
@@ -719,6 +727,8 @@ icmpv6.mtu
719727
Match on the ICMPv6 MTU optional value. Will not match if the MTU is not
720728
present.
721729

730+
icmpv6.mtu uses an :ref:`unsigned 32-bits integer <rules-integer-keywords>`.
731+
722732
The format of the keyword::
723733

724734
icmpv6.mtu:<min>-<max>;

‎doc/userguide/rules/http-keywords.rst‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ The ``urilen`` keyword is used to match on the length of the request
237237
URI. It is possible to use the ``<`` and ``>`` operators, which
238238
indicate respectively *smaller than* and *larger than*.
239239

240+
urilen uses an :ref:`unsigned 64-bits integer <rules-integer-keywords>`.
241+
240242
The format of ``urilen`` is::
241243

242244
urilen:3;

‎doc/userguide/rules/http2-keywords.rst‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ http2.priority
3131

3232
Match on the value of the HTTP2 priority field present in a PRIORITY or HEADERS frame.
3333

34+
http2.priority uses an :ref:`unsigned 8-bits integer <rules-integer-keywords>`.
35+
3436
This keyword takes a numeric argument after a colon and supports additional qualifiers, such as:
3537

3638
* ``>`` (greater than)
@@ -49,6 +51,8 @@ http2.window
4951

5052
Match on the value of the HTTP2 value field present in a WINDOWUPDATE frame.
5153

54+
http2.window uses an :ref:`unsigned 32-bits integer <rules-integer-keywords>`.
55+
5256
This keyword takes a numeric argument after a colon and supports additional qualifiers, such as:
5357

5458
* ``>`` (greater than)
@@ -68,6 +72,8 @@ Match on the size of the HTTP2 Dynamic Headers Table.
6872
More information on the protocol can be found here:
6973
`<https://tools.ietf.org/html/rfc7541#section-6.3>`_
7074

75+
http2.size_update uses an :ref:`unsigned 64-bits integer <rules-integer-keywords>`.
76+
7177
This keyword takes a numeric argument after a colon and supports additional qualifiers, such as:
7278

7379
* ``>`` (greater than)

‎doc/userguide/rules/ike-keywords.rst‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ ike.exchtype
6161

6262
Match on the value of the Exchange Type.
6363

64+
ike.exchtype uses an :ref:`unsigned 8-bits integer <rules-integer-keywords>`.
65+
6466
This keyword takes a numeric argument after a colon and supports additional qualifiers, such as:
6567

6668
* ``>`` (greater than)
@@ -106,6 +108,8 @@ ike.key_exchange_payload_length
106108

107109
Match against the length of the public key exchange payload (e.g. Diffie-Hellman) of the server or client.
108110

111+
ike.key_exchange_payload_length uses an :ref:`unsigned 32-bits integer <rules-integer-keywords>`.
112+
109113
This keyword takes a numeric argument after a colon and supports additional qualifiers, such as:
110114

111115
* ``>`` (greater than)
@@ -138,6 +142,8 @@ ike.nonce_payload_length
138142

139143
Match against the length of the nonce of the server or client.
140144

145+
ike.nonce_payload_length uses an :ref:`unsigned 32-bits integer <rules-integer-keywords>`.
146+
141147
This keyword takes a numeric argument after a colon and supports additional qualifiers, such as:
142148

143149
* ``>`` (greater than)

‎doc/userguide/rules/index.rst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Suricata Rules
77
meta
88
header-keywords
99
payload-keywords
10+
integer-keywords
1011
transforms
1112
prefilter-keywords
1213
flow-keywords
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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

‎doc/userguide/rules/mqtt-keywords.rst‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ mqtt.protocol_version
88

99
Match on the value of the MQTT protocol version field in the fixed header.
1010

11+
mqtt.protocol_version uses an :ref:`unsigned 8-bits integer <rules-integer-keywords>`.
12+
1113
The format of the keyword::
1214

1315
mqtt.protocol_version:<min>-<max>;

0 commit comments

Comments
 (0)