



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Version: December 13, 2012 Website: http://www.bro-ids.org Email: [email protected] Download: https://github.com/broids/cheat-sheet License: Attribution-NonCommercial-ShareAlike 3.0 Unported
bro [options] [file ...] file.................... .Bro policy script or stdin -e code............ Augment policies by given code -h................... Display command line options -i iface................ Read from given interface -p pfx........ Add given prefix to policy resolution -r file................ Read from given PCAP file -w file........ Write to given file in PCAP format -x file................. Print contents of state file -C.......................... Ignore invalid checksum
Lowercase letters represent instance variables and up- percase letters represent types. In general, x is an instance of type T and y an instance of type U. Argu- ment names and record fields begin with a, b,... , and z represents a default instance variable which takes on the type of the right-hand side expression. For nota- tional convenience, x can often be replaced with an expression of type T.
Constant qualifier............................ const Constant redefinition............ redef x op expr Scope qualifier....................... local, global Declaration............................ scope x: T Declaration & Definition.......... scope z = expr
Type................................ type name : T Function.............. function f(a: T, ...): R Event......................... event e(a: T, ...)
Script import.......................... @load path Set current namespace to ns............ module ns Export global symbols............. export { ... } Access module or enum namespace............. T::a
Basic statement.................... stmt ; or expr ; Code block........................ { stmt ; ... } Assignment.............................. z = expr Function assignment. z = function(...): R {..} Event queuing....................... event e(...) Event scheduling... schedule 10 secs { e(...) } Print expression to stdout............. print expr
Branching if (expr ) { ... } else if (expr ) { ... } else { ... }
Iteration for (i in x) { ... } Asynchronous when (expr ) { ... } when (local x = expr ) { ... }
Control break continue next return
Operators !.......................................... Negation $, ?$............. Dereference, record field existence +, - , *, /, %............................. .Arithmetic ++, --.............. Post-increment, post-decrement +=, -=, *=, /=........... Arithmetic and assignment ==, !=.......................... Equality, inequality <, <=, >=, >............ Less/greater than (or equal) &&, ||..................... Conjunction, disjunction in, !in........... .Membership or pattern matching [x].................... Index strings and containers |x| Cardinality/size for addresses, strings, containers f(...)................................ Function call expr? expr : expr............ Ternary if-then-else
Basic addr IP address (v4: 127.0.0.1, v6: [fe80::db15])
bool............................ .Boolean flag (T, F) count.................. 64-bit unsigned integer ( 42 ) double....... Double-precision floating point (99.9) int....................... 64-bit signed integer (-7) interval.... Time interval (8 sec/min/hr/day[s]) pattern......... Regular expression (/^br[oO])$/) port........ Transport-layer port (22/tcp, 53/udp) string...................... String of bytes ("foo") subnet........... CIDR subnet mask (10.0.0.0/8) time............ Absolute epoch time ( 1320977325 )
Enumerables Declaration.................... enum { FOO, BAR } Assignment......................... scope x = FOO
Records Declaration........ record { a: T, b: U, ... } Constructor............ .record($a=x, $b=y, ...) Assignment........ scope r = [$a=x, $b=y, ...] Access..................................... z = r$a Field assignment........................... r$b = y Deletion................................ delete r$a
Sets Declaration................................. set[T ] Constructor........................... set(x, ...) Assignment................ .scope s = { x, ... } Access.................................... z = s[x] Insertion................................. .add s[x] Deletion.............................. delete s[x]
Tables Declaration........................ table[T ] of U Constructor................. table([x] = y, ...) Assignment......... scope t = { [x] = y, ... } Access.................................... z = t[x] Insertion................................. .t[x] = y Deletion.............................. delete t[x]
Vectors Declaration........................... vector of T Constructor....................... vector(x, ...) Assignment................ .scope v = { x, ... } Access.................................... z = v[0] Insertion................................ v[42] = x
Attributes occur at the end of type/event declarations and change their behavior. The syntax is &key or &key=val, e.g., type T: set[count] &read_expire=5min or event foo() &priority=-3.
&optional..................................... Allow record field to be missing &default=x......... Use default value x for record fields and container elements &redef............................. Allow for redefinition of initial object value &expire_func=f.................. .Call f right before container element expires &read_expire=x................ Remove element after not reading it for time x &write_expire=x............... Remove element after not writing it for time x &create_expire=x................. Remove element after time x from insertion &persistent..................... Write state to disk (per default on shutdown) &synchronized.............................. .Synchronize variable across nodes &raw_output........ Do not escape non-ASCII characters when writing to a file &mergeable............... Prefer set union to assignment for synchronized state &priority=x.. Execution priority of event handler, higher values first, default 0 &group="x"...... Events in the same group can be jointly activated/deactivated &log................................................... Write record field to log
Core
Math
x.
String Processing
split_all("a-b--cd", /(-)+/) returns {"a", "-", "b", "--", "cd"}. Odd-indexed elements do not match the pattern and even-indexed ones do.
Network Type Processing