Commit graph

1367 commits

Author SHA1 Message Date
Bernhard Amann
5b4a1b2762 update test baselines 2014-03-04 14:31:41 -08:00
Bernhard Amann
ea1616bed5 At the moment, SSL connections where the ssl_established event does not fire are not logged.
That means that, for example, connections that are terminated with an alert during the
handshake never appear in the ssl.log.

This patch changes this behavior - now all ssl connections that fire any event are logged.

The protocol confirmation of the ssl analyzer is moved to the client_hello instead to
the server hello. Furthermore, an additional field is added to ssl.log, which indicates
if a connection has been established or not (which probably indicates a handshake problem).
2014-03-04 14:23:49 -08:00
Robin Sommer
d6d26a3ea7 Merge branch 'topic/robin/http-connect'
* topic/robin/http-connect:
  HTTP fix for output handlers.
  Expanding the HTTP methods used in the signature to detect HTTP traffic.
  Updating submodule(s).
  Fixing removal of support analyzers, plus some tweaking and cleanup of CONNECT code.
  HTTP CONNECT proxy support.

BIT-1132 #merged
2014-03-03 16:53:46 -08:00
Robin Sommer
7774af7518 Merge remote-tracking branch 'origin/topic/bernhard/ticket-1144'
* origin/topic/bernhard/ticket-1144:
  Allow iterating over bif functions with result type vector of any.

BIT-1144 #merged
2014-03-03 16:35:00 -08:00
Robin Sommer
02ab000b81 Merge remote-tracking branch 'origin/master' into topic/robin/http-connect
Conflicts:
	scripts/base/protocols/ssl/consts.bro
2014-03-02 13:55:13 -08:00
Robin Sommer
338d521003 Fixing removal of support analyzers, plus some tweaking and cleanup of
CONNECT code.

Removal of support analyzers was broken. The code now actually doesn't
delete them immediately anymore but instead just flags them as
disabled. They'll be destroyed with the parent analyzer later.

Also includes a new leak tests exercising the CONNECT code.

Lines starting # with '#' will be ignored, and an empty message aborts
the commit. # On branch topic/robin/http-connect # Changes to be
committed: # modified: scripts/base/protocols/http/main.bro #
modified: scripts/base/protocols/ssl/consts.bro # modified:
src/analyzer/Analyzer.cc # modified: src/analyzer/Analyzer.h #
modified: src/analyzer/protocol/http/HTTP.cc # new file:
testing/btest/core/leaks/http-connect.bro # modified:
testing/btest/scripts/base/protocols/http/http-connect.bro # #
Untracked files: # .tags # changes.txt # conn.log # debug.log # diff #
mpls-in-vlan.patch # newfile.pcap # packet_filter.log # reporter.log #
src/PktSrc.cc.orig # weird.log #
2014-03-02 13:52:32 -08:00
Bernhard Amann
80c319b522 adjust timings of a few leak tests.
Without the longer timeouts, these consistently fail for me
on caddy when doing "make test".
2014-02-26 14:47:40 -08:00
Bernhard Amann
b3bd509b3f Allow iterating over bif functions with result type vector of any.
This changes the internal type that is used to signal that a vector
is unspecified from any to void.

I tried to verify that the behavior of Bro is still the same. After
a lot of playing around, I think everything still should worl as before.

However, it might be good for someone to take a look at this.

addresses BIT-1144
2014-02-25 15:30:29 -08:00
Jon Siwek
90026f7196 Update to libmagic version 5.17, address BIT-1136. 2014-02-19 10:32:27 -06:00
Robin Sommer
ba81aa4387 Support for MPLS over VLAN.
Patch by Chris Kanich.

BIT-1017 #merged
2014-02-14 12:07:24 -08:00
Robin Sommer
7d0fbcd7b7 Merge remote-tracking branch 'origin/topic/jsiwek/dns-perf'
* origin/topic/jsiwek/dns-perf:
  Refactor DNS script's state management to improve performance.

BIT-1133
2014-02-13 16:42:41 -08:00
Jon Siwek
3c95d1d695 Refactor DNS script's state management to improve performance.
The amount of timers involved in DNS::PendingMessage tables'
expiration attributes have a significant performance hit.  Instead the
script now relies solely on maximum thresholds for pending message
quantities to limit amount of accumulated state.  There's a new option,
"DNS::max_pending_query_ids", to limit the number outstanding messages
across all DNS query IDs ("DNS::max_pending_msgs" still limits number
of outstanding messages for a *given* query ID).
2014-02-13 14:55:45 -06:00
Robin Sommer
a57f0ef9a0 Merge remote-tracking branch 'origin/fastpath'
* origin/fastpath:
  Increase timeouts of some unit tests.
  Fix memory leak in modbus analyzer.
  add channel_id tls extension number.
2014-02-13 12:45:02 -08:00
Seth Hall
dd0856a57f HTTP CONNECT proxy support.
- The HTTP analyzer now supports handling HTTP CONNECT proxies
   same as the SOCKS analyzer handles proxying.
2014-02-12 22:38:59 -05:00
Jon Siwek
e844727e73 Increase timeouts of some unit tests. 2014-02-12 17:03:51 -06:00
Robin Sommer
39be3828fd Baseline updates for DNS change.
I assume these are expected, and in any case it's DS that's being
tested not DNS. :)
2014-02-11 16:16:09 -08:00
Seth Hall
70316a3f14 Merge remote-tracking branch 'origin/topic/jsiwek/dns-improvements'
* origin/topic/jsiwek/dns-improvements:
  Rewrite DNS state tracking which matches queries and replies.
  Change dns.log to include only standard DNS queries.
  Improve DNS analysis.
2014-02-09 23:50:43 -05:00
Robin Sommer
2fb9efa294 Merge remote-tracking branch 'origin/fastpath'
* origin/fastpath:
  Fix x509-extension test sometimes failing.
2014-02-07 08:07:08 -08:00
Robin Sommer
d81bfed45d Fixing memory leaks in input framework. 2014-02-06 17:58:56 -08:00
Bernhard Amann
4b63b30901 Fix x509-extension test sometimes failing.
For some fields, the format apparently is not consistens over
OpenSSL versions. For the test, we simply skip those.
2014-02-05 10:01:51 -08:00
Robin Sommer
126fbb6ba9 Merge remote-tracking branch 'origin/topic/jsiwek/tcp-improvements'
* origin/topic/jsiwek/tcp-improvements:
  Add script to detect filtered TCP traces, addresses BIT-1119.

BIT-1119 #merged

If we could only disable an event handler dynamically ...
2014-02-04 22:34:35 -08:00
Jon Siwek
0cb2a90da4 Add script to detect filtered TCP traces, addresses BIT-1119.
If reading a trace file w/ only TCP control packets, a warning is
emitted to suggest the 'detect_filtered_traces' option if the user
doesn't desire Bro to report missing TCP segments for such a trace file.
2014-01-31 17:04:58 -06:00
Robin Sommer
4621745906 Merge remote-tracking branch 'origin/fastpath'
* origin/fastpath:
  Also use exec-module test to check for leaks.
2014-01-30 16:02:22 -08:00
Robin Sommer
dfcb4938d0 Merge remote-tracking branch 'origin/topic/jsiwek/tcp-improvements'
* origin/topic/jsiwek/tcp-improvements:
  Fix file_over_new_connection event to trigger when entire file is missed.
  Improve TCP connection size reporting for half-open connections.
  Improve gap reporting in TCP connections that never see data.
  Improve TCP FIN retransmission handling.

BIT-1119
2014-01-28 15:24:20 -08:00
Bernhard Amann
62b3cb0a5b Also use exec-module test to check for leaks. 2014-01-28 12:28:12 -08:00
Jon Siwek
31866f8f59 Change dns.log to include only standard DNS queries.
The scope of dns.log is now only standard queries (OPCODE == 0).  Other
kinds of queries (e.g. inverse query) were not handled correctly and
could interfere with the state tracking of the default DNS scripts.
2014-01-28 13:56:22 -06:00
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
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
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
Jon Siwek
e18084b68d Add unit tests for new Bro Manual docs. 2014-01-21 16:01:55 -06: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
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
Jon Siwek
58c7fcbbf1 Canonify output of a unit test. 2013-12-20 11:44:06 -06:00
Robin Sommer
ae9e0d4cb6 Fixing segfault with mismatching set &default in record field. 2013-12-18 09:17:05 -08:00
Jon Siwek
63c36d58f3 Another attempt to improve core.when-interpreter-exceptions unit test.
lookup_hostname("localhost") occassionally timed out (after allowed 10
secs) when running test suite on some systems.  Not sure why, but
changed to use the Exec module for when block conditions instead as the
scope of the test doesn't depend on a particular type of condition, it
just needs something that will work reliably/quickly.
2013-12-11 14:28:23 -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
5049d68c1b Merge remote-tracking branch 'origin/topic/seth/ie11-software-parsing'
* origin/topic/seth/ie11-software-parsing:
  Updated software framework to support parsing IE11 user-agent strings.
  Fix the irc_reply event for several server message types.

BIT-1104 #merged
2013-12-09 13:21:20 -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
Seth Hall
6d782e6834 Updated software framework to support parsing IE11 user-agent strings. 2013-12-05 15:05:11 -05:00
Bernhard Amann
504d22b91b fix memory leak in input framework.
If the input framework was used to read event streams and
those streams contained records with more than one field, not all
elements of the threading Values were cleaned up.

The reason for this is, that the SendEventStreamEvent function
returned the number of record elements in the outmost record
instead of the number of unrolled elements in the whole vector.

This number is later used to determine how many objects to delete.

Also - add a whole bunch of leak checks for the input framework
that would have caught that and should cover quite a number of
use-cases.
2013-12-05 10:53:12 -08:00
Robin Sommer
574018f478 Merge remote-tracking branch 'origin/fastpath'
* origin/fastpath:
  Improve a unit test involving 'when' conditionals.
2013-12-05 07:54:18 -08:00
Robin Sommer
81096820f3 Merge remote-tracking branch 'origin/topic/jsiwek/string-slicing-fix'
* origin/topic/jsiwek/string-slicing-fix:
  Support omission of string slice low/high indices, BIT-1097.
2013-12-04 13:45:47 -08:00
Robin Sommer
3c6f82ca73 More test updates.
The dump-events.bro generates output that would show in the Broxygen
all-script tests. Suppressing that manually in the test for lack of a
better idea.
2013-12-04 13:45:03 -08:00
Jon Siwek
8515d3aa57 Support omission of string slice low/high indices, BIT-1097.
Omission of the low index defaults to 0:

    s = "12345"; s[:3] == "123"

Omission of the high index defaults to length of the string:

    s = "12345"; s[3:] == "45"
2013-12-04 15:11:48 -06:00
Robin Sommer
dda5e43aa9 Merge branch 'topic/robin/string-slicing-fix' 2013-12-04 12:42:22 -08:00