Commit graph

6667 commits

Author SHA1 Message Date
Jon Siwek
0e0e74e49c Improve DNS analysis.
- Fix parsing of empty question sections (when QDCOUNT == 0).  In this
  case, the DNS parser would extract two 2-byte fields for use in either
  "dns_query_reply" or "dns_rejected" events (dependent on value of
  RCODE) as qclass and qtype parameters.  This is not correct, because
  such fields don't actually exist in the DNS message format when
  QDCOUNT is 0.  As a result, these events are no longer raised when
  there's an empty question section.  Scripts that depends on checking
  for an empty question section can do that in the "dns_message" event.

- Add a new "dns_unknown_reply" event, for when Bro does not know how
  to fully parse a particular resource record type.  This helps fix a
  problem in the default DNS scripts where the logic to complete
  request-reply pair matching doesn't work because it's waiting on more
  RR events to complete the reply.  i.e. it expects ANCOUNT number of
  dns_*_reply events and will wait until it gets that many before
  completing a request-reply pair and logging it to dns.log.  This could
  cause bogus replies to match a previous request if they happen to
  share a DNS transaction ID.
2014-01-28 11:04:01 -06:00
Bernhard Amann
f821a13cce Merge remote-tracking branch 'origin/master' into topic/bernhard/file-analysis-x509
Conflicts:
	src/analyzer/protocol/ssl/events.bif

Still broken.
2014-01-28 06:43:08 -08:00
Bernhard Amann
2c7e7f962e Make x509 certificates an opaque type 2014-01-28 06:39:50 -08:00
Robin Sommer
462fd68931 Prototype of a netmap packet source.
TODO: Add userland BPF filtering so that our filters work.
2014-01-27 16:44:21 -08:00
Robin Sommer
9a9451af00 A series of updates and tweaks to the new PktSrc interface. 2014-01-27 15:20:02 -08:00
Bernhard Amann
6d73b8c57e Fix x509_extension event.
The event now really returns the extension. If openssl supports printing
it, it is converted into the openssl ascii output.

The output does not always look pretty because it can contain newlines.

New event syntax:
event x509_extension(c: connection, is_orig: bool, cert:X509, extension: X509_extension_info)

Example output for extension:
  [name=X509v3 Extended Key Usage,
    short_name=extendedKeyUsage,
    oid=2.5.29.37,
    critical=F,
    value=TLS Web Server Authentication, TLS Web Client Authentication]
  [name=X509v3 Certificate Policies,
   short_name=certificatePolicies,
   oid=2.5.29.32,
   critical=F,
   value=Policy: 1.3.6.1.4.1.6449.1.2.1.3.4^J  CPS: https://secure.comodo.com/CPS^J]
2014-01-27 10:24:57 -08:00
Robin Sommer
191b63e334 Merge branch 'topic/robin/dynamic-plugins-2.3' into topic/robin/pktsrc 2014-01-27 09:31:15 -08:00
Robin Sommer
3f47c5bc87 Merge remote-tracking branch 'origin/master' into topic/robin/dynamic-plugins-2.3 2014-01-24 20:26:00 -08:00
Vlad Grigorescu
56acd99d15 Fix misidentification of SOCKS traffic. Traffic that had a certain bytestring would get incorrectly identified as SOCKS. This seemed to happen a lot with DCE/RPC traffic. 2014-01-24 21:00:55 -05:00
Jon Siwek
e09763e061 Fix file_over_new_connection event to trigger when entire file is missed.
If a file is nothing but gaps (e.g. due to missing/dropped packets), Bro
can sometimes detect a file is supposed to have been present and never
saw any of its content, but failed to raise file_over_new_connection
events for it.  This was mostly apparent because the tx_hosts/rx_hosts
fields in files.log would not be populated in such cases (but are now
with this change).
2014-01-24 16:47:00 -06:00
Jon Siwek
6d46144c3b Improve TCP connection size reporting for half-open connections.
If TCP endpoint A and B are synchronized at some point, but A
closes/aborts/crashes and B goes on without knowledge of it and then A
tries to re-synchronize, Bro could end up seeing something like
(sequence numbers made up):

A: SYN 100
B: ACK 500
A: RST 500

The final sequence number of A, in this case, is not useful in the
context of determining the number of data bytes sent by A, so Bro now
reports that as 0 (where before it could often be misleadingly large).
2014-01-24 16:32:55 -06:00
Jon Siwek
9b12967d40 Improve gap reporting in TCP connections that never see data.
The previous behavior was to accomodate SYN/FIN/RST-filtered traces by
not reporting missing data (via the content_gap event) for such
connections.  The new behavior always reports gaps for connections that
are established and terminate normally, but sequence numbers indicate
that all data packets of the connection were missed.  The behavior can
be reverted by redef'ing "detect_filtered_trace".
2014-01-24 16:21:02 -06:00
Jon Siwek
5b3573394e Improve TCP FIN retransmission handling.
In the case multiple FIN packets are seen from a TCP endpoint (e.g.
when one is retransmitted), only the first counted towards a byte in the
sequence space.  This could cause a subsequent FIN packet to induce an
incorrect wrap around in the sequence numbers (e.g.  the retransmitted
FIN packet now is one sequence number behind the the first) and
misleadingly large connection sizes.  The change is to always treat a
FIN packet as counting one byte in to the sequence space.
2014-01-24 15:51:58 -06:00
Robin Sommer
18bd20fe29 Fixing initialization context in anonymous functions.
When an anonymoys function was defined inside an initialization
context, that context transfered over to the function body and could
lead to spurious error messages.
2014-01-23 14:18:30 -08:00
Robin Sommer
ee75958951 Adding meta hooks.
This is mainly an experiment to see if this makes sense. I'm not very
fond of the arguments being wrapped into a discriminating union, but I
like it better than other alternatives at least.

The new code is untested.
2014-01-22 14:29:22 -08:00
Robin Sommer
2c34101394 Moving existing built-in plugins over to new interface. 2014-01-20 13:39:11 -08:00
Robin Sommer
ea01a1be30 Reworking plugin interface to not rely on macros.
The Plugin.cc file is now just a standard class, with the interface
changed a bit to make it more easy to write. However, there're still
some conventions that one must follow to make everything work (like
using the right namespace structure).

This commit also includes the option to compile built-in plugins
dynamically instead of statically by adding
SET(BRO_PLUGIN_BUILD_DYNAMIC TRUE) to their CMake config. This hasn't
been tested much yet, and I'm still undecided if it's somethign we
would want to do by default--but we could now if wanted. :)

Also some minor other cleanup of plugin APIs and built infrastructure.

All tested on MacOS only currently.
2014-01-20 13:39:11 -08:00
Robin Sommer
ba9571f9ff Merge remote-tracking branch 'origin/topic/jsiwek/gre'
* origin/topic/jsiwek/gre:
  Simplify FragReassembler memory management.
  BIT-867 - Support GRE tunnel decapsulation.

BIT-867 #merged
2014-01-20 12:27:13 -08:00
Robin Sommer
32707c6c62 Merge remote-tracking branch 'origin/topic/jsiwek/libmagic-integration'
* origin/topic/jsiwek/libmagic-integration:
  Don't use LOG_* options to ExternalProject_Add if not supported.
  Integrate libmagic 5.16 via CMake ExternalProject.

BIT-1116 #merged
2014-01-20 11:42:58 -08:00
Jon Siwek
4901032660 Simplify FragReassembler memory management. 2014-01-16 16:40:23 -06:00
Jon Siwek
7717a3eb67 BIT-867 - Support GRE tunnel decapsulation.
This includes enhanced GRE headers.  GRE tunnels are treated just like
IP-in-IP tunnels by parsing past the GRE header in between the delivery
and payload IP packets.
2014-01-16 16:03:04 -06:00
Jon Siwek
c48c531629 Integrate libmagic 5.16 via CMake ExternalProject.
- Bumps CMake requirement to CMake 2.8.
- Bro now always relies on builtin/shipped magic library/database.
2014-01-15 14:19:29 -06:00
Robin Sommer
69ef268a44 Fixing compile problems with some versions of libc++.
Reported by Craig Leres.
2014-01-13 09:31:23 -08:00
Robin Sommer
ca55d14f67 Merge remote-tracking branch 'origin/fastpath'
* origin/fastpath:
  Improve GeoIP City database support.
  Broxygen init fixes, addresses BIT-1110.
  Fix for packet writing to make it use the global snaplength.
  Fix for traffic with TCP segmentation offloading with IP header len field being set to zero.
2014-01-13 01:38:56 -08:00
Jon Siwek
e0082e6bcb Improve GeoIP City database support.
When trying to open a city database, it now considers both the "REV0"
and "REV1" versions of the city database instead of just the former.
The extra fields of the "REV1" version (metro/area code) aren't yet put
in geo_location records, this change just allows this version of the
city database to be opened w/ same functionality as the other version.
This should be convenient because libGeoIP expects either version to
live at the same file system path, it's hard to tell which version
you've got, and current free GeoLite databases seem to be "REV1".
2014-01-10 15:17:54 -06:00
Jon Siwek
beea92ce6c Broxygen init fixes, addresses BIT-1110.
- Don't check mtime of bro binary if BRO_DISABLE_BROXYGEN env var set.

- Fix failure to locate bro binary if invoking from a relative
  path and '.' isn't in PATH.
2014-01-10 15:06:10 -06:00
Seth Hall
22f8bb9dd8 Fix for packet writing to make it use the global snaplength. 2014-01-08 21:50:03 -05:00
Seth Hall
28673bd198 Fix for traffic with TCP segmentation offloading with IP header len field being set to zero. 2014-01-08 21:47:38 -05:00
Seth Hall
38dbba7622 More file reassembly work.
- The reassembly behavior can be modified per-file by enabling or
   disabling the reassembler and/or modifying the size of the reassembly
   buffer.

 - Changed the file extraction analyzer to use the stream to avoid
   issues with the chunk based approach not immediately triggering
   the file_new event due to mime-type detection delay.  Early chunks
   frequently ended up lost before.

 - Generally things are working now and I'd consider this in testing.
2014-01-05 04:58:01 -05:00
Seth Hall
0b78f444a1 Initial commit of file reassembly. 2013-12-20 00:05:08 -05:00
Robin Sommer
bc3e3034e6 Removing a stale piece of CMake code. 2013-12-19 08:31:36 -08:00
Daniel Thayer
0a90ddc1dd Merge remote-tracking branch 'origin/master' into topic/dnthayer/doc-updates 2013-12-18 14:35:22 -06:00
Robin Sommer
ae9e0d4cb6 Fixing segfault with mismatching set &default in record field. 2013-12-18 09:17:05 -08:00
Robin Sommer
5efce5c7e4 Compile fix. 2013-12-16 12:26:12 -08:00
Robin Sommer
a80dd10215 Updates of the dynamic plugin code.
Includes:

    - Cleanup of the plugin API, in particular generally changing
      const char* to std::string

    - Renaming environment variable BRO_PLUGINS to BRO_PLUGIN_PATH,
      defaulting to <prefix>/lib/bro/plugins

    - Reworking how dynamic plugins are searched and activated. See
      doc/devel/plugins.rst for details.

    - New @load-plugin directive to explicitly activate a plugin

    - Support for Darwin. (Linux untested right now)

    - The init-plugin updates come with support for "make test", "make
      sdist", and "make bdist" (see how-to).

    - Test updates.

Notes: The new hook mechanism, which allows plugins to hook into Bro's
core a well-defined points, is still essentially untested.
2013-12-16 11:57:56 -08:00
Robin Sommer
987452beff Cleanup of plugin component API.
- Move more functionality into base class.
- Remove cctors and assignment operators (weren't actually needed anymore)
- Switch from const char* to std::string.
2013-12-16 10:07:20 -08:00
Robin Sommer
207b7e7102 Merge remote-tracking branch 'origin/fastpath'
* origin/fastpath:
  Improve warnings emitted from raw/execute input reader.
2013-12-16 08:50:54 -08:00
Vlad Grigorescu
8688c764a0 Fix a couple memleaks. 2013-12-13 15:04:43 -05:00
Jon Siwek
8ea56ae567 Improve warnings emitted from raw/execute input reader.
Some return values of the setpgid() call in that parent proc are ok
(or contradict reality).
2013-12-12 13:26:19 -06:00
Robin Sommer
61ee2b9172 Fixing rebase relicts. 2013-12-11 20:57:05 -08:00
Robin Sommer
93d9dde969 IOSource reorg.
A bunch of infrastructure work to move IOSource, IOSourceRegistry (now
iosource::Manager) and PktSrc/PktDumper code into iosource/, and over
to a plugin structure.

Other IOSources aren't touched yet, they are still in src/*.

It compiles and does something with a small trace, but that's all I've
tested so far. There are quite certainly a number of problems left, as
well as various TODOs and cleanup; and nothing's cast in stone yet.

Will continue to work on this.
2013-12-11 18:00:34 -08:00
Vlad Grigorescu
f3c0d17541 Basic RADIUS functionality implemented. 2013-12-10 22:09:16 -05:00
Vlad Grigorescu
ccd8b15d52 Merge branch 'master' of ssh://git.bro.org/bro into topic/vladg/radius 2013-12-10 19:40:00 -05:00
Jon Siwek
5a67135486 Fix uninitialized field in basename/dirname util wrapper.
Shouldn't cause a problem as it's always set in subclass ctors,
just silences a coverity warning.
2013-12-10 14:08:09 -06:00
Robin Sommer
e8739f785b Merge remote-tracking branch 'origin/topic/bernhard/input-error-fixes'
* origin/topic/bernhard/input-error-fixes:
  Several fixes for input manager error handling.

BIT-1106 #merged
2013-12-09 15:21:18 -08:00
Robin Sommer
ca37f3d2dd Merge remote-tracking branch 'origin/topic/jsiwek/misc-fixes'
BIT-1105 #merged

* origin/topic/jsiwek/misc-fixes:
  Fix table &default reference counting for record ctor expressions.
  Close signature files after done parsing.
  Fix unlikely null ptr deref in broxygen::Manager.
  FreeBSD build fix addendum: unintended variable shadowing.
  Fix build on FreeBSD.
2013-12-09 13:26:47 -08:00
Robin Sommer
b8c511f31f Merge remote-tracking branch 'origin/topic/bernhard/ticket1103'
* origin/topic/bernhard/ticket1103:
  fix memory leak in input framework.

BIT-1103 #merged
BIT-1095 # Add to 2.2.1
2013-12-09 13:19:22 -08:00
Jon Siwek
dedc39d784 Minor Broxygen improvements, addresses BIT-1098.
- Internals: move type alias table to private static BroType member.

- Sphinx extension: now uses absolute path to bro binary.

- reST ouput formatting: remove "param" from function desriptions
  and change package overview docs so script link+summaries render
  consistently.
2013-12-06 09:35:35 -06:00
Bernhard Amann
3c59aa9459 Several fixes for input manager error handling.
- First:
Due to architectural constraints, it is very hard for the
input framework to handle optional records. For an optional record,
either the whole record has to be missing, or all non-optional elements
of the record have to be defined. This information is not available
to input readers after the records have been unrolled into the threading
types.

Behavior so far was to treat optional records like they are non-optional,
without warning. The patch changes this behavior to emit an error on stream-
creation (during type-checking) and refusing to open the file. I think this
is a better idea - the behavior so far was undocumented and unintuitive.

- Second:
For table and event streams, reader backend creation was done very early,
before actually checking if all arguments are valid. Initialization is moved
after the checks now - this makes a number of delete statements unnecessary.
Also - I suspect threads of failed input reader instances were not deleted
until shutdown

- Third:
Add a couple more consistency checks, e.g. checking if the destination value
of a table has the same type as we need. We did not check everything in all
instances, instead we just assigned the things without caring (which works,
but is not really desirable).

This change also exposed a few bugs in other testcases where table definitions
were wrong (did not respect $want_record)

- Fourth:
Improve error messages and write testcases for all error messages (I think).
2013-12-05 15:53:12 -08:00
Jon Siwek
54ebe98458 Fix table &default reference counting for record ctor expressions. 2013-12-05 14:23:32 -06:00