% $Header: /home/jaguar/u0/vern/bro/bro-doc/RCS/started.tex,v 1.9 2002/11/16 00:41:05 vern Exp vern $

\labsectchapter{{Getting Started}}{\label{getting-started}}
%HEVEA\cutdef[1]{section}

This chapter gives an overview of how to get started with operating Bro:
\emph{(i)} compiling it, \emph{(ii)} running it interactively, on live
network traffic, and on recorded traces, \emph{(iii)} how Bro locates the
policy files it should evaluate and how to modify them, \emph{(iv)} the
arguments you can give it to control its operation, and \emph{(v)} some
helper utilities also distributed with Bro that you'll often find handy.

\section{Running Bro}

\index{running Bro}
\index{Bro!running}

This section discusses how to build and install Bro, running it interactively
(mostly useful for building up familiarity with the policy language, not
for traffic analysis), running it on live and recorded network traffic,
modifying Bro policy scripts, and the different run-time flags.

\subsection{Building and installing Bro}
\index{Bro!installing}
\index{building Bro}
\index{compiling Bro}

\subsubsection{ Supported platforms }

\index{Unix support}
\index{Windows!not supported}
\index{NT!not supported}

Bro builds on a number of types of Unix: \updateme{ FreeBSD, Solaris,
Linux, SunOS, and Digital Unix}, though not all versions.  It does \emph{not}
build under non-Unix operating systems such as Windows NT.

\subsubsection{ The Bro source code distribution }
\index{source code!for Bro}
\index{Bro!source code}
\index{Bro!web page}

You can get the latest public release of Bro from the Bro web page,
\latexhtml{{\tt http:\linebreak[0]//www.icir.org/\linebreak[0]vern/\linebreak[0]bro.html}}{\htmladdnormallink{http://www.icir.org/vern/bro.html}{http://www.icir.org/vern/bro.html}}.
Bro is distributed as a \emph{gzip}'d Unix \emph{tar} archive, which
you can unpack using:
\begin{quotation}
    {\verb+gzcat +\emph{tar-file} \verb+| tar xf -+}
\end{quotation}
or, on some Unix systems:
\begin{quotation}
    {\verb+tar zxf +\emph{tar-file}}
\end{quotation}
This creates a subdirectory {\verb+bro-+\emph{XXX}\verb+-+\emph{version}},
where \emph{XXX} is a tag such as {\tt pub} for public releases and
{\tt priv} for private releases, and \emph{version} reflects a version
and possibly a subversion, such as \updateme{{\tt 0.8a20}} for version
\emph{0.8} and subversion \emph{a20}.

To build Bro, change to the Bro directory and enter:
\begin{quotation}
    {\tt \noindent ./configure \\
    make
    }
\end{quotation}

\fixme{Need to discuss configuration options here.}
\indconfig{enable-brov6}

\index{BIND!non-blocking DNS lookups}
\index{non-blocking DNS lookups}
\index{DNS lookups!non-blocking}
This will compile all of the Bro sources, including a version of the BIND
DNS library, version~8, which Bro uses for its non-blocking DNS lookups.

\index{Linux!compiling Bro under}
\note{ For Linux systems, you may need to use the header files in
the \emph{linux-include/} subdirectory included in the Bro distribution
to successfully compile Bro. }

\subsubsection{ Installing Bro }
\index{installing Bro}

You install Bro by issuing:
\begin{quotation}
    \tt \noindent make install
\end{quotation}

\note{ I don't actually use this functionality myself, so it does not tend
to be well tested and may have bugs. }

\subsubsection{ Tuning BPF }
\index{Bro!system configuration}
\index{system configuration}
\index{optimizing your system for Bro}
\index{BPF (Berkeley Packet Filter)!tuning}

Bro is written using \indlibrary{libpcap}, the portable packet-capture
library available from
{\tt ftp:\linebreak[0]//ftp.ee.lbl.gov/\linebreak[0]libpcap.tar.Z}.  While
\emph{libpcap} knows how to use a wide range of Unix packet filters, it
far and away performs most efficiently used in conjunction with the Berkeley
Packet Filter (BPF) and with BPF descendants (such as the Digital Unix
packet filter).  Althought BPF is available from
{\tt ftp:\linebreak[0]//ftp.ee.lbl.gov/\linebreak[0]bpf.tar.Z}, installing
it involves modifying your kernel, and perhaps requires significant porting
work.  However, it comes as part of several operating systems, such as
FreeBSD, NetBSD, and OpenBSD.

For BPF systems, you should be aware of the follwoing tuning and
configuration issues:
\begin{description}
\item[BPF kernel support]
You need to make sure that kernel support for BPF is enabled.  In addition,
some systems default to configuring kernel support for only one BPF device.
This often proves to be a headache because it means you cannot run more
than one Bro at a time, nor can you run it at the same time as
\indttbang{tcpdump}{running concurrently with Bro}.

\item[/dev/bpf devices]\index{dev/bpf@{\em /dev/bpf}}  Related to the
previous item, on BPF systems access to the packet filter is via special
\emph{/dev/bpf} devices, such as \emph{/dev/bpf0}.  Just as you need to
make sure that the kernel's configuration supports multiple BPF devices,
so to must you make sure that an equal number of device files reside in
\emph{/dev/}.

\item[packet filter permissions]\index{packet filter!permissions}\index{packet filter!access}\index{root!Bro not running as}\index{Bro!not running as root}
On systems for which access to the packet filter is via the file system,
you should consider whether you want to only allow root access, or instead
create a Unix \emph{group} for which you enable read access to
the device file(s).  The latter allows you to run Bro as a user other
than root, which is \emph{strongly recommended}!

\item[large BPF buffers]
\index{BPF buffers!ensuring they are large}
\index{large BPF buffers}
\index{buffers!large for BPF}
While running with BPF is often necessary for high performance, it's not
necessarily sufficient.  By default, BPF programs use very modest kernel
buffers for storing packets, which leads to high context switch overhead
as the kernel very often has to deliver packets to the user-level Bro
process.  Minimizing the overhead requires increasing the buffer sizes.
This can make a \emph{large} difference!

Under FreeBSD, the configuration variable to increase is
{\tt debug.bpf_bufsize}, which you can set via \emph{sysctl}.  We
recommend creating a script run at boot-up time that increases it
from its small default value to something on the order of 100~KB--2~MB,
depending on how fast (heavily loaded) is the link being monitored,
and how much physical memory the monitor machine has at its disposal.

\index{libpcap buffer size patch@{\emph libpcap} buffer size patch}
\index{buffer size patch for libpcap@buffer size patch for {\emph libpcap}}
\emph{Important note}:  some versions of \xreflibrary{libpcap} have
internal code that limits the maximum buffer size to 32~KB.  For
these systems, you should apply the patch included in the Bro distribution
in the file {\tt libpcap.patch} .

Finally, once you have increased the buffer sizes, you should \emph{check}
that running Bro does indeed consume the amount of kernel memory you
expect.  You can do this under FreeBSD using \emph{vmstat -m} and
searching in the output for the summary of BPF memory.  You should find
that the \emph{MemUse} statistic goes up by twice the buffer size for
every concurrent Bro or {\tt tcpdump} you run.\footnote{Providing that
these programs have been recompiled with the corrected \emph{libpcap}
noted above.}  The reason the increase is by twice the buffer size is
because Bro uses double-buffering to avoid dropping packets when the
buffer fills up.
\end{description}

\subsection{Using Bro interactively}
\index{Bro!interactive use}

Once you've built Bro, you can run it interactively to try out simple
facets of the policy language.  Note that in this mode, Bro is \emph{not}
reading network traffic, so you cannot do any traffic analysis; this mode
is simply to try out Bro language features.

You run Bro interactively by simply executing ``{\tt bro}'' without
any arguments.  It then reads from \emph{stdin} and writes to \emph{stdout}.

Try typing the following to it:
\begin{quotation}
    \noindent {\tt print "hello, world";} \\
    \noindent \verb+^D+ \emph{(i.e., end of file)}
\end{quotation}
(The end-of-file is critical to remember.  It's also a bit annoying for
interactive evaluation, but reflects the fact that Bro is not actually
meant for interactive use, it simply works as a side-effect of Bro's
structure.)

Bro will respond by printing:
\begin{quotation}
    \noindent hello, world
\end{quotation}
to \emph{stdout} and exiting.

You can further declare variables and print expressions, for example:
\begin{verbatim}
    global a = telnet;
    print a, a > ftp;
    print www.microsoft.com;
\end{verbatim}
will print
\begin{verbatim}
    23/tcp, T
    207.46.230.229, 207.46.230.219, 207.46.230.218
\end{verbatim}
where {\tt 23/tcp} reflects the fact that {\tt telnet} is a predefined
variable whose value is TCP port 23, which is larger than TCP port 21
(i.e., {\tt ftp}); and the DNS name \emph{www.microsoft.com} currently
returns the above three addresses.

You can also define functions:
\begin{verbatim}
    function top18bits(a: addr): addr
        {
        return mask_addr(a, 18);
        }

    print top18bits(128.3.211.7);
\end{verbatim}
prints
\begin{verbatim}
    128.3.192.0
\end{verbatim}
and even event handlers:
\begin{verbatim}
    event bro_done()
        {
        print "all done!";
        }
\end{verbatim}
which prints ``{\tt all done!}'' when Bro exits.

\subsection{Specifying policy scripts}

Usually, rather than running Bro interactively you want it to execute
a policy script or a set of policy scripts.  You do so by specifying
the names of the scripts as command-line arguments, such as:
\begin{verbatim}
    bro ~/my-policy.bro ~/my-additional-policy.bro
\end{verbatim}
Bro provides several mechanisms for simplifying how you specify which
policies to run.

First, if a policy file doesn't exist then it will
try again using {\tt .bro} as a suffix, so the above could be specified as:
\begin{verbatim}
    bro ~/my-policy ~/my-additional-policy
\end{verbatim}

Second, Bro consults the colon-separated search path \xrefenv{BROPATH}
to locate policy scripts.  If your home directory was listed in {\tt \$BROPATH},
then you could have invoked it above using:
\begin{verbatim}
    bro my-policy my-additional-policy
\end{verbatim}

\note{ If you define {\tt \$BROPATH}, you \emph{must} include
\emph{bro-dir}{\tt{}/policy}, where \emph{bro-dir} is where you have
built or installed Bro, because it has to be able to locate
\emph{bro-dir}{\tt{}/policy/bro.init} to initialize itself at run-time. }

Third, the \load directive can be used in a policy script to indicate the
Bro should at that point process another policy script (like C's {\tt include}
directive; see \xref{analyzer-load}).  So you could have in \emph{my-policy}:
\begin{verbatim}
    @load my-additional-policy
\end{verbatim}
and then just invoke Bro using:
\begin{verbatim}
    bro my-policy
\end{verbatim}
providing you \emph{always} want to load \emph{my-additional-policy}
whenever you load \emph{my-policy}.

Note that the predefined Bro module \xrefmodule{mt} loads almost
all of the other standard Bro analyzers, so you can pull them in
with simply:
\begin{verbatim}
    @load mt
\end{verbatim}
or by invoking Bro using ``{\tt bro mt \emph{my-policy}}''.

\subsection{Running Bro on network traffic}

There are two ways to run Bro on network traffic: on traffic captured
live by the network interface(s), and on traffic previously recorded
using the {\tt -w} flag of \indttbang{tcpdump}{reading save files} or Bro
itself.

\labsectsubsubsection{{Live traffic}}{\label{network-interfaces}}
\index{network interfaces}
\index{analysis!on-line}
\index{on-line analysis}

Bro reads live traffic from the local network interface whenever you
specify the \xrefflag{-i} flag.  As mentioned below, you can specify
multiple instances to read from multiple interfaces simultaneously,
however the interfaces must all be of the same link type (e.g., you
can't mix reading from a Fast Ethernet with reading from an FDDI link,
though you can mix a 10 Mbps Ethernet interface with a 100 Mbps Ethernet).

In addition, Bro will read live traffic from the interface(s) listed in
the \xrefglobalind{interfaces} variable, \emph{unless} you specify
the \xrefflag{-r} flag (and do not specify \xrefflag{-i}).  So, for
example, if your policy script contains:
\begin{verbatim}
    const interfaces += "sk0";
    const interfaces += "sk1";
\end{verbatim}
then Bro will read from the \emph{sk0} and \emph{sk1} interfaces,
and you don't need to specify {\tt -i}.

\subsubsection{Traffic traces}
\index{analysis!off-line}
\index{off-line analysis}

To run on recorded traffic, you use the \xrefflag{-r} flag to indicate
the trace file Bro should read.  As with \xrefflag{-i}, you can use the
flag multiple times to read from multiple files; Bro will merge the packets
from the files into a single packet stream based on their timestamps.

The Bro distribution includes an example trace that you can try out,
\emph{example.ftp-attack.trace}.  If you invoke Bro using:
\begin{verbatim}
    setenv BRO_ID example
    bro -r example.ftp-attack.trace mt
\end{verbatim}
you'll see that it generates a connection summary to \emph{stdout},
a summary of the FTP sessions to {\tt ftp.example}, a copy of what
would have been real-time alerts had Bro been running on live traffic
to {\tt log.example}, and a summary of unusual traffic anomalies (none in
this trace) to {\tt weird.example}.

\subsection{Modifying Bro policy}

One way to alter the policy Bro executes is of course to directly
edit the scripts.  When this can be avoided, however, that is preferred,
and Bro provides a pair of related mechanisms to help you specify
\emph{refinements} to existing policies in separate files.

The first such mechanism is that you can define \emph{multiple}
handlers for a given event.  So, for example, even though the standard
\xrefanalyzer{ftp} analyzer (\emph{bro-dir}{\tt{}/policy/ftp.bro})
defines a handler for \xrefevent{ftp_request}, you can define another handler
if you wish in your own policy script, even if that policy script loads
(perhaps indirectly, via the \xrefmodule{mt} module) the {\tt ftp} analyzer.
When the event engine generates an {\tt ftp_request} event, \emph{both}
handlers will be invoked.  \deficiency{ Presently, you do not have control
over the order in which they are invoked; you also cannot completely override
one handler with another, preventing the first from being invoked. }

Second, the standard policy scripts are often written in terms of
\emph{redefinable} variables.  For example, {\tt ftp.bro} contains
a variable \xrefvar{ftp_guest_ids} that defines a list of usernames
the analyzer will consider to reflect guest accounts:
\begin{verbatim}
    const ftp_guest_ids = { "anonymous", "ftp", "guest", } &redef;
\end{verbatim}
While ``{\tt const}'' marks this variables as constant at run-time,
the attribute ``{\tt \&redef}'' specifies that its value can be
redefined.

For example, in your own script you could have:
\begin{verbatim}
    redef ftp_guest_ids = { "anonymous", "guest", "visitor", "student" };
\end{verbatim}
instead.  (Note the use of ``{\tt redef}'' rather than ``{\tt const}'',
to indicate that you realize you are redefining an existing variable.)

In addition, for most types of variables you can specify \emph{incremental}
changes to the variable, either new elements to add or old ones to
subtract.  For example, you could instead express the above as:
\begin{verbatim}
    redef ftp_guest_ids += { "visitor", "student" };
    redef ftp_guest_ids -= "ftp";
\end{verbatim}
The potential advantage of incremental refinements such as these are that
if any \emph{other} changes are made to {\tt ftp.bro}'s original definition,
your script will automatically inherit them, rather than replacing them
if you used the first definition above (which explicitly lists all four
names to include in the variable).  Sometimes, however, you don't want this
form of inheriting later changes; you need to decide on a case-by-case
basis, though our experience is that generally the incremental approach
works best.

Finally, the use of \emph{prefixes} provides a way
to specify a whole set of policy scripts to load in a particular context.
For example, if you set \xrefenv{BRO_PREFIXES} to ``{\tt dialup}'',
then a load of {\tt ftp.bro} will \emph{also} load {\tt dialup.ftp.bro}
automatically (if it exists).  See \xref{prefixes} for further discussion.

\subsection{Bro flags and run-time environment}

\subsubsection{Flags}

When invoking Bro, you can control its behavior using the following flags:
\begin{description}
\indflagtwo{f}{filter}
Use \emph{filter} as the \indttbang{tcpdump}{filters} filter for
capturing packets, rather than the combination of \xrefglobalind{capture_filter}
and \xrefglobalind{restrict_filter}, or the default of
``{\tt tcp or udp}'' \pxref{filtering}.

\index{help message}
\index{Bro!usage}
\index{usage message}
\indflag{h}
Generate a help message summarizing Bro's options and environment variables,
and exit.

\index{network interfaces}
\index{analysis!on-line}
\index{on-line analysis}
\indflagtwo{i}{interface}
Add \emph{interface} to the list of interfaces from which Bro should
read network traffic \pxref{network-interfaces}.  You can use this flag
multiple times to direct Bro to read from multiple interfaces.
You can also, or in addition, use refinements of the \xrefglobalind{interfaces}
variable to specify interfaces.

Note that if no interfaces are specified, then Bro will not read
any network traffic.  It does \emph{not} have a notion of a ``default''
interface from which to read.

\indenvnotext{BRO_PREFIXES}
\index{prefixes}
\indflagtwo{p}{prefix}
Add \emph{prefix} to the list of prefixes searched by Bro when \loadx'ing
a script.  You can also, or in addition, use \prefix to specify search
prefixes.  See \xref{prefixes} for discussion.

\index{trace file!reading}
\index{save file!reading}
\index{analysis!off-line}
\index{off-line analysis}
\index{reading tcpdump files@reading {\tt tcpdump} files}
\indflagtwo{r}{readfile}
Add \emph{readfile} to the list of \indttbang{tcpdump}{reading save files}
save files that Bro should read.  You can use this flag multiple times to
direct Bro to read from multiple save files; it will merge the packets
read from the different files based on their timestamps.  Note that if
the save files contain only packet headers and not contents, then of
course Bro's analysis of them will be limited.

Note that use of {\tt -r} is \emph{mutually exclusive} with use of {\tt -i}.
However, you can use {\tt -r} when running scripts that refine
\xrefglobal{interfaces}, in which case the {\tt -r} option takes precedence
and Bro performs off-line analysis.

\index{trace file!writing}
\index{save file!writing}
\index{writing tcpdump files@writing {\tt tcpdump} files}
\index{HTTP packets!contents not being recorded}
\indflagtwo{w}{writefile}
Write a \indttbang{tcpdump}{writing save files} save file to the file
\emph{writefile}.  Bro will record all of the packets it captures,
including their contents, except as controlled by calls to
\xreffunc{set_record_packets}.

\index{SYN control packet}
\index{FIN control packet}
\index{RST control packet}
\index{TCP control packets (SYN/FIN/RST)}
\index{control packets (SYN/FIN/RST)}
\index{packets!control (SYN/FIN/RST)}
\note{ One exception is that unless you are analyzing HTTP events
(for example, by \loadx'ing the \xrefanalyzer{http} analyzer), Bro does
\emph{not} record the \emph{contents} of HTTP SYN/FIN/RST packets to the
trace file.  The reason for this is that HTTP FIN packets often contain
a large amount of data, which is not of any interest if you are not using
HTTP analysis, and due to the very high volume of HTTP traffic at many
sites, removing this data can significantly reduce the size of the save
file.} \deficiency{ Clearly, this should not be hardwired into Bro but
under user control. }

Save files written using {\tt -w} are of course readable using {\tt -r}.
Accordingly, you will generally want to use {\tt -w} when running Bro on
live network traffic so you can rerun it off-line later to understand
any problems that arise, and also to experiment with the effects of changes
to the policy scripts.

You can also combine {\tt -r} with {\tt -w} to both read a save file(s) and
write another.  This is of interest when using multiple instances of
{\tt -r}, as it provides a way to merge \indttbang{tcpdump}{merging save files}
save files.

\index{version message}
\index{Bro!version}
\indflag{v}
Print the version of Bro and exit.

\index{DNS!Bro's private cache!forcing access to}
\index{forcing access to Bro's private DNS cache}
\index{Bro!private caches}
\indflag{F}
Instructs Bro that it \emph{must} resolve all hostnames out of its
private DNS cache \pxref{dns-cache}.  If the script refers to a hostname
not in the cache, then Bro \emph{exits} with a fatal error.

\index{checkpointing Bro}
\index{Bro!checkpointing}
The point behind this option is to ensure that Bro starts quickly, rather
than possibly stalling for an indeterminant amount of time resolving a
hostname.  Fast startup simplifies checkpointing a running Bro---you can
start up a new Bro and then killing off the old one shortly after.
You'd like this to occur in a manner such that there's no period during
which neither Bro is watching the network (the older because you killed
it off too early, the newer because it's stuck resolving hostnames).

\deficiency{ {\tt -F} should also force Bro to load all regular expressions
from its regular expression cache \pxref{re-cache}, but currently it
doesn't do so. }

\index{optimizer for policy script interpreter}
\index{policy script interpreter!optimizer}
\index{Bro!optimizer}
\indflag{O}
Turns on Bro's optimizer for improving its internal representation
of the policy script.  \note{ Currently, the amount of improvement
is modest, and there's (as always) a risk of an optimizer bug introducing
errors into the execution of the script, so the optimizer is not
enabled by default. }

\index{regular expressions!Bro's private cache}
\index{caches!Bro's private ones}
\index{Bro!private caches}
\index{priming Bro's private caches (DNS, regular expression)}
\indflag{P}
Instructs Bro to \emph{prime} its private DNS cache \pxref{dns-cache}.
It does so by parsing the policy scripts, but not executing them.
Bro looks up each hostname's address(es) and records them in the private
cache.  The idea is that once {\tt bro -P} finishes, you can then use
{\tt bro -F} to start up Bro quickly because it will read all the
information it needs from the cache.

\index{regular expressions!compiling}
\index{Bro!startup slow due to compiling regular expressions}
\index{slow startup due to compiling regular expressions}
\index{startup slow due to compiling regular expressions}
\index{compiling regular expressions}
\index{bro-RE-cache.v1@{\tt .bro-RE-cache.v1}}
\label{re-cache}
In addition to resolving DNS lookups, Bro will also compile all of the
regular expressions used in the script.  \note{ Such compilations can
take a \emph{long} time---many minutes---so it is crucial for Bro to
cache the results.}  It does so in the file
``{\tt .bro-RE-cache.v1}'' in the user's home directory.  You can delete
this file whenever you want, for example to purge out old entries no longer
needed.

\note{ You don't actually need to use {\tt -P} to tell Bro to compile
the regular expressions.  It does so anyway whenever it encounters one
that isn't already in the cache.  Likewise, you don't need to use
{\tt -F} to tell Bro to use the regular expression cache---it will do
so automatically whenever it can.  But it's important that Bro does
compilation during {\tt -P} to help with ensuring that a subsequent
invocation of Bro starts up quickly. }

\deficiency{ Bro should support \emph{incrementally compiled} regular
expressions to avoid the expensive compilation phase altogether. }

\index{Bro!wedging}
\index{watchdog}
\index{Bro!watchdog}
\index{Bro!execution aborted}
\index{aborted execution}
\indruntime{watchdog timer expired}
\indflag{W}
Instructs Bro to activate its internal \emph{watchdog}.  The watchdog
provides self-monitoring to enable Bro to detect if its processing is
wedged.

Bro only activates the watchdog if it is reading live network traffic.
The watchdog consists of a periodic timer that fires every
\indintvar{WATCHDOG_INTERVAL} seconds.  (\deficiency{clearly this
should be a user-definable value.})  At that point, the watchdog checks
to see whether Bro is still working on the same packet as it was the last
time the watchdog expired.  If so, then the watchdog logs this fact along
with some information regarding when Bro began processing the current
packet and how many events it processed after handling the packet.  Finally,
it prints the packet drop information for the different interfaces Bro
was reading from, and aborts execution.

\end{description}

\subsubsection{Run-time environment}

Bro is also sensitive to the following environment variables:
\begin{description}
\index{search path}
\index{Bro!search path}
\index{policy directories}
\index{usr/local/lib/bro@\emph{/usr/local/lib/bro/} policy directory}
\index{policy@\emph{policy/} policy directory}
\index{policy/local@\emph{policy/local/} policy directory}
\itemindenv{BROPATH}
A colon-separated list of directories that Bro searches whenever
you \load a policy file.  It loads the first instance it finds (though
see {\tt \$BRO_PREFIXES} for how a single \load can lead to Bro loading
multiple files).

Default: if you don't set this variable, then Bro uses the path
\begin{verbatim}
    .:policy:policy/local:/usr/local/lib/bro
\end{verbatim}
That is, the current directory, any \emph{policy/} and \emph{policy/local/}
subdirectories, and \emph{/usr/local/lib/bro/}.

\index{prefixes}
\index{bro suffix@{\tt .bro} suffix}
\indruntime{can't open}
\itemindenv{BRO_PREFIXES}
A colon-separate lists of \emph{prefixes} that Bro should apply to
each name in a \load directive.  For a given prefix and load-name, Bro
constructs the filename:
\begin{quotation}
    \emph{prefix}{\tt{}.}\emph{load-name}{\tt{}.bro}
\end{quotation}
(where it doesn't add {\tt .bro} if \emph{load-name} already ends in
{\tt .bro}).  It then searches for the filename using {\tt \$BROPATH}
and loads it if its found.  Furthermore, it \emph{repeats} this process
for all of the other prefixes (left-to-right), and loads \emph{each}
file it finds for the different prefixes.  \note{ Bro \emph{also} first
attempts to load the filename without any prefix at all. If this load
fails, then Bro exits with an error complaining that it can't open
the given \load file.}

For example, if you set {\tt \$BRO_PREFIXES} to:
\begin{verbatim}
    mysite:mysite.wan
\end{verbatim}
and then issue ``\load {\tt ftp}'', Bro will attempt to load each of the
following scripts in the following order:
\begin{verbatim}
    ftp.bro
    mysite.ftp.bro
    mysite.wan.ftp.bro
\end{verbatim}

Default: if you don't specify a value for {\tt \$BRO_PREFIXES}, it defaults
to empty, and for the example above Bro would only attempt to \load
{\tt ftp.bro}.

\end{description}

\section{Helper utilities}

\subsection{Scripts}

% here ###
Documentation missing.

\subsection{The \indutility{hf} utility}

\index{hostnames!mapping addresses to}
\index{addresses!mapping to hostnames}
\index{dotted quads}
The \emph{hf} utility reads text on \emph{stdin} and attempts to convert any
``dotted quads'' it sees to hostnames.  It is very convenient for running
on Bro log files to generate human-readable forms.  See the manual page
included with the distribution for details.

\subsection{The \indutility{cf} utility}

\index{timestamps!mapping to readable form}
\index{Unix timestamps}
The \emph{cf} utility reads Unix timestamps at the beginning of lines on
\emph{stdin} and converts them to human-readable form.  For example,
for the input line:
\begin{verbatim}
972499885.784104 #26 131.243.70.68/1899 > 64.55.26.206/ftp start
\end{verbatim}
it will generate:
\begin{verbatim}
Oct 25 11:51:25 #26 131.243.70.68/1899 > 64.55.26.206/ftp start
\end{verbatim}

It takes two flags:
\begin{description}
\item[{\tt -l}]\nl
specifies the \emph{long} human-readable form, which includes the year.
For example, on the above input, the output would instead be:
\begin{verbatim}
Oct 25 11:51:25 2000 #26 131.243.70.68/1899 > 64.55.26.206/ftp start
\end{verbatim}

\item[{\tt -s}]\nl
specifies \emph{strict} checking to ensure that the number at the beginning
of a line is a plausible timestamp: it must have at least 9 digits, at most
one decimal, and must have a decimal if there are 10 or more digits.

Without {\tt -s}, an input like:
\begin{verbatim}
131.243.70.68 > 64.55.26.206
\end{verbatim}
generates the output:
\begin{verbatim}
Dec 31 16:02:11 > 64.55.26.206
\end{verbatim}
which, needless to say, is not very helpful.  \deficiency{ It seems clear
that {\tt -s} should be the default behavior. }

\end{description}

%HEVEA\cutend

