Blog Feed Post

Network Security: Analyze & Search Bro IDS Logs with Elasticsearch

Intrusion detection systems generate highly valuable logs with network usage details and alerts.
They collect vast amounts of data and typically store them in structures with a large number of fields.  To make sense of so much data and to make such information actionable requires advanced analytics, alerts, and search functionality. Because of that the IDS systems and Log Management systems are a perfect match!

Nevertheless, parsing, shipping and analyzing logs could be challenging.
In this blog post we’ll show an easy way to set up for the popular trio – Bro Network Security Monitor, Logagent, and Elasticsearch – and get you started with IDS log analysis within just a few minutes!

Meet the Bro Intrusion Detection System

Bro is a powerful network analysis framework that is much different from the typical IDS you may know.

While focusing on network security monitoring, Bro provides a comprehensive platform for more general network traffic analysis as well. Well grounded in more than 15 years of research, Bro has successfully bridged the traditional gap between academia and operations since its inception. Today, it is relied upon operationally in particular by many scientific environments for securing their cyberinfrastructure. Bro’s user community includes major universities, research labs, supercomputing centers, and open-science communities.

Bro has originally been developed by Vern Paxson, who continues to lead the project now jointly with a core team of researchers and developers at the International Computer Science Institute in Berkeley, CA; and the National Center for Supercomputing Applications in Urbana-Champaign, IL.

Source: www.bro-ids.org

IDS systems like Bro produce vast amounts of information for network security. A simple network connection log message might contain key information for security incident post-mortem analysis, so that, along many other things, needs to be logged. One can use various existing and custom Bro IDS scripts to detect nearly any anomaly in the network from the collected data, but they have a few downsides, such as:

  • You don’t know in advance which events should be reported
  • To write a custom script you need to learn Bro scripting language and available field names for each protocol

To make our lives with Bro easier we want to make the resulting IDS logs searchable. Doing that allowed iterative, interactive, ad-hoc querying, which results in a big productivity boost for security incident post-mortems. It also lets us create  alert queries on the continuous stream of this log data, thus enabling near real-time reactions to reported issues.

This post provide the recipe for making Bro logs searchable with Elasticsearch. The idea is to configure Bro IDS to generate logs in JSON format and then use a log shipper to forward them to Elasticsearch or Logsene. We will start with some Bro IDS basics, then configure Logagent as the log shipper, and finally show the results in Logsene, a handy ELK as a Service we’ll use to avoid needing to run our own Elasticearch.

Step 1:  Get started with a few Bro IDS basics:

Install Bro on Debian/Ubuntu Linux

$ apt-get install bro 

Run Bro to capture packets on the eth0 interface

$ sudo bro -i eth0 

Note that there is no output on the console because all information is written to various log files in the current directory. Press CTRL+C to terminate Bro and run ls *.log to see the generated log files and display e.g. the connection log:

$ cat conn.log
#separator \x09
#set_separator ,
#empty_field (empty)
#unset_field -
#path conn
#open 2017-01-12-13-09-36
#fields ts uid id.orig_h id.orig_p id.resp_h id.resp_p proto service duration orig_bytes resp_bytes conn_state local_orig local_resp missed_bytes history orig_pkts orig_ip_bytes resp_pkts
 resp_ip_bytes tunnel_parents
#types time string addr port addr port enum string interval count count string bool bool count string count count count count set[string]
1484222976.365029 C2mUt14hC9iOrC8se 62663 443 tcp - - - - OTH - - 0 d 0 0 1 494 (empty)
1484222975.423814 CDpOCg4wzHbeAbQn4 49904 443 tcp - 0.000002 0 976 OTH - - 0 d 0 0 2 1080 (empty)
1484222974.911667 C75yx91lD2bArc9CKj 56717 443 tcp - - - - OTH - - 0 a 0 0 1 52 (empty)
1484222974.852917 CQISpU3YnsqbRkLAf5 56911 443 tcp - - - - OTH - - 0 a 0 0 1 52 (empty)
1484222976.235060 Cdl9TTqFYx2fdG7Gi 51730 443 tcp - 0.097194 0 4330 OTH - - 0 ad 0 0 4 4538 (empty)
1484222975.149426 Cgw13b4NHZwoK73N41 49699 443 tcp - 0.072127 0 62 OTH - - 0 ad 0 0 2 166 (empty)
#close 2017-01-12-13-09-36

Now let’s adjust Bro log format to JSON and run Bro again

$ sudo bro -i eth0 -e 'redef LogAscii::use_json=T;' 

Check that JSON format is used

$ cat conn.log

This was easy! Bro logs all info in different Bro log files like conn.log, http.log, dns.log, weird.log etc.

Step 2:  Install & Configure Logagent

Install Logagent

Install Node.js runtime including npm package manager:

curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs

Install Logagent package and create a service for Logagent:

sudo npm i @sematext/logagent -g

# create logagent service, but stop it until we are done with the whole setup

sudo logagent-setup bro_ids_logs && sudo service service logagent stop

We will create the configuration for Logagent in the following steps and, once done, we’ll start the run Logagent service again.

Logagent Configuration

Having the IDS information in separate log files and in JSON makes it easy to configure a log shipper to index those logs in Elasticsearch or Logsene. Using Logagent we’ll do the following:

  1. Start Bro IDS using Logagent input-command plugin and collect all Bro logs
  2. Convert the timestamp (ts field) from Bro logs to a date and put it in the @timestamp field for Elasticsearch
  3. Configure bulk indexing for Elasticsearch

We will use Logagent input-command plugin to start Bro with Logagent. The Logagent input-command plugin can execute any command, watch the process, and even restart it if it terminates. If the command produces output on the console, Logagent will capture that output.  This way we will capture any error messages Bro outputs to console and index them to Elasticsearch as well. To capture the network event logs produced by Bro we’ll use the Logagent file input plugin. Bro always logs to files in the current directory, so we combine a few commands to start Bro, create a directory, and then run Bro in that directory. With this setup we collect the logs from the directory specified in the run command:

    module: command
    # store BRO logs in /tmp/bro in JSON format
    command: mkdir /tmp/bro; cd /tmp/bro; bro -i eth0 -e 'redef LogAscii::use_json=T;'
    sourceName: bro
    restart: 1
  # read the BRO logs from the file system ...
      - '/tmp/bro/*.log'

To index logs in Elasticsearch we need a valid date for the timestamp. Bro provides a UNIX timestamp in the ts field, which needs to be converted to a JavaScript Date object with a JavaScript transform function in the Logagent parser configuration. In addition, let’s set the _type for logs based on the Bro logs file names so we can use that for filtering. For example, for all logs from /tmp/bro/dns.log we’ll use “dns” as _type. Here is the relevant parser config and the JS transform function:

    enabled: true
    transform: !!js/function >
      function (sourceName, parsed, config) {
        var src = sourceName.split('/')
        // generate Elasticsearch _type out of the log file sourceName
        // e.g. "dns" from /tmp/bro/dns.log
        if (src && src[src.length-1]) {
        parsed._type = src[src.length-1].replace(/\.log/g,'')
        // store log file path in each doc
        parsed.logSource = sourceName
        // convert Bro timestamps to JavaScript timestamps
        if (parsed.ts) {
        parsed[[email protected]'] = new Date(parsed.ts * 1000)

Finally, let’s define where to store logs using the Elasticsearch output plugin and, in addition, let’s activate output to the console in YAML format so we can see the logs on the console:

  stdout: yaml
    module: elasticsearch 
    url: http://localhost:9200
    index: bro_ids_logs

To ship data to Logsene and avoid having to run your own Elasticsearch cluster simply replace url and index parameters. Use the Logsene App token as index name and HTTPS so your logs are encrypted on their way to Logsene:

  stdout: yaml
    module: elasticsearch 
    url: https://logsene-receiver.sematext.com
    index: 4f70a0c7-9458-43e2-bbc5-xxxxxxxxx

After we store the whole config as bro-ids.yaml we can run Logagent with Bro to test the configuration:

$ sudo logagent --config bro-ids.yaml
2017-01-12T12:34:12.205Z pid[26732] add command to plugin list
2017-01-12T12:34:12.207Z pid[26732] init plugins
2017-01-12T12:34:12.207Z pid[26732] init plugins
2017-01-12T12:34:12.208Z pid[26732] init plugins
2017-01-12T12:34:12.208Z pid[26732] ../lib/plugins/input/stdin
2017-01-12T12:34:12.227Z pid[26732] ../lib/plugins/output/stdout
2017-01-12T12:34:12.237Z pid[26732] ../lib/plugins/input/command.js
2017-01-12T12:34:12.245Z pid[26732] ../lib/plugins/input/command.js
2017-01-12T12:34:12.248Z pid[26732] ../lib/plugins/output/elasticsearch.js
2017-01-12T12:34:12.429Z pid[26732] ../lib/plugins/input/files
2017-01-12T12:34:12.522Z pid[26732] using glob pattern: /tmp/bro/*.log
2017-01-12T12:34:12.603Z pid[26732] Watching file:/tmp/bro/conn.log from position: 85285
2017-01-12T12:34:12.604Z pid[26732] Watching file:/tmp/bro/dns.log from position: 12106
2017-01-12T12:34:12.604Z pid[26732] Watching file:/tmp/bro/files.log from position: 24284
2017-01-12T12:34:12.604Z pid[26732] Watching file:/tmp/bro/http.log from position: 10745
2017-01-12T12:34:12.605Z pid[26732] Watching file:/tmp/bro/packet_filter.log from position: 89
2017-01-12T12:34:12.605Z pid[26732] Watching file:/tmp/bro/reporter.log from position: 556
2017-01-12T12:34:12.605Z pid[26732] Watching file:/tmp/bro/ssl.log from position: 26345
2017-01-12T12:34:12.605Z pid[26732] Watching file:/tmp/bro/weird.log from position: 5299
2017-01-12T12:34:12.606Z pid[26732] Watching file:/tmp/bro/x509.log from position: 35791
ts: 1484222526.821381
uid: ChYffm3LeTFNXIvVBg
id.orig_p: 2185
id.resp_p: 59096
proto: tcp
duration: 0.110198
orig_bytes: 0
resp_bytes: 0
conn_state: OTH
missed_bytes: 0
history: HA
orig_pkts: 2
orig_ip_bytes: 112
resp_pkts: 0
resp_ip_bytes: 0
 (empty array)
@timestamp: Thu Jan 12 2017 13:02:06 GMT+0100 (CET)
_type: conn
logSource: /tmp/bro/conn.log

For permanent network monitoring, use the Logagent Linux (or Mac OS X) service:

sudo cp bro-ids.yml /etc/sematext/logagent.conf
sudo service logagent start

After a minute we should see Bro logs indexed in Logsene. Now we can easily search all data provided by Bro or use Kibana to create charts that provide insights about our network activity.

https://sematext.com/wp-content/uploads/2017/02/image02-300x180.png 300w, https://sematext.com/wp-content/uploads/2017/02/image02-768x461.png 768w, https://sematext.com/wp-content/uploads/2017/02/image02-1024x615.png 1024w" sizes="(max-width: 1999px) 100vw, 1999px" />
https://sematext.com/wp-content/uploads/2017/02/image01-300x143.png 300w, https://sematext.com/wp-content/uploads/2017/02/image01-768x367.png 768w, https://sematext.com/wp-content/uploads/2017/02/image01-1024x489.png 1024w" sizes="(max-width: 1999px) 100vw, 1999px" />

https://sematext.com/wp-content/uploads/2017/02/image00-300x188.png 300w, https://sematext.com/wp-content/uploads/2017/02/image00-768x480.png 768w, https://sematext.com/wp-content/uploads/2017/02/image00-1024x640.png 1024w" sizes="(max-width: 1280px) 100vw, 1280px" />

Kibana Dashboard in Logsene

Got other, better,  or more interesting Kibana dashboards and charts?  Ping @sematext or leave a comment, we’d love to see them!

Read the original blog entry...

More Stories By Sematext Blog

Sematext is a globally distributed organization that builds innovative Cloud and On Premises solutions for performance monitoring, alerting and anomaly detection (SPM), log management and analytics (Logsene), and search analytics (SSA). We also provide Search and Big Data consulting services and offer 24/7 production support for Solr and Elasticsearch.

Latest Stories
@DevOpsSummit at Cloud Expo taking place Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center, Santa Clara, CA, is co-located with the 21st International Cloud Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The widespread success of cloud computing is driving the DevOps revolution in enterprise IT. Now as never before, development teams must communicate and collaborate in a dynamic, 24/7/365 environment. There is ...
After more than five years of DevOps, definitions are evolving, boundaries are expanding, ‘unicorns’ are no longer rare, enterprises are on board, and pundits are moving on. Can we now look at an evolution of DevOps? Should we? Is the foundation of DevOps ‘done’, or is there still too much left to do? What is mature, and what is still missing? What does the next 5 years of DevOps look like? In this Power Panel at DevOps Summit, moderated by DevOps Summit Conference Chair Andi Mann, panelists loo...
Cloud applications are seeing a deluge of requests to support the exploding advanced analytics market. “Open analytics” is the emerging strategy to deliver that data through an open data access layer, in the cloud, to be directly consumed by external analytics tools and popular programming languages. An increasing number of data engineers and data scientists use a variety of platforms and advanced analytics languages such as SAS, R, Python and Java, as well as frameworks such as Hadoop and Spark...
"MobiDev is a Ukraine-based software development company. We do mobile development, and we're specialists in that. But we do full stack software development for entrepreneurs, for emerging companies, and for enterprise ventures," explained Alan Winters, U.S. Head of Business Development at MobiDev, in this SYS-CON.tv interview at 20th Cloud Expo, held June 6-8, 2017, at the Javits Center in New York City, NY.
A look across the tech landscape at the disruptive technologies that are increasing in prominence and speculate as to which will be most impactful for communications – namely, AI and Cloud Computing. In his session at 20th Cloud Expo, Curtis Peterson, VP of Operations at RingCentral, highlighted the current challenges of these transformative technologies and shared strategies for preparing your organization for these changes. This “view from the top” outlined the latest trends and developments i...
Automation is enabling enterprises to design, deploy, and manage more complex, hybrid cloud environments. Yet the people who manage these environments must be trained in and understanding these environments better than ever before. A new era of analytics and cognitive computing is adding intelligence, but also more complexity, to these cloud environments. How smart is your cloud? How smart should it be? In this power panel at 20th Cloud Expo, moderated by Conference Chair Roger Strukhoff, paneli...
You know you need the cloud, but you’re hesitant to simply dump everything at Amazon since you know that not all workloads are suitable for cloud. You know that you want the kind of ease of use and scalability that you get with public cloud, but your applications are architected in a way that makes the public cloud a non-starter. You’re looking at private cloud solutions based on hyperconverged infrastructure, but you’re concerned with the limits inherent in those technologies.
For organizations that have amassed large sums of software complexity, taking a microservices approach is the first step toward DevOps and continuous improvement / development. Integrating system-level analysis with microservices makes it easier to change and add functionality to applications at any time without the increase of risk. Before you start big transformation projects or a cloud migration, make sure these changes won’t take down your entire organization.
The current age of digital transformation means that IT organizations must adapt their toolset to cover all digital experiences, beyond just the end users’. Today’s businesses can no longer focus solely on the digital interactions they manage with employees or customers; they must now contend with non-traditional factors. Whether it's the power of brand to make or break a company, the need to monitor across all locations 24/7, or the ability to proactively resolve issues, companies must adapt to...
SYS-CON Events announced today that TMC has been named “Media Sponsor” of SYS-CON's 21st International Cloud Expo and Big Data at Cloud Expo, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Global buyers rely on TMC’s content-driven marketplaces to make purchase decisions and navigate markets. Learn how we can help you reach your marketing goals.
Managing mission-critical SAP systems and landscapes has never been easy. Add public cloud with its myriad of powerful cloud native services and this may not change any time soon. Public cloud offers exciting new possibilities for enterprise workloads. But to make use of these possibilities and capabilities, IT teams need to re-think everything they have done before. Otherwise, they will just end up using public cloud as a hosting platform for their workloads, aka known as “lift and shift.”
Cloud promises the agility required by today’s digital businesses. As organizations adopt cloud based infrastructures and services, their IT resources become increasingly dynamic and hybrid in nature. Managing these require modern IT operations and tools. In his session at 20th Cloud Expo, Raj Sundaram, Senior Principal Product Manager at CA Technologies, will discuss how to modernize your IT operations in order to proactively manage your hybrid cloud and IT environments. He will be sharing bes...
SYS-CON Events announced today that TechTarget has been named “Media Sponsor” of SYS-CON's 21st International Cloud Expo, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. TechTarget storage websites are the best online information resource for news, tips and expert advice for the storage, backup and disaster recovery markets.
SYS-CON Events announced today that Telecom Reseller has been named “Media Sponsor” of SYS-CON's 21st International Cloud Expo, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Telecom Reseller reports on Unified Communications, UCaaS, BPaaS for enterprise and SMBs. They report extensively on both customer premises based solutions such as IP-PBX as well as cloud based and hosted platforms.
Artificial intelligence, machine learning, neural networks. We’re in the midst of a wave of excitement around AI such as hasn’t been seen for a few decades. But those previous periods of inflated expectations led to troughs of disappointment. Will this time be different? Most likely. Applications of AI such as predictive analytics are already decreasing costs and improving reliability of industrial machinery. Furthermore, the funding and research going into AI now comes from a wide range of com...