Commit graph

1917 commits

Author SHA1 Message Date
Arne Welzel
48e76f38cb mysql: Make auth_plugin_ a std::string 2024-07-25 11:53:40 +02:00
Arne Welzel
e98b80d140 mysql: Fix auth_plugin_data_part2 length computation 2024-07-25 11:53:40 +02:00
Fupeng Zhao
c82756bda4 Refactored connection phase state handling
Added `ConnectionExpected` enum for expected packet types during the connection phase.
2024-07-25 11:53:40 +02:00
Fupeng Zhao
e8bdf149f2 Add support for "auth switch" and "query attrs"
Also fix the issue where Resultset could not correctly distinguish between EOF_Packet and OK_Packet.
2024-07-25 11:53:40 +02:00
Fupeng Zhao
9cb618c718 Add support for parsing the "caching_sha2_password" auth plugin 2024-07-25 11:53:35 +02:00
Tim Wojtulewicz
2844d54f67 Fix handling of zero-length SMB2 error responses 2024-07-24 12:44:46 -07:00
Johanna Amann
7c0c48b290 Spicy TLS - refactoring and partial connection fix
The analyzer now detects partial connections at the beginning of a
connection - and will skip them. This makes behavior more similar to the
binpac analyzer.

The decryption test is skipped.

And some minor refacoring.
2024-07-23 15:34:10 +01:00
Arne Welzel
d4778f451c ldap: Add heuristic for wrap tokens
Instead of dissecting the GSSAPI handshake, add another heuristic
into MaybeEncrypted to check for the WRAP token identifier.

After this change, the pcap on the following ticket is processed
nicely: https://gitlab.com/wireshark/migration-test/-/issues/9398
2024-07-23 11:29:00 +02:00
Arne Welzel
ca25516e03 ldap: Ignore ec/rrc for sealed wrap tokens
It shouldn't matter for the encrypted payload that we'll
just consume and ignore.
2024-07-23 11:29:00 +02:00
Arne Welzel
3846db6ccf ldap: Reintroduce encryption after SASL heuristic
@dopheide-esnet provided sample captures where SASL SRP is used as
a SASL mechanism and the follow-up LDAP messages are encrypted. It's
not clear how to determine whether encryption will or will not happen,
so re-add a heuristic to determine this based on the first byte of
the first message *after* the successful bindResponse handshake. If
that byte is 0x30, assume cleartext.

I haven't been able to produce such pcaps, unfortunately, but the
cleartext path is tested via the existing sasl-ntlm.pcap.
2024-07-23 11:29:00 +02:00
Arne Welzel
724c08f286 ldap: Fix assuming GSS-SPNEGO for all bindResponses
In retrospect that's an obvious bug.
2024-07-23 11:29:00 +02:00
Arne Welzel
09a48c7028 ldap: Implement extended request/response and StartTLS support
PCAP was produced with a local OpenLDAP server configured to support StartTLS.

This puts the Zeek calls into a separate ldap_zeek.spicy file/module
to separate it from LDAP.
2024-07-23 11:29:00 +02:00
Johanna Amann
f95f5d2adb Merge remote-tracking branch 'origin/master' into topic/johanna/spicy-tls
* origin/master:
  Update broker submodule [nomail]
  telemetry: Deprecate prometheus.zeek policy script
  input/Manager: Improve type checks of record fields with type any
  Bump zeek-testing-cluster to pull in tee SIGPIPE fix
  ldap: Remove MessageWrapper with magic 0x30 searching
  ldap: Harden parsing a bit
  ldap: Handle integrity-only KRB wrap tokens
  Bump auxil/spicy to latest development snapshot
  CI: Set FETCH_CONTENT_FULLY_DISCONNECTED flag for configure
  Update broker and cmake submodules [nomail]
  Fix a broken merge
  Do not emit hook files for builtin modules
  Fix warning about grealpath when running 'make dist' on Linux
  Start of 7.1.0 development
  Updating submodule(s) [nomail]
  Update the scripts.base.frameworks.telemetry.internal-metrics test
  Revert "Temporarily disable the scripts/base/frameworks/telemetry/internal-metrics btest"
  Bump Broker to pull in new Prometheus support and pass in Zeek's registry
  Do not emit hook files for builtin modules
2024-07-23 10:21:49 +01:00
Arne Welzel
e7aca5b388 ldap: Remove MessageWrapper with magic 0x30 searching
This unit implements a heuristic to search for the 0x30 sequence
byte if Message couldn't readily be parsed. Remove it with the
idea of explicit and predictable support for SASL mechanisms.
2024-07-17 15:28:27 +02:00
Arne Welzel
0cab87c185 ldap: Harden parsing a bit
ASN1Message(True) may go off parsing arbitrary input data as
"something ASN.1" This could be GBs of octet strings or just very
long sequences. Avoid this by open-coding some top-level types expected.

This also tries to avoid some of the &parse-from usages that result
in unnecessary copies of data.

Adds a locally generated PCAP with addRequest/addResponse that we
don't currently handle.
2024-07-17 15:27:14 +02:00
Arne Welzel
31122f335f ldap: Handle integrity-only KRB wrap tokens
Mostly staring at the PCAPs and opened a few RFCs. For now, only if the
MS_KRB5 OID is used and accepted in a bind response, start stripping
KRB5 wrap tokens for both, client and server traffic.

Would probably be nice to forward the GSS-API data to the analyzer...

Closes zeek/spicy-ldap#29.
2024-07-17 15:26:30 +02:00
Johanna Amann
990c97b5ba Spicy SSL - run spicy-format 2024-07-17 12:51:13 +01:00
Johanna Amann
f36be3dafc Spicy-TLS: address review feedback re convert-functions
This switches convert-functions from being called in the evt file to
being called directly in the spicy file.

See GH-3765 for details.
2024-07-17 12:44:14 +01:00
Benjamin Bannier
41db05238b Bump auxil/spicy to latest development snapshot
This patch bump Spicy to the latest development snapshot. This
introduces a backwards-incompatible change in that it removes support
for a never officially supported syntax to specify unit fields (so I
would argue: not strictly a breaking change).
2024-07-16 08:17:31 +02:00
Johanna Amann
4acd0297b0 Merge remote-tracking branch 'origin/master' into topic/johanna/spicy-tls
* origin/master: (89 commits)
  Update doc submodule [nomail] [skip ci]
  Bump cmake submodule [nomail]
  testing/btest: Default to HILTI_JIT_PARALLELISM=1
  Revert "CI: Use ccache and a single CPU when building spicy analyzers for btests"
  Update doc submodule [nomail] [skip ci]
  CI: Use ccache and a single CPU when building spicy analyzers for btests
  Extend btest for logging of disabled analyzers
  Update zeek-aux submodule [nomail]
  Add logging of disabled analyzers to analyzer.log
  Bump auxil/spicy to latest development snapshot
  Management framework: bump cluster testsuite to pull in telemetry tests
  Management framework: bump zeek-client
  Management framework: augment deployed configs with instance IP addresses
  Management framework: add auto-enumeration of metrics ports
  Management framework: propagate metrics port from agent
  Management framework: add metrics port in management & Supervisor node records
  Harden the telemetry manager against unset Telemetry::metrics_address
  Comment-only tweaks for telemetry-related settings.
  Fix for --display-cmake in configure Moved build directory creation further down in the script so that --display-cmake has a chance to happen before build tree setup.
  Update submodules [nomail]
  ...
2024-07-11 14:02:28 +01:00
Arne Welzel
377fd711bd HTTP: Implement FlipRoles()
When Zeek flips roles of a HTTP connection subsequent to the HTTP analyzer
being attached, that analyzer would not update its own ContentLine analyzer
state, resulting in the wrong ContentLine analyzer being switched into
plain delivery mode.

In debug builds, this would result in assertion failures, in production
builds, the HTTP analyzer would receive HTTP bodies as individual header
lines, or conversely, individual header lines would be delivered as a
large chunk from the ContentLine analyzer.

PCAPs were generated locally using tcprewrite to select well-known-http ports
for both endpoints, then editcap to drop the first SYN packet.

Kudos to @JordanBarnartt for keeping at it.

Closes #3789
2024-07-04 11:38:33 +02:00
Arne Welzel
c6368fc3f0 ContentLineAnalyzer: Add getter for skip_partial 2024-07-04 11:38:24 +02:00
Johanna Amann
0f27657418 Spicy TLS: address review feedback & run spicy-lint 2024-06-20 10:10:10 +01:00
Arne Welzel
5dfff4492c ssh: Revert half-duplex robustness
This reverts part of commit a0888b7e36 due
to inhibiting analyzer violations when parsing non SSH traffic when
the &restofdata path is entered.

@J-Gras reported the analyzer not being disabled when sending HTTP
traffic on port 22.

This adds the verbose analyzer.log baselines such that future improvements
of these scenarios become visible.
2024-06-19 16:04:51 +02:00
Robin Sommer
956e147f70
Bump Spicy. 2024-06-14 13:10:47 +02:00
Johanna Amann
95506ab149 Spicy TLS: disable debug prints 2024-06-04 14:50:52 +01:00
Johanna Amann
4cce4a4c5f Add configure option to enable/disable spicy SSL
Spicy SSL is now only enabled when specifying the --enable-spicy-ssl
configure-time option.

This should allow merging this into Zeek on an experimental basis.
2024-06-04 14:13:59 +01:00
Johanna Amann
adab894d31 Merge remote-tracking branch 'origin/master' into topic/johanna/spicy-tls
* origin/master: (173 commits)
  Bump Spicy to latest dev snapshot
  Update docs submodule [nomail] [skip ci]
  Add type aliases for instrument and family shared_ptrs
  Update NEWS for double and is_sum changes
  Remove is_sum arguments from counters and gauges
  Change all instruments to only handle doubles
  Add comment to telemetry::Manager::InitPostScript
  Remove all of the ZEEK_METRICS_ environment variables
  Fix header comments in scripts/policy/frameworks/telemetry/prometheus.zeek
  Change all prometheus #includes to use angle brackets
  Update zeekctl submodule for metrics_port node.cfg option
  Regenerate docs [nomail]
  Remove the is_sum argument from BIF histogram creation methods
  Update NEWS for Telemetry rework
  Remove Telemetry::metrics_export_prefixes option
  Validate that label names are constant in non-zeek metrics
  Avoid calling Collect() in counter/gauge Value() methods if not needed
  Fix some determinism issues with btests
  Temporarily disable the scripts/base/frameworks/telemetry/internal-metrics btest
  Fix the scripts.policy.frameworks.telemetry.prometheus btest to use the service discovery endpoint
  ...
2024-06-04 13:27:35 +01:00
Robin Sommer
82be6425e6
Merge remote-tracking branch 'origin/topic/robin/gh-3561-forward-to-udp'
* origin/topic/robin/gh-3561-forward-to-udp:
  Update docs.
  Add explicit children life-cycle management method to analyzers.
  Spicy: Support UDP in Spicy's `protocol_*` runtime functions.
  Add method to analyzer to retrieve direct child by name.
  Extend PIA's `FirstPacket` API.
  Spicy: Prepare for supporting forwarding to protocols other than TCP.
2024-05-10 11:15:20 +02:00
Robin Sommer
93a424b28a
Spicy: Fix service reporting for replaced analyzers.
We accidentally applied analyzer mappings when looking up an
analyzer's name from scriptland.

Closes #3725.
2024-05-08 14:01:46 +02:00
Vern Paxson
a0888b7e36 make SSH analyzer robust to half-duplex connections 2024-05-07 11:40:47 -07:00
Robin Sommer
b4f68a2681
Add explicit children life-cycle management method to analyzers. 2024-05-07 18:19:47 +02:00
Robin Sommer
df3d50ea07
Add method to analyzer to retrieve direct child by name. 2024-05-07 18:19:46 +02:00
Robin Sommer
2ec44f098f
Extend PIA's FirstPacket API.
`FirstPacket()` so far supported only TCP. To extend this to UDP, we
move the method into the PIA base class; give it a protocol parameter
for the case that there's no actual packet is available; and add the
ability to create fake UDP packets as well, not just TCP.

This whole thing is pretty ugly to begin with, and this doesn't make
it nicer, but we need this extension that so we can feed UDP data into
the signature engine that's tunneled over other protocols. Without the
fake packets, DPD signatures in particular wouldn't have anything to
match on.
2024-05-07 18:19:46 +02:00
Robin Sommer
5d0c61e68b
Add component API to transparently remap one component to another one.
When a specific component is requested through its tag or name, one
can now have the component manager transparently return a different
one that has been registered to replace the original one. We limit
this to disabled components to avoid unnecessary confusion. That also
means that remappings are currently only supported for analyzers
(because other types of components cannot be disabled for now, per the
previous change).
2024-05-06 09:45:11 +02:00
Robin Sommer
ac1a7508ee
Move enabled/disabled functionality from analyzers into Component base class API.
The different analyzers types all had their own methods for
enabling/disabling their availability. This change abstracts that into
a new API inside their base class (`plugin::Component`) so that they
can be toggled in a unified way.

In principle, other types of components could/should use this as well
now, so that, e.g., an input reader's availability could be toggled at
runtime. The code doesn't make that broader change for now because it
would requires a series of changes wherever these other component
types are being used. However, that means that one now could try
toggling some other component through the new API without that having
any effect. To catch that, there's a runtime check in place that turns
any such attempt into an internal error.
2024-05-06 09:45:11 +02:00
Vern Paxson
68aa8221e1 factor some functionality used by BiFs to make accessible to ZAM instructions 2024-04-25 09:15:13 -07:00
Tim Wojtulewicz
bac6ad62b5 Allow SMB_TCP record to contain multiple protocol identifiers/headers 2024-04-22 15:55:25 -07:00
Johanna Amann
be9bbff6b9 Spicy TLS: inout/reference updates for recent spicy changes 2024-04-16 08:28:05 +01:00
Johanna Amann
83a1165675 Merge remote-tracking branch 'origin/master' into topic/johanna/spicy-tls
* origin/master: (352 commits)
  Bump Spicy.
  Remove support for old Spicy versions from QUIC analyzer.
  Make sure that vcpkg isn't preferred if pcap_root_dir is passed in
  Remove some unused Spicy state.
  Bump Spicy.
  ZAM fix for concretizing vectors in record constructors
  improve ZAM's estimation of profiling overheads
  CI: Remove commented openssl 1.1 workaround from macOS preparation script
  CI: Fix installation of python package on macOS
  Address review feedback for configure error change
  Raise configure error message for unsupported archives
  fix ZAM "cat" of doubles/times to include trailing ".0" per normal BiF behavior
  CI: Specify the xcode version of the macOS Sonoma instance
  Remove vestigial Conan bit in CMakeLists.txt
  When configuring Spicy, be prepated for zeek_lib or zeek_exe targets.
  Fix a typo in CMakeLists.txt when building Zeek as a library
  Bump Spicy to current `main`.
  tie into updates to gen-zam
  ZAM documentation updated to reflect finer-grained profiling
  ZAM-specific BTest baseline changes for tweak to how ZAM bodies print
  ...
2024-04-16 08:08:16 +01:00
Robin Sommer
ed4aed40c1
Bump Spicy.
Includes a couple of updates for the QUIC analyzer.
2024-04-15 17:25:12 +02:00
Robin Sommer
cfbe8de3e8
Remove support for old Spicy versions from QUIC analyzer.
Seems too old to be worth the trouble.
2024-04-15 11:18:38 +02:00
Robin Sommer
db98dc4193
Port Spicy integration to new AST API. 2024-03-04 15:48:39 +01:00
Arne Welzel
bd26d41d6b websocket: Implement Spicy's unmask in C++
This improves runtime for the test pcap I have from 22 seconds to
12 seconds, about 1.8x times faster.
2024-02-07 12:47:24 +01:00
Arne Welzel
c1a685a05d websocket: Add Spicy parser version, too.
The Spicy analyzer is added as a child analyzer when enabled and the
WebSocket.cc logic dispatches between the BinPac and Spicy version.

It substantially slower when tested against a somewhat artificial
2.4GB PCAP. The first flamegraph indicates that the unmask() function
stands out with 35% of all samples, and above it shared_ptr samples.
2024-02-06 17:29:55 +01:00
Arne Welzel
33acfdc630 quic: Continue decryption attempts for later INITIAL packets
The original logic stopped decrypting any INITIAL packets after the
first. The Firefox/cloudflare pcaps actually show that the server
replies with a QUIC INITAL packet containing just ACK frames and no
CRYPTO frames. Only the second QUIC INITIAL packet from the server
then contains the CRYPTO frames.

There's no good reason to stop decryption attempts, either we succeed
down the road and then stop, or we fail and raise analyzer violations.
2024-01-30 21:46:38 +01:00
Arne Welzel
ba510f018c Merge remote-tracking branch 'origin/topic/awelzel/websocket-continuation-opcode-fix'
* origin/topic/awelzel/websocket-continuation-opcode-fix:
  websocket: Fix opcode for continuation frames
2024-01-25 12:21:37 +01:00
Arne Welzel
fb7799bdf6 websocket: Fix opcode for continuation frames
A continuation frame has the same type as the first frame, but that
information wasn't used nor kept, resulting payload of continuation
frames not being forwarded. The pcap was created with a fake Python
server and a bit of message crafting.
2024-01-24 22:57:24 +01:00
Arne Welzel
11e0322f0f HTTP: Coverity std::move suggestion 2024-01-24 10:50:42 +01:00
Arne Welzel
96376fe487 WebSocket: Coverity std::move suggestion 2024-01-24 10:50:42 +01:00