blob: ec9f9cbd74c1643c29e592752d60b73fd8de6809 [file] [log] [blame]
<!DOCTYPE html>
<!--
| Generated by Apache Maven Doxia Site Renderer 1.8 from src/site/markdown/use-cases/typosquat_detection/index.md at 2019-05-14
| Rendered using Apache Maven Fluido Skin 1.7
-->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="Date-Revision-yyyymmdd" content="20190514" />
<meta http-equiv="Content-Language" content="en" />
<title>Metron &#x2013; Problem Statement</title>
<link rel="stylesheet" href="../../css/apache-maven-fluido-1.7.min.css" />
<link rel="stylesheet" href="../../css/site.css" />
<link rel="stylesheet" href="../../css/print.css" media="print" />
<script type="text/javascript" src="../../js/apache-maven-fluido-1.7.min.js"></script>
<script type="text/javascript">
$( document ).ready( function() { $( '.carousel' ).carousel( { interval: 3500 } ) } );
</script>
</head>
<body class="topBarDisabled">
<div class="container-fluid">
<div id="banner">
<div class="pull-left"><a href="http://metron.apache.org/" id="bannerLeft"><img src="../../images/metron-logo.png" alt="Apache Metron" width="148px" height="48px"/></a></div>
<div class="pull-right"></div>
<div class="clear"><hr/></div>
</div>
<div id="breadcrumbs">
<ul class="breadcrumb">
<li class=""><a href="http://www.apache.org" class="externalLink" title="Apache">Apache</a><span class="divider">/</span></li>
<li class=""><a href="http://metron.apache.org/" class="externalLink" title="Metron">Metron</a><span class="divider">/</span></li>
<li class=""><a href="../../index.html" title="Documentation">Documentation</a><span class="divider">/</span></li>
<li class="active ">Problem Statement</li>
<li id="publishDate" class="pull-right"><span class="divider">|</span> Last Published: 2019-05-14</li>
<li id="projectVersion" class="pull-right">Version: 0.7.1</li>
</ul>
</div>
<div class="row-fluid">
<div id="leftColumn" class="span2">
<div class="well sidebar-nav">
<ul class="nav nav-list">
<li class="nav-header">User Documentation</li>
<li><a href="../../index.html" title="Metron"><span class="icon-chevron-down"></span>Metron</a>
<ul class="nav nav-list">
<li><a href="../../CONTRIBUTING.html" title="CONTRIBUTING"><span class="none"></span>CONTRIBUTING</a></li>
<li><a href="../../Upgrading.html" title="Upgrading"><span class="none"></span>Upgrading</a></li>
<li><a href="../../metron-analytics/index.html" title="Analytics"><span class="icon-chevron-right"></span>Analytics</a></li>
<li><a href="../../metron-contrib/metron-docker/index.html" title="Docker"><span class="none"></span>Docker</a></li>
<li><a href="../../metron-contrib/metron-performance/index.html" title="Performance"><span class="none"></span>Performance</a></li>
<li><a href="../../metron-deployment/index.html" title="Deployment"><span class="icon-chevron-right"></span>Deployment</a></li>
<li><a href="../../metron-interface/index.html" title="Interface"><span class="icon-chevron-right"></span>Interface</a></li>
<li><a href="../../metron-platform/index.html" title="Platform"><span class="icon-chevron-right"></span>Platform</a></li>
<li><a href="../../metron-sensors/index.html" title="Sensors"><span class="icon-chevron-right"></span>Sensors</a></li>
<li><a href="../../metron-stellar/stellar-3rd-party-example/index.html" title="Stellar-3rd-party-example"><span class="none"></span>Stellar-3rd-party-example</a></li>
<li><a href="../../metron-stellar/stellar-common/index.html" title="Stellar-common"><span class="icon-chevron-right"></span>Stellar-common</a></li>
<li><a href="../../metron-stellar/stellar-zeppelin/index.html" title="Stellar-zeppelin"><span class="none"></span>Stellar-zeppelin</a></li>
<li><a href="../../use-cases/index.html" title="Use-cases"><span class="icon-chevron-down"></span>Use-cases</a>
<ul class="nav nav-list">
<li><a href="../../use-cases/forensic_clustering/index.html" title="Forensic_clustering"><span class="none"></span>Forensic_clustering</a></li>
<li><a href="../../use-cases/geographic_login_outliers/index.html" title="Geographic_login_outliers"><span class="none"></span>Geographic_login_outliers</a></li>
<li><a href="../../use-cases/parser_chaining/index.html" title="Parser_chaining"><span class="none"></span>Parser_chaining</a></li>
<li class="active"><a href="#"><span class="none"></span>Typosquat_detection</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<hr />
<div id="poweredBy">
<div class="clear"></div>
<div class="clear"></div>
<div class="clear"></div>
<div class="clear"></div>
<a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy"><img class="builtBy" alt="Built by Maven" src="../../images/logos/maven-feather.png" /></a>
</div>
</div>
</div>
<div id="bodyColumn" class="span10" >
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<h1>Problem Statement</h1>
<p><a name="Problem_Statement"></a></p>
<p><a class="externalLink" href="https://en.wikipedia.org/wiki/Typosquatting">Typosquatting</a> is a form of cybersquatting which relies on likely typos to trick unsuspecting users to visit possibly malicious URLs. In the best case, this is a mischievous joke as in the following RickRoll: <a class="externalLink" href="http://www.latlmes.com/breaking/apache-metron-named-best-software-by-asf-1">http://www.latlmes.com/breaking/apache-metron-named-best-software-by-asf-1</a>. In the worst case, however, it can be overtly malicious as Bitcoin users found out in <a class="externalLink" href="https://nakedsecurity.sophos.com/2014/03/24/bitcoin-user-loses-10k-to-typosquatters/">2016</a> when thousands of dollars of Bitcoin was stolen as part of a phishing attack which used typosquatting.</p>
<p>It is therefore of use for us to detect so called typosquatting attacks as they appear over the network. We have had for some time, through the flatfile loader and open source typosquatting generation tools such as <a class="externalLink" href="https://github.com/elceef/dnstwist">DNS Twist</a>, the ability to generated potential typosquatted domains, import them into HBase and look them up via <tt>ENRICHMENT_EXISTS</tt>.</p>
<p>There are some challenges with this approach, though entirely viable:</p>
<ul>
<li>Even for modest numbers of domains, the number of records can grow quite large. The Top Alexa 10k domains has on the order of 3 million potential typosquatted domains.</li>
<li>It still requires a network hop if out of cache.</li>
</ul>
<p><a name="The_Tools_Metron_Provides"></a></p>
<h1>The Tools Metron Provides</h1>
<div class="section">
<h2><a name="Bloom_Filters"></a>Bloom Filters</h2>
<p>It would be nice to have a local solution for these types of problems that may tradeoff accuracy for better locality and space. Those who have been following the general theme of Metron&#x2019;s analytics philosophy will see that we are likely in the domain where a probabalistic sketching data structure is in order. In this case, we are asking simple existence queries, so a <a class="externalLink" href="https://en.wikipedia.org/wiki/Bloom_filter">Bloom Filter</a> fits well here.</p>
<p>In Metron, we have the ability to create, add and merge bloom filters via:</p>
<ul>
<li><tt>BLOOM_INIT( size, fpp)</tt> - Creates a bloom filter to handle <tt>size</tt> number of elements with <tt>fpp</tt> probability of false positives (<tt>0 &lt; fpp &lt; 1</tt>).</li>
<li><tt>BLOOM_ADD( filter, object)</tt> - Add an item to an existing bloom filter.</li>
<li><tt>BLOOM_MERGE( filters )</tt> - Merge a <tt>filters</tt>, a list of Bloom Filters.</li>
</ul></div>
<div class="section">
<h2><a name="Typosquatting_Domain_Generation"></a>Typosquatting Domain Generation</h2>
<p>Now that we have a suitable data structure, we need a way to generate potential typosquatted domains for a given domain. Following the good work of <a class="externalLink" href="https://github.com/elceef/dnstwist">DNS Twist</a>, we have ported their set of typosquatting strategies to Metron:</p>
<ul>
<li>Bitsquatting - See <a class="externalLink" href="http://dinaburg.org/bitsquatting.html">here</a></li>
<li>Homoglyphs - Substituting characters for ascii or unicode analogues which are visually similar (e.g. <tt>latlmes.com</tt> for <tt>latimes.com</tt> as above)</li>
<li>Subdomain - Making part of the domain a subdomain (e.g. <tt>am.azon.com</tt>)</li>
<li>Hyphenation</li>
<li>Insertion</li>
<li>Addition</li>
<li>Omission</li>
<li>Repetition</li>
<li>Replacement</li>
<li>Transposition</li>
<li>Vowel swapping</li>
</ul>
<p>The Stellar function in Metron is <tt>DOMAIN_TYPOSQUAT( domain )</tt>. It is recommended to remove the TLD from the domain. You can see it in action here with our rick roll example above:</p>
<div>
<div>
<pre class="source">[Stellar]&gt;&gt;&gt; 'latlmes' in DOMAIN_TYPOSQUAT( 'latimes')
true
</pre></div></div>
</div>
<div class="section">
<h2><a name="Generating_Summaries"></a>Generating Summaries</h2>
<p>We need a way to generate the summary sketches from flat data for this to work. This is similar to, but somewhat different from, loading flat data into HBase. Instead of each row in the file being loaded generating a record in HBase, what we want is for each record to contribute to the summary sketch and at the end to write out the summary sketch.</p>
<p>For this purpose, we have a new utility <tt>$METRON_HOME/bin/flatfile_summarizer.sh</tt> to accompany <tt>$METRON_HOME/bin/flatfile_loader.sh</tt>. The same extractor config is used, but we have 3 new configuration options:</p>
<ul>
<li><tt>state_init</tt> - Allows a state object to be initialized. This is a string, so a single expression is created. The output of this expression will be available as the <tt>state</tt> variable.</li>
<li><tt>state_update</tt> - Allows a state object to be updated. This is a map, so you can have temporary variables here. Note that you can reference the <tt>state</tt> variable from this.</li>
<li><tt>state_merge</tt> - Allows a list of states to be merged. This is a string, so a single expression. There is a special field called <tt>states</tt> available, which is a list of the states (one per thread). If this is not in existence, the number of threads is bound to one.</li>
</ul>
<p>Just as with <tt>flatfile_loader.sh</tt>, you can specify the number of threads (via <tt>-p</tt>) and batch size (via <tt>-b</tt>), but now you have the opportunity to specify the output destination (via <tt>-o</tt>) and the output mode (via <tt>-om</tt>). The current output modes are:</p>
<ul>
<li><tt>LOCAL</tt> - The default, to local disk.</li>
<li><tt>CONSOLE</tt> - Write the object summarized out to std out. This is useful to get summary statistics about the data imported. For instance, you could determine how many typosquatted domains there are for the Alexa 10k.</li>
<li><tt>HDFS</tt></li>
</ul></div>
<div class="section">
<h2><a name="Reading_Summaries_In-Stream"></a>Reading Summaries In-Stream</h2>
<p>These summaries are immutable data and are stored in HDFS. We want to read them in and cache them for later, so a new stellar function called <tt>OBJECT_GET( hdfs_path )</tt> will allow you to read the data from HDFS and deserialize the data into an object which can be used. Subsequent calls for the next 24 hours (by default, defaults of the cache can be changed in the global config) will be read from the static cache.</p>
<p>For instance, if you have used the <tt>flatfile_summarizer.sh</tt> utility described above to write out an object to <tt>/apps/metron/objects/alexa_10k_filter.ser</tt>, you can read and deserialize this object and use the bloom filter to determine if the domain <tt>goggle</tt> is a typosquatted domain:</p>
<div>
<div>
<pre class="source">BLOOM_EXISTS( OBJECT_GET('/apps/metron/objects/alexa_10k_filter.ser'), 'goggle')
</pre></div></div>
<p><a name="Example"></a></p>
<h1>Example</h1>
<p>In the following demo, we will:</p>
<ul>
<li>Generate summary data from the top 10k Alexa domains in a Bloom Filter</li>
<li>Use this to detect potential typosquatting instances in proxy data</li>
</ul></div>
<div class="section">
<h2><a name="Preliminaries"></a>Preliminaries</h2>
<p>We assume that the following environment variables are set:</p>
<ul>
<li><tt>METRON_HOME</tt> - the home directory for metron</li>
<li><tt>ZOOKEEPER</tt> - The zookeeper quorum (comma separated with port specified: e.g. <tt>node1:2181</tt> for full-dev)</li>
<li><tt>BROKERLIST</tt> - The Kafka broker list (comma separated with port specified: e.g. <tt>node1:6667</tt> for full-dev)</li>
<li><tt>ES_HOST</tt> - The elasticsearch master (and port) e.g. <tt>node1:9200</tt> for full-dev.</li>
</ul>
<p>Also, this does not assume that you are using a kerberized cluster. If you are, then the parser start command will adjust slightly to include the security protocol.</p>
<p>Before editing configurations, be sure to pull the configs from zookeeper locally via</p>
<div>
<div>
<pre class="source">$METRON_HOME/bin/zk_load_configs.sh --mode PULL -z $ZOOKEEPER -o $METRON_HOME/config/zookeeper/ -f
</pre></div></div>
<p>If you are doing this on full-dev, I&#x2019;d recommend stopping existing parsers and the profiler to free up resources. You can do this in Ambari.</p></div>
<div class="section">
<h2><a name="Install_Squid_Proxy"></a>Install Squid Proxy</h2>
<p>Before starting, we&#x2019;re going to need to install and start squid by executing the following commands:</p>
<ul>
<li><tt>yum install -y squid</tt></li>
<li><tt>service squid start</tt></li>
</ul></div>
<div class="section">
<h2><a name="Retrieve_Alexa_Data"></a>Retrieve Alexa Data</h2>
<p>From the Metron access node in <tt>~</tt>, retrieve the <a class="externalLink" href="https://en.wikipedia.org/wiki/Alexa_Internet">Alexa top domains</a> data via:</p>
<div>
<div>
<pre class="source">cd ~
wget http://s3.amazonaws.com/alexa-static/top-1m.csv.zip
unzip top-1m.csv.zip
head -n 10000 top-1m.csv &gt; top-10k.csv
</pre></div></div>
<p>You should now have a file <tt>~/top-10k.csv</tt> which contains the top 10,000 domains as per <a class="externalLink" href="https://en.wikipedia.org/wiki/Alexa_Internet">Alexa</a>.</p></div>
<div class="section">
<h2><a name="Summarize"></a>Summarize</h2>
<div class="section">
<h3><a name="Configure_the_Bloom_Filter"></a>Configure the Bloom Filter</h3>
<p>In order to configure the bloom filter, we need to know two things:</p>
<ol style="list-style-type: decimal">
<li>Roughly how many elements are going into the bloom filter (an upper bound will do)</li>
<li>What kind of false positive probability do we want?</li>
</ol>
<p>Both of these are going to inform how large the bloom filter is going to be. We can decide 2, but 1 is going to require some computation. Let&#x2019;s use the <tt>CONSOLE</tt> output mode of the <tt>flatfile_summarizer.sh</tt> to count the number of typosquatted domains across the entire document.</p>
<p>Create a file <tt>~/extractor_count.json</tt> with the following content:</p>
<div>
<div>
<pre class="source">{
&quot;config&quot; : {
&quot;columns&quot; : {
&quot;rank&quot; : 0,
&quot;domain&quot; : 1
},
&quot;value_transform&quot; : {
&quot;domain&quot; : &quot;DOMAIN_REMOVE_TLD(domain)&quot;
},
&quot;value_filter&quot; : &quot;LENGTH(domain) &gt; 0&quot;,
&quot;state_init&quot; : &quot;0L&quot;,
&quot;state_update&quot; : {
&quot;state&quot; : &quot;state + LENGTH( DOMAIN_TYPOSQUAT( domain ))&quot;
},
&quot;state_merge&quot; : &quot;REDUCE(states, (s, x) -&gt; s + x, 0)&quot;,
&quot;separator&quot; : &quot;,&quot;
},
&quot;extractor&quot; : &quot;CSV&quot;
}
</pre></div></div>
<p>In this extractor config we are using the CSV extractor with the following config properties:</p>
<ul>
<li><tt>columns</tt> - Indicates the schema of the CSV. There are 2 columns, <tt>rank</tt> at the first position and <tt>domain</tt> at the second position.</li>
<li><tt>separator</tt> - Use a comma to separate the columns.</li>
<li><tt>value_transform</tt> - For each row, transform each <tt>domain</tt> column by removing the TLD.</li>
<li><tt>value_filter</tt> - Only consider non-empty domains</li>
<li><tt>state_init</tt> - Initialize the state, a long integer, to 0.</li>
<li><tt>state_update</tt> - For each row in the CSV, update the state, which is the running partial sum, with the number of typosquatted domains for the domain</li>
<li><tt>state_merge</tt> - For each thread, we have a partial sum, we want to merge the partial sums into the total.</li>
</ul>
<p>We can run this via:</p>
<div>
<div>
<pre class="source">$METRON_HOME/bin/flatfile_summarizer.sh -i ~/top-10k.csv -e ~/extractor_count.json -p 5 -om CONSOLE
</pre></div></div>
<p>The output should be something like:</p>
<div>
<div>
<pre class="source">17/12/22 17:05:19 WARN extractor.TransformFilterExtractorDecorator: Unable to setup zookeeper client - zk_quorum url not provided. **This will limit some Stellar functionality**
Processing /root/top-10k.csv
17/12/22 17:05:20 WARN resolver.BaseFunctionResolver: Using System classloader
Processed 9999 - \
3496552
</pre></div></div>
<p>So, we the total number of possible elements in the bloom filter summary, <tt>3,496,552</tt>.</p></div>
<div class="section">
<h3><a name="Generate_the_Bloom_Filter"></a>Generate the Bloom Filter</h3>
<p>Now we can generate the bloom filter on HDFS. As before, we will adapt our previous extractor config to generate the bloom filter rather than the sum of the typosquatted domains.</p>
<p>Create a file <tt>~/extractor_filter.json</tt> with the following contents:</p>
<div>
<div>
<pre class="source">{
&quot;config&quot; : {
&quot;columns&quot; : {
&quot;rank&quot; : 0,
&quot;domain&quot; : 1
},
&quot;value_transform&quot; : {
&quot;domain&quot; : &quot;DOMAIN_REMOVE_TLD(domain)&quot;
},
&quot;value_filter&quot; : &quot;LENGTH(domain) &gt; 0&quot;,
&quot;state_init&quot; : &quot;BLOOM_INIT(3496552, 0.001)&quot;,
&quot;state_update&quot; : {
&quot;state&quot; : &quot;REDUCE( DOMAIN_TYPOSQUAT( domain ), (s, x) -&gt; BLOOM_ADD(s, x), state)&quot;
},
&quot;state_merge&quot; : &quot;BLOOM_MERGE(states)&quot;,
&quot;separator&quot; : &quot;,&quot;
},
&quot;extractor&quot; : &quot;CSV&quot;
}
</pre></div></div>
<p>Most of the configs are the same, but there are three that are different:</p>
<ul>
<li><tt>state_init</tt> - We have changed our state to be a bloom filter, initialized with
<ul>
<li><tt>3496552</tt> - the size calculated in the previous step</li>
<li><tt>0.001</tt> - The false positive probability (<tt>0.1%</tt>)</li>
</ul>
</li>
<li><tt>state_update</tt> - Update the bloom filter (the <tt>state</tt> variable) with each typosquatted domain</li>
<li><tt>state_merge</tt> - Merge the bloom filters generated per thread into a final, single bloom filter to be written.</li>
</ul>
<p>Now we can generate the bloom filter in HDFS at <tt>/tmp/reference/alexa10k_filter.ser</tt> via</p>
<div>
<div>
<pre class="source">$METRON_HOME/bin/flatfile_summarizer.sh -i ~/top-10k.csv -o /tmp/reference/alexa10k_filter.ser -e ~/extractor_filter.json -p 5 -om HDFS
</pre></div></div>
<p>You can try out the object to ensure it functions as expected via the Stellar REPL (<tt>$METRON_HOME/bin/stellar -z $ZOOKEEPER</tt>):</p>
<div>
<div>
<pre class="source">[Stellar]&gt;&gt;&gt; BLOOM_EXISTS(OBJECT_GET('/tmp/reference/alexa10k_filter.ser'), 'gogle')
true
[Stellar]&gt;&gt;&gt; BLOOM_EXISTS(OBJECT_GET('/tmp/reference/alexa10k_filter.ser'), 'google')
false
[Stellar]&gt;&gt;&gt; BLOOM_EXISTS(OBJECT_GET('/tmp/reference/alexa10k_filter.ser'), 'github')
false
[Stellar]&gt;&gt;&gt; BLOOM_EXISTS(OBJECT_GET('/tmp/reference/alexa10k_filter.ser'), 'gituub')
true
</pre></div></div>
<p>Notice the lag on the first call is more substantial than the subsequent calls as they are pulled from the cache.</p></div></div>
<div class="section">
<h2><a name="Parser"></a>Parser</h2>
<p>Start the squid parser via:</p>
<ul>
<li>Create the squid topic: <tt>/usr/hdp/current/kafka-broker/bin/kafka-topics.sh --zookeeper $ZOOKEEPER --create --topic squid --partitions 1 --replication-factor 1</tt></li>
<li>Start the squid parser: <tt>$METRON_HOME/bin/start_parser_topology.sh -z $ZOOKEEPER -s squid</tt></li>
</ul></div>
<div class="section">
<h2><a name="Set_up_Enrichment.2C_Threat_Intel_and_Threat_Triage"></a>Set up Enrichment, Threat Intel and Threat Triage</h2>
<p>Now that we have squid parser running, we should create an enrichment to add a field <tt>is_potential_typosquat</tt> which determines if the domain is potentially a typosquatted domain. Furthermore, we should set an alert if it&#x2019;s so and triage those messages.</p>
<p>We can do this by creating <tt>$METRON_HOME/config/zookeeper/enrichments/squid.json</tt> with the following content:</p>
<div>
<div>
<pre class="source">{
&quot;enrichment&quot;: {
&quot;fieldMap&quot;: {
&quot;stellar&quot; : {
&quot;config&quot; : [
&quot;domain_without_tld := DOMAIN_REMOVE_TLD(domain_without_subdomains)&quot;,
&quot;is_potential_typosquat := BLOOM_EXISTS(OBJECT_GET('/tmp/reference/alexa10k_filter.ser'), domain_without_tld)&quot;,
&quot;domain_without_tld := null&quot;
]
}
}
,&quot;fieldToTypeMap&quot;: { }
},
&quot;threatIntel&quot;: {
&quot;fieldMap&quot;: {
&quot;stellar&quot; : {
&quot;config&quot; : [
&quot;is_alert := is_alert || is_potential_typosquat&quot;
]
}
},
&quot;fieldToTypeMap&quot;: { },
&quot;triageConfig&quot; : {
&quot;riskLevelRules&quot; : [
{
&quot;name&quot; : &quot;Alexa 10k Typosquat Bloom&quot;,
&quot;comment&quot; : &quot;Inspect a bloom filter with potentially typosquatted domains from the top Alexa 10k&quot;,
&quot;rule&quot; : &quot;is_potential_typosquat != null &amp;&amp; is_potential_typosquat&quot;,
&quot;score&quot; : 10,
&quot;reason&quot; : &quot;FORMAT('%s is a potential typosquatted domain from the top 10k domains from alexa', domain_without_subdomains)&quot;
}
],
&quot;aggregator&quot; : &quot;MAX&quot;
}
}
}
</pre></div></div>
<p>As you can see, following the pattern of enrichments the following are done:</p>
<ul>
<li>A new field <tt>is_potential_typosquat</tt> is created which indicates whether the domain sans TLD and subdomains is a typosquatted domain according to our bloom filter of the top 10k Alexa domains</li>
<li><tt>is_alert</tt> is updated based on the <tt>is_potential_typosquat</tt> field</li>
<li>A new threat triage rule is added to give the analyst sufficient context if this alert triggers and a score of 10.</li>
</ul>
<p>Push the configs via <tt>$METRON_HOME/bin/zk_load_configs.sh -m PUSH -i $METRON_HOME/config/zookeeper -z $ZOOKEEPER</tt></p></div>
<div class="section">
<h2><a name="Setup_Indices"></a>Setup Indices</h2>
<p>We have to adjust the mappings for the indices we just created to add the <tt>alert</tt> nested property and ensure each of our properties gets the right type. One does not want to rely entirely on elasticsearch to guess the right types. We will do that by specifying a template:</p>
<div>
<div>
<pre class="source">curl -XPOST &quot;http://$ES_HOST/_template/squid_index&quot; -d '{
&quot;template&quot;: &quot;squid_index*&quot;,
&quot;mappings&quot;: {
&quot;squid_doc&quot;: {
&quot;dynamic_templates&quot;: [
{
&quot;timestamps&quot;: {
&quot;match&quot;: &quot;*:ts&quot;,
&quot;match_mapping_type&quot;: &quot;*&quot;,
&quot;mapping&quot;: {
&quot;type&quot;: &quot;date&quot;,
&quot;format&quot;: &quot;epoch_millis&quot;
}
}
},
{
&quot;threat_triage_score&quot;: {
&quot;mapping&quot;: {
&quot;type&quot;: &quot;float&quot;
},
&quot;match&quot;: &quot;threat:triage:*score&quot;,
&quot;match_mapping_type&quot;: &quot;*&quot;
}
},
{
&quot;threat_triage_reason&quot;: {
&quot;mapping&quot;: {
&quot;type&quot;: &quot;text&quot;,
&quot;fielddata&quot;: &quot;true&quot;
},
&quot;match&quot;: &quot;threat:triage:rules:*:reason&quot;,
&quot;match_mapping_type&quot;: &quot;*&quot;
}
}
],
&quot;properties&quot; : {
&quot;action&quot; : {
&quot;type&quot; : &quot;text&quot;,&quot;fielddata&quot; : true
},
&quot;bytes&quot; : {
&quot;type&quot; : &quot;long&quot;
},
&quot;code&quot; : {
&quot;type&quot; : &quot;long&quot;
},
&quot;domain_without_subdomains&quot; : {
&quot;type&quot; : &quot;text&quot;,&quot;fielddata&quot; : true
},
&quot;elapsed&quot; : {
&quot;type&quot; : &quot;long&quot;
},
&quot;full_hostname&quot; : {
&quot;type&quot; : &quot;text&quot;,&quot;fielddata&quot; : true
},
&quot;guid&quot; : {
&quot;type&quot; : &quot;keyword&quot;
},
&quot;ip_dst_addr&quot; : {
&quot;type&quot; : &quot;ip&quot;
},
&quot;ip_src_addr&quot; : {
&quot;type&quot; : &quot;ip&quot;
},
&quot;is_alert&quot; : {
&quot;type&quot; : &quot;text&quot;,&quot;fielddata&quot; : true
},
&quot;is_potential_typosquat&quot; : {
&quot;type&quot; : &quot;boolean&quot;
},
&quot;method&quot; : {
&quot;type&quot; : &quot;text&quot;,&quot;fielddata&quot; : true
},
&quot;original_text&quot; : {
&quot;type&quot; : &quot;text&quot;,&quot;fielddata&quot; : true
},
&quot;source:type&quot; : {
&quot;type&quot; : &quot;keyword&quot;
},
&quot;timestamp&quot; : {
&quot;type&quot; : &quot;date&quot;,
&quot;format&quot;: &quot;epoch_millis&quot;
},
&quot;url&quot; : {
&quot;type&quot; : &quot;text&quot;,&quot;fielddata&quot; : true
},
&quot;metron_alert&quot; : {
&quot;type&quot; : &quot;nested&quot;
}
}
}
}
}'
</pre></div></div>
</div>
<div class="section">
<h2><a name="Generate_Sample_Data"></a>Generate Sample Data</h2>
<p>We can now use <tt>squidclient</tt> to visit a regular domain and typosquatted domain and send the data to kafka:</p>
<div>
<div>
<pre class="source">squidclient http://www.github.com
squidclient http://gituub.com/apache/metron
cat /var/log/squid/access.log | /usr/hdp/current/kafka-broker/bin/kafka-console-producer.sh --broker-list $BROKERLIST --topic squid
</pre></div></div>
</div>
<div class="section">
<h2><a name="Investigate_via_the_Alerts_UI"></a>Investigate via the Alerts UI</h2>
<p>We should now have data in our elasticsearch indices, so let&#x2019;s investigate via the alerts UI.<br />
We can visit the Alerts UI (find the link from Ambari if not on full-dev. If on full-dev, go <a class="externalLink" href="http://node1:4201/alerts-list">here</a>.</p>
<p>From there you should see the following data from squid with one as an alert and the other not</p>
<p><img src="../../images/squid_search.png" alt="Alerts" /></p>
<p>Now, if you drill down into the alert, you can see our fields and the reasons specified</p>
<p><img src="../../images/drill_down.png" alt="Drill Down" /></p>
<div class="section">
<h3><a name="Version_Info"></a>Version Info</h3>
<p>Verified against:</p>
<ul>
<li>METRON_VERSION=0.5.0</li>
<li>ELASTIC_VERSION=5.6.2</li>
</ul></div></div>
</div>
</div>
</div>
<hr/>
<footer>
<div class="container-fluid">
<div class="row-fluid">
© 2015-2016 The Apache Software Foundation. Apache Metron, Metron, Apache, the Apache feather logo,
and the Apache Metron project logo are trademarks of The Apache Software Foundation.
</div>
</div>
</footer>
</body>
</html>