<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mikko Korkalo on Medium]]></title>
        <description><![CDATA[Stories by Mikko Korkalo on Medium]]></description>
        <link>https://medium.com/@mikko.korkalo?source=rss-c74bbaa45c32------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*5BadPqXa2RBLsnKS.</url>
            <title>Stories by Mikko Korkalo on Medium</title>
            <link>https://medium.com/@mikko.korkalo?source=rss-c74bbaa45c32------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 12:48:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mikko.korkalo/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Streaming events from SensorFleet to Elastic Stack or Azure Sentinel]]></title>
            <link>https://medium.com/sensorfleet/streaming-events-from-sensorfleet-to-elastic-stack-or-azure-sentinel-93286b22847a?source=rss-c74bbaa45c32------2</link>
            <guid isPermaLink="false">https://medium.com/p/93286b22847a</guid>
            <category><![CDATA[logstash]]></category>
            <category><![CDATA[sentinel]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[elasticsearch]]></category>
            <category><![CDATA[siem]]></category>
            <dc:creator><![CDATA[Mikko Korkalo]]></dc:creator>
            <pubDate>Mon, 09 Aug 2021 09:12:05 GMT</pubDate>
            <atom:updated>2021-08-09T09:12:05.956Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This blog post will show you step-by-step how to configure Logstash on top of SensorFleet Sensor for streaming events to your SIEM.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lQd2TpLFxoaF6_fdQdD4Cw.png" /></figure><p><strong>Introduction</strong></p><p>Up until recently, the go-to method for integrating SensorFleet event pipeline to SIEM has been the <a href="https://sensorfleet.com/instruments/eventexporter">Event Exporter Instrument</a>. It’s simple and lightweight, but it has required you to run a custom integration script to feed the events from our API to your SIEM.</p><p>Now you have a new option available: the <a href="https://sensorfleet.com/instruments/logforwarder">Log Forwarder Instrument</a>. It integrates Logstash into the SensorFleet Event Pipeline, so you have standard Logstash features available for the integration. In this guide, we will be configuring a standard HTTPS based event delivery from SensorFleet to your SIEM. In this case, we will be using Elastic Stack as the SIEM, but you could run anything that’s capable of accepting JSON events from Logstash.</p><p>In this case, we will be using Elastic Stack as the SIEM, but you could run anything that’s capable of accepting JSON events from Logstash. There’s also a configuration sample for Azure Sentinel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-oAAImq598YfC_NB.png" /></figure><p><strong>Requirements</strong></p><p>We assume you already have a Sensor deployed, along with a working Fleet Management and a SIEM setup that accepts events delivered by Logstash.</p><p>Required SensorFleet version: 2.3.6 or later</p><p><strong>Step 1: Add Log Forwarder Instrument to Sensor</strong></p><p>Add a Log Forwarder Instrument to your Sensor using Fleet Management UI.</p><p>Open the dropdown menu from your Sensor and choose Add Instrument.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/0*jAkcMD9OuDxjA0Yt.png" /></figure><p>Then, add a Log Forwarder Instrument by clicking the “Add Instrument” button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/0*HNTwe_NF_VbuexS2.png" /></figure><p><strong>Step 2: Configure networking for Log Forwarder Instrument</strong></p><p>Let’s add an Interface with connectivity to your upstream SIEM system. In our case, we have a dedicated physical interface that’s connected towards the SIEM. We configure that interface to our Instrument.</p><p>Choose Configure from the Log Forwarder Instrument dropdown menu.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/0*FLkkSSIYjghnpeBD.png" /></figure><p>Add an Interface. If using static IP configuration, remember to add a default route and DNS. Make sure to choose RX (receiver) and TX (transmit) capabilities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*z4hh_GXkowC3kiLA.png" /></figure><p><strong>Step 3: Configure Fleet Event Pipeline</strong></p><p>Next up, choose the Custom Configuration tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pQqmg7wtdXNDe36a.png" /></figure><p>The SensorFleet event subscription pipeline is a configuration to feed SensorFleet events from the Sensor to the <strong>local</strong> Logstash instance. In other words, these events will be fed to the Logstash instance running inside the Log Forwarder Instrument.</p><p>Here’s a sample SensorFleet event subscription pipeline to copy-paste into the textbox.</p><pre>- mongodb_terms: &#39;{}&#39;<br>  get_history: false<br>  logstash_port: 15044<br>  logstash_proto: beats<br>  unique_id: test</pre><ul><li>mongodb_terms: Search terms for the event subscription. Only events matching these search terms will be delivered. In this example, we get all events by using an empty filter ‘{}’.</li><li>get_history: false means that no event history before this moment will be fetched. Only events from now on. Be warned, setting this to true can cause a lot of events to be delivered at once.</li><li>logstash_port: To which local port will the events be delivered. This should match the port in your Logstash pipeline configuration (done in next step).</li><li>logstash_proto: Use beats for best performance. “http” is also supported.</li><li>unique_id: Set this to some descriptive short string. It will be used by pipeline stats loggers, for example.</li></ul><p><strong>Step 4: Configure Logstash pipeline</strong></p><p>In this context, Logstash pipeline is the pipeline that will receive events from Sensor, using the SensorFleet event pipeline configured previously. Received events will then be delivered to upstream SIEM.</p><p>Here’s a sample configuration to copy-paste into the logstash Pipelines.yml configuration box.</p><pre>- pipeline.id: siem-pipeline-1<br>  queue.type: persisted<br>  queue.max_events: 5<br>  queue.max_bytes: 1gb<br>  config.string: |<br>    input {<br>      beats {<br>        codec =&gt; plain<br>        host =&gt; &quot;127.0.0.1&quot;<br>        port =&gt; 15044<br>      }<br>    }<br>    output {<br>      http {<br>        url =&gt; &quot;https://elastic.my-upstream-siem.net:8899&quot;<br>        codec =&gt; json<br>        http_method =&gt; put<br>        client_cert =&gt; &quot;/transient-data/logstash/files/logstash_client.crt&quot;<br>        cacert =&gt; &quot;/transient-data/logstash/files/ca.crt&quot;<br>        client_key =&gt; &quot;/transient-data/logstash/files/logstash_client.key&quot;<br>      }<br>      # You can use stdout for debugging purposes.<br>      #stdout {}<br>    }</pre><ul><li><em>queue.type: persisted</em> means that events can be saved on disk temporarily.</li><li><em>beats</em> input plugin is the receiver for SensorFleet events. HTTP is also supported, but use of it is discouraged due to worse performance.</li><li><em>queue.max_events</em> is a small number. That’s by purpose, because we want to quickly see if the pipeline is not working. This configuration will cause <em>backpressure</em> in the HTTP input plugin after the queue of 5 events is full, which in turn causes the Fleet Pipeline to display the error.</li><li><em>http</em> output plugin is the sender that will deliver events to external SIEM.</li><li>In this example, we’re using TLS client certificates for authentication. For non-production testing purposes, you may change the protocol to http:// for plain HTTP without the hassle with TLS certificates.</li></ul><p>I have prepared a <a href="https://raw.githubusercontent.com/sensorfleet/sensorfleet.github.io/master/misc/openssl_ca.sh">helper script</a> to to generate TLS certificates to be used for Logstash client authentication, just change the server hostname to match whatever is in your https URL. Note that the use of EC keys might not be supported in your Logstash instance.</p><p><strong>Step 5: Configure TLS certificates for https output (optional)</strong></p><p>You will need 3 files:</p><ul><li>logstash_client.crt</li><li>logstash_client.key</li><li>ca.crt</li></ul><p>The TLS helper script provided in the previous step creates these files. You need to open the generated files, and copy-paste their content into the configuration UI in the following format:</p><pre>- file_name: logstash_client.crt<br>  file_text: |<br>    -----BEGIN CERTIFICATE-----<br>    MIIDUzCCAjugAwIBAgIUb5mZUZ...<br>    -----END CERTIFICATE-----<br>- file_name: logstash_client.key<br>  file_text: |<br>    -----BEGIN PRIVATE KEY-----<br>    MIIEvQIBA...<br>    -----END PRIVATE KEY-----<br>- file_name: ca.crt<br>  file_text: |<br>    -----BEGIN CERTIFICATE-----<br>    MIIDYTCCAkmgAwIBAgIUd...<br>    -----END CERTIFICATE-----</pre><p>Indenting the keys to correct indentation level (=4 spaces) is critical. I suggest using something like VSCode or VIM to do that. Future versions of the configuration UI will make this easier, but that’s how it works at the time of writing this blog.</p><p><strong>Step 5: Configure SIEM http(s) input and indexing</strong></p><p>Next we will configure your SIEM HTTP input. This part assumes that you run a Logstash instance next to ElasticSearch for receiving the events.</p><p>The relevant part for your receiver Logstash configuration. This configuration will typically go to /etc/logstash/conf.d/something.conf, actual filename depending on your Logstash installation.</p><pre>input {<br>  http {<br>    host =&gt; &quot;0.0.0.0&quot;<br>    port =&gt; 8899<br>    ssl =&gt; true<br>    ssl_certificate =&gt; &quot;/etc/logstash/logstash_server.crt&quot;<br>    ssl_certificate_authorities =&gt; [&quot;/etc/logstash/ca.crt&quot;]<br>    ssl_key =&gt; &quot;/etc/logstash/logstash_server_pk8.key&quot;<br>    ssl_verify_mode =&gt; &quot;force_peer&quot;<br>    codec =&gt; json<br>  }<br>}<br>output {<br>  elasticsearch {<br>    codec =&gt; json<br>    hosts =&gt; [&quot;http://localhost:9200&quot;]<br>    index =&gt; &quot;%{[@metadata][beat]}-%{[@metadata][version]}-%{+YYYY.MM.dd}&quot;<br>    #user =&gt; &quot;elastic&quot;<br>    #password =&gt; &quot;changeme&quot;<br>  }<br>  stdout {}<br>}</pre><ul><li>Copy the generated server side keys and certs from Step 4 to correct paths.</li><li>You may also need to configure your Logstash host’s firewall to accept connections to TCP port 8899.</li><li>Make sure to configure the correct ElasticSearch url and credentials.</li></ul><p><strong>Step 6: Test event pipeline</strong></p><p>Finally, time to see if your setup is working correctly.</p><p>First of all, check if your Log Forwarder Instrument is not in error state. It should look like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/0*31sz3I2tCtds3iVa.png" /></figure><p>If your configuration shows a yellow warning, it means the connection to upstream Logstash is not working. That could be due to many reasons — for example firewall blocking the traffic or TLS certificate misconfiguration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/0*czXCLDd0EBYF2pic.png" /></figure><p>Next, we need to make sure that the Log Forwarder Instrument has some events to forward. Log Forwarder instance is periodically producing statistics events, so you don’t need an event generator for testing purposes. You should at least see events like this in the Fleet Management event view:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8wZr2iKXlDrygH6f.png" /></figure><p>If your error counters are not increasing and the instrument stays has OK status, you should see the events in your receiving Logstash instance. Check your Logstash receiver logs: if you enabled the stdout output module, you should see something like this in logs:</p><pre>root@sf-elk-demo:~# journalctl -f -u logstash<br>{<br>  &quot;source_instrument&quot; =&gt; &quot;logforwarder_0@testsensor&quot;,<br>  &quot;type&quot; =&gt; &quot;instruments.logforwarder.pipeline_stats&quot;,<br>  &quot;message&quot; =&gt; &quot;pipeline test processed=6, errors=0&quot;,<br>  &quot;context_uuid&quot; =&gt; &quot;e41d4fbf-482f-4f74-a4e2-60717b03f623&quot;,<br>  &quot;sensor_event_id&quot; =&gt; 871,</pre><p>This means that the pipeline from your Sensor to external Logstash is working.</p><p><strong>Step 7: Configure event format</strong></p><p>By default, the event format for exported events is SensorFleet specific. For example, the timestamp field is not compatible with the default format expected by ElasticSearch. We’re going to take the SensorFleet event header, and put them inside <em>_sensorfleet_event</em> key, and actual event data goes to top level.</p><p>That way many of the compatible event formats forwarded by the SensorFleet sensor, such as Suricata and Zeek events, can be recognized by further event parsers, such as Filebeat ECS conversion routines or Azure Sentinel’s log parser.</p><p>Add this part to your Logstash event pipeline configuration, after the HTTP input plugin:</p><pre>filter {<br>  mutate {<br>    remove_field =&gt; [&quot;headers&quot;, &quot;tags&quot;, &quot;host&quot;]<br>  }<br>  ruby {<br>    code =&gt; &#39;<br>        # Move SensorFleet specific fields from root to _sensorfleet_event<br>        event.to_hash.each { |k, v|<br>            unless [ &quot;@timestamp&quot;, &quot;@version&quot;, &quot;host&quot;].include?(k)<br>                event.set(&quot;[_sensorfleet_event][#{k}]&quot;, v)<br>                event.remove(k)<br>            end<br>        }</pre><pre>        # Copy fields from SensorFleet event data to root level (if any)<br>        data = event.get(&quot;[_sensorfleet_event][data]&quot;)<br>        unless data.nil?<br>            data.to_hash.each { |k, v|<br>                event.set(&quot;[#{k}]&quot;, v)<br>            }<br>        end<br>    &#39;<br>  }<br>  mutate {<br>    # Optional: remove [_sensorfleet_event][data] if you want to avoid<br>    # duplicating the data.<br>    remove_field =&gt; &quot;[_sensorfleet_event][data]&quot;</pre><pre>  }</pre><pre>  mutate {<br>    add_tag =&gt; [ &quot;sensorfleet_event&quot; ]<br>  }<br>}</pre><p>You can do this either in the Log Forwarder’s Logstash instance, or in the receiving Logstash instance. It doesn’t really matter.</p><p>After applying the configuration, you should see events like this in the receiving Logtash instance:</p><pre>root@sf-elk-demo:~# journalctl -f -u logstash<br>{<br>       &quot;_sensorfleet_event&quot; =&gt; {<br>            &quot;source_sensor&quot; =&gt; &quot;testsensor&quot;,<br>                &quot;timestamp&quot; =&gt; 1614868533.946555,<br>                     &quot;uuid&quot; =&gt; &quot;cc2b3bb1-bd8f-4b9c-a89e-0e06ecb9cab3&quot;,<br>        &quot;source_instrument&quot; =&gt; &quot;logforwarder_0@testsensor&quot;,<br>                     &quot;type&quot; =&gt; &quot;instruments.logforwarder.pipeline_stats&quot;,</pre><p>Checking the Elastic Stack, we can see events being properly indexed by ElasticSearch:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0MkdfG0V5XfoMd3N.png" /></figure><h3>Other SIEM systems</h3><p>Logstash supports many other output plugins. For example, The SensorFleet integration includes a Azure Sentinel (Loganalytics) plugin by default. Here is an example output plugin configuration for that:</p><pre># Example for Azure Sentinel<br>microsoft-logstash-output-azure-loganalytics {<br>  workspace_id =&gt; &quot;your-uuid-here&quot;<br>  workspace_key =&gt; &quot;your-key-here&quot;<br>  custom_log_table_name =&gt; &quot;sflogforwarder&quot;<br>}</pre><p>For integration to work, you need to obtain workspace ID and workspace key from your Azure Loganalytics administrator. That’s all there is to it, add the correct output configuration and events will go into the specified table in Loganalytics. For more information, see <a href="https://docs.microsoft.com/en-us/azure/sentinel/connect-logstash">Use Logstash to connect data sources to Azure Sentinel</a>.</p><h3>Final Words</h3><p>After completing this guide, you have an Event Pipeline working from SensorFleet to your SIEM. More advanced event formatting is possible to match your deployment. For some pointers, if you want Suricata events in your Elastic Stack in a format that is supported by the standard tools, you should be using ECS formatting. That can be achieved by using Logstash along with Filebeat on the receiving side. Filebeat will do the ECS formatting for you, and your Elastic Stack will be more context aware. Completing this guide helps you collect more events and integrate more sources into your Logstash compatible SIEM or Azure Sentinel setup with off-the-shelf SensorFleet solution.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=93286b22847a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/sensorfleet/streaming-events-from-sensorfleet-to-elastic-stack-or-azure-sentinel-93286b22847a">Streaming events from SensorFleet to Elastic Stack or Azure Sentinel</a> was originally published in <a href="https://medium.com/sensorfleet">SensorFleet</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Zeek to find persistent threats by using a canary file (part 2)]]></title>
            <link>https://medium.com/sensorfleet/using-zeek-to-find-persistent-threats-by-using-a-canary-file-part-2-7a48a615dc0d?source=rss-c74bbaa45c32------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a48a615dc0d</guid>
            <category><![CDATA[threat-hunting]]></category>
            <category><![CDATA[honeypot]]></category>
            <category><![CDATA[zeek]]></category>
            <category><![CDATA[intrusion-detection]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Mikko Korkalo]]></dc:creator>
            <pubDate>Wed, 07 Oct 2020 00:00:00 GMT</pubDate>
            <atom:updated>2020-10-12T12:06:47.297Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*6L0fLOG4fjDg9Q9y_g7W-Q.png" /><figcaption>You can detect the download of your canary file by analysing network traffic</figcaption></figure><h3>Introduction</h3><p>This is a continuation to my <a href="https://sensorfleet.com/2020/09/29/Using-Zeek-to-find-persistent-threats-by-monitoring-DNS.html">previous blog</a>. Previously we set up some monitoring for DNS anomalies, like sustained DNS connections. This guide assumes that you read the previous one, so if you want to try this, please read the <a href="https://sensorfleet.com/2020/09/29/Using-Zeek-to-find-persistent-threats-by-monitoring-DNS.html">previous blog</a> first.</p><h3>Step 1: honeypot, using network monitoring only?</h3><p>Do you have some server that contains confidential information? Perhaps a NAS file server or intranet web server?</p><p>There is an effective and nearly zero-false-positive way to detect breach of your server. Often, a honeypot software is deployed somewhere, and we would listen to any connections to the honeypot.</p><p>There is another way as well. Let’s say you have a public directory on your file server or webserver. Somewhere, where nobody really looks into. But it should still be publicly available. Then you create a “canary” file in that directory, that looks like it contains really sensitive information, like “credit_cards.db”. You write random bytes to the file. That should get the attention of an attacker. Naming suggests it’s a database containing credit cards, but the bytes are not understandable by any normal CLI tool.</p><p>If the file is downloaded without encryption (e.g. over HTTP connection), you can detect whenever it’s downloaded. Over Windows network share, email, HTTP, doesn’t matter. Zeek will create a file event from it (and log it if logging files is enabled).</p><p>Then, we have a special blacklist module that utilizes Zeek’s Intel Framework.</p><p>You save a file hash of your canary to zeek blacklist, and the blacklist engine will create an alert whenever that file is seen in the network traffic. Neat, isn’t it?</p><h3>Step 2: Prepare the canary file</h3><p>This step requires the use of a Linux or other Unix shell, with access to the /dev/urandom device and sha256 command.</p><ul><li>Create an interesting looking file, say <em>credit_cards.db</em>:</li></ul><pre>dd if=/dev/urandom of=/tmp/credit_cards.db bs=1 count=1851</pre><ul><li>Copy the file somewhere in your server. You could copy it to multiple places. If it leaks from anywhere, you will get an alert.</li><li>Calculate a SHA256 sum for the file:</li></ul><pre>sha1sum /tmp/credit_cards.db</pre><ul><li>(or sha1 on some systems)</li><li>Store the checksum of your file somewhere. In our case, the checksum is <em>c2c46a1f1c21d4aa77593e1f641576a068cc2afe</em>.</li></ul><h3>Step 3: Add file hash to blacklist</h3><p>Now you have the file hash ready and canary file is deployed.</p><p>Next, we add the file hash to Zeek Intel Framework. That process is a bit different depending on if you’re on SensorFleet environment or generic environment.</p><p><strong>Generic environment</strong></p><ul><li>Locate Zeek’s index-default.zeek script</li><li>Edit that script</li></ul><pre>vim /opt/zeek/share/zeek/base/init-default.zeek</pre><ul><li>Add the following code:</li></ul><pre><a href="http://twitter.com/load">@load</a> base/frameworks/intel<br><a href="http://twitter.com/load">@load</a> policy/frameworks/intel/seen<br><a href="http://twitter.com/load">@load</a> policy/frameworks/intel/do_notice<br><a href="http://twitter.com/load">@load</a> policy/frameworks/files/hash-all-files<br>redef Intel::read_files += { &quot;/opt/zeek_file_blacklist.txt&quot; };</pre><ul><li>Create a file /opt/zeek_file_blacklist.txt, containing the sha1 hash from previous step, in following format:</li></ul><pre>#fields indicator indicator_type meta.source c2c46a1f1c21d4aa77593e1f641576a068cc2afe Intel::FILE_HASH canary</pre><ul><li>Note: the columns must be tab separated.</li><li>Restart Zeek:</li></ul><pre>service zeek restart</pre><p><strong>SensorFleet environment</strong></p><ul><li>Open Rule Manager UI</li><li>Navigate to Zeek tab, blacklists and click Add blacklist:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/0*WcUhYVcBDDJbOMj_.png" /></figure><ul><li>Set blacklist name, add the file hash, and set blacklist type, validate and Save.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0j99g3WKHo0-lMnw.png" /></figure><ul><li>Commit blacklist changes:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/0*IU-tGlQfxDc0M9ml.png" /></figure><ul><li>Add a zeek script to load policy to calculate all file checksums:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/0*sOP3-__47FUfqGI3.png" /></figure><ul><li>Set code:</li></ul><pre><a href="http://twitter.com/load">@load</a> policy/frameworks/files/hash-all-files</pre><ul><li>Set script name, validate and Save.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kBb-ZLZQ1KUJjjsj.png" /></figure><ul><li>Commit script changes</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/0*sICDIbQmUcsrMhLj.png" /></figure><h3>Step 4: Test downloading the canary</h3><ul><li>Download the canary file to see if an Intel event occurs. In our case, the canary is downloaded using HTTP:</li></ul><pre>curl <a href="http://my_server/path/to/canary/credit_cards.db">http://my_server/path/to/canary/credit_cards.db</a> -o /dev/null</pre><ul><li>(you could download it by using a browser running on a Windows machine as well)</li><li>See if event occurs. In our case, there is such event:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MSmkrk03OEfMpBt4.png" /></figure><h3>Final words</h3><p>You will now get a notification whenever someone downloads your canary file. If you ever get such an event, the chances are that your network is compromised or someone with legitimate access accidentally found the file and didn’t know of it being a canary trap.</p><p>The cool thing about this is, you’re not required to modify your infrastructure. Just plant a file, and monitor your network traffic. That’s what IDS systems like Zeek do.</p><p><em>Originally published at </em><a href="https://sensorfleet.com/2020/10/07/Using-Zeek-to-find-persistent-threats-by-using-a-canary-file-part-2.html"><em>https://sensorfleet.com</em></a><em> on October 7, 2020.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a48a615dc0d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/sensorfleet/using-zeek-to-find-persistent-threats-by-using-a-canary-file-part-2-7a48a615dc0d">Using Zeek to find persistent threats by using a canary file (part 2)</a> was originally published in <a href="https://medium.com/sensorfleet">SensorFleet</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Zeek to find persistent threats by monitoring DNS anomalies (part 1)]]></title>
            <link>https://medium.com/sensorfleet/using-zeek-to-find-persistent-threats-by-monitoring-dns-anomalies-part-1-9997fa638272?source=rss-c74bbaa45c32------2</link>
            <guid isPermaLink="false">https://medium.com/p/9997fa638272</guid>
            <category><![CDATA[command-and-control]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[zeek]]></category>
            <category><![CDATA[intrusion-detection]]></category>
            <category><![CDATA[dns]]></category>
            <dc:creator><![CDATA[Mikko Korkalo]]></dc:creator>
            <pubDate>Tue, 29 Sep 2020 00:00:00 GMT</pubDate>
            <atom:updated>2020-10-02T06:24:32.428Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/525/1*e6J763awPMqUEZFsPkVCGQ.png" /><figcaption>You can detect C&amp;C connections that use only DNS connectivity by analysing network traffic</figcaption></figure><h3>Introduction</h3><p>Ever heard of Bro or Zeek, coolest thing(s) in network traffic analysis? Never got around to install it? I had, many times, and never did, until now. Zeek (formerly Bro) is a free and open-source software network analysis framework. In this article we’re going to take a look at Zeek as an IDS engine and some examples of what you can do with it. We are using the <a href="https://sensorfleet.com/">SensorFleet platform</a> to run <a href="https://sensorfleet.com/instruments/zeek/">Zeek Instrument</a>, but you could run Zeek on its own as well.</p><p>Many types of customizable rules are supported by Zeek, here’s two:</p><ul><li>Scripts (using the <a href="https://docs.zeek.org/en/current/examples/scripting/">Zeek scripting engine</a>)</li><li>Blacklists (using the <a href="https://docs.zeek.org/en/current/frameworks/intel.html">Zeek Intel Framework</a>).</li></ul><p>We’re going to try both of those to do something useful.</p><ul><li>Part 1: Deploy a script to find persistent threats by monitoring DNS anomalies.</li><li>Part 2: Add a “canary” file to an internal server to be used as a honeypot, and add the file hash to Zeek as a blacklist.</li></ul><h3>Step 1: Setting up Zeek</h3><p>Zeek will need a capture interface with mirrored IP traffic.</p><p>Setting that up will be heavily environment specific.</p><p>For our task, we will want the <strong>internal</strong> network traffic to be mirrored to our Sensor because we want to see DNS traffic with internal IP addresses.</p><p>Setting up a mirror interface is out of scope of this guide, but for general guidelines:</p><ul><li>Have a switch capable or port mirroring</li><li>Configure switch to mirror your internal traffic towards the sensor you’re running Zeek on</li><li>Configure Zeek to listen on that mirror interface</li></ul><p><strong>Generic environment</strong></p><p>If you are installing Zeek manually, outside of SensorFleet platform, refer to <a href="https://docs.zeek.org/en/current/install/install.html">Zeek Installation Manual</a>.</p><p><strong>SensorFleet environment</strong></p><p>We assume a preconfigured Sensor running the SensorFleet software.</p><p>We start by looking up the correct Sensor from the <a href="https://sensorfleet.com/solution/">Fleet Management</a> UI.</p><p>You can also add Zeek to your Fleet Management if that’s only that you have and the server can handle the load.</p><p>We’re going to use “Epycprobe”, our AMD EPYC based test Sensor.</p><ul><li>Click from the dropdown button and choose Add Instrument.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZisF8Fx-4wtnBVIE.png" /></figure><ul><li>Navigate Zeek Instrument from the list and click Add Intrument.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/528/1*Eympz9VTLX759a3jbMdvRg.png" /></figure><ul><li>Go to FM main UI and choose Configure from the Zeek instrument.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wQSvl183Ej55kw6x.png" /></figure><ul><li>We need to add a capture interface before it actually can see any traffic. Choose Add Interface, pick correct Sensor Bridge, choose only RX capability.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XZRrmWVjKaD7dA9y.png" /></figure><ul><li>Click Create.</li></ul><h3>Step 2: View Zeek events</h3><p>Zeek is now running. We can check that by viewing the events Zeek is generating.</p><p><strong>Generic environment</strong></p><p>If you’re running outside of SensorFleet platform, refer to <a href="https://docs.zeek.org/en/current/examples/logs/">Logging in Zeek Manual</a>.</p><p>Zeek logs individual event types into log files by default, e.g. <em>base.protocols.conn</em> logs to conn.log which could be found in <em>/opt/zeek/logs/current/conn.log</em> depending on the installation.</p><p><strong>SensorFleet environment</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JnQQv3zFWBWhHPsp.png" /></figure><p>Zeek is quite noisy by default: an event is generated <em>per connection</em>! That is a lot of events and a lot of useless information for many use cases. Unless you’re going to use Zeek as a network history audit tool, you probably want to disable a lot of the default connections. Another approach would be to generate lots of events, and handle them in SIEM accordingly.</p><h3>Step 3: Configuring Zeek for less noise</h3><p><strong>Generic environment</strong></p><ul><li>First, locate the file init-default.zeek in your Zeek installation. In our case, that is located at /opt/zeek/share/zeek/base/init-default.zeek.</li><li>Edit that file with your favorite editor and disable some modules:</li></ul><pre>vim /opt/zeek/share/zeek/base/init-default.zeek</pre><ul><li>If you wanted to disable all of them, you’d comment out the <em>@load</em> lines with the following vim command:</li></ul><pre>:%s/^<a href="http://twitter.com/load">@load</a>/#@load/g</pre><ul><li>Then save and quit using:</li></ul><pre>:wq</pre><ul><li>Restart Zeek:</li></ul><pre>/etc/init.d/zeek restart</pre><ul><li>Keep disabling zeek modules until you’ve reached the desired noise level in your event log.</li></ul><p><strong>SensorFleet environment</strong></p><ul><li>Navigate to Zeek Configuration menu (Zeek Instrument -&gt; Configure -&gt; Custom configuration).</li><li>Tick off some of the noisiest base modules and hit save.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uwRmOcU9poYxCGQp.png" /></figure><ul><li>Keep disabling Zeek modules until you’ve reached the desired noise level in your event log.</li><li>Prefer the dark, text only screen? No problem, you can use the excellent <em>fleet</em> CLI tool, in our case:</li></ul><pre>fleet config edit zeek_0@epycprobe</pre><ul><li>For more details about the fleet CLI tool, refer to SensorFleet User Manual.</li></ul><h3>Step 4: Add script to detect DNS anomalies</h3><p><strong>Generic environment</strong></p><ul><li>Install the dns-anomalous package using Zeek Package Manager:</li></ul><pre>zkg install sensorfleet/anomalous-dns</pre><ul><li>Restart Zeek instance: (command may depend on installation)</li></ul><pre>/etc/init.d/zeek restart</pre><p><strong>SensorFleet environment</strong></p><ul><li>Install IDS Rule Manager Instrument. For managing the custom Zeek scripts, we’re using the <a href="https://sensorfleet.com/instruments/rmgr/">IDS Rule Manager Instrument</a>. If you don’t have it installed yet, just add it using the UI similarly as you added <a href="https://sensorfleet.com/instruments/zeek/">Zeek Instrument</a>.</li><li>Add DNS anomaly detection script. I created a <a href="http://sensorfleet.com/misc/anomalous_dns_bundle.zeek">single-file version</a> of the <a href="https://github.com/jbaggs/anomalous-dns">anomalous-dns</a> Zeek package by github user jbaggs. I also added <a href="https://github.com/sensorfleet/anomalous-dns">a more aggressive whitelisting support</a> to it. Let’s add that to our Zeek install.</li><li>Open IDS Rule Manager Instrument UI</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9h9pxXPsptXnVPpa.png" /></figure><ul><li>Navigate to Zeek tab and click Add script</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/1*L6zyFiGaQLNaw4GkcJJ5fQ.png" /></figure><ul><li>Copy the contents of the <a href="http://sensorfleet.com/misc/anomalous_dns_bundle.zeek">anomalous-dns script</a> and paste it into the text field. Type some name for the script, and validate the syntax. Finally, click Save.</li><li>Click Commit script changes from the IDS Rule Manager UI</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/0*5AHQnzpRKh5pXXx_.png" /></figure><ul><li>The Zeek instance will restart with the new script shortly.</li></ul><h3>Step 5: Configure DNS anomalies whitelist</h3><ul><li>Navigate to Zeek events list to see if it’s producing any events. Depending on the network and port mirroring configuration, you might see false positives in the event output. For SensorFleet environment, use the UI. For generic environment, watch Zeek’s <em>notice.log</em>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hVA-UqEqRYL3UW7X.png" /></figure><ul><li>By viewing the produced events, it seems we have some false positives. That’s normal, because there are e.g. some mail servers and domain handling DNS servers in our monitoring setup. We need to configure our whitelist.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/0*KitD23nNX2A5c3JH.png" /></figure><ul><li>Open the script in a text editor. On SensorFleet environment, you can use the Rule Manager UI for editing. On Generic environment, locate anomalous-dns package in the Zeek installation, and open domain-whitelist.zeek in a text editor.</li><li>Edit the last few lines, they look like this:</li></ul><pre>redef domain_whitelist = /.../;<br>redef local_dns_servers = set(...);<br>redef totally_ignored_ips = set(...);</pre><ul><li>Add any domains or DNS servers to appropriate whitelists. I ended up adding some DNS and mail servers to <em>totally_ignored_ips</em> field to silence them, and a few common domains in <em>domain_whitelist</em>. There are a few syntax samples in the whitelist. For more details, see <a href="https://docs.zeek.org/en/current/examples/scripting/#data-structures">Zeek scripting manual for set, addr and pattern</a>.</li><li>Save script changes and restart Zeek:</li><li>On SensorFleet, just re-save the script and Commit script changes.</li><li>On General environment, save the script and run /etc/init.d/zeek restart (depending on the platform).</li></ul><h3>Step 6: Does it really work?</h3><p>Once you have the script running, and it’s not creating too much false positives anymore, you may want to see if it really can detect persistent DNS tunnels. Let’s test it.</p><ul><li>For testing, you will need a Linux or other unix shell, or a Windows PowerShell capable shell in your monitored network that has the host command (or nslookup on windows). The host must not be whitelisted, of course.</li><li>Command to run in unix shell: (bash-style syntax)</li></ul><pre>for n in {1..100}; do host dnstest$n.sensorfleet.com 8.8.4.4; done</pre><ul><li>Similar test command for Windows powershell:</li></ul><pre>for (($n = 0); $n -lt 100; $n++) { nslookup &quot;dnstest$i.sensorfleet.com&quot; 8.8.4.4 }</pre><ul><li>The test should result in an event like this:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/0*ZxXBO-M7LQHzaatT.png" /></figure><ul><li>Here, the id.orig_h (or src field) is the source of our potential threat.</li></ul><h3>Final words</h3><p>You will now get a notification of anomalous DNS behaviors, such as long running malware C&amp;C connections over DNS. This can be fairly useful if your network is restricted (e.g. HTTP proxy), but allows direct DNS access.</p><p>Also, some malwares might use DNS by default, even if HTTP was allowed, because DNS might be harder to detect since they do not make direct connections to the outside world, but instead leverage your DNS resolver.</p><p>I found out that configuring the whitelist for nearly zero false positives can take a lot of work, though, depending on your network. That’s why I ended up patching the <a href="https://github.com/jbaggs/anomalous-dns">jbaggs/anomalous-dns</a> for a more aggressive whitelist.</p><p>We now use the above detection method in monitoring of our own infrastructure.</p><p>Hopefully this will help someone to realize how neat things you can do just by using open source tools such as Zeek. And it gets even easier when using commercial products to round the rough edges a bit.</p><p>Stay tuned for the part 2 of our Zeek guide: We’re going to add a “canary” file to an internal server to be used as a honeypot, and add the file hash to Zeek as a blacklist.</p><p><em>Originally published at </em><a href="https://sensorfleet.com/2020/09/29/Using-Zeek-to-find-persistent-threats-by-monitoring-DNS.html"><em>https://sensorfleet.com</em></a><em> on September 29, 2020.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9997fa638272" width="1" height="1" alt=""><hr><p><a href="https://medium.com/sensorfleet/using-zeek-to-find-persistent-threats-by-monitoring-dns-anomalies-part-1-9997fa638272">Using Zeek to find persistent threats by monitoring DNS anomalies (part 1)</a> was originally published in <a href="https://medium.com/sensorfleet">SensorFleet</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Detection of ZeroLogon (CVE-2020–1472) using SensorFleet]]></title>
            <link>https://medium.com/sensorfleet/detection-of-zerologon-cve-2020-1472-using-sensorfleet-b8dd41713ea8?source=rss-c74bbaa45c32------2</link>
            <guid isPermaLink="false">https://medium.com/p/b8dd41713ea8</guid>
            <category><![CDATA[suricata]]></category>
            <category><![CDATA[intrusion-detection]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[zerologon]]></category>
            <category><![CDATA[information-security]]></category>
            <dc:creator><![CDATA[Mikko Korkalo]]></dc:creator>
            <pubDate>Mon, 21 Sep 2020 00:00:00 GMT</pubDate>
            <atom:updated>2020-09-29T10:56:07.506Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*IFN3QwL3StIBVyN0Cmuqzw.png" /><figcaption>Zerologon can be detected just by analysing IP traffic</figcaption></figure><h3>Introduction</h3><p>ZeroLogon can be used to exploit a serious vulnerability in Windows Domain Controllers.</p><p>I was recently asked if you could detect a ZeroLogon attempt using a SensorFleet-based Sensor. It is easy because we have plug &amp; play support for Emerging Threats intrusion detection ruleset and <a href="https://rules.emergingthreats.net/changelogs/suricata-5.0-enhanced.etpro.2020-09-14T23:52:58.txt">ZeroLogon was added to the ruleset on September 14th 2020</a>.</p><p>Emerging Threats can be enabled in our <a href="https://sensorfleet.com/instruments/rmgr/">IDS Rule Manager</a>- and <a href="https://sensorfleet.com/instruments/suricata/">Suricata IDS</a> Instruments.</p><p>Here’s how you do it. We’re going to assume that basic Sensor configuration is already done.</p><h3>Step 1: Install Rule Manager and Suricata</h3><p>There are few easy steps to take if you don’t have <a href="https://sensorfleet.com/instruments/rmgr/">IDS Rule Manager</a> and <a href="https://sensorfleet.com/instruments/suricata/">Suricata IDS</a> already enabled:</p><ul><li>Navigate to <a href="https://sensorfleet.com/solution/">SensorFleet Fleet Management</a> UI</li><li>Choose your target Sensor, and choose Add Instrument from the dropdown menu</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9g9W5aAcD84vxyKp.png" /></figure><ul><li>Click Add instrument for Suricata and IDS Rule Manager</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1022/0*ZtwG2g2G2NsBJW29.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/0*jEJiTSQp2kSilqu_.png" /></figure><h3>Step 2: Configure a capture interface for Suricata</h3><p>Even if you don’t have it already done, setting up traffic monitoring is a breeze. It is enough to choose the capture interface since SensorFleet Capture Engine is usually already configured as part of standard Sensor configuration.</p><ul><li>Locate Suricata IDS from your Fleet Management UI and choose Configure from the dropdown menu (it might display an error status due to missing capture interface — that’s normal).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7z-P5G_yc1wWlj7x.png" /></figure><ul><li>Choose Add Interface, select Sensor bridge, type some interface name, only choose capability RX and hit Create.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GJ9hlqinnyZHIlaT.png" /></figure><ul><li>Suricata status will change to OK after the configuration:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rWNIQ10zf0ymxhNs3i8TFg.png" /></figure><h3>Step 3: Add Emerging Threats ruleset</h3><p>Downloader Instrument is enabled as part of standard Sensor configuration and it gives you a centrally controlled way to fetch external configuration, such as the Emerging Threats ruleset. You just need to add a new source and the Downloader will do the heavy lifting.</p><ul><li>Locate IDS Rule Manager Instrument from Fleet Management UI and click the UI button</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hyUNGjzIc-20QV_V.png" /></figure><ul><li>Click Add rulesource</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/0*ePEKte_iP5r2M770.png" /></figure><ul><li>Type settings for the rulesource:</li></ul><pre>Name: Emerging Threats<br>URL: https://rules.emergingthreats.net/open/suricata-5.0/emerging.rules.tar.gz<br>Source type: External<br>Import Interval: 3600<br>[X] Enabled</pre><ul><li>With these settings, the URL will be checked for updates with HTTP HEAD every 3600 seconds, and downloaded only when file changes.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*khNen80vf5PDBA27.png" /></figure><ul><li>After a while, you will see the Emerging Threats rules in Rule Manager UI.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Fy5bdEC6ViQMaE2L.png" /></figure><ul><li>Just in case, you can search the ruleset to find the ZeroLogon Rule. Open Rule search and type <em>zerologon</em> to show the zerologon rules.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*f4gm9cD0Ka--N7Ry.png" /></figure><h3>Step 4: Testing the rule</h3><p>It is always a good idea to test your ruleset.</p><p>Right now, the easiest way to test it against ZeroLogon detection would be to replay a traffic capture (pcap) that should trigger the alert. Luckily <a href="https://github.com/corelight/zerologon/blob/master/testing/Traces/CVE-2020-1472_exploit_win2019.pcap">there is a pcap that does just this</a>.</p><p>There is another way — <a href="https://github.com/dirkjanm/CVE-2020-1472">launch a live attack against your Windows Domain Controller</a>. I wouldn’t try that in production though.</p><p>We’re going to try the pcap. This assumes you only have a single bridge in your setup.</p><ul><li>Login to your sensor using SSH.</li><li>List active bridges:</li></ul><pre>fleet config show &lt;sensor_id&gt;</pre><ul><li>Install the <em>tcpreplay</em> utility:</li></ul><pre>sudo apt update &amp;&amp; sudo apt install tcpreplay</pre><ul><li>Grant permissions to write to the bridge interface from host:</li></ul><pre>cat &gt; /etc/ferm/ferm.d/99-allow-br0-hostbridge.conf &lt;&lt;EOF<br>domain eb chain INPUT logical-in br0 ACCEPT;<br>domain eb chain OUTPUT logical-out br0 ACCEPT;<br>EOF<br>service ferm reload</pre><ul><li>Download the test pcap to your sensor:</li></ul><pre>curl \<br>https://github.com/corelight/zerologon/blob/master/testing/Traces/CVE-2020-1472_exploit_win2019.pcap \<br>        -o /root/zerologon.pcap</pre><ul><li>The exploit in pcap uses the IP addresses <em>172.16.0.10</em> and <em>172.16.5.58</em>. Those should be included in your Sensor’s homenets. Add <em>172.16.0.0/21</em> to your Sensor homenets: Choose configure from the Sensor dropdown menu, open Settings tab, add home network <em>172.16.0.0/21</em> and Save.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*V-5T9nm-vwG13ekC.png" /></figure><ul><li>Replay the pcap file to your bridge interface</li></ul><pre>tcpreplay-edit -i br0 /root/zerologon.pcap</pre><ul><li>Open Suricata IDS events page. You should see events like these:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*W2Pz5bwVSMmc5lH0.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/0*04A_aKfhViVcmhug.png" /><figcaption>Example zerologon event</figcaption></figure><pre>Event message: Suricata alert 172.16.0.10 -&gt; 172.16.5.58: ET EXPLOIT Possible Zerologon NetrServerAuthenticate with 0x00 Client Credentials (CVE-2020-1472)</pre><h3>Final words</h3><p>Running Suricata in your network can be very useful. With good quality free rules like Emerging Threats, you can catch a lot of badness in your network before things get out of control. If you see such an event, there might be still time to shutdown or disconnect the servers and create last minute snapshots of the data before the attacker installs a cryptolocker software or some other means to disrupt your business.</p><p><em>Originally published at </em><a href="https://sensorfleet.com/2020/09/21/Detection-of-ZeroLogon-CVE-2020-1472-using-SensorFleet.html"><em>https://sensorfleet.com</em></a><em> on September 21, 2020.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b8dd41713ea8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/sensorfleet/detection-of-zerologon-cve-2020-1472-using-sensorfleet-b8dd41713ea8">Detection of ZeroLogon (CVE-2020–1472) using SensorFleet</a> was originally published in <a href="https://medium.com/sensorfleet">SensorFleet</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Picking the right message encoder]]></title>
            <link>https://medium.com/sensorfleet/picking-the-right-message-encoder-805a5e9c0de5?source=rss-c74bbaa45c32------2</link>
            <guid isPermaLink="false">https://medium.com/p/805a5e9c0de5</guid>
            <category><![CDATA[messagepack]]></category>
            <category><![CDATA[json]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[benchmark]]></category>
            <category><![CDATA[encoding]]></category>
            <dc:creator><![CDATA[Mikko Korkalo]]></dc:creator>
            <pubDate>Thu, 22 Mar 2018 10:43:45 GMT</pubDate>
            <atom:updated>2018-03-22T13:18:19.924Z</atom:updated>
            <cc:license>http://creativecommons.org/publicdomain/zero/1.0/</cc:license>
            <content:encoded><![CDATA[<p>We’re designing a messaging solution to be used in the<a href="http://www.sensorfleet.com/"> SensorFleet</a> product. The protocol will use some messaging library like <a href="http://zeromq.org/">ZeroMQ</a>. With that in mind, we will also need a way to encode messages to be sent over the wire.</p><p>Consider this:</p><ul><li>We will have a lot of different message types, even kinds we don’t have control of.</li><li>Messages/sec matters.</li><li>Size over the wire matters.</li><li>Ease of use matters. We probably don’t want to maintain 100 protocol definition files, unless there is a really good gain from it.</li><li>Our primary language is Python, but other languages need to be supported too. At some point, we might want to rewrite the messaging implemention in a language faster than Python, but right now we just want a Version 1 that is maintainable and “fast enough”. Also, we can’t assume that all 3rd party developers will want to use, or can use Python.</li></ul><p>Instead of blindly choosing one that seemed good, I wanted to test the different encoders out how they perform in the real world. There are encoder benchmarks available, but I wanted to test our use case; a message envelope, that contains some metadata like ids, and a payload field, that contains a binary or text data between 0 to maybe tens of megabytes. Implementation in Python.</p><p>The code is available at GitHub: <a href="https://github.com/mkorkalo/encoder_benchmarks">https://github.com/mkorkalo/encoder_benchmarks</a></p><h3>Results with Python 3.6 implementations</h3><pre>┌─────────────┬─────────┬────────┬──────────────┐<br>│  Encoders   │ 14B/sec │ 1M/sec │ Encoded size │<br>├─────────────┼─────────┼────────┼──────────────┤<br>│ JSON        │   79698 │     86 │          112 │<br>│ Cap&#39;n&#39;Proto │  177571 │   3030 │           80 │<br>│ BSON        │   23255 │   2036 │          104 │<br>│ MsgPack     │  159359 │   4537 │           74 │<br>└─────────────┴─────────┴────────┴──────────────┘</pre><p>Results tell us how many 14 byte and 1 Mbyte payloads were handled per second, also final encoded size for the 14 byte payload + envelope over the wire is given.</p><p>Disclaimer: I didn’t go into depths on why the performance looks like this. Also I noticed that my Cap’n’Proto implementation doesn’t having packing enabled. YMMV.</p><p>The <a href="https://capnproto.org/"><strong>Cap’n’Proto</strong></a> message spec is easy to write and I really like the idea of writing/reading directly to/from the wire format. It sounds like a huge improvement over Protocol Buffers. However, all of the protobuf-like encoders suffer from the same drawback: you have to maintain protocol definitions. Whether that’s a problem or not, depends on the use. We could use it with the message envelope, but probably not with the payload where we will have tons of different messages.</p><p>For all the other message encoders presented here, just take a Python dictionary and encode it.</p><p><a href="https://www.json.org/"><strong>JSON</strong></a> obviously has a pretty big drawback: it cannot efficiently encode binary data. This causes the high payload (1 MB of /dev/urandom) performance to suffer a lot. It’s fast with smaller payloads though.</p><p><a href="http://bsonspec.org/"><strong>BSON</strong></a> seems to be inefficient with small messages. I honestly don’t know what causes this and I also don’t have the time to research it. BSON also differs from JSON in other ways: it breaks compatibility. For example, you cannot have lists as top level items. I would like to see something that is fully compatible, in the data type sense, with JSON.</p><p>Behold, <a href="https://msgpack.org/"><strong>MessagePack</strong></a> comes to the rescue. It is surprisingly fast even though it has to encode field names from the dictionary to the wire format. It is nearly as fast as Cap’n’Proto with small messages, and actually faster with big payloads where the field name encoding is irrelevant. Maybe the Python implementation is optimized better than Cap’n’Proto’s. And it doesn’t need protocol definitions, you just:</p><pre>encoded = msgpack.packb({&quot;foo&quot;:&quot;bar&quot;}, use_bin_type=True)<br>msgpack.unpackb(encoded, raw=False)</pre><p>Other related projects, that were not included in this benchmark:</p><ul><li><a href="https://developers.google.com/protocol-buffers/">Protocol Buffers</a></li><li><a href="https://google.github.io/flatbuffers/">FlatBuffers</a></li></ul><p>Which one do you use and <strong>why</strong>?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=805a5e9c0de5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/sensorfleet/picking-the-right-message-encoder-805a5e9c0de5">Picking the right message encoder</a> was originally published in <a href="https://medium.com/sensorfleet">SensorFleet</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>