Skip to content

Commit

Permalink
enip: convert to rust
Browse files Browse the repository at this point in the history
Ticket: 3958

- enip_command keyword accepts now string enumeration as values.
- transactions are now bidirectional
- there is a logger
- gap support is improved with probing for resync
- SEQUENCE_ADDR_ITEM value is fixed to 0x8002 instead of 0xB002
- frames support
- app-layer events
- add enip.status keyword
- add identity keywords :
    enip.product_name, enip.protocol_version, enip.revision,
    enip.identity_status, enip.state, enip.serial, enip.product_code,
    enip.device_type, enip.vendor_id, enip.capabilities,
    enip.cip_attribute, enip.cip_class, enip.cip_instance,
    enip.cip_status, enip.cip_extendedstatus
  • Loading branch information
catenacyber committed Dec 1, 2023
1 parent d84c41b commit 5e86426
Show file tree
Hide file tree
Showing 63 changed files with 7,198 additions and 2,656 deletions.
3 changes: 2 additions & 1 deletion doc/userguide/configuration/suricata-yaml.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1761,7 +1761,8 @@ incompatible with ``decode-mime``. If both are enabled,
Maximum transactions
~~~~~~~~~~~~~~~~~~~~

MQTT, FTP, PostgreSQL, SMB, DCERPC and NFS have each a `max-tx` parameter that can be customized.
MQTT, FTP, PostgreSQL, SMB, DCERPC, ENIP and NFS have each a `max-tx`
parameter that can be customized.
`max-tx` refers to the maximum number of live transactions for each flow.
An app-layer event `protocol.too_many_transactions` is triggered when this value is reached.
The point of this parameter is to find a balance between the completeness of analysis
Expand Down
219 changes: 202 additions & 17 deletions doc/userguide/rules/enip-keyword.rst
Original file line number Diff line number Diff line change
@@ -1,40 +1,225 @@
ENIP/CIP Keywords
=================

The enip_command and cip_service keywords can be used for matching on various properties of
ENIP requests.
enip_command
------------

There are three ways of using this keyword:
For the ENIP command, we are matching against the command field found in the ENIP encapsulation.

Examples::

* matching on ENIP command with the setting "enip_command";
* matching on CIP Service with the setting "cip_service".
* matching both the ENIP command and the CIP Service with "enip_command" and "cip_service" together
enip_command:99;
enip_command:ListIdentity;


For the ENIP command, we are matching against the command field found in the ENIP encapsulation.
cip_service
-----------

For the CIP Service, we use a maximum of 3 comma separated values representing the Service, Class and Attribute.
These values are described in the CIP specification. CIP Classes are associated with their Service, and CIP Attributes
are associated with their Service. If you only need to match up until the Service, then only provide the Service value.
If you want to match to the CIP Attribute, then you must provide all 3 values.


Syntax::

enip_command:<value>
cip_service:<value(s)>
enip_command:<value>, cip_service:<value(s)>


Examples::

enip_command:99
cip_service:75
cip_service:16,246,6
enip_command:111, cip_service:5


(cf. http://read.pudn.com/downloads166/ebook/763211/EIP-CIP-V1-1.0.pdf)

Information on the protocol can be found here:
`<http://literature.rockwellautomation.com/idc/groups/literature/documents/wp/enet-wp001_-en-p.pdf>`_

enip.status
-----------

For the ENIP status, we are matching against the status field found in the ENIP encapsulation.
It uses a 32-bit unsigned integer as value.

Examples::

enip.status:100;
enip.status:>106;

enip.protocol_version
---------------------

Match on the protocol version in different messages.
It uses a 16-bit unsigned integer as value.

Examples::

enip.protocol_version:1;
enip.protocol_version:>1;

enip.cip_attribute
------------------

Match on the cip attribute in different messages.
It uses a 32-bit unsigned integer as value.

This allows to match without needing to match on cip.service.

Examples::

enip.cip_attribute:1;
enip.cip_attribute:>1;

enip.cip_instance
-----------------

Match on the cip instance in CIP request path.
It uses a 32-bit unsigned integer as value.

Examples::

enip.cip_instance:1;
enip.cip_instance:>1;

enip.cip_class
--------------

Match on the cip class in CIP request path.
It uses a 32-bit unsigned integer as value.

This allows to match without needing to match on cip.service.

Examples::

enip.cip_class:1;
enip.cip_class:>1;

enip.cip_extendedstatus
-----------------------

Match on the cip extended status if any (one of them in case of multiple service packet).
It uses a 16-bit unsigned integer as value.

Examples::

enip.cip_extendedstatus:1;
enip.cip_extendedstatus:>1;

enip.revision
---------------------

Match on the revision in identity message.
It uses a 16-bit unsigned integer as value.

Examples::

enip.revision:1;
enip.revision:>1;

enip.identity_status
--------------------

Match on the status in identity message (not in ENIP header).
It uses a 16-bit unsigned integer as value.

Examples::

enip.identity_status:1;
enip.identity_status:>1;

enip.state
----------

Match on the state in identity message.
It uses a 8-bit unsigned integer as value.

Examples::

enip.state:1;
enip.state:>1;

enip.serial
-----------

Match on the serial in identity message.
It uses a 32-bit unsigned integer as value.

Examples::

enip.serial:1;
enip.serial:>1;

enip.product_code
-----------------

Match on the product code in identity message.
It uses a 16-bit unsigned integer as value.

Examples::

enip.product_code:1;
enip.product_code:>1;

enip.device_type
----------------

Match on the device type in identity message.
It uses a 16-bit unsigned integer as value.

Examples::

enip.device_type:1;
enip.device_type:>1;

enip.vendor_id
--------------

Match on the vendor id in identity message.
It uses a 16-bit unsigned integer as value.

Examples::

enip.vendor_id:1;
enip.vendor_id:>1;

enip.product_name
-----------------

Match on the product name in identity message.

Examples::

enip.product_name; pcre:"/^123[0-9]*/";
enip.product_name; content:"swordfish";

``enip.product_name`` is a 'sticky buffer' and can be used as ``fast_pattern``.

enip.service_name
-----------------

Match on the service name in list services message.

Examples::

enip.service_name; pcre:"/^123[0-9]*/";
enip.service_name; content:"swordfish";

``enip.service_name`` is a 'sticky buffer' and can be used as ``fast_pattern``.

enip.capabilities
-----------------

Match on the capabilities in list services message.
It uses a 16-bit unsigned integer as value.

Examples::

enip.capabilities:1;
enip.capabilities:>1;

enip.cip_status
---------------------

Match on the cip status (one of them in case of multiple service packet).
It uses a 8-bit unsigned integer as value.

Examples::

enip.cip_status:1;
enip.cip_status:>1;
Loading

0 comments on commit 5e86426

Please sign in to comment.