zeek
july 2023
Last updated
july 2023
Last updated
Zeek, or bro is an amazing network analyzer tool. Personally, I love it for its ability to create custom script -> meaning that there's more flexibility for growth!
Let's dig into it!
To set up a zeek environment, I will be using:
Debian 11 (Where Zeek runs)
Kali Linux (Generate Traffic as 'Attacker')
Firstly, I insert the zeek project repository link into the source link so that my Debian knows where to go to obtain the repository
If the operation is successful, you will see the above output.
Next, I will try to run the following command to obtain the release key.
As seen, curl cannot be found (curl is not defaultly installed), so a simple fix can be done:
The above installs curl command.
Rerun the code on 'curl...'. If the command returns no output, you can then move onto the next step.
Update Debian
Install zeek
To check whether zeek is installed, run the folllwing command:
The above is the path at which zeek is downloaded locally.
To see the manual of zeek, run the following command:
The purpose of these is to ensure that the interface has traffic and should any issues pop up regarding zeek, it would then be a zeek issue, rather than an interface issue. (Helps in troubleshooting)
To check if the interface is up and running, run the following commands:
ip a -> checks the network interfaces on this device
tcpdump
-n -> Leaves addresses in their device name
-i -> Specifies interface for network to be captured on
First, I enter zeekcontrol, an interactive shell to perform actions or initialize Zeek.
In the /opt/zeek/bin directory, run the following command:
[EDIT] Run the following code so that zeek commands can be accessed anywhere throughout the machine
In ZeekControl (ZeekCtl), start zeek.
If this is your first time starting zeek, instead of start
, use deploy
If zeek has been sucessfully started, you will see these:
A quick run of the command status
would also show that zeek is running smoothly.
To stop zeek, run the command stop
To start playing with Zeek, we need to capture some live network traffic to create logs.
To do so, we run this command:
-i -> interface (to change depending on the interface you would like to listen to)
-s -> specifies number of packets to capture. By placing 0 here, it means too capture all packets here, unlimitedly.
-w -> specifies the pcap file name the results of the network traffic capture will be output into
Next, we process the network capture.
-C -> Disable checksum validation
-r -> Read the given pcap file
Logs in Zeek
After the above command has been run, several zeek log files will be generated from the network packet capture. There are several logs that may be of interest:
notice.log
Anomalies detected by Zeek are raised and a notice regarding the anomaly will be placed in this log file.
intel.log
When Zeek detects traffic with known malicious indicators, the traffic is flagged and logged in this log file.
signatures.log
Known malicious or faulty packet signatures detected by Zeek are logged in this log file.
conn.log
Contains information about all TCP/UDP/ICMP connections, gathered from packet capture
files.log
Consists of analytic result of packet counts and session duration from packet capture.
packet_filter.log
Lists active filters applied to Zeek upon reading packet capture
weird.log
Contains data about packets that are non-conformant to standard protocols, or packets with corrupted/damaged header fields from the packet capture.
x507.log
Contains public key certificates used by protocols detected by Zeek from the packet capture
(protocol).log (eg. dhco.log, http.log)
File containing information about packets found in each respective protocol from the packet capture
To view log files, we can employ several methods.
Use the cat
command
Replace conn.log with any of the log names.
However, this method displays results in an extremely messy manner, and can be not very user friendly when your terminal is small-sized.
Use the zeek-cut utility to parse the log files
The above command filters the connection log for the following columns, and displays the result:
id.org_h -> Source IP address
id.org_p -> Source port
id.resp_h -> Destination IP address
id.resp_p -> Destintation port
Use head
and tail
instead of cat
reduce the file contents displayed, especially if the file is large sized.
The -n option can also be used to specify the number of rows to be returned.
The output of the logs after using zeek-cut can also be output into a text file or csv file.
Text file:
CSV file:
-F -> Changes the default delimiter from '\t' (tab) to ','; Separates the data values using the specified delimiter.
More Log Parsing Commands
To observe what services were observed from the packet capture
rn -> Organize rows in reverse numerical order (descending)
-c -> Removes duplicates while returning unique instances and their counts
syk
One last thing - we will need tcpdump, a command that will be allow Debian to start monitoring/sniffing the packets on a specified network interface. It then prints out the detected packets for us to see
You've managed to download Zeek!
While starting up, I faced this issue where Zeek failed to start.
So, I ran a diag
to find out what issue occurred. Scrolling down to the ====.cmdline section, you can see that the network interface is set to eth0 (default).
You'll be brought into the config file, where you will have to change the default interface to whatever your device uses. (ens33 in my case)