Commit graph

3085 commits

Author SHA1 Message Date
Arne Welzel
a0aa00fa81 logging: Add event_groups to Stream
This commit adds an optional event_groups field to the Logging::Stream record
to associated event groups with logging streams.

This can be used to disable all event groups of a logging stream when it is
disabled. It does require making an explicit connection between the
logging stream and the involved groups, however.
2022-12-09 16:59:36 +01:00
Arne Welzel
85ce48eb1e analyzer/files: handle non-analyzer names in describe_file()
When a fa_file object is created through the use of Input::add_analysis(),
the fa_file's source is likely not valid representation of an analyzer's
tag and a Files::describe() should not error and instead return an empty
description.

Add a new Analyzer::is_tag() helper that can be used to pre-check `f$source`.
2022-12-06 11:17:30 +01:00
Arne Welzel
1e06c8bfda frameworks/notice: Handle fa_file with no or more than a single connection better
* When a file is transferred over multiple connection, have
  create_file_info() just pick the first one instead of none.

* Do not unconditionally assume cid and cuid as set on a
  Notice::FileInfo object.
2022-12-06 11:17:30 +01:00
Christian Kreibich
1c381b5531 Merge branch 'topic/christian/gh-846-tcp-duration-docs'
* topic/christian/gh-846-tcp-duration-docs:
  Expand Conn::Info$duration comment to clarify TCP end-of-connection handling
2022-11-30 09:42:18 -08:00
Christian Kreibich
b0f96fa22c Expand Conn::Info$duration comment to clarify TCP end-of-connection handling
From Vern in GH-846: This is a conscious decision in the TCP analysis to
consider a connection's "duration" to run up through the end of its
productive (= data can be delivered) lifetime, not extending beyond that. So
once it's closed, packets seen subsequently (until the state-holding for the
connection times out) get processed in terms of updating the associated
history, but not the duration. This can include (unnecessarily) retransmitted
data packets, like in one of the examples above. An advantage of this definition
of "duration" is it allows more accurate computation of connection data rates.
2022-11-30 09:39:57 -08:00
Johanna Amann
f4527ee4db Merge remote-tracking branch 'origin/topic/awelzel/2514-expire-all-timers-special-case'
* origin/topic/awelzel/2514-expire-all-timers-special-case:
  TimerMgr: Add back max_timer_expires=0 special case
  Add btest for expiration of all pending timers.
2022-11-30 13:45:09 +00:00
Johanna Amann
3253168a53 Merge remote-tracking branch 'origin/topic/awelzel/2583-mqtt-to-base'
* origin/topic/awelzel/2583-mqtt-to-base:
  mqtt: Move from policy/ into base/
2022-11-30 13:44:27 +00:00
Arne Welzel
eb3bea4e4a mqtt: Move from policy/ into base/
Register dpd signatures and the analyzer when running in default mode.

Closes #2583
2022-11-30 10:14:20 +01:00
Arne Welzel
2becb1337f TimerMgr: Add back max_timer_expires=0 special case
Commit 58fae22708 removed the max_expire==0
handling from DoAdvance() due to not being obvious what use it is. Jan
later reported that it broke the `redef max_timer_expires=0` (#2514).

This commit adds back the special case re-introducing the `max_timer_expires=0` ,
trying to make it fairly explicit that it exists.

This is an adaption of #2516 not adding a new option and trying a bit
to avoid global variable accesses down in DoAdvance(), though that
just moved to InitPostScript().

Fixes #2514.
2022-11-27 15:02:14 +01:00
Arne Welzel
8698a00f03 smb: Drop references to uid_map in state.
This isn't ever written to and probably was meant to be removed during
the following commit: 5b5589e167
2022-11-23 18:19:53 +01:00
Arne Welzel
b04f378f0f smb: Drop AUTH_LOG
This is never used and probably should've been removed
with 143eee5d8d
2022-11-23 18:18:20 +01:00
Tim Wojtulewicz
9e8833e2d5 Merge remote-tracking branch 'security/topic/awelzel/121-ftp-timeout-again'
* security/topic/awelzel/121-ftp-timeout-again:
  ftp: Introduce FTP::max_command_length
2022-11-22 12:27:37 -07:00
Tim Wojtulewicz
26030f4a57 Merge remote-tracking branch 'nadav/topic/nadavk/ntlm'
* nadav/topic/nadavk/ntlm:
  Added NTLM challenge and response
2022-11-21 09:09:18 -07:00
Arne Welzel
3f5cb75a2a ftp: Introduce FTP::max_command_length
oss-fuzz produced FTP traffic with a ~550KB long FTP command. Cap FTP command
length at 100 bytes, log a weird if a command is larger than that and move
on to the next. Likely it's not actual FTP traffic, but raising an
analyzer violation would allow clients an easy way to disable the analyzer
by sending an overly long command.

The added test PCAP was generated using a fake Python socket server/client.
2022-11-21 09:36:29 +01:00
Josh Soref
186fe346ad spelling: repetitions
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2022-11-18 10:26:33 -05:00
nadavkluger
dd849bc339 Added NTLM challenge and response 2022-11-17 18:38:49 +02:00
Tim Wojtulewicz
6055a85b3c Merge remote-tracking branch 'origin/topic/awelzel/smb1-avoid-dialect-index-error'
* origin/topic/awelzel/smb1-avoid-dialect-index-error:
  smb1: Ensure existence of dialect_index in offered dialects
2022-11-16 14:51:56 -07:00
Arne Welzel
e9fa853048 smb1: Ensure existence of dialect_index in offered dialects
When a negotiate request offers no dialects, but the response contains
an ntlm record which selects a dialect, a script error is triggered.

    $ zeek -C -r ./f2b0e.pcap 'DPD::ignore_violations+={ Analyzer::ANALYZER_SMB }'
    1668615340.837882 expression error in /home/awelzel/corelight-oss/zeek/scripts/base/protocols/smb/./smb1-main.zeek, line 96: no such index (SMB1::c$smb_state$current_cmd$smb1_offered_dialects[SMB1::response$ntlm$dialect_index])

Script error triggered by fuzzing when testing Tim's all-the-fuzzing branch.
2022-11-16 17:49:55 +01:00
Arne Welzel
187096d4a4 ssh: Test for c$ssh$analyzer_id existence
While unusual, analyzer_confirmation() may never be called for the
SSH analyzer, but still ssh_auth_attempted is invoked later indicating
successful authentication. I haven't checked how that is actually possible,
but seems prudent to check for the existence of c$ssh$analyzer_id before
referencing it (also in light of runtime enable/disabling of events).

This was found testing Tim's all-the-fuzzing branch on large system,
merging this should avoid oss-fuzz telling us about it.

    $ zeek -C -r ./e83db.pcap 'DPD::ignore_violations+={ Analyzer::ANALYZER_SSH }'
    1668610572.429058 expression error in scripts/base/protocols/ssh/./main.zeek, line 260: field value missing (SSH::c$ssh$analyzer_id)
2022-11-16 16:35:57 +01:00
Arne Welzel
c9b2b15eb9 init-bare: Fix zeek:see after bif renaming
The docs build is currently broken due to this :-/
2022-11-15 16:04:37 +01:00
Tim Wojtulewicz
bfd5b06943 Minor renaming changes to event handler stats bif, plus a test 2022-11-14 09:13:31 -07:00
Tim Wojtulewicz
5d5f5de1d1 Remove statistics plugin in favor of stats bif 2022-11-10 13:37:31 -07:00
Elad Solomon
c3b9756576 Zeek Statistics
- Added statistics hook
- Fixed rlimit usage
- Removed POpen for windows implementation layer
- Completed statistics plugin
2022-11-09 18:15:33 +02:00
Arne Welzel
8b04868de3 {http,smtp}/entities: Align header regexes with extract_filename_from_content_disposition() 2022-11-08 16:45:25 -07:00
Arne Welzel
c58cdf407a analyzer: Cap analyzer violations at 1000 per analyzer instance 2022-11-08 16:44:30 -07:00
Arne Welzel
c132d140ae ftp: Limit pending commands to FTP::max_pending_commands (default 20) 2022-11-08 16:44:17 -07:00
Robin Sommer
3a9320dab3
Merge remote-tracking branch 'origin/topic/awelzel/2528-cluster-layout-content-warning'
* origin/topic/awelzel/2528-cluster-layout-content-warning:
  cluster: Add warning about cluster-layout.zeek content
2022-11-07 11:28:57 +01:00
Tim Wojtulewicz
68450eac47 Merge remote-tracking branch 'origin/topic/timw/update-dns-types'
* origin/topic/timw/update-dns-types:
  Update external test hashes
  Update DNS type strings to match correct mappings
2022-11-03 08:57:19 -07:00
Arne Welzel
28336709b8 cluster: Add warning about cluster-layout.zeek content
Relates to #2528, #991.
2022-11-03 14:02:43 +01:00
Josh Soref
21e0d777b3 Spelling fixes: scripts
* accessing
* across
* adding
* additional
* addresses
* afterwards
* analyzer
* ancillary
* answer
* associated
* attempts
* because
* belonging
* buffer
* cleanup
* committed
* connects
* database
* destination
* destroy
* distinguished
* encoded
* entries
* entry
* hopefully
* image
* include
* incorrect
* information
* initial
* initiate
* interval
* into
* java
* negotiation
* nodes
* nonexistent
* ntlm
* occasional
* omitted
* otherwise
* ourselves
* paragraphs
* particular
* perform
* received
* receiver
* referring
* release
* repetitions
* request
* responded
* retrieval
* running
* search
* separate
* separator
* should
* synchronization
* target
* that
* the
* threshold
* timeout
* transaction
* transferred
* transmission
* triggered
* vetoes
* virtual

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2022-11-02 17:36:39 -04:00
Tim Wojtulewicz
c9610ec45b Update DNS type strings to match correct mappings 2022-11-02 14:22:46 -07:00
Robin Sommer
9f3a234f40
Merge remote-tracking branch 'origin/topic/awelzel/blank-identifer'
* origin/topic/awelzel/blank-identifer:
  scripts: Migrate table iteration to blank identifiers
  Introduce special treatment for the blank identifier _
2022-10-25 12:36:23 +02:00
Christian Kreibich
147283c8f5 Management framework: add websocket support to controller
The controller now listens on an additional port, defaulting to 2149, for Broker
connections via websockets. Configuration works as for the existing traditional
Broker port (2150), via ZEEK_CONTROLLER_WEBSOCKET_ADDR and
ZEEK_CONTROLLER_WEBSOCKET_PORT environment variables, as well as corresponding
redef'able constants.

To disable the websockets feature, leave ZEEK_CONTROLLER_WEBSOCKET_PORT unset
and redefine Management::Controller::default_port_websocket to 0/unknown.
2022-10-24 15:59:26 -07:00
Arne Welzel
8c5896a74d scripts: Migrate table iteration to blank identifiers
No obvious hot-cases. Maybe the describe_file() ones or the intel ones
if/when there are hot intel hits.
2022-10-24 10:36:09 +02:00
Tim Wojtulewicz
81357853ed Restore reporting messages for pcap filter issues 2022-10-21 10:50:00 -07:00
Tim Wojtulewicz
5e4db6d0c4 Add column to packet_filter.log for failure reason 2022-10-21 10:50:00 -07:00
Tim Wojtulewicz
82adecb2ad Store error message from BPF compilation 2022-10-21 10:09:56 -07:00
Tim Wojtulewicz
a91d363e56 smtp: Prevent script errors when smtp$entity is not set
This is the same issue presented in 38e226bf75 but
for SMTP instead of HTTP.
2022-10-10 11:26:08 -07:00
Johanna Amann
3d9a1157f9 Update CT log list.
This uses the v3 json as a source for the first time. The test needed
some updating because Google removed a couple more logs - in the future
this should hopefully not be neccessary anymore because I think v3
should retain all logs.

In theory this might be neat in 5.1.
2022-10-06 15:10:59 +01:00
Robin Sommer
6fcbb55ccd Merge remote-tracking branch 'origin/topic/awelzel/analyzer-module-enable-disable-file-analyzer'
* origin/topic/awelzel/analyzer-module-enable-disable-file-analyzer:
  analyzer: Add file_analyzer support to enable_analyzer()/disable_analyzer()
2022-10-05 13:27:23 +02:00
Tim Wojtulewicz
37d4a28816 Merge remote-tracking branch 'origin/topic/awelzel/http-no-current-entity'
* origin/topic/awelzel/http-no-current-entity:
  http: Prevent script errors when http$current_entity is not set
2022-10-03 09:44:46 -07:00
Arne Welzel
81fe46f123 analyzer: Add file_analyzer support to enable_analyzer()/disable_analyzer()
This allows to enable/disable file analyzers through the same interfaces
as packet and protocol analyzers, specifically Analyzer::disable_analyzer
could be interesting.
2022-09-30 11:47:56 +02:00
Arne Welzel
3e0374f564 const: Deprecate tunnel-specific enable_* flags
With packet analyzers being toggle-able at runtime these can go.
They hadn't been consistently implemented either (VXLAN, Geneve).
2022-09-30 09:31:02 +02:00
Arne Welzel
af5a0215c0 packet_analysis: Introduce PacketAnalyzer::__disable_analyzer()
This adds machinery to the packet_analysis manager for disabling
and enabling packet analyzers and implements two low-level bifs
to use it.

Extend Analyzer::enable_analyzer() and Analyzer::disable_analyzer()
to transparently work with packet analyzers, too. This also allows
to add packet analyzers to Analyzer::disabled_analyzers.
2022-09-30 09:27:22 +02:00
Arne Welzel
bc8fd5a4c6 Introduce generic analyzer_confirmation_info and analyzer_violation_info
Introduce two new events for analyzer confirmation and analyzer violation
reporting. The current analyzer_confirmation and analyzer_violation
events assume connection objects and analyzer ids are available which
is not always the case. We're already passing aid=0 for packet analyzers
and there's not currently a way to report violations from file analyzers
using analyzer_violation, for example.

These new events use an extensible Info record approach so that additional
(optional) information can be added later without changing the signature.
It would allow for per analyzer extensions to the info records to pass
analyzer specific info to script land. It's not clear that this would be
a good idea, however.

The previous analyzer_confirmation and analyzer_violation events
continue to exist, but are deprecated and will be removed with Zeek 6.1.
2022-09-27 17:49:51 +02:00
Arne Welzel
38e226bf75 http: Prevent script errors when http$current_entity is not set
The current_entity tracking in HTTP assumes that client/server never
send HTTP entities at the same time. The attached pcap (generated
artificially) violates this and triggers:

    1663698249.307259 expression error in <...>base/protocols/http/./entities.zeek, line 89: field value missing (HTTP::c$http$current_entity)

For the http-no-crlf test, include weird.log as baseline. Now that weird is
@load'ed from http, it is actually created and seems to make sense
to btest-diff it, too.
2022-09-26 10:18:24 +02:00
Arne Welzel
660172013b scripts/conn: Open-code determine_service()
...and avoid doing it as suggested by Justin to avoid the extra over-head
in scan scenarios where c$service is empty.
2022-09-20 23:07:26 +02:00
Arne Welzel
7ed6cbeee5 Make connection$service_violation a set[string]
To stay consistent with connection$service.
2022-09-20 23:07:26 +02:00
Arne Welzel
0e28a7faf5 strings: Implement join_string_set() as bif
Haven't measured speed, but this is probably faster than
the cat() and string invocations.
2022-09-20 23:07:26 +02:00
Arne Welzel
31aeb58e10 dpd: Replace negated service fmt() magic with dedicated field
...the only known cases where the `-` for `connection$service` was
handled is to skip/ignore these analyzers.

Slight suspicion that join_string_set() should maybe become a bif
now determine_service() runs once for each connection.

Closes #2388
2022-09-20 23:07:26 +02:00