<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Detecting Beaconing Using Fourier Transform (FFT) in Security</title>
    <link>https://community.splunk.com/t5/Security/Detecting-Beaconing-Using-Fourier-Transform-FFT/m-p/581384#M15813</link>
    <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161348"&gt;@dokaas_2&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can extend &lt;A href="https://splunkbase.splunk.com/app/2890/" target="_self"&gt;Splunk Machine Learning Toolkit&lt;/A&gt; to include the FFT algorithm. The following is an example adapted from&amp;nbsp;&lt;A href="https://www.ritchievink.com/blog/2017/04/23/understanding-the-fourier-transform-by-example/" target="_self"&gt;https://www.ritchievink.com/blog/2017/04/23/understanding-the-fourier-transform-by-example/&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;First, let's generate the sample data:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;| makeresults count=500 
| streamstats count as t 
| eval t=exact(t/1000)-0.001, s=sin(40*2*pi()*t)+0.5*sin(90*2*pi()*t) 
| table t s&lt;/LI-CODE&gt;&lt;P&gt;We should have signals with frequencies of 40 and 90 cycles.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dokaas_2_samples.png" style="width: 959px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/17581i1E4F1CD6598211E5/image-size/large?v=v2&amp;amp;px=999" role="button" title="dokaas_2_samples.png" alt="dokaas_2_samples.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Next, let's add our algorithm stanza to $SPLUNK_HOME/etc/apps/Splunk_ML_Toolkit/local/algos.conf:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;[FFT]&lt;/LI-CODE&gt;&lt;P&gt;Restart Splunk to enable the algorithm.&lt;/P&gt;&lt;P&gt;Next, let's write the algorithm interface in&amp;nbsp;$SPLUNK_HOME/etc/apps/Splunk_ML_Toolkit/bin/algos/FFT.py. This is just an example with no input validation:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;#!/usr/bin/env python

import numpy as np
import pandas as pd

from base import BaseAlgo

class FFT(BaseAlgo):
    def __init__(self, options):
        # Option checking &amp;amp; initializations here
        pass

    def fit(self, df, options):
        # Fit an estimator to df, a pandas DataFrame of the search results

        s = df[self.target_variable]
        t = df[self.feature_variables]

        fft = np.fft.fft(s)
        T = t[t.columns[0]][1] - t[t.columns[0]][0]
        N = fft.size
        freq = np.linspace(0, 1 / T, N)[:N // 2]
        amp = np.abs(fft)[:N //2 ] * 1 / N

        df = pd.DataFrame({'Frequency': freq, 'Amplitude': amp}, columns=['Frequency', 'Amplitude'])

        return df&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Finally, let's try the algorithm with the fit command:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;| makeresults count=500 
| streamstats count as t 
| eval t=exact(t/1000)-0.001, s=sin(40*2*pi()*t)+0.5*sin(90*2*pi()*t) 
| table t s
| fit FFT s from t&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dokaas_2_fft.png" style="width: 959px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/17582i6E96A5AB339BA125/image-size/large?v=v2&amp;amp;px=999" role="button" title="dokaas_2_fft.png" alt="dokaas_2_fft.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Signals were detected at 40 and 90 cycles with the amplitudes (halved) shown.&lt;/P&gt;&lt;P&gt;If you have a sample data set, we can test it directly.&lt;/P&gt;</description>
    <pubDate>Mon, 17 Jan 2022 19:53:58 GMT</pubDate>
    <dc:creator>tscroggins</dc:creator>
    <dc:date>2022-01-17T19:53:58Z</dc:date>
    <item>
      <title>Detecting Beaconing Using Fourier Transform (FFT)</title>
      <link>https://community.splunk.com/t5/Security/Detecting-Beaconing-Using-Fourier-Transform-FFT/m-p/580294#M15803</link>
      <description>&lt;P&gt;Does anyone know of an add-on or other script that would allow one to analyze network traffic to detect beaconing using a Fourier transform (FFT)?&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jan 2022 16:53:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Detecting-Beaconing-Using-Fourier-Transform-FFT/m-p/580294#M15803</guid>
      <dc:creator>dokaas_2</dc:creator>
      <dc:date>2022-01-07T16:53:26Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting Beaconing Using Fourier Transform (FFT)</title>
      <link>https://community.splunk.com/t5/Security/Detecting-Beaconing-Using-Fourier-Transform-FFT/m-p/581384#M15813</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161348"&gt;@dokaas_2&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can extend &lt;A href="https://splunkbase.splunk.com/app/2890/" target="_self"&gt;Splunk Machine Learning Toolkit&lt;/A&gt; to include the FFT algorithm. The following is an example adapted from&amp;nbsp;&lt;A href="https://www.ritchievink.com/blog/2017/04/23/understanding-the-fourier-transform-by-example/" target="_self"&gt;https://www.ritchievink.com/blog/2017/04/23/understanding-the-fourier-transform-by-example/&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;First, let's generate the sample data:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;| makeresults count=500 
| streamstats count as t 
| eval t=exact(t/1000)-0.001, s=sin(40*2*pi()*t)+0.5*sin(90*2*pi()*t) 
| table t s&lt;/LI-CODE&gt;&lt;P&gt;We should have signals with frequencies of 40 and 90 cycles.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dokaas_2_samples.png" style="width: 959px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/17581i1E4F1CD6598211E5/image-size/large?v=v2&amp;amp;px=999" role="button" title="dokaas_2_samples.png" alt="dokaas_2_samples.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Next, let's add our algorithm stanza to $SPLUNK_HOME/etc/apps/Splunk_ML_Toolkit/local/algos.conf:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;[FFT]&lt;/LI-CODE&gt;&lt;P&gt;Restart Splunk to enable the algorithm.&lt;/P&gt;&lt;P&gt;Next, let's write the algorithm interface in&amp;nbsp;$SPLUNK_HOME/etc/apps/Splunk_ML_Toolkit/bin/algos/FFT.py. This is just an example with no input validation:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;#!/usr/bin/env python

import numpy as np
import pandas as pd

from base import BaseAlgo

class FFT(BaseAlgo):
    def __init__(self, options):
        # Option checking &amp;amp; initializations here
        pass

    def fit(self, df, options):
        # Fit an estimator to df, a pandas DataFrame of the search results

        s = df[self.target_variable]
        t = df[self.feature_variables]

        fft = np.fft.fft(s)
        T = t[t.columns[0]][1] - t[t.columns[0]][0]
        N = fft.size
        freq = np.linspace(0, 1 / T, N)[:N // 2]
        amp = np.abs(fft)[:N //2 ] * 1 / N

        df = pd.DataFrame({'Frequency': freq, 'Amplitude': amp}, columns=['Frequency', 'Amplitude'])

        return df&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Finally, let's try the algorithm with the fit command:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;| makeresults count=500 
| streamstats count as t 
| eval t=exact(t/1000)-0.001, s=sin(40*2*pi()*t)+0.5*sin(90*2*pi()*t) 
| table t s
| fit FFT s from t&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dokaas_2_fft.png" style="width: 959px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/17582i6E96A5AB339BA125/image-size/large?v=v2&amp;amp;px=999" role="button" title="dokaas_2_fft.png" alt="dokaas_2_fft.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Signals were detected at 40 and 90 cycles with the amplitudes (halved) shown.&lt;/P&gt;&lt;P&gt;If you have a sample data set, we can test it directly.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jan 2022 19:53:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Detecting-Beaconing-Using-Fourier-Transform-FFT/m-p/581384#M15813</guid>
      <dc:creator>tscroggins</dc:creator>
      <dc:date>2022-01-17T19:53:58Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting Beaconing Using Fourier Transform (FFT)</title>
      <link>https://community.splunk.com/t5/Security/Detecting-Beaconing-Using-Fourier-Transform-FFT/m-p/581387#M15814</link>
      <description>&lt;P&gt;Drop the mic and let me buy you a drink at the next .CONF!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jan 2022 20:25:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Detecting-Beaconing-Using-Fourier-Transform-FFT/m-p/581387#M15814</guid>
      <dc:creator>dokaas_2</dc:creator>
      <dc:date>2022-01-17T20:25:24Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting Beaconing Using Fourier Transform (FFT)</title>
      <link>https://community.splunk.com/t5/Security/Detecting-Beaconing-Using-Fourier-Transform-FFT/m-p/581394#M15815</link>
      <description>&lt;P&gt;So here's a scatter chart plotting the resultant magnitude.&amp;nbsp; I find a scatter chart a little easier to see the dominant frequencies (those that show stacked columns).&amp;nbsp; Clearly there is a strong beacon at 1 Hz and even stronger one at 1/2 Hz (every 2 sec).&amp;nbsp;&amp;nbsp; There are probably others to inspect.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data was generated looking at DNS traffic from Corelight data.&amp;nbsp; The data could have come from Splunk Stream just as easily, but we already have a Corelight infrastructure.&amp;nbsp; The query excludes internal DNS traffic and includes only A, AAAA, TXT DNS records.&amp;nbsp; Of course there's a lot of other factors such as&amp;nbsp; DNS caching and rotating ads to consider.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Now on to some addition hunting to find and exclude benign sources and hopefully find nothing!&amp;nbsp;&amp;nbsp; As an aside, if anyone wants to see an fun use of the Fourier series, lookup "Fourier" and "Homer Simpson" on YouTube and see how Fourier series can draw Homer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Splunk_Beacon_Analysis.PNG" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/17583i4490A17C32F1A4F9/image-size/large?v=v2&amp;amp;px=999" role="button" title="Splunk_Beacon_Analysis.PNG" alt="Splunk_Beacon_Analysis.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jan 2022 21:09:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Detecting-Beaconing-Using-Fourier-Transform-FFT/m-p/581394#M15815</guid>
      <dc:creator>dokaas_2</dc:creator>
      <dc:date>2022-01-17T21:09:57Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting Beaconing Using Fourier Transform (FFT)</title>
      <link>https://community.splunk.com/t5/Security/Detecting-Beaconing-Using-Fourier-Transform-FFT/m-p/581399#M15816</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161348"&gt;@dokaas_2&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You've adapted this better than I have! I was looking for ways to define and group FFT output by specific features, e.g. src-dest tuples.&lt;/P&gt;&lt;P&gt;What general form did your base search take?&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jan 2022 22:10:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Detecting-Beaconing-Using-Fourier-Transform-FFT/m-p/581399#M15816</guid>
      <dc:creator>tscroggins</dc:creator>
      <dc:date>2022-01-17T22:10:05Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting Beaconing Using Fourier Transform (FFT)</title>
      <link>https://community.splunk.com/t5/Security/Detecting-Beaconing-Using-Fourier-Transform-FFT/m-p/581558#M15825</link>
      <description>&lt;P&gt;So here's a sample dashboard.&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DNS_Beacon_Detectin_Using_FFT.PNG" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/17603i84DFBB6164229F2C/image-size/large?v=v2&amp;amp;px=999" role="button" title="DNS_Beacon_Detectin_Using_FFT.PNG" alt="DNS_Beacon_Detectin_Using_FFT.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jan 2022 21:07:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Detecting-Beaconing-Using-Fourier-Transform-FFT/m-p/581558#M15825</guid>
      <dc:creator>dokaas_2</dc:creator>
      <dc:date>2022-01-18T21:07:56Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting Beaconing Using Fourier Transform (FFT)</title>
      <link>https://community.splunk.com/t5/Security/Detecting-Beaconing-Using-Fourier-Transform-FFT/m-p/581560#M15826</link>
      <description>&lt;P&gt;The query is something like this:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;The query uses CoreLight data and excludes local and well known sources.&lt;/LI&gt;&lt;LI&gt;| timechart count as s&amp;nbsp; span=5ds&lt;/LI&gt;&lt;LI&gt;| fillnull value = 0&lt;/LI&gt;&lt;LI&gt;| eval time_interval = 0.5&lt;/LI&gt;&lt;LI&gt;| eval sequence_number = 1&lt;/LI&gt;&lt;LI&gt;| streamstats current=f sum(sequence_number) as seq&lt;/LI&gt;&lt;LI&gt;| streamstats sum(time_interval) as time&lt;/LI&gt;&lt;LI&gt;| eval time = time - time_interval&lt;/LI&gt;&lt;LI&gt;| head=4096&lt;/LI&gt;&lt;LI&gt;| table time, s&lt;/LI&gt;&lt;LI&gt;| fit FFT s from time&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Still working with it ....&amp;nbsp; Do you have any suggestions, improvements?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jan 2022 21:20:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Detecting-Beaconing-Using-Fourier-Transform-FFT/m-p/581560#M15826</guid>
      <dc:creator>dokaas_2</dc:creator>
      <dc:date>2022-01-18T21:20:20Z</dc:date>
    </item>
  </channel>
</rss>

