{"id":8845,"date":"2021-05-17T23:15:44","date_gmt":"2021-05-17T20:15:44","guid":{"rendered":"https:\/\/kifarunix.com\/?p=8845"},"modified":"2024-03-18T22:23:43","modified_gmt":"2024-03-18T19:23:43","slug":"install-zeek-on-ubuntu","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-zeek-on-ubuntu\/","title":{"rendered":"Install Zeek on Ubuntu 20.04"},"content":{"rendered":"\n
Follow through this tutorial to learn how to install Zeek on Ubuntu 20.04. Zeek<\/a>, formerly Bro IDS, is the world’s leading passive open source network security monitoring tool.<\/p>\n\n\n\n Zeek is not an active security device, like a firewall or intrusion prevention system. Rather, Zeek sits on a \u201csensor,\u201d a hardware, software, virtual, or cloud platform that quietly and unobtrusively observes network traffic. Zeek interprets what it sees and creates compact, high-fidelity transaction logs, file content, and fully customized output, suitable for manual review on disk or in a more analyst-friendly tool like a security and information event management (SIEM) system<\/em>.<\/p>\n\n\n\n Zeek can be installed by building it from the source code<\/a> or by directly via the Zeek APT repositories<\/a>.<\/p>\n\n\n\n In this tutorial, we will choose the later.<\/p>\n\n\n\n To install Zeek from the Zeek APT repositories;<\/p>\n\n\n\n Add Zeek repository to Ubuntu 20.04:<\/p>\n\n\n\n Run system update;<\/p>\n\n\n\n Zeek 4.0.1 is the current stable release as of this writing, confirm the same by running the command below;<\/p>\n\n\n\n You can then install Zeek by running the command below;<\/p>\n\n\n\n During the installation, you will be prompted for some Postfix settings, choose Internet Site and enter your system FQDN.<\/p>\n\n\n\n By default, Zeek is installed under To begin with, add Zeek binary path to PATH;<\/p>\n\n\n\n Next, you need to tell Zeek which local networks to monitor. This can be specified in the The default networks defined are 10.0.0.0\/8, 172.16.0.0\/16, 192.168.0.0\/16<\/strong>. So, in our case, the network we want to monitor is 192.168.59.0\/24<\/strong>.<\/p>\n\n\n\n Hence;<\/p>\n\n\n\n Save the file and exit once you made your network configuration changes.<\/p>\n\n\n\n Zeek can be run in standalone mode or in a cluster setup. To define whether to run in a cluster or standalone setup, you need to edit the According to Zeek quickstart guide, using the standalone \/ single process mode of Zeek is not suitable for setups with significant amounts of traffic. In these cases one will almost certainly want to make use of a Zeek cluster, even on a single system<\/em>.<\/p>\n\n\n\n Therefore, we will see how to setup Zeek cluster. You can have a look at Zeek cluster architecture<\/a>.<\/p>\n\n\n\n The default Zeek node configuration is like;<\/p>\n\n\n\n Since we are running a single node Zeek Cluster in this setup, comment out the Zeek standalone configuration, section under So what are these components;<\/p>\n\n\n\n So below is our single node Zeek cluster configuration setup;<\/p>\n\n\n\n Next, you need to review the global ZeekControl configuration file, Most of the default values in configuration files should suffice. The only change you might want to make or update here is the recipient address for all emails sent out by Zeek and ZeekControl, if you have any set. The default value is root@localhost.<\/p>\n\n\n\n Before you can install and start Zeek, you need to validate the configuration file;<\/p>\n\n\n\n If all is fine, install ZeekControl configuration and start the Zeek instance;<\/p>\n\n\n\n You can check the status of Zeek instance by executing;<\/p>\n\n\n\n Zeek will start analyzing traffic according to a default policy and write the log results in Some logs that are worth explicit mention:<\/em><\/p>\n\n\n\n Sample conn.log<\/strong> logs;<\/p>\n\n\n\n The fields and types are;<\/p>\n\n\n\n You can check processes running on each node by executing;<\/p>\n\n\n\n For example, to check processes on Zeek manager node;<\/p>\n\n\n\n Installing Zee<\/a>k<\/a><\/p>\n\n\n\n Install and Configure AIDE on Debian 10<\/a><\/p>\n\n\n\n Install ModSecurity 3 with Apache in a Docker Container<\/a><\/p>\n\n\n\nInstalling Zeek on Ubuntu 20.04<\/h2>\n\n\n\n
echo 'deb http:\/\/download.opensuse.org\/repositories\/security:\/zeek\/xUbuntu_20.04\/ \/' | sudo tee \/etc\/apt\/sources.list.d\/security:zeek.list<\/code><\/pre>\n\n\n\n
curl -fsSL https:\/\/download.opensuse.org\/repositories\/security:zeek\/xUbuntu_20.04\/Release.key | gpg --dearmor | sudo tee \/etc\/apt\/trusted.gpg.d\/security_zeek.gpg > \/dev\/null<\/code><\/pre>\n\n\n\n
apt update<\/code><\/pre>\n\n\n\n
apt-cache policy zeek<\/code><\/pre>\n\n\n\n
zeek:\n Installed: (none)\n Candidate: 4.0.1-0\n Version table:\n 4.0.1-0 500\n 500 http:\/\/download.opensuse.org\/repositories\/security:\/zeek\/xUbuntu_20.04 Packages<\/code><\/pre>\n\n\n\n
apt install zeek<\/code><\/pre>\n\n\n\n
Configuring Zeek on Ubuntu 20.04<\/h3>\n\n\n\n
Configure the Run-Time Environment<\/h4>\n\n\n\n
\/opt\/zeek<\/strong><\/code>.<\/p>\n\n\n\n
echo \"export PATH=$PATH:\/opt\/zeek\/bin\" >> ~\/.bashrc<\/code><\/pre>\n\n\n\n
source ~\/.bashrc<\/code><\/pre>\n\n\n\n
Define the Local Networks to Monitor<\/h4>\n\n\n\n
\/opt\/zeek\/etc\/networks.cfg<\/strong><\/code> configuration file.<\/p>\n\n\n\n
vim \/opt\/zeek\/etc\/networks.cfg<\/code><\/pre>\n\n\n\n
\n# List of local networks in CIDR notation, optionally followed by a\n# descriptive tag.\n# For example, \"10.0.0.0\/8\" or \"fe80::\/64\" are valid prefixes.\n\n#10.0.0.0\/8 Private IP space\n#172.16.0.0\/12 Private IP space\n#192.168.0.0\/16 Private IP space\n192.168.59.0\/24 Kifarunix-demo IP space<\/strong>\n<\/code><\/pre>\n\n\n\n
Configure Zeek Cluster<\/h4>\n\n\n\n
\/opt\/zeek\/etc\/node.cfg<\/strong><\/code> configuration file.<\/p>\n\n\n\n
\n
cat \/opt\/zeek\/etc\/node.cfg<\/code><\/pre>\n\n\n\n
\n# Example ZeekControl node configuration.\n#\n# This example has a standalone node ready to go except for possibly changing\n# the sniffing interface.\n\n# This is a complete standalone configuration. Most likely you will\n# only need to change the interface.\n[zeek]\ntype=standalone\nhost=localhost\ninterface=eth0\n\n## Below is an example clustered configuration. If you use this,\n## remove the [zeek] node above.\n\n#[logger-1]\n#type=logger\n#host=localhost\n#\n#[manager]\n#type=manager\n#host=localhost\n#\n#[proxy-1]\n#type=proxy\n#host=localhost\n#\n#[worker-1]\n#type=worker\n#host=localhost\n#interface=eth0\n#\n#[worker-2]\n#type=worker\n#host=localhost\n#interface=eth0\n<\/code><\/pre>\n\n\n\n
[zeek]<\/strong><\/code> and define host address for your Zeek
logger<\/strong><\/code>,
manager<\/strong><\/code>,
proxy<\/strong><\/code> and
worker<\/strong><\/code>.<\/p>\n\n\n\n
\n
cat \/opt\/zeek\/etc\/node.cfg<\/code><\/pre>\n\n\n\n
\n# Example ZeekControl node configuration.\n#\n# This example has a standalone node ready to go except for possibly changing\n# the sniffing interface.\n\n# This is a complete standalone configuration. Most likely you will\n# only need to change the interface.\n#[zeek]\n#type=standalone\n#host=localhost\n#interface=eth0\n\n## Below is an example clustered configuration. If you use this,\n## remove the [zeek] node above.\n\n[kifarunix-demo-zeek-logger]\ntype=logger\nhost=192.168.59.16\n#\n[kifarunix-demo-zeek-manager]\ntype=manager\nhost=192.168.59.16\n#\n[kifarunix-demo-zeek-proxy]\ntype=proxy\nhost=192.168.59.16\n#\n[kifarunix-demo-zeek-worker]\ntype=worker\nhost=192.168.59.16\ninterface=enp0s8\n#\n[kifarunix-demo-worker-lo]\ntype=worker\nhost=localhost\ninterface=lo\n<\/code><\/pre>\n\n\n\n
Review Global ZeekControl configuration file<\/h4>\n\n\n\n
\/opt\/zeek\/etc\/zeekctl.cfg<\/strong><\/code>.<\/p>\n\n\n\n
Validate Zeek Configuration<\/h4>\n\n\n\n
zeekctl check<\/code><\/pre>\n\n\n\n
\nHint: Run the zeekctl \"deploy\" command to get started.\nkifarunix-demo-zeek-logger scripts are ok.\nkifarunix-demo-zeek-manager scripts are ok.\nkifarunix-demo-zeek-proxy scripts are ok.\nkifarunix-demo-zeek-worker scripts are ok.\nkifarunix-demo-worker-lo scripts are ok.\n<\/code><\/pre>\n\n\n\n
Deploy ZeekControl Configurations<\/h4>\n\n\n\n
zeekctl deploy<\/code><\/pre>\n\n\n\n
\nchecking configurations ...\ninstalling ...\ncreating policy directories ...\ninstalling site policies ...\ngenerating cluster-layout.zeek ...\ngenerating local-networks.zeek ...\ngenerating zeekctl-config.zeek ...\ngenerating zeekctl-config.sh ...\nstopping ...\nstopping workers ...\nstopping proxy ...\nstopping manager ...\nstopping logger ...\nstarting ...\nstarting logger ...\nstarting manager ...\nstarting proxy ...\nstarting workers ...\n<\/code><\/pre>\n\n\n\n
Check the status of Zeek Instance<\/h4>\n\n\n\n
zeekctl status<\/code><\/pre>\n\n\n\n
\nName Type Host Status Pid Started\nkifarunix-demo-zeek-logger logger 192.168.59.16 running 17911 17 May 03:52:41\nkifarunix-demo-zeek-manager manager 192.168.59.16 running 17962 17 May 03:52:43\nkifarunix-demo-zeek-proxy proxy 192.168.59.16 running 18011 17 May 03:52:45\nkifarunix-demo-zeek-worker worker 192.168.59.16 running 18081 17 May 03:52:48\nkifarunix-demo-worker-lo worker localhost running 18082 17 May 03:52:48\n<\/code><\/pre>\n\n\n\n
Checking Zeek Logs<\/h4>\n\n\n\n
\/opt\/zeek\/logs\/current<\/strong><\/code> directory.<\/p>\n\n\n\n
ls -1 \/opt\/zeek\/logs\/current\/<\/code><\/pre>\n\n\n\n
\nbroker.log\ncapture_loss.log\ncluster.log\nconn.log\ndhcp.log\nknown_services.log\nloaded_scripts.log\nnotice.log\npacket_filter.log\nreporter.log\nstats.log\nstderr.log\nstdout.log\nweird.log\n<\/code><\/pre>\n\n\n\n
\n
conn.log<\/strong><\/code>: Contains an entry for every connection seen on the wire, with basic properties such as time and duration, originator and responder IP addresses, services and ports, payload size, and much more. This log provides a comprehensive record of the network\u2019s activity.<\/em><\/li>\n\n\n\n
notice.log<\/strong><\/code>: Identifies specific activity that Zeek recognizes as potentially interesting, odd, or bad. Such activity is called a \u201cnotice\u201d.<\/em><\/li>\n\n\n\n
known_services.log<\/strong><\/code>: This log file contains the services detected on the local network and are known to be actively used by the clients on the network. It helps in enumerating what all services are observed on a local network and if they all are intentional and known to the network administrator.<\/em><\/li>\n\n\n\n
weird.log<\/strong><\/code>: Contains unusual or exceptional activity that can indicate malformed connections, traffic that doesn\u2019t conform to a particular protocol, malfunctioning or misconfigured hardware\/services, or even an attacker attempting to avoid\/confuse a sensor.<\/em><\/li>\n\n\n\n
tail \/opt\/zeek\/logs\/current\/conn.log<\/code><\/pre>\n\n\n\n
\n1621277534.729878\tCY3bmP18QlSIvSFxej\t192.168.59.16\t8132\t192.168.59.16\t80\ttcp\t-\t-\t-\t-\tRSTRH\tT\tT\t0\t^r\t00\t1\t40\t-\n1621277534.729881\tCGVzYD19RQxUT0Vzq\t192.168.59.16\t8133\t192.168.59.16\t80\ttcp\t-\t-\t-\t-\tS0\tT\tT\t0\tS\t140\t0\t0\t-\n1621277534.729883\tC8jp1t2D0NHoUeOiF1\t192.168.59.16\t8133\t192.168.59.16\t80\ttcp\t-\t-\t-\t-\tRSTRH\tT\tT\t0\t^r\t00\t1\t40\t-\n1621277564.065743\tCduRKb4f4bLM38gakl\t192.168.59.16\t47762\t192.168.59.16\t58282\ttcp\t-\t-\t-\t-\tOTH\tT\tT\t0\tCcc00\t0\t0\t-\n1621277564.065833\tCRgk0dMeT9AeMyROd\t192.168.59.16\t47762\t192.168.59.16\t58288\ttcp\t-\t-\t-\t-\tOTH\tT\tT\t0\tCcc00\t0\t0\t-\n1621277564.215195\tCg09q71OaurnFkIdRe\t192.168.59.16\t38834\t192.168.59.16\t47761\ttcp\t-\t-\t-\t-\tOTH\tT\tT\t0\tCc\t00\t0\t0\t-\n1621277566.725573\tCG17M71tH9TV52bBe7\t192.168.59.16\t38836\t192.168.59.16\t47761\ttcp\t-\t-\t-\t-\tOTH\tT\tT\t0\tCc\t00\t0\t0\t-\n1621277574.895432\tC2aJF016ENvM3nF6da\t192.168.59.16\t34700\t192.168.59.16\t80\ttcp\t-\t-\t-\t-\tOTH\tT\tT\t0\tC\t00\t0\t0\t-\n1621277570.315909\tCQp7gp31EAsSvqgIn1\t192.168.59.16\t38846\t192.168.59.16\t47761\ttcp\t-\t-\t-\t-\tOTH\tT\tT\t0\tCc\t00\t0\t0\t-\n1621277574.895458\tCIP6UASndf9AtymV2\t192.168.59.16\t34700\t192.168.59.16\t80\ttcp\t-\t-\t-\t-\tOTH\tT\tT\t0\t^cC00\t0\t0\t-\n<\/code><\/pre>\n\n\n\n
\n#fields\nts\tuid\tid.orig_h\tid.orig_p\tid.resp_h\tid.resp_p\tproto\tservice\tduration\torig_bytes\tresp_bytes\tconn_state\tlocal_orig\tlocal_resp\tmissed_bytes\thistory\torig_pkts\torig_ip_bytes\tresp_pkts\tresp_ip_bytes\ttunnel_parents\n#types\ntime\tstring\taddr\tport\taddr\tport\tenum\tstring\tinterval\tcount\tcount\tstring\tbool\tbool\tcount\tstring\tcount\tcount\tcount\tcount\tset[string]\n<\/code><\/pre>\n\n\n\n
Checking Zeek Node Processes<\/h4>\n\n\n\n
zeekctl ps.zeek <node><\/code><\/pre>\n\n\n\n
zeekctl ps.zeek kifarunix-demo-zeek-manager <\/pre>\n\n\n\n
\n USER PID PPID %CPU %MEM VSZ RSS TT S STARTED TIME COMMAND\n>>> 192.168.59.16\n (-) root 17911 17905 0.1 4.3 821252 88788 ? S 03:52:41 00:00:02 zeek\n (+) root 17962 17956 0.0 4.3 642664 89200 ? S 03:52:43 00:00:01 zeek\n (-) root 18011 18005 0.0 4.2 640972 87516 ? S 03:52:45 00:00:01 zeek\n (-) root 18081 18069 0.1 10.7 772672 219204 ? S 03:52:47 00:00:03 zeek\n (-) root 18082 18071 0.1 10.7 772148 218668 ? S 03:52:47 00:00:03 zeek\n<\/code><\/pre>\n\n\n\n
Reference<\/h3>\n\n\n\n
Other Tutorials<\/h3>\n\n\n\n