-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
detect: add ldap operation keywords - v4 #12447
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,3 +50,4 @@ Suricata Rules | |
multi-buffer-matching | ||
tag | ||
vlan-keywords | ||
ldap-keywords |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
LDAP Keywords | ||
============= | ||
|
||
.. role:: example-rule-action | ||
.. role:: example-rule-header | ||
.. role:: example-rule-options | ||
.. role:: example-rule-emphasis | ||
|
||
LDAP Request and Response operations | ||
------------------------------------ | ||
|
||
.. table:: **Operation values for ldap.request.operation and ldap.responses.operation keywords** | ||
|
||
==== ================================================ | ||
Code Operation | ||
==== ================================================ | ||
0 bind_request | ||
1 bind_response | ||
2 unbind_request | ||
3 search_request | ||
4 search_result_entry | ||
5 search_result_done | ||
6 modify_request | ||
7 modify_response | ||
8 add_request | ||
9 add_response | ||
10 del_request | ||
11 del_response | ||
12 mod_dn_request | ||
13 mod_dn_response | ||
14 compare_request | ||
15 compare_response | ||
16 abandon_request | ||
19 search_result_reference | ||
23 extended_request | ||
24 extended_response | ||
25 intermediate_response | ||
==== ================================================ | ||
|
||
The keywords ldap.request.operation and ldap.responses.operation | ||
accept both the operation code and the operation name as arguments. | ||
|
||
ldap.request.operation | ||
---------------------- | ||
|
||
Suricata has a ``ldap.request.operation`` keyword that can be used in signatures to identify | ||
and filter network packets based on Lightweight Directory Access Protocol request operations. | ||
|
||
Syntax:: | ||
|
||
ldap.request.operation: operation; | ||
|
||
ldap.request.operation uses :ref:`unsigned 8-bit integer <rules-integer-keywords>`. | ||
|
||
This keyword maps to the eve field ``ldap.request.operation`` | ||
|
||
Examples | ||
^^^^^^^^ | ||
|
||
Example of a signatures that would alert if the packet has an LDAP bind request operation: | ||
|
||
.. container:: example-rule | ||
|
||
alert tcp any any -> any any (msg:"Test LDAP bind request"; :example-rule-emphasis:`ldap.request.operation:0;` sid:1;) | ||
|
||
.. container:: example-rule | ||
|
||
alert tcp any any -> any any (msg:"Test LDAP bind request"; :example-rule-emphasis:`ldap.request.operation:bind_request;` sid:1;) | ||
|
||
ldap.responses.operation | ||
------------------------ | ||
|
||
Suricata has a ``ldap.responses.operation`` keyword that can be used in signatures to identify | ||
and filter network packets based on Lightweight Directory Access Protocol response operations. | ||
|
||
Syntax:: | ||
|
||
ldap.responses.operation: operation[,index]; | ||
|
||
ldap.responses.operation uses :ref:`unsigned 8-bit integer <rules-integer-keywords>`. | ||
|
||
This keyword maps to the eve field ``ldap.responses[].operation`` | ||
|
||
An LDAP request operation can receive multiple responses. By default, the ldap.responses.operation | ||
keyword matches all indices, but it is possible to specify a particular index for matching | ||
and also use flags such as ``all`` and ``any``. | ||
|
||
.. table:: **Index values for ldap.responses.operation keyword** | ||
|
||
========= ================================================ | ||
Value Description | ||
========= ================================================ | ||
[default] Match with any index | ||
all Match only if all indexes match | ||
any Match with any index | ||
0>= Match specific index | ||
0< Match specific index with back to front indexing | ||
========= ================================================ | ||
|
||
Examples | ||
^^^^^^^^ | ||
|
||
Example of a signatures that would alert if the packet has an LDAP bind response operation: | ||
|
||
.. container:: example-rule | ||
|
||
alert tcp any any -> any any (msg:"Test LDAP bind response"; :example-rule-emphasis:`ldap.responses.operation:1;` sid:1;) | ||
|
||
.. container:: example-rule | ||
|
||
alert tcp any any -> any any (msg:"Test LDAP bind response"; :example-rule-emphasis:`ldap.responses.operation:bind_response;` sid:1;) | ||
|
||
Example of a signature that would alert if the packet has an LDAP search_result_done response operation at index 1: | ||
|
||
.. container:: example-rule | ||
|
||
alert tcp any any -> any any (msg:"Test LDAP search response"; :example-rule-emphasis:`ldap.responses.operation:search_result_done,1;` sid:1;) | ||
|
||
Example of a signature that would alert if all the responses are of type search_result_entry: | ||
|
||
.. container:: example-rule | ||
|
||
alert tcp any any -> any any (msg:"Test LDAP search response"; :example-rule-emphasis:`ldap.responses.operation:search_result_entry,all;` sid:1;) | ||
|
||
The keyword ldap.responses.operation supports back to front indexing with negative numbers, | ||
this means that -1 will represent the last index, -2 the second to last index, and so on. | ||
This is an example of a signature that would alert if a search_result_entry response is found at the last index: | ||
|
||
.. container:: example-rule | ||
|
||
alert tcp any any -> any any (msg:"Test LDAP search response"; :example-rule-emphasis:`ldap.responses.operation:search_result_entry,-1;` sid:1;) | ||
|
||
ldap.responses.count | ||
-------------------- | ||
|
||
Matches based on the number of responses. | ||
|
||
Syntax:: | ||
|
||
ldap.responses.count: [op]number; | ||
|
||
It can be matched exactly, or compared using the ``op`` setting:: | ||
|
||
ldap.responses.count:3 # exactly 3 responses | ||
ldap.responses.count:<3 # less than 3 responses | ||
ldap.responses.count:>=2 # more or equal to 2 responses | ||
|
||
ldap.responses.count uses :ref:`unsigned 32-bit integer <rules-integer-keywords>`. | ||
|
||
This keyword maps to the eve field ``len(ldap.responses[])`` | ||
|
||
Examples | ||
^^^^^^^^ | ||
|
||
Example of a signature that would alert if a packet has 0 LDAP responses: | ||
|
||
.. container:: example-rule | ||
|
||
alert ip any any -> any any (msg:"Packet has 0 LDAP responses"; :example-rule-emphasis:`ldap.responses.count:0;` sid:1;) | ||
|
||
Example of a signature that would alert if a packet has more than 2 LDAP responses: | ||
|
||
.. container:: example-rule | ||
|
||
alert ip any any -> any any (msg:"Packet has more than 2 LDAP responses"; :example-rule-emphasis:`ldap.responses.count:>2;` sid:1;) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lukashino what do you think about this ? cf your work on #11951
Especially, is the log field written the correct way ?
Here this is a simple case, but what about the 2 others with arrays :
ldap.responses[].operation
andlen(ldap.responses[])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also should we update schema.json to document the revert mapping ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @jasonish had some more thoughts about this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to document my thoughts more throuroughly somewhere, but I think its just a simplified version of what @lukashino had previous proposed. Looking at LDAP and the schema we see:
We could extend it out like:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More here: #11951 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I understand that the PR is good as is, and we wait for a decision on what needs to be updated in the schema.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think Victor was just poking me here so I'd write down some thoughts I had on the matter.