zeek/testing/btest/signatures/dpd.bro
Jon Siwek e835a55229 Add IPv6 support to signature header conditions.
- "src-ip" and "dst-ip" conditions can now use IPv6 addresses/subnets.
  They must be written in colon-hexadecimal representation and enclosed
  in square brackets (e.g. [fe80::1]).  Addresses #774.

- "icmp6" is now a valid protocol for use with "ip-proto" and "header"
  conditions.  This allows signatures to be written that can match
  against ICMPv6 payloads.  Addresses #880.

- "ip6" is now a valid protocol for use with the "header" condition.
  (also the "ip-proto" condition, but it results in a no-op in that
  case since signatures apply only to the inner-most IP packet when
  packets are tunneled).  This allows signatures to match specifically
  against IPv6 packets (whereas "ip" only matches against IPv4 packets).

- "ip-proto" conditions can now match against IPv6 packets.  Before,
  IPv6 packets were just silently ignored which meant DPD based on
  signatures did not function for IPv6 -- protocol analyzers would only
  get attached to a connection over IPv6 based on the well-known ports
  set in the "dpd_config" table.
2012-10-17 11:11:51 -05:00

54 lines
1.6 KiB
Text

# @TEST-EXEC: bro -b -s myftp -r $TRACES/ftp-ipv4.trace %INPUT >dpd-ipv4.out
# @TEST-EXEC: bro -b -s myftp -r $TRACES/ipv6-ftp.trace %INPUT >dpd-ipv6.out
# @TEST-EXEC: bro -b -r $TRACES/ftp-ipv4.trace %INPUT >nosig-ipv4.out
# @TEST-EXEC: bro -b -r $TRACES/ipv6-ftp.trace %INPUT >nosig-ipv6.out
# @TEST-EXEC: btest-diff dpd-ipv4.out
# @TEST-EXEC: btest-diff dpd-ipv6.out
# @TEST-EXEC: btest-diff nosig-ipv4.out
# @TEST-EXEC: btest-diff nosig-ipv6.out
# DPD based on 'ip-proto' and 'payload' signatures should be independent
# of IP protocol.
@TEST-START-FILE myftp.sig
signature my_ftp_client {
ip-proto == tcp
payload /(|.*[\n\r]) *[uU][sS][eE][rR] /
tcp-state originator
event "matched my_ftp_client"
}
signature my_ftp_server {
ip-proto == tcp
payload /[\n\r ]*(120|220)[^0-9].*[\n\r] *(230|331)[^0-9]/
tcp-state responder
requires-reverse-signature my_ftp_client
enable "ftp"
event "matched my_ftp_server"
}
@TEST-END-FILE
@load base/utils/addrs
event bro_init()
{
# no analyzer attached to any port by default, depends entirely on sigs
print "dpd_config", dpd_config;
}
event signature_match(state: signature_state, msg: string, data: string)
{
print fmt("signature_match %s - %s", state$conn$id, msg);
}
event ftp_request(c: connection, command: string, arg: string)
{
print fmt("ftp_request %s:%s - %s %s", addr_to_uri(c$id$orig_h),
port_to_count(c$id$orig_p), command, arg);
}
event ftp_reply(c: connection, code: count, msg: string, cont_resp: bool)
{
print fmt("ftp_reply %s:%s - %s %s", addr_to_uri(c$id$resp_h),
port_to_count(c$id$resp_p), code, msg);
}