Commit graph

138 commits

Author SHA1 Message Date
Johanna Amann
7c48aad582 Update DTLS error handling
DTLS now only outputs protocol violations once it saw something that
looked like a DTLS connection (at least a client hello). Before the
danger that it misinterprets something is too high.

It has a configurable number of invalid packets that it can skip over
(because other protocols might be interleaved with the connection) and a
maximum amount of Protocol violations that it outputs because of wrong
packet versions.
2019-04-04 12:27:42 -07:00
Jon Siwek
9eb5449ecb Merge branch 'smb3-transform-header' of https://github.com/mauropalumbo75/zeek
* 'smb3-transform-header' of https://github.com/mauropalumbo75/zeek:
  clean up, test and pcap for transform_header added
  added smb2-com-transform-header for smb3.x
2019-03-20 19:30:32 -07:00
Jon Siwek
01d303b480 Migrate table-based for-loops to key-value iteration 2019-03-15 19:54:44 -07:00
Robin Sommer
72fa3f16ad Merge remote-tracking branch 'origin/topic/jsiwek/vxlan'
* origin/topic/jsiwek/vxlan:
  GH-250: Improve/cleanup VXLAN decapsulation support
  Initial VXLAN support, need -C flag to work when running bro
2019-03-14 17:59:42 +00:00
Jon Siwek
1239a286e2 Merge branch 'patch-1' of https://github.com/neu5ron/bro
* 'patch-1' of https://github.com/neu5ron/bro:
  Update main.bro
  Update main.bro
2019-03-13 13:49:17 -07:00
Jon Siwek
09ae539ea8 GH-250: Improve/cleanup VXLAN decapsulation support
* Better parsing/error-checking of VXLAN and encapsulated packet headers

* Add/implement the "vxlan_packet" event

* Add "Tunnel::vxlan_ports" option to tune the set of VXLAN ports to
  analyze/decapsulate

* Add "Tunnel::validate_vxlan_checksums" option to allow for tuning of how
  checksums associated with the outer UDP header of a possible VXLAN
  tunnel are handled

Fixes GH-250
2019-03-12 18:15:34 -07:00
Jon Siwek
92b6656bad GH-289: Add options to limit entries in http.log file fields
The "orig_fuids", "orig_filenames", "orig_mime_types" http.log fields as
well as their "resp" counterparts are now limited to having
"HTTP::max_files_orig" or "HTTP::max_files_resp" entries, which are 15
by default.  The limit can also be ignored case-by-case via the
"HTTP::max_files_policy" hook.

Fixes GH-289
2019-02-27 14:25:15 -06:00
mauro
a346b01a85 clean up, test and pcap for transform_header added 2019-02-21 12:01:02 +01:00
Jon Siwek
0d685efbf5 Add Broker::peer_counts_as_iosource option
Disabling this option allows one to read pcaps, but still initiate
Broker peerings and automatically exit when done processing the pcap
file.  The default behavior would normally cause Broker::peer() to
prevent shutting the process down even after done reading the pcap.
2019-01-16 19:03:35 -06:00
Johanna Amann
60fd0e1b8d Baseline update for catch-and-release change. 2019-01-10 09:10:08 -08:00
Jon Siwek
635e030be2 Merge remote-tracking branch 'origin/master' into dev/2.7
* origin/master:
  Fix SumStats "last" plugin in cluster mode
  Remove unnessary check
  Support appending to vector of any
  Fix coding conventions nits/typos
  Updating submodule(s).
  Revert "Switch frag_timeout from redef to option"
  Improve error handling in x509_ocsp_verify function
  Updating submodule(s).
  Updating submodule(s).
  Update baseline for plugins.hooks for redef -> option changes
  Switch frag_timeout from redef to option
  Switch GridFTP options from redef to option
  Updating submodule(s).
  Fix a unit test relying on a bash-ism
2018-11-08 12:43:22 -06:00
Jon Siwek
c1f02aaa61 Revert "Switch frag_timeout from redef to option"
This reverts commit 38259afa8d.

The change to an option wasn't yet incomplete -- that would
require dynamic lookup of the value at the C++ layer.
2018-11-06 09:32:58 -06:00
Vlad Grigorescu
4f6db2f960 Update baseline for plugins.hooks for redef -> option changes 2018-11-05 14:00:44 -06:00
Jon Siwek
1f450c0510 Improve introspection of Record and TypeType values
* TypeType values are now printable and yield the type name/alias
* Fix record_fields BIF to return correct type name for fields
* Allow TypeType values that point to a RecordType to be used with
  record_fields BIF
2018-10-18 15:10:02 -05:00
Jon Siwek
f05ef0cb1e Fix test baseline for plugin skeleton update 2018-10-12 12:51:53 -04:00
Johanna Amann
005bf5b6a4 Convert site::local_nets, etc. into options.
These are probably some of the most desired options to be dynamically
changeable; since they only are accessed in script-land there should not
be any problems with them changing on the fly.
2018-10-09 16:33:26 -07:00
Johanna Amann
9f0e422bec Update test baselines (weird options) 2018-09-05 13:33:56 -07:00
Jon Siwek
60da98fa73 Merge remote-tracking branch 'origin/topic/seth/ntlm-fixes'
* origin/topic/seth/ntlm-fixes:
  Test baseline updates.
  Updates to NTLM script handling.
2018-09-04 17:18:56 -05:00
Robin Sommer
6de436f3f6 Merge remote-tracking branch 'origin/topic/jsiwek/bit-1967'
* origin/topic/jsiwek/bit-1967:
  Fix a routing loop in control framework
  Add Broker::forward() function
  Enable implicit Broker message forwarding by default
  Remove Cluster::broadcast_topic
  Remove Intel Broker topics, re-use existing Cluster topics
  Remove "relay" family of Broker functions
2018-08-30 00:08:12 +00:00
Johanna Amann
4fd6cbd138 Merge remote-tracking branches 'origin/topic/dnthayer/ticket1963' and 'origin/topic/jsiwek/improve-input-reread'
* origin/topic/dnthayer/ticket1963:
  Convert more redef-able constants to runtime options

* origin/topic/jsiwek/improve-input-reread:
  Improve input framework re-read logic
2018-08-28 14:36:28 -07:00
Jon Siwek
1a75ef2abd Remove "relay" family of Broker functions
Namely these are now removed:

    - Broker::relay
    - Broker::publish_and_relay
    - Cluster::relay_rr
    - Cluster::relay_hrw

The idea being that Broker may eventually implement the necessary
routing (plus load balancing) functionality.  For now, code that used
these should "manually" handle and re-publish events as needed.
2018-08-27 16:49:35 -05:00
Johanna Amann
e055f9b36b Merge remote-tracking branch 'origin/topic/dnthayer/ticket1963'
* origin/topic/dnthayer/ticket1963:
  Add a missing initializer to a runtime option
  Convert more redef-able constants to runtime options
2018-08-24 18:05:34 -07:00
Jon Siwek
6595b21e2e Merge remote-tracking branch 'origin/topic/dnthayer/ticket1963'
* origin/topic/dnthayer/ticket1963:
  Remove unused redef-able constants
  Convert some redef-able constants to runtime options
2018-08-20 12:44:58 -05:00
Jon Siwek
fcabd72b92 BIT-1815: move SMB::write_cmd_log functionality into policy/ script
The option is removed, but same functionality is now enabled simply
by loading policy/protocols/smb/log-cmds.bro
2018-08-17 11:15:18 -05:00
Jon Siwek
a04c76c035 Enable SMB by default by moving scripts from policy/ to base/ 2018-08-16 17:23:28 -05:00
Robin Sommer
554e8cc73d Merge remote-tracking branch 'origin/topic/jsiwek/broker-listen-env'
BIT-1935 #merged

* origin/topic/jsiwek/broker-listen-env:
  Allow BRO_DEFAULT_LISTEN_ADDRESS to control broker listen address
2018-06-08 16:38:31 +00:00
Jon Siwek
a43c7d0691 Merge remote-tracking branch 'origin/topic/jsiwek/ncp-fixes'
* origin/topic/jsiwek/ncp-fixes:
  Add NCP::max_frame_size tuning option
  Migrate NCP analyzer to use latest analyzer API
2018-06-05 11:32:38 -05:00
Jon Siwek
1b4e0116f4 Allow BRO_DEFAULT_LISTEN_ADDRESS to control broker listen address
This environment variable is now set to listen only on IPv4 loopback
when running unit tests (instead of using the default INADDR_ANY).

This also moves some of the @loads out from init-bare.bro into a new
init-frameworks-and-bifs.bro in order to better support calling BIFs
(like `getenv`) from variable initializations in those particular
frameworks.
2018-06-01 15:38:11 -05:00
Robin Sommer
fe7e1ee7f0 Merge topic/actor-system throug a squashed commit. 2018-05-18 22:39:23 +00:00
Jon Siwek
057c982b9d Merge branch 'BIT-1927' of https://github.com/hosom/bro
* 'BIT-1927' of https://github.com/hosom/bro:
  Fix for BIT-1927: notice/extend-email relocation

And updated coverage unit tests.

BIT-1927 #close
2018-05-10 11:28:08 -05:00
Jon Siwek
81133f3116 Merge remote-tracking branch 'origin/topic/seth/dhcp-update'
* origin/topic/seth/dhcp-update:
  Rework to the DHCP analyzer.
  First step of DHCP analyzer rearchitecture.
  Add .btest scripts for dhck_ack and dhcp_discover messages verifying that new options are correctly reported in dhcp.log records.
  Extend DHCP protocol analyzer with new options.

BIT-1924 #merged

Additional changes:

* Removed known-hosts.bro as the only thing populating its table was
  the already-removed known-hosts-and-devices.bro.  So a
  known_devices.log will no longer be generated.

* In dhcp-options.pac, the process_relay_agent_inf_option had a memleak
  and also process_auto_proxy_config_option looked like it accessed one
  byte past the end of the available bytestring, so fixed those.
2018-05-01 18:06:41 -05:00
Seth Hall
e76b56ce53 Rework to the DHCP analyzer.
Highlights:
 - Reduced all DHCP events into a single dhcp_message event. (removed legacy events since they weren't widely used anyway)
 - Support many more DHCP options.
 - DHCP log is completely reworked and now represents DHCP sessions
   based on the transaction ID (and works on clusters).
 - Removed the known-devices-and-hostnames script since it's generally
   less relevant now with the updated log.
2018-03-01 08:36:32 -08:00
Robin Sommer
fff4db5145 Merge remote-tracking branch 'origin/topic/johanna/config'
Closes BIT-1900.

* origin/topic/johanna/config:
  Use port_mgr->Get() in the input framework config changes.
  Allow the empty field separator to be empty; use in config framework.
  Fix small bug in config reader.
  Fix segmentation fault when parsing sets containing invalid elements.
  Add config framework.
2018-02-07 14:10:48 -08:00
Jon Siwek
4cd9f0edf9 Merge branch 'smb-transaction-messages' of https://github.com/jbencteux/bro
* 'smb-transaction-messages' of https://github.com/jbencteux/bro:
  add test for smb1_com_transaction_response event changes
  add test for smb1_com_transaction2_secondary_request event changes
  add test for smb1_com_transaction2_request event changes
  add test for smb1_com_transaction_secondary_request event changes
  add test for smb1_com_transaction_request event changes
  fix setup field handling in smb1_com_transaction_request messages
  fix smb1_com_transaction* messages
  add smb1_transaction2_secondary_request event
  add smb1_transaction_secondary_request event
  add parameters and data to smb1_transaction_request/response messages
  add SMB_Parameters.Words to smb1_transaction2_request event
2018-02-05 16:33:25 -06:00
Johanna Amann
ac9fd000e0 Merge remote-tracking branch 'origin/master' into topic/johanna/config 2018-01-29 14:43:20 -08:00
Johanna Amann
a4a9bf4199 Logging: implement get_filter_names and small fixes.
get_filter_names(id: ID) : set[string] returns the names of the current
list of filters for a specified log stream.

Furthermore this commit makes a number of logging functions more robust
by checking existence of values before trying to modify them. This
commit also really implements (and tests) the enable_stream function.
2018-01-17 09:47:20 -08:00
Johanna Amann
6f9524e082 Make tunnel_parents in conn.log optional.
This makes conn.logs a bit prettier (and smaller) because all lines that
do not use a tunnel will now have a "-" instead of the "(empty)" for
tunnel_parents.
2018-01-12 13:46:00 -08:00
Johanna Amann
db6f028003 Add config framework.
The configuration framework consists of three mostly distinct parts:

* option variables
* the config reader
* the script level framework

I will describe the three elements in the following.

Internally, this commit also performs a range of changes to the Input
manager; it marks a lot of functions as const and introduces a new
ValueToVal method (which could in theory replace the already existing
one - it is a bit more powerful).

This also changes SerialTypes to have a subtype for Values, just as
Fields already have it; I think it was mostly an oversight that this was
not introduced from the beginning. This should not necessitate any code
changes for people already using SerialTypes.

option variable
===============

The option keyword allows variables to be specified as run-tine options.
Such variables cannot be changed using normal assignments. Instead, they
can be changed using Option::set. It is possible to "subscribe" to
options and be notified when an option value changes.

Change handlers can also change values before they are applied; this
gives them the opportunity to reject changes. Priorities can be
specified if there are several handlers for one option.

Example script:

option testbool: bool = T;

function option_changed(ID: string, new_value: bool): bool
  {
  print fmt("Value of %s changed from %s to %s", ID, testbool, new_value);
  return new_value;
  }

event bro_init()
  {
  print "Old value", testbool;
  Option::set_change_handler("testbool", option_changed);
  Option::set("testbool", F);
  print "New value", testbool;
  }

config reader
=============

The config reader provides a way to read configuration files back into
Bro. Most importantly it automatically converts values to the correct
types. This is important because it is at least inconvenient (and
sometimes near impossible) to perform the necessary type conversions in
Bro scripts themselves. This is especially true for sets/vectors.

Configuration generally look like this:

[option name][tab/spaces][new variable value]

so, for example:

testaddr 2607:f8b0:4005:801::200e
testinterval 60
testtime 1507321987
test_set a	b	c	d	erdbeerschnitzel

The reader uses the option name to look up the type that variable has in
the Bro core and automatically converts the value to the correct type.

Example script use:

type Idx: record {
  option_name: string;
};

type Val: record {
  option_val: string;
};

global currconfig: table[string] of string = table();

event InputConfig::new_value(name: string, source: string, id: string, value: any)
  {
  print id, value;
  }

event bro_init()
  {
  Input::add_table([$reader=Input::READER_CONFIG, $source="../configfile", $name="configuration", $idx=Idx, $val=Val, $destination=currconfig, $want_record=F]);
  }

Script-level config framework
=============================

The script-level framework ties these two features together and makes
them a bit more convenient to use. Configuration files can simply be
specified by placing them into Config::config_files. The framework also
creates a config.log that shows all value changes that took place.

Usage example:

redef Config::config_files += {configfile};

export {
  option testbool : bool = F;
}

The file is now monitored for changes; when a change occurs the
respective option values are automatically updated and the value change
is written to config.log.
2017-11-29 13:46:59 -08:00
Johanna Amann
91dcefe104 Fix and extend behavior of HookLoadFile
This commit fixes and extends the behavior of HookLoadFile. Before this
change, HookLoadFile appended ".bro" to each path that was @loaded, even
if the path specified directory names. Furthermore it only gave the path
of the file as it was specified in the Bro script without revealing the
final path of the file that it was going to load.

This patch changes this behavior - in addition to giving the unmodified
path given in the @load command, the hook now returns the resolved path
of the file or directory it is going to load (if found). The hook is
furthermore raises for @load-sigs and @load-plugin; a enum specifies the
kind of load that is happening.
2017-11-16 12:31:27 -08:00
Johanna Amann
b7a7e45a07 Merge remote-tracking branch 'origin/master' into topic/johanna/ocsp-sct-validate 2017-06-26 11:16:08 -07:00
Johanna Amann
876f492a35 OCSP/TLS/SCT: Fix a number of test failures.
These were caused by earlier code updates.

This commit also removes the ocsp stapling logging script; it was
defunctional and the information provided by it wnever really has been
especially interesting.
2017-05-06 08:01:20 -07:00
Johanna Amann
684ea8aa37 Plugin: Add hooks for log init and writing.
The two hooks being added are:

void HookLogInit(const std::string& writer, const std::string& instantiating_filter, bool local, bool remote, const logging::WriterBackend::WriterInfo& info, int num_fields, const threading::Field* const* fields);

which is called when a writer is being instantiated and contains
information about the fields being logged, as well as

bool HookLogWrite(const std::string& writer, const std::string& filter, const logging::WriterBackend::WriterInfo& info, int num_fields, const threading::Field* const* fields, threading::Value** vals);

which is called for each log line being written by each writer. It
contains all the data being written. The data can be changed in the
function call and lines can be prevented from being written.

This commit also fixes a few small problems with plugin hooks itself,
and extends the tests that were already there, besides introducing tests
for the added functionality.
2017-04-24 14:02:05 -07:00
Seth Hall
01a3943635 Do some updates to remove build time warnings.
The linker was complaining about linking files that didn't
have any symbols.  These were actually empty files so I just
got rid of them and removed references to them.
2017-02-28 12:40:01 -05:00
Seth Hall
0b8b76cfab Refactor base krb scripts and update tests. 2017-02-18 13:55:39 -05:00
Seth Hall
08bc5ccd42 Fixing tests 2017-01-25 02:06:35 -05:00
Johanna Amann
e991189fff Remove brocon event.
It make the plugins/hooks test fail, because the number of the current
year shows up in the Baseline.
2017-01-19 13:01:35 -08:00
Johanna Amann
c92060a8ca Merge remote-tracking branch 'origin/topic/seth/smb-auth-fixes'
* origin/topic/seth/smb-auth-fixes:
  Disable SMB2 error data parsing.
  Removed some files that aren't being used.
  Fix SMB tree connect handling.
  Fix a small issue where DCE_RPC commands were improperly being logged.
  SMB fixes and cleanup.
  Including a test for raw NTLM in SMB
  Updates for SMB auth handling from Martin van Hensbergen.

BIT-1721 #merged
2016-11-02 10:25:33 -07:00
Robin Sommer
b0a2586309 Updating tests. 2016-10-25 17:06:25 -07:00
Johanna Amann
fdef28ce7c TLS 1.3 support.
Well, at least -draft-16, and we don't quite parse all extensions yet
(not that there is that much left to parse).
2016-10-07 12:51:43 -07:00
Johanna Amann
14c119c7f9 Really fix plugins/hooks test this time 2016-10-06 15:00:48 -07:00