An SNMP parser, implemented with the nom parser combinator framework.
It is written in pure Rust, fast, and makes extensive use of zero-copy. It also aims to be panic-free.
The goal of this parser is to implement SNMP messages analysis, for example to use rules from a network IDS.
To read a message, different functions must be used depending on the expected message
version.
This crate implements the [asn1_rs::FromBer
] trait, so to parse a message, use the
expected object and call function from_ber
.
For example, to parse a SNMP v1 or v2c message (message structure is the same), use
[SnmpMessage
]::from_ber(input)
.
To parse a SNMP v3 message, use [SnmpV3Message
]::from_ber(input)
.
If you don't know the version of the message and want to parse a generic SNMP message,
use [SnmpGenericMessage
]::from_ber(input)
.
Other methods of parsing (functions) are provided for compatibility:
these functions are parse_snmp_v1
,
parse_snmp_v2c
and
parse_snmp_v3
.
If you don't know the version of the message and want to parse a generic SNMP message,
use the parse_snmp_generic_message
function.
The code is available on Github and is part of the Rusticata project.
- Update asn1-rs to 0.7
- Update thiserror to 2.0
- Fix clippy warnings: elided lifetime has a name
- Use
#[from]
instead of From impl for asn1 error - Re-export
Oid
andOidParseError
- Fix renamed lint
- Implement
FromBer
for all top-level messages
Thanks: @MattesWhite
- Update asn1-rs to 0.6
- Convert to asn1-rs
- Set MSRV to 1.57
- Upgrade to nom 7 / der-parser 6
- Upgrade to nom 6 / der-parser 5
- Upgrade to der-parser 4
- Use
parse_ber_u32
from der-parser crate
- Fix parsing: use BER parsing so DER constraints are not applied
- Upgrade to nom 5 and der-parser 3
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.