activecm / espy

Endpoint detection for remote hosts for consumption by RITA and Elasticsearch
GNU General Public License v3.0
67 stars 16 forks source link

Espy - Sysmon Network Log Collector and Adapter

Brought to you by Active Countermeasures.


Espy collects Microsoft Sysmon network and DNS events in Elastic ECS format and adapts it for use with other tools. Currently, Espy supports converting Sysmon network connection events into Zeek TSV entries.

In addition, Espy optionally forwards data to an external Elasticsearch server such as the one included in BeaKer.

How it works

Installation

Espy Server System Requirements

Espy Agent System Requirements

Automated Install: Espy Server

Download the latest release tar file, extract it, and inside the Espy directory, run ./install_espy.sh on the Linux machine that will collect your Sysmon data and store the resulting Zeek logs.

The automated installer will:

The ./espy.sh script inside of the release tar file is a wrapper around docker-compose and can be used to manage Espy.

After running ./install_espy.sh you should be able to access Redis at localhost:6379. Note that Redis is exposed on every network interface available on the Docker host.

The Espy service will begin writing Zeek TSV formatted log data out to /opt/zeek/logs and will rotate the log files each hour.

The easiest way to begin sending data to the server is to use the automated Espy agent installer.

Automated Install: Espy Agent

The PowerShell script ./agent/install-sysmon-beats.ps1 will install Sysmon and WinLogBeats, and configure WinLogBeats to begin sending data to the Espy Redis server.

To install the agent, run the script as .\install-sysmon-beats.ps1 ip.or.hostname.of.espy.server.

The script then:

Forwarding Events to BeaKer's Elasticsearch Instance

One of our open source tools, BeaKer, uses Elasticsearch with Kibana dashboards. If you wish to forward the log events for all of the Windows hosts running the Espy agent to BeaKer's Elasticsearch instance, there are some configuration changes needed.

In /etc/espy/espy.yaml, edit the Elasticsearch block as follows:

Elasticsearch:
  # Set the host to the address of Docker's network bridge.
  Host: "172.17.0.1:9200"
  # Use the credentials created for BeaKer's ingestion tasks.
  # If the automated installer for BeaKer was used, the account is sysmon-ingest.
  User: "sysmon-ingest"
  # If you forgot the password for the sysmon-ingest user, it can be reset within Kibana under Management>Security>Users
  # Resetting the password requires updating each Windows system running the BeaKer agent with the new password
  Password: "password"

  TLS:
    # TLS must be enabled.
    Enable: true
    # Do not verify certs or provide a CA file if using the automated installer.
    VerifyCertificate: false
    CAFile: ""

Note that the configuration example sets the Host to the address of Docker's network bridge. This is a quick way to get Espy hooked up to BeaKer. If your network or Docker installation has a non-standard configuration, this change may not work.

Why?

BeaKer exposes port 9200 for Elasticsearch, so the Elastic instance runs on the Docker host's loopback address (localhost, 127.0.0.1). This means that Elasticsearch/Kibana is accessible on your server/network and is not isolated to the Docker containers/network. Espy exposes port 6379 for Redis, so Redis is accessible on your server/network, and therefore is able to receive logs from endpoints with the Espy agent installed. Since winlogbeat only supports one output source, we cannot directly pass logs over to Elasticsearch and instead must forward logs over from Redis/Espy. Since Espy's event forwarder runs in a container, it does not have access to the server's loopback address via localhost or 127.0.0.1. Therefore, setting the Host field in espy.yaml to localhost:9200 or 127.0.0.1:9200 would be pointing to the Espy container's loopback address, which does not host the Elastic instance, so it would fail.

There are multiple ways to get a Docker container to be able to connect to the Docker host's network. This tutorial shows a few of those methods. If using 172.17.0.1 as the Elastic host address doesn't work for you, maybe some of these other methods will. Some methods do impose security risks, so be sure to review what would be exposed with each method. One thing to note is that the forwarder receives the value of the Host parameter as a string, so using any Docker based variables that are usually used in Compose or Dockerfiles would not work unless Docker literally translates the routing address to the name of the variable. (i.e Can the Espy container reach https://host.docker.internal:9200/ ?)

Data Collected By Sysmon Per Network Connection

Data Collected By Sysmon Per DNS Lookup

Developer Information

To generate a new release tarball, run ./scripts/installer/generate_installer.sh.

To build the Espy service natively:

To run the native Espy service:

To run the Espy service and Redis in Docker, without installing:

The default credentials for development are:

To access a shell for Redis in Docker:

License

GNU GPL V3 © Active Countermeasures ™