### Zeek Management Framework Quickstart Source: https://docs.zeek.org/en/master/scripts/base/protocols/http/files Provides a basic quickstart guide for the Zeek Management Framework. This section is intended to get users up and running with the framework quickly. ```zeek # Example Zeek Management Framework Configuration Snippet # This is a placeholder and not functional code. # Actual configuration involves ZeekControl commands and node definitions. ``` -------------------------------- ### Zeek Controller and Agent Startup Example Source: https://docs.zeek.org/en/master/scripts/base/frameworks/logging/index This snippet shows a basic example of launching the Zeek controller and agent processes. It demonstrates the command-line arguments used for starting these components. ```bash # Start Controller zeekctl deploy # Start Agent on a remote host (example) zeekctl start-agent --host --keyfile /path/to/ssh/key ``` -------------------------------- ### Standalone zeek-client Installation Example Source: https://docs.zeek.org/en/master/scripts/base/protocols/http/index Provides instructions for installing the `zeek-client` binary in a standalone mode, which is useful for environments where a full Zeek installation is not desired or possible. ```bash # Download the zeek-client binary from the Zeek releases page or compile it. # Example assuming you have the binary in the current directory: # Make the binary executable: # chmod +x zeek-client # Move it to a location in your PATH: # sudo mv zeek-client /usr/local/bin/ # Verify installation: # zeek-client --version ``` -------------------------------- ### Simple Supervisor Example Source: https://docs.zeek.org/en/master/scripts/base/bif/plugins/Zeek_FTP.events.bif Demonstrates a basic setup for the Supervisor Framework, showing how to start and manage a single Zeek process. ```zeek supervisor_programs += [ supervisor::Program( name = "zeek-worker", cmd = "/usr/local/zeek/bin/zeek", args = "-i eth0 -C local.zeek", num_workers = 1 ) ]; supervisor::start(supervisor_programs); ``` -------------------------------- ### Zeek zeek-client CLI Configuration Example Source: https://docs.zeek.org/en/master/scripts/base/protocols/http/files Shows an example configuration for the `zeek-client` command-line interface. This includes settings for standalone installations and compatibility. ```zeek # Placeholder for zeek-client configuration file content. # Example: configuration: # ... ``` -------------------------------- ### Zeek Script - Simple Supervisor Example Source: https://docs.zeek.org/en/master/scripts/base/bif/plugins/Zeek_NTP.events.bif Demonstrates a basic example of the Zeek Supervisor framework, showing how to start and manage a single process. ```zeek Supervisor::add("my_process", "/usr/bin/my_command --option"); Supervisor::start("my_process"); ``` -------------------------------- ### Basic Zeek Scripting: Hello World Example Source: https://docs.zeek.org/en/master/scripts/policy/frameworks/management/controller/api A fundamental 'Hello World' example demonstrating basic Zeek scripting principles, including script structure, event handlers, and outputting messages. This is often the starting point for learning Zeek scripting. ```zeek module HelloWorld; export { redef record global_vars += { name: string &default = "World"; }; } event zeek_init() { print fmt("Hello, %s!", global_vars.name); } ``` -------------------------------- ### Basic Zeek Scripting: Hello World Example Source: https://docs.zeek.org/en/master/scripts/base/packet-protocols/ip/__load__ Demonstrates a simple 'Hello World' script in Zeek, illustrating the basic syntax and execution model. This is a starting point for learning Zeek scripting. ```zeek event bro_init() { print "Hello, World!"; } ``` -------------------------------- ### Simple Supervisor Framework Example Source: https://docs.zeek.org/en/master/scripts/policy/protocols/conn/mac-logging A basic example showcasing the Zeek Supervisor Framework, likely demonstrating how to start and manage a single Zeek process. ```zeek Supervisor::add_process("my_zeek_process", "/path/to/zeek -i eth0", "/var/run/my_zeek.pid"); Supervisor::start("my_zeek_process"); ``` -------------------------------- ### Zeek TypeScript Basic 'Hello World' Example Source: https://docs.zeek.org/en/master/scripts/policy/protocols/http/detect-webapps A basic 'Hello World' example using TypeScript for Zeek scripting. This demonstrates the syntax and setup for writing Zeek scripts in TypeScript. ```typescript console.log("Hello, World from TypeScript!"); // Example of a simple Zeek event handler in TypeScript zeek.on("connection_established", (conn: zeek.Connection) => { console.log(`New connection established: ${conn.toString()}`); }); ``` -------------------------------- ### Basic Zeek Scripting: Hello World Example Source: https://docs.zeek.org/en/master/devel/plugins An introductory example demonstrating the fundamental structure of a Zeek script, including the 'Hello World' concept. This serves as a starting point for understanding Zeek's scripting language and execution model. ```zeek export module HelloWorld; redef enum Log::ID += { LOG_HELLO }; type HelloRec: record { msg: string; }; const hello_log: Log::Format = Log::default_format + "$msg\n"; init event hello_init() { # This event runs once when the script is loaded. print "Hello World script initialized!"; } event connection_started(c: connection) { # This event runs for every new connection. # For demonstration, we'll log a message. local h: HelloRec; h$msg = fmt("Connection from %s to %s started.", c$id$orig_h, c$id$resp_h); Log::write(LOG_HELLO, h); } # To run: zeek -r hello_world.zeek # Analyze the generated hello.log file. ``` -------------------------------- ### Zeek Scripting: Basic 'Hello World' Example in JavaScript Source: https://docs.zeek.org/en/master/scripts/base/protocols/irc/dcc-send This example demonstrates a basic 'Hello World' script in JavaScript for Zeek. It covers the preamble, the built-in plugin, and the execution model, providing a starting point for users new to Zeek scripting. ```javascript /* Zeek JavaScript Example: Hello World */ // Preamble (optional, often for metadata) @zeek.plugin("hello_world") // Basic function to log a message function say_hello() { zeek.log("Hello, World from Zeek JavaScript!"); } // Call the function when the script loads or at a specific event // For this basic example, we'll call it directly. say_hello(); ``` -------------------------------- ### Zeek Supervisor Framework: Simple Example Source: https://docs.zeek.org/en/master/scripts/base/frameworks/logging/index This snippet illustrates a simple use case of the Zeek Supervisor Framework. It demonstrates how to start and manage a single Zeek process using the supervisor. ```bash # supervisor.conf example: [program:zeek] command=/usr/local/zeek/bin/zeek -C -i eth0 autostart=true autorestart=true ``` -------------------------------- ### Zeek Framework: Cluster Setup Example Source: https://docs.zeek.org/en/master/scripts/policy/protocols/conn/failed-service-logging An example illustrating the setup and basic usage of a Zeek cluster. This covers the core components like Manager, Worker, Proxy, and Logger, and how they interact for large-scale network analysis. ```zeek # Example Zeek cluster configuration snippet load frameworks/cluster/manager load frameworks/cluster/worker ``` -------------------------------- ### Zeek JavaScript Hello World Example Source: https://docs.zeek.org/en/master/scripts/base/bif/plugins/Zeek_NCP.events.bif A simple 'Hello, World!' example demonstrating the basic syntax and execution model of Zeek scripts written in JavaScript. This serves as a starting point for new users. ```javascript print("Hello, World!"); ``` -------------------------------- ### Zeek Scripting: Hello World Example Source: https://docs.zeek.org/en/master/scripts/base/protocols/ssl/__load__ A fundamental example demonstrating the creation and execution of a simple 'Hello World' script in Zeek using JavaScript. This serves as a starting point for learning Zeek scripting. ```javascript // Preamble @prefix : . // Hello World script export script Hello { event hello() { print "Hello, World!"; } } ``` -------------------------------- ### Zeek Scripting: Hello World Example Source: https://docs.zeek.org/en/master/scripts/policy/frameworks/files/entropy-test-all-files This snippet demonstrates a basic 'Hello World' example in Zeek scripting, illustrating the fundamental structure and execution of a simple script. It's a starting point for understanding Zeek's scripting capabilities. ```zeek event bro_init() { print "Hello, World!"; } ``` -------------------------------- ### Zeek Cluster Framework: Zeek Cluster Setup Example Source: https://docs.zeek.org/en/master/scripts/base/bif/plugins/Zeek_HTTP.functions.bif This example provides a basic configuration for setting up a Zeek cluster. It outlines the necessary `redef` statements to define the cluster topology, roles, and communication settings. ```zeek @load cluster # Manager configuration redef Cluster::local_role = "manager"; redef Cluster::node_subscriptions = set("manager", "worker", "proxy", "logger"); redef Cluster::manager_listen_port = 9997; # Worker configuration (example for one worker) # Create a separate config file for each worker/proxy/logger # redef Cluster::local_role = "worker"; # redef Cluster::manager_address = ""; # redef Cluster::manager_listen_port = 9997; ``` -------------------------------- ### Basic Zeek Scripting: Hello World Example Source: https://docs.zeek.org/en/master/scripts/base/bif/plugins/Zeek_TCP.types.bif This snippet introduces basic Zeek scripting with a 'Hello World' example. It demonstrates the fundamental structure of a Zeek script, including Preamble, built-in plugins, and the execution model. This serves as a starting point for writing custom Zeek analysis scripts. ```zeek @Zeek # Preamble (optional) # Define a constant const greeting: string = "Hello, World!"; # Define an event handler that runs when the script is loaded event scripting_finished() { print greeting; } ``` -------------------------------- ### Basic Zeek Scripting: Hello World Example Source: https://docs.zeek.org/en/master/scripts/base/frameworks/cluster/main This snippet demonstrates a fundamental 'Hello, World!' example in Zeek scripting, illustrating the basic structure and execution of a simple script. It's a starting point for understanding Zeek's scripting capabilities. ```zeek event bro_init() { print "Hello, World!"; } ``` -------------------------------- ### Hello World Example in Zeek JavaScript Source: https://docs.zeek.org/en/master/script-reference/notices A simple 'Hello World' example demonstrating the basic syntax and execution of JavaScript within the Zeek environment. This serves as a starting point for developers new to Zeek scripting with JavaScript. ```javascript /** @type {import('zeek').ZeekGlobal} */ const zeek = require('zeek'); zeek.print('Hello, Zeek World!'); ``` -------------------------------- ### Zeek JavaScript Hello World Example Source: https://docs.zeek.org/en/master/scripts/base/bif/communityid.bif A simple 'Hello World' example demonstrating the basic syntax and execution of JavaScript scripts within the Zeek environment. This serves as a starting point for learning Zeek scripting. ```javascript // Zeek JavaScript 'Hello World' console.log('Hello, Zeek!'); ``` -------------------------------- ### Zeek Cross-Compilation Setup and Build Source: https://docs.zeek.org/en/master/_sources/building-from-source This example demonstrates the process of cross-compiling Zeek for a target system, such as a Raspberry Pi. It involves first building essential native tools (binpac and bifcl) on the host, then configuring Zeek with specific toolchain and dependency paths, and finally compiling and installing it. The toolchain file specifies the cross-compilation environment, including the system, C/C++ compilers, and paths for locating dependencies on the target system. ```console ./configure --builddir=../zeek-buildtools ( cd ../zeek-buildtools && make binpac bifcl ) ./configure --toolchain=/home/jon/x-tools/RaspberryPi-toolchain.cmake --with-binpac=$(pwd)/../zeek-buildtools/auxil/binpac/src/binpac --with-bifcl=$(pwd)/../zeek-buildtools/src/bifcl make make install ``` ```cmake set(CMAKE_SYSTEM_NAME Linux) set(toolchain /home/jon/x-tools/arm-rpi-linux-gnueabihf) set(CMAKE_C_COMPILER ${toolchain}/bin/arm-rpi-linux-gnueabihf-gcc) set(CMAKE_CXX_COMPILER ${toolchain}/bin/arm-rpi-linux-gnueabihf-g++) set(CMAKE_FIND_ROOT_PATH /home/jon/x-tools/zeek-rpi-deps ${toolchain}/arm-rpi-linux-gnueabihf/sysroot ) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) ``` -------------------------------- ### Zeek Cluster Setup Example (ZPL) Source: https://docs.zeek.org/en/master/scripts/base/bif/plugins/Zeek_NCP.events.bif Provides a conceptual example of setting up a Zeek cluster, outlining the roles of Manager, Worker, Proxy, and Logger nodes. It also touches upon the need for data and event synchronization across these nodes. ```zpl # Conceptual Zeek Cluster Setup # On Manager node: # Load "manager.bro" # Broker::connect("worker1", 9999); # Broker::connect("proxy1", 9999); # On Worker node: # Load "worker.bro" # Broker::connect("manager", 9999); # On Proxy node: # Load "proxy.bro" # Broker::connect("manager", 9999); # On Logger node: # Load "logger.bro" # Broker::connect("manager", 9999); ``` -------------------------------- ### Basic Zeek Scripting: Hello World Example Source: https://docs.zeek.org/en/master/scripts/base/bif/plugins/Zeek_ConnSize.functions.bif This is a fundamental example of Zeek scripting, demonstrating a 'Hello World' script. It introduces the basic structure of a Zeek script, including the use of `print` statements and the event handling mechanism. This serves as a starting point for learning Zeek scripting. ```zeek print "Hello, World!"; # Example of a simple event handler event bro_init() { print "Zeek script initialized."; } ``` -------------------------------- ### Zeek Scripting - Managing Zeek Example Source: https://docs.zeek.org/en/master/get-started This command illustrates how to use the `zeekctl` utility to manage Zeek daemons, such as starting, stopping, or restarting them. This is crucial for operating Zeek in a production environment. ```bash zeekctl start ``` -------------------------------- ### Configure and Install Zeek with PF_RING Source: https://docs.zeek.org/en/master/_sources/cluster/pf_ring These commands configure and install Zeek, linking it against the PF_RING libpcap libraries. The `--with-pcap` flag points Zeek to the PF_RING installation directory. ```bash ./configure --with-pcap=/opt/pfring make make install ``` -------------------------------- ### Simple Example (Zeek Script) Source: https://docs.zeek.org/en/master/logs/dns A basic demonstration of the Supervisor Framework, showing how to monitor and manage a single process. ```zeek redef Supervisor::processes = set( Supervisor::Process("my_process", "/usr/bin/my_daemon --foreground", T) ); event supervisor_start() { print "Supervisor started."; } event supervisor_stop() { print "Supervisor stopped."; } ``` -------------------------------- ### Zeek Building from Source - Configuring and Building Source: https://docs.zeek.org/en/master/get-started These commands show the standard process for configuring and building Zeek from its source code. It involves running the `./configure` script, followed by `make` and `make install`. ```bash ./configure make sudo make install ``` -------------------------------- ### Install PF_RING Libraries and Kernel Module Source: https://docs.zeek.org/en/master/_sources/cluster/pf_ring This snippet shows the commands to download, compile, and install PF_RING libraries and the kernel module. It requires downloading the PF_RING source, configuring, and making the userland libraries and kernel module. Ensure you replace the version number with your downloaded version. ```bash cd /usr/src tar xvzf PF_RING-5.6.2.tar.gz cd PF_RING-5.6.2/userland/lib ./configure --prefix=/opt/pfring make install cd ../libpcap ./configure --prefix=/opt/pfring make install cd ../tcpdump-4.1.1 ./configure --prefix=/opt/pfring make install cd ../../kernel make make install modprobe pf_ring enable_tx_capture=0 min_num_slots=32768 ``` -------------------------------- ### Set PF_RING First Application Instance Source: https://docs.zeek.org/en/master/_sources/cluster/pf_ring This configuration variable in `zeekctl.cfg` specifies the starting application instance number when using `pfdnacluster_master` for load balancing. This is useful when `pfdnacluster_master` is configured with a range of instance IDs. ```ini pfringfirstappinstance=4 ``` -------------------------------- ### Basic Zeek Scripting: Hello World Example Source: https://docs.zeek.org/en/master/scripts/base/misc/find-checksum-offloading A fundamental 'Hello World' example in Zeek scripting, demonstrating the basic syntax and execution model. This serves as an entry point for learning Zeek scripting. ```zeek hello_world.bro ``` -------------------------------- ### Configure ZeekWorker for PF_RING+DNA pfdnacluster_master Source: https://docs.zeek.org/en/master/_sources/cluster/pf_ring This configuration example shows how to set up a Zeek worker to use PF_RING with DNA and `pfdnacluster_master`. The interface is specified in the `dnacluster:` format, and `lb_procs` should match the number of processes managed by `pfdnacluster_master`. ```ini [worker-1] type=worker host=10.0.0.50 interface=dnacluster:21 lb_method=pf_ring lb_procs=10 ``` -------------------------------- ### Zeek Plugin Development - Testing Plugins Example Source: https://docs.zeek.org/en/master/get-started This command demonstrates how to run Zeek's test suite for plugins. It's used to verify that a plugin is functioning correctly and integrates well with Zeek. ```bash make test-plugins ``` -------------------------------- ### Configure ZeekWorker for PF_RING Load Balancing Source: https://docs.zeek.org/en/master/_sources/cluster/pf_ring This is an example configuration for a Zeek worker node in `node.cfg` that utilizes PF_RING for load balancing. It specifies the load balancing method, the number of processes, and optionally pins them to specific CPU cores. ```ini [worker-1] type=worker host=10.0.0.50 interface=eth0 lb_method=pf_ring lb_procs=10 pin_cpus=2,3,4,5,6,7,8,9,10,11 ``` -------------------------------- ### Zeek Plugin Development - `init-plugin` Example Source: https://docs.zeek.org/en/master/get-started This is a placeholder for the `init-plugin` command, which is used to initialize a new Zeek plugin project. The actual command would involve specific arguments. ```bash zeek-plugin-init my_plugin ``` -------------------------------- ### Configure ZeekWorker for PF_RING+DNA Symmetric RSS Source: https://docs.zeek.org/en/master/_sources/cluster/pf_ring This configuration example sets up a Zeek worker to use PF_RING with DNA and symmetric RSS. The interface is set to `dna0`, and the number of load balancing processes (`lb_procs`) should match the number of RSS queues configured with `ethtool`. ```ini [worker-1] type=worker host=10.0.0.50 interface=dna0 lb_method=pf_ring lb_procs=10 ``` -------------------------------- ### Introduction to Zeek Scripting: Hello World Example Source: https://docs.zeek.org/en/master/frameworks/netcontrol This is a basic introduction to Zeek scripting, demonstrating a 'Hello World' example. It covers understanding scripts, the event queue, event handlers, and the connection record data type. This snippet is conceptual and doesn't contain executable code. ```zeek # Conceptual example for Zeek scripting basics # This is not executable code, but illustrates the concepts. # Example of defining a simple event handler: # event my_custom_event(msg: string) { # print(msg); # } # To trigger this event, you would typically have another part of the script or a protocol handler call it: # my_custom_event("Hello, Zeek World!"); ``` -------------------------------- ### Zeek Scripting: Hello World Example in JavaScript Source: https://docs.zeek.org/en/master/frameworks/storage This snippet demonstrates a basic 'Hello World' script using JavaScript within the Zeek scripting environment. It illustrates the fundamental structure of a Zeek script, including the use of `print` for output. This serves as a starting point for learning Zeek scripting. ```javascript /** * Zeek Script: Hello World * Description: A simple script that prints "Hello, Zeek World!" to the console. */ // This is a comment in JavaScript // Use the Zeek 'print' function to output messages print("Hello, Zeek World!"); // You can also use console.log, which Zeek often maps to its own logging // console.log("Another way to print."); // Example of defining a variable let message = "Welcome to Zeek scripting!"; print(message); ``` -------------------------------- ### Basic Zeek Scripting: Hello World Example Source: https://docs.zeek.org/en/master/scripts/base/bif/plugins/Zeek_SMB.smb1_com_transaction_secondary.bif A fundamental 'Hello World' example in Zeek scripting. This demonstrates the basic syntax and execution model for creating simple Zeek scripts. ```zeek printf("Hello World!\n"); ``` -------------------------------- ### Zeek Documentation - Local Previewing Example Source: https://docs.zeek.org/en/master/get-started This command demonstrates how to build the Zeek documentation locally for previewing. It typically involves using a build system like CMake. ```bash mkdir build && cd build cmake .. make docs ``` -------------------------------- ### Importing Installed Spicy Grammars in Zeek Source: https://docs.zeek.org/en/master/devel/spicy/index This example shows how to import an installed Spicy grammar into your Zeek scripts. The grammar is located in the Zeek installation prefix under `share/spicy/`. This allows you to reuse existing parsers within your custom Zeek analysis. ```zeek import Finger from "finger"; # Now you can use the Finger grammar for analysis. ``` -------------------------------- ### Zeek CLI: Standalone Installation Source: https://docs.zeek.org/en/master/scripts/base/protocols/smb/smb1-main Details the steps for performing a standalone installation of the `zeek-client` command-line interface. ```bash # Example installation command (may vary by OS) sudo apt-get install zeek-client ``` -------------------------------- ### Basic Zeek Scripting: Hello World Example Source: https://docs.zeek.org/en/master/scripts/base/protocols/ntp/main This snippet demonstrates a fundamental 'Hello World' example in Zeek scripting, illustrating the basic structure and execution of a Zeek script. It serves as an entry point for learning Zeek's scripting capabilities. ```zeek event zeek_init() { print "Hello, World!"; } ``` -------------------------------- ### Basic Zeek Scripting: Hello World Example Source: https://docs.zeek.org/en/master/scripts/base/frameworks/openflow/plugins/broker A fundamental "Hello World" example in Zeek scripting (JavaScript) to demonstrate basic script execution and output. ```javascript function hello_world() { print "Hello, World!"; } hello_world(); ``` -------------------------------- ### Zeek Cluster - Manager Sending Events (Example) Source: https://docs.zeek.org/en/master/scripts/base/protocols/ftp/utils This example shows a Zeek Manager node sending events to its Worker nodes within a cluster setup. ```zeek event send_to_workers(message: string) { for (node_name in cluster::get_workers()) { try { cluster::send_event(node_name, "worker_message", message); } catch (e) {} } } ``` -------------------------------- ### Installing and Configuring GeoIP Databases for Zeek Source: https://docs.zeek.org/en/master/scripts/base/frameworks/openflow/plugins/__load__ This guide explains how to install and configure GeoIP databases for use with Zeek. It involves downloading the databases and placing them in the appropriate directory for Zeek to access. ```bash # Download GeoIP databases (e.g., GeoLite2 City) wget "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=YOUR_LICENSE_KEY&suffix=tar.gz" tar -xzf GeoLite2-City_*.tar.gz # Move the database file to Zeek's database directory sudo mv GeoLite2-City_*/GeoLite2-City.mmdb /usr/share/GeoIP/ # Configure Zeek script to use the database # @load frameworks/geoip # redef GeoIP::city_file = "/usr/share/GeoIP/GeoLite2-City.mmdb"; ``` -------------------------------- ### Zeek Scripting: Hello World Example Source: https://docs.zeek.org/en/master/acknowledgements A basic 'Hello World' example for Zeek scripting, demonstrating the fundamental structure and execution within the Zeek environment. ```javascript Hello World ``` -------------------------------- ### Management Framework: The zeek-client CLI (Standalone Installation) Source: https://docs.zeek.org/en/master/scripts/base/bif/plugins/Zeek_HTTP.functions.bif Describes the standalone installation and usage of the `zeek-client` CLI tool. This tool is part of the Management Framework and is used for interacting with Zeek agents and controllers, especially in standalone or distributed setups. Installation typically involves package managers or source compilation. ```bash # Install zeek-client (example using apt) sudo apt-get update sudo apt-get install zeek-client # Verify installation zeek-client --version ``` -------------------------------- ### Basic Zeek Scripting - Hello World Example (JavaScript) Source: https://docs.zeek.org/en/master/scripts/base/frameworks/openflow/plugins/ryu This example demonstrates a 'Hello, World!' script in Zeek using JavaScript. It covers the basic structure of a Zeek script, including the preamble and how to output messages. This is a foundational example for learning Zeek scripting. ```javascript export "id"; const id = "hello_world"; let hello_world = { name: "hello_world", version: "1.0", description: "A simple hello world script." }; print("Hello, World!"); ``` -------------------------------- ### Zeek Scripting Fundamentals: Hello World in JavaScript Source: https://docs.zeek.org/en/master/scripts/base/bif/plugins/Zeek_SMB.smb1_com_transaction2_secondary.bif This example demonstrates a basic 'Hello World' script in JavaScript for Zeek. It covers the preamble, built-in plugins, and the execution model for simple scripts. This serves as an entry point for learning Zeek scripting. ```javascript // Preamble //@ts-check // Built-in Plugin // import * as zeek from "zeek"; // Hello World console.log("Hello, World!"); ``` -------------------------------- ### Installing and Configuring GeoIP Databases for Zeek Source: https://docs.zeek.org/en/master/scripts/base/frameworks/logging/index This snippet guides users on installing and configuring GeoIP databases required for Zeek's address geolocation and AS lookup features. It covers downloading databases and setting paths. ```bash # Download GeoIP databases (e.g., GeoLite2-City.mmdb) # Place them in a known directory, e.g., /usr/share/GeoIP/ # Configure Zeek to use the databases redef DnsCache::geoip_db_path = "/usr/share/GeoIP/GeoLite2-City.mmdb"; ``` -------------------------------- ### Zeek Cluster: Zeek Cluster Setup Example (Zeek Script) Source: https://docs.zeek.org/en/master/scripts/base/frameworks/supervisor/__load__ Provides an example of how to configure and set up a Zeek cluster. This involves defining the roles of different nodes (manager, worker, proxy, logger) and their communication. ```zeek # Example Zeek cluster configuration (often in local.zeek or related files) # Manager Node Configuration # @load bro_cluster # cluster = "my_cluster" # node_type = "manager" # manager_host = "zeek-manager.example.com" # Worker Node Configuration # @load bro_cluster # cluster = "my_cluster" # node_type = "worker" # manager_host = "zeek-manager.example.com" # Proxy Node Configuration # @load bro_cluster # cluster = "my_cluster" # node_type = "proxy" # manager_host = "zeek-manager.example.com" ``` -------------------------------- ### Introduction to Zeek Scripting: Hello World Example Source: https://docs.zeek.org/en/master/scripts/base/bif/plugins/Zeek_DHCP.types.bif This snippet demonstrates a basic 'Hello World' example in Zeek scripting (JavaScript syntax). It shows how to define a simple script that can be executed within the Zeek environment, illustrating the fundamental structure of Zeek scripts. ```javascript /** * A simple "Hello, World!" script for Zeek. * This script will print "Hello, World!" to the Zeek log when executed. */ print "Hello, World!"; ``` -------------------------------- ### Zeek Scripting: Hello World in JavaScript Source: https://docs.zeek.org/en/master/scripts/base/bif/plugins/Zeek_SMB.smb1_com_nt_create_andx.bif This is a basic 'Hello World' example in JavaScript for Zeek scripting. It demonstrates the fundamental structure of a Zeek script using JavaScript, including how to define and execute a simple function. This serves as a starting point for more complex JavaScript-based analyses. ```javascript function hello_world() { console.log("Hello, Zeek World!"); } # To run this, you would typically include it in a Zeek script # and potentially call the function based on certain events. # For example: # event network_traffic(c: connection) { # if (c$id$orig_port == 80) { # hello_world(); # } # } ``` -------------------------------- ### Supervised Cluster Example in Zeek Source: https://docs.zeek.org/en/master/scripts/policy/protocols/conn/mac-logging Illustrates a more complex example using the Zeek Supervisor Framework to manage a cluster of Zeek instances. This likely involves starting multiple processes and defining their roles. ```zeek Supervisor::add_process("controller", "/path/to/zeek -i eth0 --controller", "/var/run/controller.pid"); Supervisor::add_process("agent1", "/path/to/zeek -i eth1 --agent", "/var/run/agent1.pid"); Supervisor::start_all(); ``` -------------------------------- ### Zeek Scripting Basics: Hello World in JavaScript Source: https://docs.zeek.org/en/master/scripts/base/misc/installation Provides a fundamental 'Hello World' example for scripting in Zeek using JavaScript. This snippet introduces the basic structure of a Zeek script and its execution model, serving as an entry point for new scripters. ```javascript function hello_world() { print "Hello, world!"; } hello_world(); ``` -------------------------------- ### Zeek Scripting Basics: Hello World in JavaScript Source: https://docs.zeek.org/en/master/scripts/base/bif/plugins/Zeek_SMB.smb2_com_session_setup.bif This snippet demonstrates a basic 'Hello World' example using JavaScript within the Zeek scripting environment. It introduces fundamental concepts of Zeek scripting, including event handlers and custom logging. ```javascript function hello_world(msg: string) { print("Hello, " + msg + "!"); } hello_world("World"); ``` -------------------------------- ### Zeek Scripting: Hello World Example Source: https://docs.zeek.org/en/master/scripts/base/bif/plugins/Zeek_Cluster_Backend_ZeroMQ.cluster_backend_zeromq.bif A basic 'Hello World' example script for Zeek, demonstrating the fundamental structure and execution of a Zeek script. This snippet is useful for beginners learning Zeek scripting, illustrating how to define and execute simple logic within the Zeek environment. ```zeek event zeek_init() { print "Hello, World!"; } ``` -------------------------------- ### Zeek CLI: zeek-client Standalone Installation Source: https://docs.zeek.org/en/master/scripts/base/frameworks/config/input Details the steps for installing the `zeek-client` command-line interface in standalone mode. This client is used for interacting with and managing Zeek clusters, especially when not running within a full ZeekControl setup. ```bash # Download and extract the Zeek distribution # Then, configure the client (e.g., by setting ZEEK_CONFIG_PATH) # Example: export ZEEK_CONFIG_PATH=/etc/zeek/zeek-client.conf # zeek-client --help ``` -------------------------------- ### Zeek Scripting: Hello World Example Source: https://docs.zeek.org/en/master/scripts/base/files/extract/__load__ A basic 'Hello, World!' example in Zeek scripting, demonstrating the fundamental structure of a script and how to print output. This is useful for beginners learning to write Zeek scripts. ```zeek redef print "Hello, World!\n"; # A more traditional script structure: # script_greeting.zeek # # @INFO "A simple script that prints Hello, World!" # # function main(): void { # print "Hello, World!"; # } # # # To run this script: # # zeek -b script_greeting.zeek ``` -------------------------------- ### Zeek Cluster: Worker Sending Events to Manager Example Source: https://docs.zeek.org/en/master/scripts/base/bif/plugins/Zeek_SMB.events.bif An example showing how a Zeek Worker node can send events back to the Manager node in a cluster setup. This covers the reverse communication path. ```zeek module WorkerEvents; event worker_status_update(status: string); # In the Worker script: # broker.send_event("manager", "WorkerEvents::worker_status_update", "idle"); # In the Manager script: # event WorkerEvents::worker_status_update(status: string) # { # print(fmt("Manager received status update: %s", status)); # } ``` -------------------------------- ### Standard Zeek Build Process Source: https://docs.zeek.org/en/master/_sources/building-from-source This snippet outlines the fundamental commands for configuring, building, and installing Zeek from its source code. It assumes all dependencies are met. The `configure` script prepares the build environment, `make` compiles the source code, and `make install` places the compiled binaries and libraries in the designated installation path, typically requiring root privileges for default locations. ```console ./configure make make install ``` -------------------------------- ### Zeek Scripting: Worker Sending Events to Manager (Framework Example) Source: https://docs.zeek.org/en/master/building-from-source This example shows how a Zeek worker node can send events back to the manager node in a cluster setup. This is crucial for aggregating results or reporting findings from workers. ```zeek module MyClusterEvents; export { redef enum Log::ID += { LOG_MY_EVENT }; type Info: record { msg: string; }; } event worker_init() { const worker_msg: Info = Info("Message from Worker!"); // Send the event to the manager Cluster::send_event(Cluster::MANAGER, MyClusterEvents::LOG_MY_EVENT, worker_msg); } ``` -------------------------------- ### Cluster Framework: Zeek Cluster Setup Source: https://docs.zeek.org/en/master/scripts/base/frameworks/notice/index This example outlines the configuration for running a Zeek cluster, detailing the roles of Manager, Worker, Proxy, and Logger nodes. It demonstrates the basic setup required for a distributed Zeek environment. ```zeek-cluster.conf # Example zeek-cluster.conf # Define nodes and their roles # Manager Node @load bro_cluster.zeek module Cluster; # Define the manager node node manager { primary_port = 9997; # Default management port } # Worker Nodes node worker-1 { manager = "127.0.0.1:9997"; type = "worker"; host = "127.0.0.1"; # Other worker-specific configurations... } node worker-2 { manager = "127.0.0.1:9997"; type = "worker"; host = "127.0.0.1"; # Other worker-specific configurations... } # Proxy Nodes (optional, for distributed analysis) node proxy-1 { manager = "127.0.0.1:9997"; type = "proxy"; host = "127.0.0.1"; # Other proxy-specific configurations... } # Logger Nodes (optional, for centralized logging) node logger-1 { manager = "127.0.0.1:9997"; type = "logger"; host = "127.0.0.1"; # Other logger-specific configurations... } ``` -------------------------------- ### Zeek Scripting - Hello World Example Source: https://docs.zeek.org/en/master/scripts/policy/frameworks/management/agent/boot A basic 'Hello World' example for Zeek scripting, demonstrating the fundamental structure and execution of a simple script. This serves as an entry point for learning Zeek's scripting capabilities. ```zeek redef Rekord "Hello World"; Hello World::hello_world(){ print "Hello, World!"; } redef EventHook(event Hello World::hello_world); ``` -------------------------------- ### Zeek Scripting - Running Zeek Example Source: https://docs.zeek.org/en/master/get-started This command shows the basic usage of the `zeek` executable to run a Zeek script file. It's the fundamental way to execute Zeek logic. ```bash zeek my_script.zeek ``` -------------------------------- ### Zeek JavaScript 'Hello World' Example Source: https://docs.zeek.org/en/master/scripts/base/bif/plugins/Zeek_SMB.events.bif A basic 'Hello World' example demonstrating the Preamble and execution model in Zeek's JavaScript scripting environment. This snippet illustrates the fundamental structure for creating and running Zeek scripts. ```javascript /* @ts-check */ // Preamble // @zeek-package-script export function helloWorld() { console.log("Hello, World!"); } // Execution Model (example) helloWorld(); ``` -------------------------------- ### Zeek JavaScript 'Hello World' Example Source: https://docs.zeek.org/en/master/scripts/base/bif/plugins/Zeek_SIP.events.bif A basic 'Hello World' example demonstrating the usage of JavaScript within Zeek for scripting. This snippet illustrates the fundamental structure for executing JavaScript code in Zeek and is a starting point for more complex scripting tasks. ```javascript function hello() { print("Hello World!"); } hello(); ``` -------------------------------- ### Basic Zeek Scripting: Hello World (JavaScript) Source: https://docs.zeek.org/en/master/scripts/base/bif/plugins/Zeek_ICMP.events.bif Introduces the basics of Zeek scripting, specifically using JavaScript syntax (or a Zeek-specific dialect that resembles it). This example demonstrates a simple 'Hello World' script, illustrating the preamble, built-in plugins, and execution model. ```javascript // Preamble (if needed, often implicit) // @zeek // Built-in plugin usage (example) print("Hello, Zeek World!"); // Execution model: Scripts are loaded and executed by the Zeek engine. ``` -------------------------------- ### Basic Zeek Scripting: Hello World Example Source: https://docs.zeek.org/en/master/scripts/base/bif/plugins/Zeek_X509.events.bif This example demonstrates a fundamental Zeek script, often referred to as 'Hello World'. It illustrates the basic structure of a Zeek script and how to define and execute simple logic. ```zeek module MyScript; export { redef enum Log::ID += { LOG_MY_SCRIPT }; } edef record connection { my_extra_field: string &optional; } ``` -------------------------------- ### Querying the Databases (Zeek Script) Source: https://docs.zeek.org/en/master/logs/dns Examples of how to query GeoIP databases within Zeek scripts to get location information for IP addresses. ```zeek event connection_established(c: connection) { local city = Dns::lookup_city(c$id$orig_h); if (city) print fmt("Originating IP %s is in city: %s", c$id$orig_h, city$city$names$en); local country = Dns::lookup_country(c$id$resp_h); if (country) print fmt("Responding IP %s is in country: %s", c$id$resp_h, country$country$iso_code); } ``` -------------------------------- ### Build and Install Zeek Plugin Source: https://docs.zeek.org/en/master/_sources/devel/plugins These shell commands illustrate the process of building and installing a Zeek plugin. 'make' compiles the plugin, and 'make install' places it in the appropriate directory for Zeek to find automatically. ```shell # make [...] # make install ``` -------------------------------- ### Simple Zeek Supervisor Framework Example Source: https://docs.zeek.org/en/master/scripts/base/bif/plugins/Zeek_X509.events.bif This demonstrates a minimal example of Zeek's Supervisor Framework. It shows how to define a simple supervised process and start it. The Supervisor Framework is used for managing and restarting child processes, ensuring the resilience of Zeek deployments. ```zeek module SupervisorExample; export { redef record supervisor_cfg += { my_process: string; # Command to run my_args: vector of string; }; } # Define a simple process to supervise edef supervisor_cfg += { my_process = "/bin/sleep"; my_args = "30"; } # Start the supervised process event zeek_init() { supervisor::start(SupervisorExample::my_process, SupervisorExample::my_args); } ``` -------------------------------- ### Zeek Control CLI Standalone Installation Source: https://docs.zeek.org/en/master/scripts/base/bif/plugins/Zeek_X509.events.bif This section provides instructions for installing the `zeek-client` command-line interface (CLI) in a standalone mode. This allows users to manage Zeek nodes and clusters without needing a full ZeekControl deployment, useful for simpler setups or remote management. ```bash # Download the zeek-client binary or package # Example using a hypothetical package manager or download link: # sudo apt-get install zeek-client # Or similar command # Alternatively, download and extract: # wget # tar -xzf zeek-client.tar.gz # sudo mv zeek-client /usr/local/bin/ # Verify installation zeek-client --version ``` -------------------------------- ### Zeek Scripting: Hello World Example Source: https://docs.zeek.org/en/master/scripts/base/frameworks/netcontrol/plugin A basic 'Hello World' example demonstrating the fundamental structure of a Zeek script. This snippet illustrates how to define and execute a simple script, likely for introductory purposes. ```javascript // Hello World example in Zeek scripting. // This is a placeholder for the actual code. ``` -------------------------------- ### Zeek Broker Communication: Remote Events Example Source: https://docs.zeek.org/en/master/scripts/base/bif/plugins/Zeek_ConnSize.functions.bif This example demonstrates how to send and receive remote events using Zeek's Broker communication framework. It shows the setup for manager-worker communication, enabling distributed event handling across multiple Zeek instances. ```zeek # Manager script (e.g., manager.zeek) event bro_init() { # Assuming Broker is configured and started # Send an event to all workers broker::send_to_all_workers(broker::default_topic("my_event"), "Hello from manager!"); } # Worker script (e.g., worker.zeek) @BROKER_EVENT my_event(msg: string) { print fmt("Worker received: %s", msg); } event bro_init() { # Subscribe to the topic broker::subscribe(broker::default_topic("my_event")); } ``` -------------------------------- ### Zeek Script Example: zeekygen/example.zeek Source: https://docs.zeek.org/en/master/index This snippet showcases a basic Zeek script example, demonstrating the structure and syntax for defining options, state variables, types, redefinitions, events, and functions within the Zeek framework. It serves as a starting point for understanding Zeek scripting. ```zeek redef enum Log::ID += [ MyCustomLog ]; module MyMod; option my_option: string = "default"; state my_state: hook_vec_t; type MyRecord: record { f1: count; f2: string; }; function my_func(x: count): count { return x * 2; } event zeek_init() { print fmt("MyMod initialized with option: %s", my_option); let r = MyRecord(f1=1, f2="hello"); print fmt("%s", r); } event connection_started(c: connection) { my_state.$.add(new_hook($name="my_hook")); let id = Log::create_id(MyCustomLog); Log::write(id, fmt("Connection started: %s", c$id$orig_h)); } ``` -------------------------------- ### Zeek Broker: Connecting to Peers Example Source: https://docs.zeek.org/en/master/scripts/base/bif/plugins/Zeek_SMB.events.bif This example demonstrates how to establish connections to peers using Zeek's Broker communication framework. It covers the fundamental steps for initiating peer connections. ```zeek module MyBrokerModule; extern type peer_connection_t; event connection_established(peer: peer_connection_t); function init_broker_peers() { const peer = broker.connect("peer_name", "192.168.1.100:9999"); if (peer) trigger connection_established(peer); } init_broker_peers(); ``` -------------------------------- ### Zeek Cluster Framework: Worker Sending Events Example Source: https://docs.zeek.org/en/master/scripts/base/packet-protocols/ppp/__load__ This example demonstrates how a Zeek Worker node can send events to the Manager node in a cluster setup. It covers the event definition and the mechanism for publishing events from workers back to the manager, crucial for reporting status, detected anomalies, or aggregated data. ```zeek # Zeek script for Worker sending events to Manager @load frameworks/cluster # Define a custom event that the Worker will send edef enum zeek::ClusterEvent { WORKER_STATUS_UPDATE } # Function to send the event to the manager function send_worker_status(status: string) { print fmt("Sending worker status: %s", status) # The 'zeek' event is a special cluster event for worker-to-manager communication Cluster::send_to_manager(zeek::ClusterEvent::WORKER_STATUS_UPDATE, status) } # Example: Send status update periodically interval 60.0 sec { send_worker_status("OK") } ``` -------------------------------- ### JavaScript for Zeek Scripting: Hello World Example Source: https://docs.zeek.org/en/master/scripts/policy/frameworks/notice/__load__ This JavaScript snippet demonstrates a basic 'Hello World' example within the Zeek scripting environment. It shows the preamble, the use of the built-in plugin, and the execution model for simple scripts. ```javascript /** * @zeek * @plugin console */ function helloWorld() { console.log("Hello, Zeek World!"); } helloWorld(); ``` -------------------------------- ### Basic Zeek Scripting: Hello World in JavaScript Source: https://docs.zeek.org/en/master/scripts/policy/protocols/ftp/detect This example demonstrates a fundamental 'Hello World' script in JavaScript within the Zeek environment. It illustrates the basic structure of a Zeek script, including the preamble and how to output messages. This serves as an entry point for users new to Zeek scripting. ```javascript /* Preamble */ @Zeek('1.0') /* Hello World */ print("Hello, Zeek!"); ``` -------------------------------- ### Zeek conn.log Entry Example Source: https://docs.zeek.org/en/master/_sources/logs/pe An example log entry from Zeek's conn.log file, detailing a TCP connection. This entry includes timestamps, IP addresses, ports, protocol, service, duration, and data transfer sizes. It serves as a starting point for analyzing network connections. ```json { "ts": "2020-09-23T00:24:31.210053Z", "uid": "Cq2b9jR12c4lqZafg", "id.orig_h": "192.168.4.152", "id.orig_p": 59125, "id.resp_h": "63.88.73.83", "id.resp_p": 80, "proto": "tcp", "service": "http", "duration": 25.614583015441895, "orig_bytes": 5753, "resp_bytes": 1975717, "conn_state": "SF", "local_orig": true, "local_resp": false, "missed_bytes": 0, "history": "ShADadttFf", "orig_pkts": 521, "orig_ip_bytes": 29041, "resp_pkts": 1367, "resp_ip_bytes": 2030409, "ip_proto": 6 } ``` -------------------------------- ### Basic Zeek Scripting: Hello World Example Source: https://docs.zeek.org/en/master/scripts/base/protocols/smb/main Introduces basic Zeek scripting with a 'Hello World' example. This demonstrates the fundamental structure and execution model of Zeek scripts, particularly in JavaScript. ```javascript /* Zeek script example */ console.log("Hello, World!"); ``` -------------------------------- ### Zeek Broker Framework Examples: Connecting to Peers Source: https://docs.zeek.org/en/master/scripts/base/frameworks/control/__load__ This section provides examples of how to establish connections between peers using Zeek's Broker Framework. ```text * Connecting to Peers ``` -------------------------------- ### Zeek Broker: Connecting to Peers Source: https://docs.zeek.org/en/master/scripts/policy/protocols/smtp/entities-excerpt This example illustrates how to establish connections to peers using the Zeek Broker framework. It covers the basic setup for peer communication. ```zeek broker::peer_add("peer1", "localhost:9999"); broker::peer_add("peer2", "192.168.1.100:9999"); ``` -------------------------------- ### Verify Zeek Linking to PF_RING Libpcap Source: https://docs.zeek.org/en/master/_sources/cluster/pf_ring This command verifies that the Zeek binary is correctly linked to the PF_RING libpcap libraries by displaying the shared object dependencies. ```bash ldd /usr/local/zeek/bin/zeek | grep pcap ``` -------------------------------- ### Zeek Management: zeek-client CLI Configuration Source: https://docs.zeek.org/en/master/scripts/base/misc/installation Demonstrates the configuration of the `zeek-client` command-line interface. This includes setting up standalone installations, defining compatibility settings, and configuring auto-completion for efficient cluster management. ```bash # Example zeek-client configuration file (~/.zeek/zeek-client.conf): # controller_addr = 192.168.1.100 # controller_port = 9999 # ca_cert = /path/to/ca.pem # client_cert = /path/to/client.pem # client_key = /path/to/client.key # Example auto-complete setup: # eval "$(zeek-client --bash-completion-script)" ``` -------------------------------- ### Zeek Example: Filter FTP by US State Source: https://docs.zeek.org/en/master/_sources/customizations An example Zeek event handler that filters FTP connections originating from hosts in Ohio, US. It utilizes the lookup_location function to get geographical data and checks for specific region and country code. It also demonstrates how to safely access optional fields like 'city'. ```zeek event ftp_reply(c: connection, code: count, msg: string, cont_resp: bool) { local client = c$id$orig_h; local loc = lookup_location(client); if (loc?$region && loc$region == "OH" && loc?$country_code && loc$country_code == "US") { local city = loc?$city ? loc$city : ""; print fmt("FTP Connection from:%s (%s,%s,%s)", client, city, loc$region, loc$country_code); } } ``` -------------------------------- ### Hello World Example in Zeek JavaScript Source: https://docs.zeek.org/en/master/scripts/base/files/x509/log-ocsp This snippet provides a fundamental 'Hello World' example using JavaScript within the Zeek scripting environment. It demonstrates the basic syntax and execution model for running JavaScript code as part of a Zeek script. This is a starting point for users new to scripting in Zeek with JavaScript. ```javascript /** * Zeek JavaScript 'Hello World' example. * This script will print "Hello, Zeek World!" to the console upon loading. */ console.log("Hello, Zeek World!"); // You can also define functions and export them if needed // export function greet(name) { // console.log(`Hello, ${name}!`); // } ``` -------------------------------- ### Zeek Scripting - Hello World in JavaScript Source: https://docs.zeek.org/en/master/scripts/base/frameworks/storage/main A basic 'Hello World' example script in JavaScript for Zeek. This demonstrates the fundamental syntax and execution model for Zeek scripts. ```javascript event hello() { print "Hello, World!"; } ```