<?xml version="1.0" encoding="utf-8" standalone="yes"?><?xml-stylesheet href="/feed_style.xsl" type="text/xsl"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="https://www.rssboard.org/media-rss">
  <channel>
    <title>Homelab on ashtrace | blog</title>
    <link>https://ashtrace.github.io/tags/homelab/</link>
    <description>Recent content in Homelab on ashtrace | blog</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <copyright>Just adhere to [CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/)</copyright>
    <lastBuildDate>Mon, 16 Mar 2026 02:33:55 -0400</lastBuildDate><atom:link href="https://ashtrace.github.io/tags/homelab/index.xml" rel="self" type="application/rss+xml" /><icon>https://ashtrace.github.io/logo.svg</icon>
    
    
    <item>
      <title>SOC Homelab 101 - Learning Defensive Solutions</title>
      <link>https://ashtrace.github.io/posts/soc_homelab_101/</link>
      <pubDate>Mon, 16 Mar 2026 02:33:55 -0400</pubDate>
      
      <guid>https://ashtrace.github.io/posts/soc_homelab_101/</guid>
      <description><![CDATA[<p>Unfortunately in the AD Homelab, I failed to focus on defensive capabilities of Wazuh as XDR so this time I planned to build a lab focused on detection solutions. Rather than Wazuh, in this iteration I tried to get my hands dirty with Elastic and Kibana from the renowned ELK stack. Furthermore, I leveraged this exercise to learn about Vagrant and automation VM provisioning so unlike the previous homelab blog, this focuses on automating steps in place of manual configurations.</p>
<p>I&rsquo;d love to take people on a stroll on how to setup ELK but there are a plethora of blogs/videos/documentation and other references on the internet. The following aims to be an explanation of the <a href="https://github.com/ashtrace/soc-homelab"><em>Vagrant provisioning scripts I developed</em></a> for automating the setup to describe the what/why/how of the steps I undertook.</p>
<h2 id="the-environment">The Environment</h2>
<p>The configuration of my host machine were as follows:</p>
<ul>
<li>OS: Debian 13</li>
<li>Hypervisor: Virtualbox</li>
</ul>
<h2 id="installing-dependencies">Installing Dependencies</h2>
<p>For Virtualbox, I downloaded the <code>.deb</code> file provided at <a href="https://www.virtualbox.org/wiki/Linux_Downloads"><em>Download VirtualBox for Linux Hosts</em></a> page for my particular host OS.</p>
<p>Whereas Vagrant, I followed the instructions at the <a href="https://developer.hashicorp.com/vagrant/install"><em>Install Vagrant</em></a> documentation for linux.</p>
<p><img src="./install-vagrant-linux.png" alt="install-vagrant-linux"></p>
<h2 id="stage-0-the-plan">Stage 0: The Plan</h2>
<p>I aimed for a simple 2 machine architecture for the lab:</p>
<p><img src="./soc-siem-lab-arch.png" alt="soc-siem-lab-arch"></p>
<p>While configuring the elastic/kibana services in the SIEM lab VM, I needed to save the API tokens and secrets being generated to leverage them while creating the endpoint device. Thus, I used the current project directory as a shared mounted drive while provisioning the VMs.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-Vagrantfile" data-lang="Vagrantfile"><span style="display:flex;"><span><span style="color:#66d9ef">Vagrant</span><span style="color:#f92672">.</span>configure(<span style="color:#e6db74">&#34;2&#34;</span>) <span style="color:#66d9ef">do</span> <span style="color:#f92672">|</span>config<span style="color:#f92672">|</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e"># Shared folder for passing Enrollment Tokens and Configs between VMs</span>
</span></span><span style="display:flex;"><span>  config<span style="color:#f92672">.</span>vm<span style="color:#f92672">.</span>synced_folder <span style="color:#e6db74">&#34;.&#34;</span>, <span style="color:#e6db74">&#34;/vagrant&#34;</span>
</span></span></code></pre></div><h2 id="stage-1-the-elasticsearch-and-the-kibana">Stage 1: The Elasticsearch and The Kibana</h2>
<p>While originally I wanted to continue with Wazuh (the reason being my very teeny-tiny experience with it beforehand), I switched to elasticsearch + kibana as I felt that I had a larger set of public documentation to refer. Bear in mind that I had no prior experience of Elastic/Kibana or any other blue-team oriented technology for that matter.</p>
<p>For the first iteration I tried to configure things manually referring to <a href="https://www.digitalocean.com/community/tutorials/how-to-install-elasticsearch-logstash-and-kibana-elastic-stack-on-ubuntu-22-04"><em>digital ocean blogpost</em></a>. Only once I felt confident in my setup, I moved to the second phase of automating it with Vagrant.</p>
<h3 id="vagrantfile">Vagrantfile</h3>
<p>I define a vm named <code>soc</code> with Ubuntu 22.04 as mentioned before. I configured a static IPv4 address <code>192.168.56.20</code> and mentioned the path of the bash script (i.e. <code>provision/soc.sh</code>) which would contain the configuration steps to be ran with the privileged user context.</p>
<p>Registering VirtualBox as my provider, I conifigured the display name visible on VirtualBox and provided with the machine with 12GB of RAM and 4 cores of CPU.</p>
<p>Finally, I enabled the <code>linked_clone</code> feature to create a lightweight copy of base image and enabled I/O APIC for OS features along with nested VM capabilities for elastic defend (more on this later in the following sections).</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-Vagrantfile" data-lang="Vagrantfile"><span style="display:flex;"><span>  <span style="color:#75715e">########################################</span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e"># SOC SIEM VM (Ubuntu 22.04 Jammy)</span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e">########################################</span>
</span></span><span style="display:flex;"><span>  config<span style="color:#f92672">.</span>vm<span style="color:#f92672">.</span>define <span style="color:#e6db74">&#34;soc&#34;</span> <span style="color:#66d9ef">do</span> <span style="color:#f92672">|</span>soc<span style="color:#f92672">|</span>
</span></span><span style="display:flex;"><span>    soc<span style="color:#f92672">.</span>vm<span style="color:#f92672">.</span>box <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;ubuntu/jammy64&#34;</span>
</span></span><span style="display:flex;"><span>    soc<span style="color:#f92672">.</span>vm<span style="color:#f92672">.</span>hostname <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;soc-siem&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    soc<span style="color:#f92672">.</span>vm<span style="color:#f92672">.</span>network <span style="color:#e6db74">&#34;private_network&#34;</span>, <span style="color:#e6db74">ip</span>: <span style="color:#e6db74">&#34;192.168.56.20&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    soc<span style="color:#f92672">.</span>vm<span style="color:#f92672">.</span>provision <span style="color:#e6db74">&#34;shell&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">path</span>: <span style="color:#e6db74">&#34;provision/soc.sh&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">privileged</span>: <span style="color:#66d9ef">true</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    soc<span style="color:#f92672">.</span>vm<span style="color:#f92672">.</span>provider <span style="color:#e6db74">&#34;virtualbox&#34;</span> <span style="color:#66d9ef">do</span> <span style="color:#f92672">|</span>vb<span style="color:#f92672">|</span>
</span></span><span style="display:flex;"><span>      vb<span style="color:#f92672">.</span>name <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;soc-siem-lab&#34;</span>
</span></span><span style="display:flex;"><span>      vb<span style="color:#f92672">.</span>memory <span style="color:#f92672">=</span> <span style="color:#ae81ff">12288</span> <span style="color:#75715e"># 12GB RAM</span>
</span></span><span style="display:flex;"><span>      vb<span style="color:#f92672">.</span>cpus <span style="color:#f92672">=</span> <span style="color:#ae81ff">4</span>       <span style="color:#75715e"># 4 cores for CPU</span>
</span></span><span style="display:flex;"><span>      
</span></span><span style="display:flex;"><span>      vb<span style="color:#f92672">.</span>linked_clone <span style="color:#f92672">=</span> <span style="color:#66d9ef">true</span>
</span></span><span style="display:flex;"><span>      vb<span style="color:#f92672">.</span>customize <span style="color:#f92672">[</span><span style="color:#e6db74">&#34;modifyvm&#34;</span>, <span style="color:#e6db74">:id</span>, <span style="color:#e6db74">&#34;--ioapic&#34;</span>, <span style="color:#e6db74">&#34;on&#34;</span><span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>      <span style="color:#75715e"># Enable nested VT-x (Required for some Elastic Defend features)</span>
</span></span><span style="display:flex;"><span>      vb<span style="color:#f92672">.</span>customize <span style="color:#f92672">[</span><span style="color:#e6db74">&#34;modifyvm&#34;</span>, <span style="color:#e6db74">:id</span>, <span style="color:#e6db74">&#34;--nested-hw-virt&#34;</span>, <span style="color:#e6db74">&#34;on&#34;</span><span style="color:#f92672">]</span> 
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">end</span>
</span></span><span style="display:flex;"><span>  <span style="color:#66d9ef">end</span>
</span></span></code></pre></div><h3 id="the-provisioning-script">The Provisioning script</h3>
<p>The <code>provision/soc.sh</code> is a bash script file with commands to configure the elastic/kibana services in automated fashion, only after I had validated them manually. It starts as follows:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="color:#75715e">#!/bin/bash
</span></span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>set -e
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">##################################################</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Configuration Variables </span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">##################################################</span>
</span></span><span style="display:flex;"><span>ELASTIC_PASSWORD<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;CHANGE_ME&#34;</span>
</span></span><span style="display:flex;"><span>SHARED_DIR<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;/vagrant&#34;</span>
</span></span><span style="display:flex;"><span>IP_ADDR<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;192.168.56.20&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>apt update
</span></span><span style="display:flex;"><span>apt install -y curl wget apt-transport-https gnupg jq unzip
</span></span></code></pre></div><p>The <code>set -e</code> command tells the script to stop running at the first error. Next, I configure the variables as mentioned in the preceeding sections. The <code>ELASTIC_PASSWORD</code> needs to be set to a secret phrase/password which shall be used to access the elasticsearch APIs and the dashboard. Following the variable declaration, dependecies are installed for later usage.</p>
<h3 id="configuring-elasticsearch">Configuring Elasticsearch</h3>
<p>Once the dependencies are installed, apt sources are configured for elasticsearch and kibana. Next, the script installs elasticsearch and configures it.</p>
<p>The YAML file sets up cluster and node name, followed by paths for data and logs. Next, it configures the network host for the server. It enables security options required by Elastic Agent during enrollment while disabling HTTPs (I did not want to <code>curl -k</code> too much, its a homelab so I can take this risk but do not follow this in production environments).</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-yaml" data-lang="yaml"><span style="display:flex;"><span><span style="color:#f92672">cluster.name</span>: <span style="color:#ae81ff">soc-lab</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">node.name</span>: <span style="color:#ae81ff">soc-node1</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">path.data</span>: <span style="color:#ae81ff">/var/lib/elasticsearch</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">path.logs</span>: <span style="color:#ae81ff">/var/log/elasticsearch</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">network.host</span>: <span style="color:#ae81ff">0.0.0.0</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">discovery.type</span>: <span style="color:#ae81ff">single-node</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># --- SECURITY SECTION ---</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">xpack.security.enabled</span>: <span style="color:#66d9ef">true</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">xpack.security.enrollment.enabled</span>: <span style="color:#66d9ef">true</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Disable HTTP SSL (for easy Browser/Kibana access)</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">xpack.security.http.ssl.enabled</span>: <span style="color:#66d9ef">false</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Disable Transport SSL</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">xpack.security.transport.ssl.enabled</span>: <span style="color:#66d9ef">false</span>
</span></span></code></pre></div><p>Next, the script starts the elasticsearch service and waits until it is reachable via <code>curl</code>. Following which, it resets the elasticsearch password to the one provided in <code>ELASTIC_PASSWORD</code> variable. Furthermore it resets kibana password and saves both of these secrets along with the version of elasticsearch installed in a text file with the shared folder (my current project directory) titled <code>elastic_config.txt</code></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="color:#75715e">##################################################</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Setup apt sources</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">##################################################</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>curl -fsSL https://artifacts.elastic.co/GPG-KEY-elasticsearch |sudo gpg --dearmor -o /usr/share/keyrings/elastic.gpg
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;deb [signed-by=/usr/share/keyrings/elastic.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main&#34;</span> &gt; /etc/apt/sources.list.d/elastic-8.x.list
</span></span><span style="display:flex;"><span>apt update
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">##################################################</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Install Elasticsearch</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">##################################################</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>apt install elasticsearch
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">##################################################</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Configure Elasticsearch (disabled HTTPS and TLS, reset password  )</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">##################################################</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>mkdir -p /var/lib/elasticsearch
</span></span><span style="display:flex;"><span>mkdir -p /var/log/elasticsearch
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>chown -R elasticsearch:elasticsearch /var/lib/elasticsearch
</span></span><span style="display:flex;"><span>chown -R elasticsearch:elasticsearch /var/log/elasticsearch
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>cat &gt; /etc/elasticsearch/elasticsearch.yml <span style="color:#e6db74">&lt;&lt;EOF
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">cluster.name: soc-lab
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">node.name: soc-node1
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">path.data: /var/lib/elasticsearch
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">path.logs: /var/log/elasticsearch
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">network.host: 0.0.0.0
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">discovery.type: single-node
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74"># --- SECURITY SECTION ---
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">xpack.security.enabled: true
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">xpack.security.enrollment.enabled: true
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74"># Disable HTTP SSL (for easy Browser/Kibana access)
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">xpack.security.http.ssl.enabled: false
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74"># Disable Transport SSL
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">xpack.security.transport.ssl.enabled: false
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">EOF</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">##################################################</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Start Elasticsearch </span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">##################################################</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>systemctl daemon-reload
</span></span><span style="display:flex;"><span>systemctl enable --now elasticsearch
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;Waiting for Elasticsearch...&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">until</span> curl http://localhost:9200 &gt;/dev/null 2&gt;&amp;<span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">do</span>
</span></span><span style="display:flex;"><span> sleep <span style="color:#ae81ff">5</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">done</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">##################################################</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Extract elastic password</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">##################################################</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>printf <span style="color:#e6db74">&#34;y\n</span>$ELASTIC_PASSWORD<span style="color:#e6db74">\n</span>$ELASTIC_PASSWORD<span style="color:#e6db74">\n&#34;</span> | /usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic -i -f
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;elastic password: </span>$ELASTIC_PASSWORD<span style="color:#e6db74">&#34;</span> &gt; <span style="color:#e6db74">${</span>SHARED_DIR<span style="color:#e6db74">}</span>/elastic_config.txt
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>KIBANA_PASSWORD<span style="color:#f92672">=</span><span style="color:#66d9ef">$(</span>/usr/share/elasticsearch/bin/elasticsearch-reset-password -u kibana_system -f -b | grep <span style="color:#e6db74">&#34;New value:&#34;</span> | awk <span style="color:#e6db74">&#39;{print $NF}&#39;</span><span style="color:#66d9ef">)</span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;kibana_system password: </span>$KIBANA_PASSWORD<span style="color:#e6db74">&#34;</span> &gt;&gt; <span style="color:#e6db74">${</span>SHARED_DIR<span style="color:#e6db74">}</span>/elastic_config.txt
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>chmod <span style="color:#ae81ff">644</span> $SHARED_DIR/elastic_config.txt
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;Validating new Elasticsearch password ...&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>curl -u elastic:$ELASTIC_PASSWORD http://localhost:9200
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>ELASTIC_VERSION<span style="color:#f92672">=</span><span style="color:#66d9ef">$(</span>curl -u elastic:$ELASTIC_PASSWORD http://localhost:9200 | jq -r <span style="color:#e6db74">&#39;.version.number&#39;</span><span style="color:#66d9ef">)</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;[*] Installed Elasticsearch version: </span>$ELASTIC_VERSION<span style="color:#e6db74">&#34;</span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;Elasticsearch version: </span>$ELASTIC_VERSION<span style="color:#e6db74">&#34;</span> &gt;&gt; <span style="color:#e6db74">${</span>SHARED_DIR<span style="color:#e6db74">}</span>/elastic_config.txt
</span></span></code></pre></div><h3 id="configuring-kibana">Configuring Kibana</h3>
<p>Within this segement, the script installs kibana, configures the server to listen on all interface, sets the elasticsearch host, username, and password generated from previous section.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-yaml" data-lang="yaml"><span style="display:flex;"><span><span style="color:#f92672">server.host</span>: <span style="color:#e6db74">&#34;0.0.0.0&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">elasticsearch.hosts</span>: [<span style="color:#e6db74">&#34;http://localhost:9200&#34;</span>]
</span></span><span style="display:flex;"><span><span style="color:#f92672">elasticsearch.username</span>: <span style="color:#e6db74">&#34;kibana_system&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">elasticsearch.password</span>: <span style="color:#e6db74">&#34;$KIBANA_PASSWORD&#34;</span>
</span></span></code></pre></div><p>Then it generates the encryption keys required by elastic defend service during enrollment. Finally, it starts the service and validates the reachability.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="color:#75715e">##################################################</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Install Kibana</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">##################################################</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>sudo apt install kibana
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>cat &gt; /etc/kibana/kibana.yml <span style="color:#e6db74">&lt;&lt;EOF
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">server.host: &#34;0.0.0.0&#34;
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">elasticsearch.hosts: [&#34;http://localhost:9200&#34;]
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">elasticsearch.username: &#34;kibana_system&#34;
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">elasticsearch.password: &#34;$KIBANA_PASSWORD&#34;
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">EOF</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># For Elastic Defend</span>
</span></span><span style="display:flex;"><span>/usr/share/kibana/bin/kibana-encryption-keys generate | grep -E <span style="color:#e6db74">&#39;^xpack\..*:&#39;</span> &gt; /tmp/kibana.keys
</span></span><span style="display:flex;"><span>cat /tmp/kibana.keys &gt;&gt; /etc/kibana/kibana.yml
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>systemctl daemon-reload
</span></span><span style="display:flex;"><span>systemctl enable --now kibana
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;[*] Waiting for Kibana ...&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">until</span> <span style="color:#f92672">[</span> <span style="color:#e6db74">&#34;</span><span style="color:#66d9ef">$(</span>curl -s -u elastic:$ELASTIC_PASSWORD http://localhost:5601/api/status | jq -r <span style="color:#e6db74">&#39;.status.overall.level&#39;</span> 2&gt;/dev/null<span style="color:#66d9ef">)</span><span style="color:#e6db74">&#34;</span> <span style="color:#f92672">==</span> <span style="color:#e6db74">&#34;available&#34;</span> <span style="color:#f92672">]</span>; <span style="color:#66d9ef">do</span>
</span></span><span style="display:flex;"><span>    echo <span style="color:#e6db74">&#34;    - Still initializing plugins...&#34;</span>
</span></span><span style="display:flex;"><span>    sleep <span style="color:#ae81ff">10</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">done</span>
</span></span></code></pre></div><h2 id="stage-2-fleet">Stage 2: Fleet</h2>
<h3 id="terminologies">Terminologies</h3>
<p>As per the elastic <a href="https://www.elastic.co/docs/reference/fleet">documentation</a>:</p>
<blockquote>
<p>Elastic Agent is a single, unified way to add monitoring for logs, metrics, and other types of data to a host. It can also protect hosts from security threats, query data from operating systems, forward data from remote services or hardware, and more. A single agent makes it easier and faster to deploy monitoring across your infrastructure. Each agent has a single policy you can update to add integrations for new data sources, security protections, and more.</p>
</blockquote>
<p>While <a href="https://www.elastic.co/docs/reference/fleet/manage-elastic-agents-in-fleet">fleet allows to</a>:</p>
<blockquote>
<p>Manage Elastic Agent binaries and specify settings installed on the host that determine whether the agent is enrolled in Fleet, what version of the agent is running, and which agent policy is used.
Manage agent policies that specify agent configuration settings, which integrations are running, whether agent monitoring is turned on, input settings, and more.</p>
</blockquote>
<p>Using <code>fleet</code> one may configure <code>elastic agents</code>. These agents allow to monitor logs through <a href="https://www.elastic.co/docs/reference/integrations"><em><code>integrations</code></em></a>.</p>
<blockquote>
<p>Integrations provide an easy way to connect Elastic to external services and systems, and quickly get insights or take action. They can collect new sources of data, and they often ship with out-of-the-box assets like dashboards, visualizations, and pipelines to extract structured fields out of logs and events.</p>
</blockquote>
<p>Another important terminology is <code>Elastic Agent Policy</code></p>
<blockquote>
<p>Agent policies specify which integrations you want to run and on which hosts. You can apply an Elastic Agent policy to multiple agents, making it even easier to manage configuration at scale.</p>
</blockquote>
<p>Thus policies help to create sets of integrations for better management.</p>
<h3 id="fleet-policies">Fleet Policies</h3>
<p>The fleet server recieves the instruction from Kibana (Fleet UI) and pushes the policies to the enrolled elastic agents while keeping track of their health and status.</p>
<p>For simplicity, I went on to configure it on the same host which already runs the elasticsearch and the kibana services.</p>
<p>The script starts with initialzing the fleet setup with the fleet-server-policy which contains the integration for fleet-server functionalities.
The <em>fleet-server-policy</em> policy when applied to an elastic agent would allow it function as a fleet-server, as mentioned in the elastic <a href="https://www.elastic.co/docs/reference/fleet/fleet-server">documentation</a>:</p>
<blockquote>
<p>Fleet Server is a subprocess that runs inside a deployed Elastic Agent. This means the deployment steps are similar to any Elastic Agent, except that you enroll the agent in a special Fleet Server policy. Typically—especially in large-scale deployments—this agent is dedicated to running Fleet Server as an Elastic Agent communication host and is not configured for data collection.</p>
</blockquote>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="color:#75715e">############################################</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># INITIALIZE FLEET</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">############################################</span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;[*] Initializing Fleet...&#34;</span>
</span></span><span style="display:flex;"><span>curl -s -X POST http://localhost:5601/api/fleet/setup -H <span style="color:#e6db74">&#34;kbn-xsrf: true&#34;</span> -u elastic:$ELASTIC_PASSWORD
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">############################################</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># CREATE FLEET-SERVER POLICY</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">############################################</span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;[*] Creating fleet-server-policy...&#34;</span>
</span></span><span style="display:flex;"><span>curl -s -u elastic:$ELASTIC_PASSWORD <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>  -X POST -H <span style="color:#e6db74">&#34;kbn-xsrf: kibana&#34;</span> -H <span style="color:#e6db74">&#34;Content-type: application/json&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;http://localhost:5601/api/fleet/agent_policies&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>  -d <span style="color:#e6db74">&#39;{
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    &#34;id&#34;: &#34;fleet-server-policy&#34;,
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    &#34;name&#34;: &#34;Fleet-Server-Policy&#34;,
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    &#34;namespace&#34;: &#34;default&#34;,
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    &#34;monitoring_enabled&#34;: []
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">  }&#39;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">############################################</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># ADD FLEET-SERVER INTEGRATION</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">############################################</span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;[*] Adding fleet-server integration...&#34;</span>
</span></span><span style="display:flex;"><span>curl -s -u elastic:$ELASTIC_PASSWORD <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>  -X POST -H <span style="color:#e6db74">&#34;kbn-xsrf: kibana&#34;</span> -H <span style="color:#e6db74">&#34;Content-type: application/json&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;http://localhost:5601/api/fleet/package_policies&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>  -d <span style="color:#e6db74">&#39;{
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    &#34;name&#34;: &#34;fleet_server-1&#34;,
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    &#34;namespace&#34;: &#34;default&#34;,
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    &#34;policy_id&#34;: &#34;fleet-server-policy&#34;,
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    &#34;package&#34;: {
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">      &#34;name&#34;: &#34;fleet_server&#34;,
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">      &#34;version&#34;: &#34;1.6.0&#34;
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    }
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">  }&#39;</span>
</span></span></code></pre></div><p>Once created, the policy (with the integration) is visible in the dashboard.</p>
<p><img src="./fleet-server-policy-with-fleet-server-integration.png" alt="fleet-server-policy-with-fleet-server-integration"></p>
<p>Next the script creates another policy with integrations for elastic defend and windows telemetry, titled &lsquo;SOC-Lab-Policy&rsquo;. This is the policy that would later-on be applied onto the agent being enrolled on the Windows 11 endpoint VM.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="color:#75715e">############################################</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># CREATE SOC POLICY</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">############################################</span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;[*] Creating SOC-Lab-Policy...&#34;</span>
</span></span><span style="display:flex;"><span>SOC_POLICY_ID<span style="color:#f92672">=</span><span style="color:#66d9ef">$(</span>curl -s -X POST http://localhost:5601/api/fleet/agent_policies <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>    -H <span style="color:#e6db74">&#34;kbn-xsrf: true&#34;</span> -H <span style="color:#e6db74">&#34;Content-Type: application/json&#34;</span> -u elastic:$ELASTIC_PASSWORD <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>    -d <span style="color:#e6db74">&#39;{&#34;name&#34;:&#34;SOC-Lab-Policy&#34;,&#34;namespace&#34;:&#34;default&#34;,&#34;monitoring_enabled&#34;:[&#34;logs&#34;,&#34;metrics&#34;]}&#39;</span> | jq -r <span style="color:#e6db74">&#39;.item.id&#39;</span><span style="color:#66d9ef">)</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;[*] SOC Policy ID: </span>$SOC_POLICY_ID<span style="color:#e6db74">&#34;</span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;SOC Policy ID: </span>$SOC_POLICY_ID<span style="color:#e6db74">&#34;</span> &gt;&gt; <span style="color:#e6db74">${</span>SHARED_DIR<span style="color:#e6db74">}</span>/elastic_config.txt
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">############################################</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># INSTALL WINDOWS INTEGRATION TO SOC POLICY</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">############################################</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;[*] Adding Windows telemetry integration...&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>WIN_VERSION<span style="color:#f92672">=</span><span style="color:#66d9ef">$(</span>curl -s -u elastic:$ELASTIC_PASSWORD <span style="color:#e6db74">&#34;http://localhost:5601/api/fleet/epm/packages/windows&#34;</span> | jq -r <span style="color:#e6db74">&#39;.item.version&#39;</span><span style="color:#66d9ef">)</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>curl -s -X POST http://localhost:5601/api/fleet/package_policies <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>  -H <span style="color:#e6db74">&#34;kbn-xsrf: true&#34;</span> -H <span style="color:#e6db74">&#34;Content-Type: application/json&#34;</span> -u elastic:$ELASTIC_PASSWORD <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>  -d <span style="color:#e6db74">&#34;{
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    \&#34;name\&#34;: \&#34;windows-integration\&#34;,
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    \&#34;namespace\&#34;: \&#34;default\&#34;,
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    \&#34;policy_id\&#34;: \&#34;</span>$SOC_POLICY_ID<span style="color:#e6db74">\&#34;,
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    \&#34;package\&#34;: {
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">      \&#34;name\&#34;: \&#34;windows\&#34;,
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">      \&#34;version\&#34;: \&#34;</span>$WIN_VERSION<span style="color:#e6db74">\&#34;
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    }
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">  }&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">############################################</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># INSTALL ELASTIC DEFEND INTEGRATION TO SOC POLICY</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">############################################</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;[*] Adding Elastic Defend integration...&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>ENDPOINT_VERSION<span style="color:#f92672">=</span><span style="color:#66d9ef">$(</span>curl -s -u elastic:$ELASTIC_PASSWORD <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>http://localhost:5601/api/fleet/epm/packages/endpoint <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>| jq -r <span style="color:#e6db74">&#39;.item.version&#39;</span><span style="color:#66d9ef">)</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>curl -s -X POST http://localhost:5601/api/fleet/epm/packages/endpoint/$ENDPOINT_VERSION <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>-H <span style="color:#e6db74">&#34;kbn-xsrf: true&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>-u elastic:$ELASTIC_PASSWORD
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>curl -s -X POST http://localhost:5601/api/fleet/package_policies <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>  -H <span style="color:#e6db74">&#34;kbn-xsrf: true&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>  -H <span style="color:#e6db74">&#34;Content-Type: application/json&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>  -u elastic:$ELASTIC_PASSWORD <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>  -d <span style="color:#e6db74">&#34;{
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    \&#34;name\&#34;: \&#34;elastic-defend\&#34;,
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    \&#34;policy_id\&#34;: \&#34;</span>$SOC_POLICY_ID<span style="color:#e6db74">\&#34;,
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    \&#34;package\&#34;: {
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">      \&#34;name\&#34;: \&#34;endpoint\&#34;,
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">      \&#34;version\&#34;: \&#34;</span>$ENDPOINT_VERSION<span style="color:#e6db74">\&#34;
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    },
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    \&#34;inputs\&#34;: [
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">      {
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">        \&#34;type\&#34;: \&#34;ENDPOINT_INTEGRATION_CONFIG\&#34;,
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">        \&#34;enabled\&#34;: true,
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">        \&#34;streams\&#34;: [],
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">        \&#34;config\&#34;: {
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">          \&#34;_config\&#34;: {
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">            \&#34;value\&#34;: {
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">              \&#34;type\&#34;: \&#34;endpoint\&#34;,
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">              \&#34;endpointConfig\&#34;: {
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">                \&#34;preset\&#34;: \&#34;EDRComplete\&#34;
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">              }
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">            }
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">          }
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">        }
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">      }
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    ]
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">  }&#34;</span>
</span></span></code></pre></div><p>The &lsquo;SOC-Lab-Policy&rsquo; is created as follows:</p>
<p><img src="./soc-lab-policy.png" alt="soc-lab-policy"></p>
<p>The windows integration allows to collect logs from different data streams as demonstrated below:</p>
<p><img src="./windows-integration-enabled-data-streams.png" alt="windows-integration-enabled-data-streams"></p>
<p>While, the elastic-defend integration allows the agent to act as an Endpoint Detection and Response (EDR) agent. The <code>EDRComplete</code> preset mentioned in the script above allows to enable the following options within the integration:</p>
<p><img src="./elastic-defend-integration-with-enabled-options.png" alt="elastic-defend-integration-with-enabled-options"></p>
<h3 id="fleet-server">Fleet Server</h3>
<p>Once the policies are in place, the script fetches the service token from the elastic service and uses it to register an elastic agent as a fleet server. It ensures that the elastic agent is compatible with the version of elasticsearch installed previously.</p>
<p>Next, it configures the fleet server host in the Kibana fleet UI and updates the output to be elasticsearch. Finally, it validates that the fleet server is up and running.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">############################################</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># INSTALL FLEET SERVER</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">############################################</span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;[*] Installing Fleet Server...&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Generate service token for the agent</span>
</span></span><span style="display:flex;"><span>SERVICE_TOKEN<span style="color:#f92672">=</span><span style="color:#66d9ef">$(</span>curl -s -u elastic:$ELASTIC_PASSWORD -X POST <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>    http://localhost:9200/_security/service/elastic/fleet-server/credential/token/fleet-token <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>    | jq -r <span style="color:#e6db74">&#39;.token.value&#39;</span><span style="color:#66d9ef">)</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;[*] Service Token: </span>$SERVICE_TOKEN<span style="color:#e6db74">&#34;</span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;Service Token: </span>$SERVICE_TOKEN<span style="color:#e6db74">&#34;</span> &gt;&gt; <span style="color:#e6db74">${</span>SHARED_DIR<span style="color:#e6db74">}</span>/elastic_config.txt
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Using the Elastic version installed</span>
</span></span><span style="display:flex;"><span>cd /tmp
</span></span><span style="display:flex;"><span>wget -q <span style="color:#e6db74">&#34;https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-</span><span style="color:#e6db74">${</span>ELASTIC_VERSION<span style="color:#e6db74">}</span><span style="color:#e6db74">-linux-x86_64.tar.gz&#34;</span> -O elastic-agent.tar.gz
</span></span><span style="display:flex;"><span>tar -xzf elastic-agent.tar.gz
</span></span><span style="display:flex;"><span>cd elastic-agent-<span style="color:#e6db74">${</span>ELASTIC_VERSION<span style="color:#e6db74">}</span>-linux-x86_64/
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>./elastic-agent install <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>  --fleet-server-es<span style="color:#f92672">=</span>http://localhost:9200 <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>  --fleet-server-service-token<span style="color:#f92672">=</span>$SERVICE_TOKEN <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>  --fleet-server-policy<span style="color:#f92672">=</span>fleet-server-policy <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>  --fleet-server-port<span style="color:#f92672">=</span><span style="color:#ae81ff">8220</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>  --insecure --non-interactive
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">############################################</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># CONFIGURE FLEET HOST</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">############################################</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;[*] Setting Fleet Server host...&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>curl -s -u elastic:$ELASTIC_PASSWORD <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>   -X PUT -H <span style="color:#e6db74">&#34;kbn-xsrf: kibana&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>   -H <span style="color:#e6db74">&#34;Content-Type: application/json&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>   <span style="color:#e6db74">&#34;http://localhost:5601/api/fleet/settings&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>   -d <span style="color:#e6db74">&#34;{\&#34;fleet_server_hosts\&#34;: [\&#34;https://</span>$IP_ADDR<span style="color:#e6db74">:8220\&#34;]}&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Add elasticsearch to fleet&#39;s default output</span>
</span></span><span style="display:flex;"><span>curl -X PUT http://localhost:5601/api/fleet/outputs/fleet-default-output <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>-u elastic:$ELASTIC_PASSWORD <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>-H <span style="color:#e6db74">&#34;kbn-xsrf: true&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>-H <span style="color:#e6db74">&#34;Content-Type: application/json&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>-d <span style="color:#e6db74">&#34;{
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">  \&#34;name\&#34;: \&#34;default\&#34;,
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">  \&#34;type\&#34;: \&#34;elasticsearch\&#34;,
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">  \&#34;hosts\&#34;: [\&#34;http://</span>$IP_ADDR<span style="color:#e6db74">:9200\&#34;],
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">  \&#34;is_default\&#34;: true,
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">  \&#34;is_default_monitoring\&#34;: true
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">}&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">############################################</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># WAIT FOR FLEET SERVER</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">############################################</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;[*] Waiting for Fleet Server...&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">until</span> curl -k https://<span style="color:#e6db74">${</span>IP_ADDR<span style="color:#e6db74">}</span>:8220/api/status &gt;/dev/null 2&gt;&amp;<span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">do</span>
</span></span><span style="display:flex;"><span>    sleep <span style="color:#ae81ff">5</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">done</span>
</span></span></code></pre></div><p>Once the server is validated to be running, the script procures the secret token to be used for enrolling subsequent agents from different endpoints into the fleet.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="color:#75715e">############################################</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># GENERATE ENROLLMENT TOKEN</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">############################################</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;[*] Generating enrollment token...&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>ENROLL_TOKEN<span style="color:#f92672">=</span><span style="color:#66d9ef">$(</span>curl -s <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>-X POST <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>http://localhost:5601/api/fleet/enrollment_api_keys <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>-H <span style="color:#e6db74">&#34;kbn-xsrf: true&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>-H <span style="color:#e6db74">&#34;Content-Type: application/json&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>-u elastic:$ELASTIC_PASSWORD <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>-d <span style="color:#e6db74">&#34;{
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">\&#34;policy_id\&#34;:\&#34;</span>$SOC_POLICY_ID<span style="color:#e6db74">\&#34;
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">}&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>| jq -r <span style="color:#e6db74">&#39;.item.api_key&#39;</span><span style="color:#66d9ef">)</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;[*] Enrollment token for windows: </span>$ENROLL_TOKEN<span style="color:#e6db74">&#34;</span> 
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;Enrollment token for windows: </span>$ENROLL_TOKEN<span style="color:#e6db74">&#34;</span> &gt;&gt; <span style="color:#e6db74">${</span>SHARED_DIR<span style="color:#e6db74">}</span>/elastic_config.txt
</span></span></code></pre></div><h2 id="stage-3-detection-rules">Stage 3: Detection Rules</h2>
<p>Having logs into the system is only a part of the equation, intelligence is dervied only once the logs are parsed against the detection rules to identify said indicators of compromise (IOCs) i.e. steps taken by a potentially malicious actor on the system being monitored.</p>
<p>The script installs the pre-packaged detection rules (~1500 at the time of writing this blog) and enables them in batches as the API allows to enable at-most 100 rules in one go.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">############################################</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># INSTALL &amp; ENABLE DETECTION RULES</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">############################################</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;[*] Validating detction engine index...&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>curl -s -k -u <span style="color:#e6db74">&#34;elastic:</span>$ELASTIC_PASSWORD<span style="color:#e6db74">&#34;</span> -X POST <span style="color:#e6db74">&#34;http://localhost:5601/api/detection_engine/index&#34;</span> -H <span style="color:#e6db74">&#34;kbn-xsrf: true&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;[*] Installing pre-packaged detection rules...&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>curl -s -u <span style="color:#e6db74">&#34;elastic:</span>$ELASTIC_PASSWORD<span style="color:#e6db74">&#34;</span>   -X PUT <span style="color:#e6db74">&#34;http://localhost:5601/api/detection_engine/rules/prepackaged&#34;</span>   -H <span style="color:#e6db74">&#34;kbn-xsrf: true&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;[*] Fetching rule IDs...&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>curl -s -u <span style="color:#e6db74">&#34;elastic:</span>$ELASTIC_PASSWORD<span style="color:#e6db74">&#34;</span> <span style="color:#e6db74">&#34;http://localhost:5601/api/detection_engine/rules/_find?per_page=10000&#34;</span> -H <span style="color:#e6db74">&#34;kbn-xsrf: true&#34;</span> | jq -r <span style="color:#e6db74">&#39;.data[].id&#39;</span> &gt; /tmp/rule_ids.txt
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;[*] Enabling rules in batches...&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>split -l <span style="color:#ae81ff">100</span> /tmp/rule_ids.txt /tmp/rules_batch_
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">for</span> file in /tmp/rules_batch_*; <span style="color:#66d9ef">do</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  IDS<span style="color:#f92672">=</span><span style="color:#66d9ef">$(</span>jq -R . <span style="color:#e6db74">&#34;</span>$file<span style="color:#e6db74">&#34;</span> | jq -s .<span style="color:#66d9ef">)</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  curl -s -u <span style="color:#e6db74">&#34;elastic:</span>$ELASTIC_PASSWORD<span style="color:#e6db74">&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>    -X POST <span style="color:#e6db74">&#34;http://localhost:5601/s/default/api/detection_engine/rules/_bulk_action&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>    -H <span style="color:#e6db74">&#34;kbn-xsrf: true&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>    -H <span style="color:#e6db74">&#34;Content-Type: application/json&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>    -d <span style="color:#e6db74">&#34;{\&#34;action\&#34;:\&#34;enable\&#34;,\&#34;ids\&#34;:</span>$IDS<span style="color:#e6db74">}&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  echo <span style="color:#e6db74">&#34;[+] Enabled batch: </span>$file<span style="color:#e6db74">&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  sleep <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">done</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;[+] Detection rules installed and enabled&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>curl -s -u <span style="color:#e6db74">&#34;elastic:</span>$ELASTIC_PASSWORD<span style="color:#e6db74">&#34;</span> <span style="color:#e6db74">&#34;http://localhost:5601/api/detection_engine/rules/_find?filter=alert.attributes.enabled:true&amp;per_page=1&#34;</span> -H <span style="color:#e6db74">&#34;kbn-xsrf: true&#34;</span> | jq <span style="color:#e6db74">&#39;.total&#39;</span>
</span></span></code></pre></div><p>After configuration completes succesfully, the installed and enabled detection rules are visible in the dashboard as follows:</p>
<p><img src="./installed-and-enabled-siem-rules.png" alt="installed-and-enabled-siem-rules"></p>
<h2 id="stage-4-summary-of-the-soc-siem-lab">Stage 4: Summary of the SOC-SIEM lab</h2>
<p>Once the above mentioned steps successfully conclude, the script displays the dashboard URL along with the credentials to access it. Meanwhile, other secret tokens are written into the <code>elastic_config.txt</code> file as mentioned above.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="color:#75715e">############################################</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># SUMMARIZE</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">############################################</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;&#34;</span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;[+] SOC LAB READY&#34;</span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;&#34;</span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;Kibana:&#34;</span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;http://</span><span style="color:#e6db74">${</span>IP_ADDR<span style="color:#e6db74">}</span><span style="color:#e6db74">:5601&#34;</span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;&#34;</span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;username: elastic&#34;</span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;password: </span><span style="color:#e6db74">${</span>ELASTIC_PASSWORD<span style="color:#e6db74">}</span><span style="color:#e6db74">&#34;</span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;&#34;</span>
</span></span></code></pre></div><h2 id="stage-5-the-windows-endpoint">Stage 5: The Windows Endpoint</h2>
<p>Once the SOC-SIEM VM is up and running, the next natural step is to setup the endpoint VM to be monitored. The Vagrantfile description for the same is:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-Vagrantfile" data-lang="Vagrantfile"><span style="display:flex;"><span>  <span style="color:#75715e">########################################</span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e"># WINDOWS ENDPOINT VM (Windows 11)</span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e">########################################</span>
</span></span><span style="display:flex;"><span>  config<span style="color:#f92672">.</span>vm<span style="color:#f92672">.</span>define <span style="color:#e6db74">&#34;win11&#34;</span> <span style="color:#66d9ef">do</span> <span style="color:#f92672">|</span>win<span style="color:#f92672">|</span>
</span></span><span style="display:flex;"><span>    win<span style="color:#f92672">.</span>vm<span style="color:#f92672">.</span>box <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;gusztavvargadr/windows-11&#34;</span>
</span></span><span style="display:flex;"><span>    win<span style="color:#f92672">.</span>vm<span style="color:#f92672">.</span>hostname <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;win11-endpoint&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    win<span style="color:#f92672">.</span>vm<span style="color:#f92672">.</span>network <span style="color:#e6db74">&#34;private_network&#34;</span>, <span style="color:#e6db74">ip</span>: <span style="color:#e6db74">&#34;192.168.56.30&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#75715e"># WinRM Configuration</span>
</span></span><span style="display:flex;"><span>    win<span style="color:#f92672">.</span>vm<span style="color:#f92672">.</span>communicator <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;winrm&#34;</span>
</span></span><span style="display:flex;"><span>    win<span style="color:#f92672">.</span>vm<span style="color:#f92672">.</span>boot_timeout <span style="color:#f92672">=</span> <span style="color:#ae81ff">1200</span>
</span></span><span style="display:flex;"><span>    win<span style="color:#f92672">.</span>winrm<span style="color:#f92672">.</span>transport <span style="color:#f92672">=</span> <span style="color:#e6db74">:plaintext</span>
</span></span><span style="display:flex;"><span>    win<span style="color:#f92672">.</span>winrm<span style="color:#f92672">.</span>basic_auth_only <span style="color:#f92672">=</span> <span style="color:#66d9ef">true</span>
</span></span><span style="display:flex;"><span>    win<span style="color:#f92672">.</span>winrm<span style="color:#f92672">.</span>timeout <span style="color:#f92672">=</span> <span style="color:#ae81ff">1800</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#75715e"># Provisioning</span>
</span></span><span style="display:flex;"><span>    win<span style="color:#f92672">.</span>vm<span style="color:#f92672">.</span>provision <span style="color:#e6db74">&#34;shell&#34;</span> <span style="color:#66d9ef">do</span> <span style="color:#f92672">|</span>s<span style="color:#f92672">|</span>
</span></span><span style="display:flex;"><span>      s<span style="color:#f92672">.</span>path <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;provision/agent.ps1&#34;</span>
</span></span><span style="display:flex;"><span>      s<span style="color:#f92672">.</span>privileged <span style="color:#f92672">=</span> <span style="color:#66d9ef">true</span>
</span></span><span style="display:flex;"><span>      <span style="color:#75715e"># Ensures the script runs in a session that can interact with the desktop if needed</span>
</span></span><span style="display:flex;"><span>      s<span style="color:#f92672">.</span>powershell_elevated_interactive <span style="color:#f92672">=</span> <span style="color:#66d9ef">true</span> 
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">end</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    win<span style="color:#f92672">.</span>vm<span style="color:#f92672">.</span>provider <span style="color:#e6db74">&#34;virtualbox&#34;</span> <span style="color:#66d9ef">do</span> <span style="color:#f92672">|</span>vb<span style="color:#f92672">|</span>
</span></span><span style="display:flex;"><span>      vb<span style="color:#f92672">.</span>name <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;win11-endpoint-lab&#34;</span>
</span></span><span style="display:flex;"><span>      vb<span style="color:#f92672">.</span>memory <span style="color:#f92672">=</span> <span style="color:#ae81ff">8192</span>  <span style="color:#75715e"># 8GB RAM</span>
</span></span><span style="display:flex;"><span>      vb<span style="color:#f92672">.</span>cpus <span style="color:#f92672">=</span> <span style="color:#ae81ff">4</span>       <span style="color:#75715e"># 4 CPU cores</span>
</span></span><span style="display:flex;"><span>      
</span></span><span style="display:flex;"><span>      vb<span style="color:#f92672">.</span>linked_clone <span style="color:#f92672">=</span> <span style="color:#66d9ef">true</span>
</span></span><span style="display:flex;"><span>      vb<span style="color:#f92672">.</span>customize <span style="color:#f92672">[</span><span style="color:#e6db74">&#34;modifyvm&#34;</span>, <span style="color:#e6db74">:id</span>, <span style="color:#e6db74">&#34;--vram&#34;</span>, <span style="color:#e6db74">&#34;128&#34;</span><span style="color:#f92672">]</span>                   <span style="color:#75715e"># for Video Memory</span>
</span></span><span style="display:flex;"><span>      vb<span style="color:#f92672">.</span>customize <span style="color:#f92672">[</span><span style="color:#e6db74">&#34;modifyvm&#34;</span>, <span style="color:#e6db74">:id</span>, <span style="color:#e6db74">&#34;--graphicscontroller&#34;</span>, <span style="color:#e6db74">&#34;vmsvga&#34;</span><span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>      vb<span style="color:#f92672">.</span>customize <span style="color:#f92672">[</span><span style="color:#e6db74">&#34;modifyvm&#34;</span>, <span style="color:#e6db74">:id</span>, <span style="color:#e6db74">&#34;--nested-hw-virt&#34;</span>, <span style="color:#e6db74">&#34;on&#34;</span><span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">end</span>
</span></span><span style="display:flex;"><span>  <span style="color:#66d9ef">end</span>
</span></span></code></pre></div><p>As observed from the definitions above, I used <code>gusztavvargadr/windows-11</code> as my base Windows 11 image and configured a static IPv4 address of <code>192.168.56.30</code> for the box. Configuring the communication medium to be <code>winrm</code>, I specified the provisioning script path (i.e. <code>provision/agent.ps1</code>). Next, I configured the VM settings for resources and customized the VRAM and graphics controller value (as I often need to do when I manually setup a Microsoft Windows VM). The <code>linked_clone</code> and nested virtualization features were enabled for requirements mentioned before.</p>
<h2 id="stage-6-endpoint-provisioning-script">Stage 6: Endpoint Provisioning Script</h2>
<p>Same as the bash script for SOC-SIEM VM, this script starts with configuring to terminate on encountering error. Next, it bypasses the execution policy for current process (i.e. the process running the provisioning powershell commands over winrm session). Next it, validates that the <code>elastic_config.txt</code> file exists in the shared folder (which is created when SOC lab is provisioned) as this file contains the secrets required for agent enrollment.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-ps1" data-lang="ps1"><span style="display:flex;"><span>$ErrorActionPreference = <span style="color:#e6db74">&#34;Stop&#34;</span>
</span></span><span style="display:flex;"><span>Set-ExecutionPolicy Bypass -Scope <span style="color:#66d9ef">Process</span> -Force
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">############################################################</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># CONFIG FILE LOCATION (shared from SOC Vagrant VM)</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">############################################################</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>$CONFIG_FILE = <span style="color:#e6db74">&#34;C:\vagrant\elastic_config.txt&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">if</span> (!(Test-Path $CONFIG_FILE)) {
</span></span><span style="display:flex;"><span>    Write-Host <span style="color:#e6db74">&#34;[-] elastic_config.txt not found&#34;</span>
</span></span><span style="display:flex;"><span>    exit <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>Once validated, it parses the <code>elastic_config.txt</code> file for required values. Next, it ensures that the fleet server is reachable.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-ps1" data-lang="ps1"><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">############################################################</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># PARSE CONFIG VALUES</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">############################################################</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>$content = Get-Content $CONFIG_FILE
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>$ELASTIC_PASSWORD = ($content | Select-String <span style="color:#e6db74">&#34;elastic password&#34;</span>).ToString().Split(<span style="color:#e6db74">&#34;:&#34;</span>)[<span style="color:#ae81ff">1</span>].Trim()
</span></span><span style="display:flex;"><span>$ELASTIC_VERSION  = ($content | Select-String <span style="color:#e6db74">&#34;Elasticsearch version&#34;</span>).ToString().Split(<span style="color:#e6db74">&#34;:&#34;</span>)[<span style="color:#ae81ff">1</span>].Trim()
</span></span><span style="display:flex;"><span>$ENROLL_TOKEN     = ($content | Select-String <span style="color:#e6db74">&#34;Enrollment token for windows&#34;</span>).ToString().Split(<span style="color:#e6db74">&#34;:&#34;</span>)[<span style="color:#ae81ff">1</span>].Trim()
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>$SIEM_IP = <span style="color:#e6db74">&#34;192.168.56.20&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Write-Host <span style="color:#e6db74">&#34;[+] Detected Elastic version: </span>$ELASTIC_VERSION<span style="color:#e6db74">&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">############################################################</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># WAIT FOR FLEET SERVER</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">############################################################</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Write-Host <span style="color:#e6db74">&#34;[*] Waiting for Fleet Server...&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">while</span> (!(Test-NetConnection -ComputerName $SIEM_IP -Port <span style="color:#ae81ff">8220</span> -InformationLevel Quiet)) {
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    Write-Host <span style="color:#e6db74">&#34;    Fleet not ready yet...&#34;</span>
</span></span><span style="display:flex;"><span>    Start-Sleep <span style="color:#ae81ff">5</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>}
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Write-Host <span style="color:#e6db74">&#34;[+] Fleet reachable&#34;</span>
</span></span></code></pre></div><h2 id="stage-7-enabling-log-sources">Stage 7: Enabling Log sources</h2>
<p>The windows telemetry integration attached in &lsquo;SOC-Lab-Policy&rsquo; monitores for logs from inbuilt windows log sources. While the agent may activate the  data streams enabled in the integration, the script goes on to enable them nevertheless beforehand (This allowed me a learning opportunity into how these options appeared within the Windows OS).</p>
<p>Next, it installs <a href="https://learn.microsoft.com/en-us/sysinternals/downloads/sysmon"><code>Sysmon</code></a> with <a href="https://github.com/olafhartong/sysmon-modular"><em>Olaf Hartong&rsquo;s configuration script</em></a>.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-ps1" data-lang="ps1"><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">############################################################</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># ENABLE WINDOWS AUDITING</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">############################################################</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Write-Host <span style="color:#e6db74">&#34;[*] Enabling Windows audit logging...&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>auditpol /set /category<span style="color:#960050;background-color:#1e0010">:</span>* /success<span style="color:#960050;background-color:#1e0010">:</span>enable /failure<span style="color:#960050;background-color:#1e0010">:</span>enable
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>reg add HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System\Audit `
</span></span><span style="display:flex;"><span> /v ProcessCreationIncludeCmdLine_Enabled `
</span></span><span style="display:flex;"><span> /t REG_DWORD /d <span style="color:#ae81ff">1</span> /f
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">############################################################</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># ENABLE POWERSHELL LOGGING</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">############################################################</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Write-Host <span style="color:#e6db74">&#34;[*] Enabling PowerShell logging...&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>reg add HKLM\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging `
</span></span><span style="display:flex;"><span> /v EnableScriptBlockLogging /t REG_DWORD /d <span style="color:#ae81ff">1</span> /f
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>reg add HKLM\Software\Policies\Microsoft\Windows\PowerShell\ModuleLogging `
</span></span><span style="display:flex;"><span> /v EnableModuleLogging /t REG_DWORD /d <span style="color:#ae81ff">1</span> /f
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>reg add HKLM\Software\Policies\Microsoft\Windows\PowerShell\ModuleLogging\ModuleNames `
</span></span><span style="display:flex;"><span> /v <span style="color:#e6db74">&#34;*&#34;</span> /t REG_SZ /d <span style="color:#e6db74">&#34;*&#34;</span> /f
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">############################################################</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># INSTALL SYSMON</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">############################################################</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Write-Host <span style="color:#e6db74">&#34;[*] Installing Sysmon...&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Set-Location C:\Windows\Temp
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Invoke-WebRequest `
</span></span><span style="display:flex;"><span> https<span style="color:#960050;background-color:#1e0010">:</span>//download.sysinternals.com/files/Sysmon.zip `
</span></span><span style="display:flex;"><span> -OutFile Sysmon.zip
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Expand-Archive Sysmon.zip -Force
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Set-Location C:\Windows\Temp\Sysmon\
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Invoke-WebRequest `
</span></span><span style="display:flex;"><span> https<span style="color:#960050;background-color:#1e0010">:</span>//raw.githubusercontent.com/olafhartong/sysmon-modular/refs/heads/master/sysmonconfig.xml `
</span></span><span style="display:flex;"><span> -OutFile sysmonconfig.xml
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>.\Sysmon64.exe -accepteula -i sysmonconfig.xml
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">if</span> (!(Get-Service Sysmon64 -ErrorAction SilentlyContinue)) {
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    Write-Host <span style="color:#e6db74">&#34;[-] Sysmon install failed&#34;</span>
</span></span><span style="display:flex;"><span>    exit <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>}
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Write-Host <span style="color:#e6db74">&#34;[+] Sysmon installed&#34;</span>
</span></span></code></pre></div><h2 id="stage-8-installing-the-agent">Stage 8: Installing the Agent</h2>
<p>Finally, the provisioning script fetches the elastic agent compatible with the version of elasticserach installed onto the SOC-SIEM lab and enrolls it into the fleet configured as per steps mentioned before.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-ps1" data-lang="ps1"><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">############################################################</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># DOWNLOAD ELASTIC AGENT MATCHING SIEM VERSION</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">############################################################</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Write-Host <span style="color:#e6db74">&#34;[*] Downloading Elastic Agent </span>$ELASTIC_VERSION<span style="color:#e6db74">...&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Set-Location C:\Windows\Temp
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>$agentZip = <span style="color:#e6db74">&#34;elastic-agent-</span>$ELASTIC_VERSION<span style="color:#e6db74">-windows-x86_64.zip&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Invoke-WebRequest `
</span></span><span style="display:flex;"><span> https<span style="color:#960050;background-color:#1e0010">:</span>//artifacts.elastic.co/downloads/beats/elastic-agent/$agentZip `
</span></span><span style="display:flex;"><span> -OutFile $agentZip
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Expand-Archive $agentZip -Force
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Set-Location <span style="color:#e6db74">&#34;elastic-agent-</span>$ELASTIC_VERSION<span style="color:#e6db74">-windows-x86_64\elastic-agent-</span>$ELASTIC_VERSION<span style="color:#e6db74">-windows-x86_64&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">############################################################</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># INSTALL AND ENROLL AGENT</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">############################################################</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Write-Host <span style="color:#e6db74">&#34;[*] Installing Elastic Agent...&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>.\elastic-agent.exe install  --url=https<span style="color:#960050;background-color:#1e0010">:</span>//${SIEM_IP}<span style="color:#960050;background-color:#1e0010">:</span><span style="color:#ae81ff">8220</span> --enrollment-token=$ENROLL_TOKEN --insecure --force
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">############################################################</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Write-Host <span style="color:#e6db74">&#34;[+] Endpoint successfully enrolled into SOC&#34;</span>
</span></span></code></pre></div><p>Once the configuration completes, one may observe that the Windows Security suggests that Virus and Threat Protection is now managed by Elastic Security.</p>
<p><img src="./windows-security.png" alt="windows-security"></p>
<h2 id="testing-the-setup">Testing the Setup</h2>
<p>To test the detection capabilities, I ran the following command from elevated PowerShell window in the monitored Windows 11 VM.</p>
<p><img src="./windows-endpoint-save-sam.png" alt="windows-endpoint-save-sam"></p>
<p>This created the following alert in the dashboard.</p>
<p><img src="./reg-save-alert.png" alt="reg-save-alert"></p>
<p><img src="./reg-save-alert-2.png" alt="reg-save-alert-2"></p>
]]></description>
      
    </item>
    
    
    
    <item>
      <title>AD Homelab 101: Building an Active Directory &#43; XDR homelab in 101 steps</title>
      <link>https://ashtrace.github.io/posts/building_homelab/</link>
      <pubDate>Fri, 23 May 2025 13:40:31 +0530</pubDate>
      
      <guid>https://ashtrace.github.io/posts/building_homelab/</guid>
      <description><![CDATA[<p>Fresh off my CRTO exam I itched for a local AD lab to practice red-team stuff. GOAD with the ELK/Wazuh extension is (at the time of writing) the best choice (author’s personal views) for this but I seriously lacked a gigaton of RAM required for 5 (lab) + 1 (extension) VMs, so I went Thanos mode and declared - Fine! I’ll do it myself.</p>
<blockquote>
<p>PS: I’ve tried GOAD (v2) without the ELK/Wazuh stack. It’s a stellar lab that hits a lot of awesome topics. If you haven’t touched it yet, crawl out from under that rock and go check it out.</p>
</blockquote>
<h2 id="my-host-device-specifications">My host device specifications</h2>
<p>The machine I used to built this lab has</p>
<ul>
<li>An AMD Ryzen 5500U processor - 6 Physical (12 Logical) cores</li>
<li>32 gigs of RAM (which might’ve been huge for ancient times, but since the dawn of LLMs I feel smol and scared.)</li>
</ul>
<h2 id="domain-controller">Domain Controller</h2>
<h3 id="fetch-windows-server-image">Fetch Windows Server Image</h3>
<p>Download the Windows Server 2022 VHD file from <a href="https://www.microsoft.com/en-us/evalcenter/download-windows-server-2022">here</a>. Create a copy of the downloaded file.</p>
<h3 id="setup-a-vm">Setup a VM</h3>
<p>I used VirtualBox to create a new VM named LAB-DC and imported the downloaded VHD file. I provided the lab with Virtualbox Host-Only network connection, which can be created leveraging the <code>Tools &gt; Network</code> window.</p>
<p><img src="./virtualbox-network.png" alt="virtualbox-network"></p>
<p>Boot up the VM and follow the installation steps:</p>
<ol>
<li>Select the Locale settings.</li>
</ol>
<p><img src="./locale.png" alt="locale"></p>
<ol start="2">
<li>
<p>Accept the License agreement.</p>
</li>
<li>
<p>Create a password for the administrator account. I used <code>lab@1234$</code>.</p>
</li>
</ol>
<p><img src="./administrator-password.png" alt="administrator-password"></p>
<ol start="4">
<li>Click on Finish.</li>
</ol>
<h3 id="configure-vm-addons">Configure VM addons</h3>
<ol start="5">
<li>
<p>Log-in as administrator.</p>
</li>
<li>
<p>From the toolbar, select add &lsquo;Virtualbox Guest-Addons&rsquo;. Install it to improve the VMs execution.</p>
</li>
</ol>
<p><img src="./vbox-guest-addons-1.png" alt="vbox-guest-addons-1"></p>
<p><img src="./vbox-guest-addons-2.png" alt="vbox-guest-addons-2"></p>
<p>Follow along after the server VM restarts.</p>
<h3 id="set-the-server-hostname">Set the server hostname</h3>
<ol start="7">
<li>In the server manager application window, navigate to <code>Local Server</code> from the left pane. Click on <code>Computer Name</code> under <code>Properties</code>. Further, click on the <code>Change</code> button to change server name.</li>
</ol>
<p><img src="./server-name-1.png" alt="server-name-1"></p>
<p><img src="./server-name-2.png" alt="server-name-2"></p>
<p>Click on <code>OK</code> and restart the VM.</p>
<h3 id="configure-the-static-ip-address">Configure the static IP address</h3>
<ol start="8">
<li>Hit <code>Win+R</code> and run <code>ncpa.cpl</code> to open Network Connections under Control Panel. View the property of the ethernet interface.</li>
</ol>
<p><img src="./static-ip-ethernet-properties.png" alt="static-ip-ethernet-properties"></p>
<ol start="9">
<li>Click on <code>Internet Protocol Version 4 (TCP/IPv4)</code> and select its properties. Set the preferred IP Address and set the gateway to Host&rsquo;s IP Address. Set the preferred DNS same as the IP Address of the server. Finally, click on <code>OK</code>.</li>
</ol>
<p><img src="./static-ip-ipv4-properties.png" alt="static-ip-ipv4-properties"></p>
<h2 id="install-active-directory-domain-services">Install Active Directory Domain Services</h2>
<ol start="10">
<li>Launch <code>Server Manager</code>. Navigate to <code>Manage &gt; Add Roles and Features</code>. Continue with default installation.</li>
</ol>
<p><img src="./server-manager-manage-add-roles-and-features.png" alt="server-manager-manage-add-roles-and-features"></p>
<p><img src="./add-roles-and-featuers-begin.png" alt="add-roles-and-featuers-begin"></p>
<ol start="11">
<li>Continue Clicking on next until <code>Select Server roles</code>. Select <code>Active Directory Domain Services</code> and click on <code>Add Features</code> in the window that pops-up.</li>
</ol>
<p><img src="./add-roles-and-featuers-select-server-roles.png" alt="add-roles-and-featuers-select-server-roles"></p>
<p>Ensuring that <code>Active Directory Doman Services</code> is selected, click on <code>Next</code>.</p>
<ol start="12">
<li>
<p>Go forward with default selection in <code>Features</code> and <code>AD DS</code> tab by clicking on <code>Next</code>.</p>
</li>
<li>
<p>On the <code>Confirmation</code> tab, select the <code>Restart the destination server automatically if required</code> if required and click on <code>Install</code>.</p>
</li>
</ol>
<p><img src="./add-roles-and-features-confirmation.png" alt="add-roles-and-features-confirmation"></p>
<ol start="14">
<li>Once greeted with following screen, click on the flag icon.</li>
</ol>
<p><img src="./add-roles-and-features-install-completed.png" alt="add-roles-and-features-install-completed"></p>
<p>Under Post-deployment configuration section, click on <code>Promote this server to a domain controller</code>.\</p>
<p><img src="./post-deployment-configuration-section.png" alt="post-deployment-configuration-section"></p>
<ol start="15">
<li>Create a new forest and set the appropriate name.</li>
</ol>
<p><img src="./post-deployment-create-forest.png" alt="post-deployment-create-forest"></p>
<p>Click on next.</p>
<ol start="16">
<li>Let the forest functional level and domain functional level be at default of <code>Windows Server 2016</code>.</li>
</ol>
<p><img src="./post-deployment-functional-level.png" alt="post-deployment-functional-level"></p>
<ol start="17">
<li>Keep the default roles for the DC. Set the DSRM password. I used <code>labdsrm@1234$</code></li>
</ol>
<p><img src="./post-deployment-dsrm.png" alt="post-deployment-dsrm"></p>
<ol start="18">
<li>In the <code>DNS Options</code> menu, just click <code>Next</code>.</li>
</ol>
<p><img src="./post-deployment-dns.png" alt="post-deployment-dns"></p>
<ol start="19">
<li>
<p>Follow through and click <code>Next</code> on verify the NetBIOS domain name.</p>
</li>
<li>
<p>Under the <code>Paths</code> configuration window go with default settings if no changes are needed.</p>
</li>
</ol>
<p><img src="./post-deployment-paths.png" alt="post-deployment-paths"></p>
<ol start="21">
<li>
<p>Click on <code>Next</code> under <code>Review Options</code> window.</p>
</li>
<li>
<p>After <code>Prerequisite Checks</code> pass, click on <code>Install</code> to continue.</p>
</li>
</ol>
<p><img src="./post-deployment-prerequisite-checks.png" alt="post-deployment-prerequisite-checks"></p>
<ol start="23">
<li>Let the server restart.</li>
</ol>
<p><img src="./post-deployment-installation-complete.png" alt="post-deployment-installation-complete"></p>
<ol start="24">
<li>Once the server restarts, log in as <code>&lt;DOMAIN&gt;\Administrator</code> using the password of administrator we setup above while installing the VM (here: <code>lab@1234$</code>).</li>
</ol>
<h2 id="creating-domain-objects">Creating Domain Objects</h2>
<h3 id="creating-organizational-units-ous">Creating Organizational Units (OUs)</h3>
<blockquote>
<p><strong>NOTE:</strong> One may skip this and directly add users.</p>
</blockquote>
<ol start="25">
<li>Launch Server Manager and navigate to <code>Tools &gt; Active Directory Users and Computers</code></li>
</ol>
<p><img src="./ad-users-and-computers.png" alt="ad-users-and-computers"></p>
<ol start="26">
<li>Right-click on the <code>&lt;DOMAIN NAME&gt;</code> (here and hereafter <code>LAB.LOCAL</code> for us), select <code>New</code> and click on <code>Organizational Unit</code>.</li>
</ol>
<p><img src="./ad-new-ou.png" alt="ad-new-ou"></p>
<p>In the dialog bog, provide with an OU name of your choice and click on <code>OK</code>.</p>
<p><img src="./ad-new-ou-lab-ou.png" alt="ad-new-ou-lab-ou"></p>
<p>We can create nested OUs by:</p>
<ul>
<li>Right-click on the OU of choice, navigate to <code>New &gt; Organizational Unit</code> and follow the process as above.</li>
</ul>
<p>I created two more OUs under our <code>LAB-OU</code> namely, <code>Users</code> and <code>Computers</code>, within <code>Users</code> I further created two OUs - <code>Administrators</code> and <code>Researchers</code>. (It made for a good practice)</p>
<p><img src="./nested-ous.png" alt="nested-ous"></p>
<h3 id="creating-a-user">Creating a User</h3>
<ol start="27">
<li>
<p>Right-click the <code>Administrators</code> OU under <code>LAB-OU &gt; Users</code>, navigate to <code>New &gt; User</code>.</p>
</li>
<li>
<p>Fill in the name details. Click on <code>Next</code>.</p>
</li>
</ol>
<p><img src="./add-user-name.png" alt="add-user-name"></p>
<ol start="29">
<li>Set the password details and select any other configuration required (here: <code>admin@1234</code>). Click on <code>Next</code>.</li>
</ol>
<p><img src="./add-user-passwd.png" alt="add-user-passwd"></p>
<ol start="30">
<li>Click on <code>Finish</code>.</li>
</ol>
<blockquote>
<p>Practise by creating multiple users.</p>
</blockquote>
<h3 id="promoting-a-user-to-domain-administrator">Promoting a user to Domain Administrator</h3>
<ol start="31">
<li>Right-click on the newly created user and navigate to <code>Properties</code>.</li>
</ol>
<p><img src="./user-properties.png" alt="user-properties"></p>
<ol start="32">
<li>Navigate to <code>Member Of</code> Tab. The screen should display the groups this particular user is part of.
Click on <code>Add...</code>.</li>
</ol>
<p><img src="./user-member-of.png" alt="user-member-of"></p>
<ol start="33">
<li>In the <code>Select Groups</code> window, within the form-field labeled <strong>Enter the object names to select (examples)</strong>, enter <code>domain</code> and Click on <code>OK</code>.</li>
</ol>
<p><img src="./select-da-group-1.png" alt="select-da-group-1"></p>
<p>A dialog box with all group names starting with <code>Domain</code> should appear, select the <code>Domain Admins</code> group and click on <code>OK</code>.</p>
<p><img src="./select-da-group-2.png" alt="select-da-group-2"></p>
<p>Click on <code>Apply</code>, then click on <code>OK</code>.</p>
<h3 id="creating-a-group">Creating a Group</h3>
<ol start="34">
<li>Navigate to the OU of your choice, right-click and select <code>New &gt; Group</code>. Add details and click on <code>OK</code>.</li>
</ol>
<p><img src="./add-group.png" alt="add-group"></p>
<h3 id="add-group-members">Add Group Members</h3>
<ol start="35">
<li>Right-click on the newly created group and select <code>Properties</code>. Open the <code>Members</code> Tab, click on <code>Add...</code>.</li>
</ol>
<p><img src="./group-members-1.png" alt="group-members-1"></p>
<ol start="36">
<li>A <code>Select Users, Contacts, Computers, Service Accounts, or Groups</code> window opens up. Within the form field under <strong>Enter the objct names to select (examples)</strong> enter the name of target user (click on <code>Check Names</code> to correct the format). Finally, click on <code>OK</code>.</li>
</ol>
<p><img src="./group-members-add-user.png" alt="group-members-add-user"></p>
<p>Click on <code>Apply</code> and then click on <code>OK</code>.</p>
<blockquote>
<p>Group membership of user can be verified by navigating to user&rsquo;s <code>Properties &gt; Member Of</code>.</p>
</blockquote>
<h2 id="creating-a-file-share">Creating a File Share</h2>
<ol start="37">
<li>Create a new folder (here <code>test-share</code>).</li>
</ol>
<p><img src="./new-folder-test-share.png" alt="new-folder-test-share"></p>
<ol start="38">
<li>Navigate to <code>Properties &gt; Sharing</code> from the context-menu of the folder. Click on <code>Advanced Sharing</code>.</li>
</ol>
<p><img src="./test-share-sharing-tab.png" alt="test-share-sharing-tab"></p>
<ol start="39">
<li>Enable <code>Share this folder</code>. Configure <code>Share name</code> if needed, click on <code>Apply</code> and click on <code>OK</code>.</li>
</ol>
<p><img src="./test-share-advanced-sharing.png" alt="test-share-advanced-sharing"></p>
<ol start="40">
<li>Visit the DC and the file-share would be visible.</li>
</ol>
<p><img src="./run-lab-dc.png" alt="run-lab-dc"></p>
<p><img src="./lab-dc-files-shares.png" alt="lab-dc-files-shares"></p>
<h3 id="configure-file-share-permissions">Configure file-share permissions</h3>
<ol start="41">
<li>Navigate to <code>Properties &gt; Security</code> Tab from context-menu of the folder/file share.</li>
</ol>
<p><img src="./test-share-security-tab.png" alt="test-share-security-tab"></p>
<ol start="42">
<li>Click on <code>Edit</code>. Next, click on <code>Add...</code></li>
</ol>
<p><img src="./permissions-for-test-share.png" alt="permissions-for-test-share"></p>
<ol start="43">
<li>In the <code>Select Users, Computers, Service Accounts, Grups</code> window, search and select the entities. Click on <code>OK</code>.</li>
</ol>
<p><img src="./test-share-select-user.png" alt="test-share-select-user"></p>
<ol start="44">
<li>Change the Permissions for the entity from the <code>Allow</code>/<code>Deny</code> list. Finally, Click on <code>Apply</code> and <code>OK</code> respectively.</li>
</ol>
<p><img src="./test-share-user-permissions.png" alt="test-share-user-permissions"></p>
<h2 id="adding-a-computer-to-the-ad-domain">Adding a computer to the AD Domain</h2>
<p>A long time ago in a galaxy far, far away Microsoft offered Windows VM images to test Internet-Explorer. The files have since been archived across internet. One may grab the version that suits them <a href="https://archive.org/download/modern.ie-vm">here</a> all other places of their choice. I am using virtualbox, so it would be a virtualbox image in my case.</p>
<ol start="45">
<li>Download the archive, extract it and import the (here <code>.ova</code>) file in virtualbox (<code>Ctrl+I</code> for importing an image).</li>
</ol>
<p><img src="./ova-file.png" alt="ova-file"></p>
<p><img src="./ova-import.png" alt="ova-import"></p>
<blockquote>
<p>Configure the network adapter of new machine to connect to Virtualbox host-only adapter (same as the DC).</p>
</blockquote>
<ol start="46">
<li>Log into the VM (<code>IEUser:Passw0rd!</code>). Run (<code>Win+R</code>) <code>ncpa.cpl</code> to enter <code>Network Connections</code> window in <code>Control Panel &gt; Network and Interent</code>. Configure the DNS server to DC IP for the Ethernet interface by navigating through <code>Properties</code> (as above).</li>
</ol>
<p>Although the Virtualbox host-only adapter would provide this VM with a range in same subnet as DC through DHCP, I will configure a static IP for this machine (for identification purposes in my later projects).</p>
<p><img src="./machine-network.png" alt="machine-network"></p>
<ol start="47">
<li>Launch <code>Settings</code> and go to <code>Accounts &gt; Access work or school</code>. Click on <code>Connect</code>.</li>
</ol>
<p><img src="./settings-add-account.png" alt="settings-add-account"></p>
<ol start="48">
<li>Click on <code>Join this device to a local Active Directory domain</code>.</li>
</ol>
<p><img src="./join-to-local-ad.png" alt="join-to-local-ad"></p>
<ol start="49">
<li>Enter the domain name in the <code>Join a domain</code> window. Click on <code>Next</code>.</li>
</ol>
<p><img src="./join-a-domain.png" alt="join-a-domain"></p>
<ol start="50">
<li>Enter the username and password of a Domain Administrator account to authenticate.</li>
</ol>
<p><img src="./login-in-ad.png" alt="login-in-ad"></p>
<ol start="51">
<li>Click on <code>Skip</code>.</li>
</ol>
<p><img src="./skip-rest.png" alt="skip-rest"></p>
<p>Restart the VM.</p>
<ol start="52">
<li>Login using one of the user accounts created earlier.</li>
</ol>
<p><img src="./user-login-ad.png" alt="user-login-ad"></p>
<ol start="53">
<li>Go to <code>Control Panel &gt; Network and Interent &gt; Network and Sharing Center</code> to validate you are connected to the domain.</li>
</ol>
<p><img src="./network-and-sharing-center.png" alt="network-and-sharing-center"></p>
<p>The reachability can be established from the command-prompt as follows:</p>
<p><img src="./cmd-domain-reachability.png" alt="cmd-domain-reachability"></p>
<blockquote>
<p>The computer would be visible in the <code>Computers</code> Section under the <code>Active Directory Users and Computers</code>. It can be <em>dragged-and-dropped</em> to any OU we created.</p>
</blockquote>
<p><img src="./domain-joined-computer.png" alt="domain-joined-computer"></p>
<h2 id="create-a-group-policy">Create a Group Policy</h2>
<ol start="54">
<li>Back on the DC machine, launch the <code>Server Manager</code> and go to <code>Tools &gt; Group Policy Management</code>.</li>
</ol>
<p><img src="./group-policy-management.png" alt="group-policy-management"></p>
<p>One can navigate through different Organizational Units (OUs), and select the one required.</p>
<p><img src="./gpm-ous.png" alt="gpm-ous"></p>
<h3 id="group-policy-to-create-a-local-administrator-account">Group policy to create a local administrator account</h3>
<ol start="55">
<li>Right click on the OU with computers, select <code>Create a GPO in this domain, and Link it here...</code></li>
</ol>
<p><img src="./create-a-gpo-and-link-it-here.png" alt="create-a-gpo-and-link-it-here"></p>
<ol start="56">
<li>Provide a name for the new Group Policy Object (GPO) and click on <code>OK</code>.</li>
</ol>
<p><img src="./new-gpo-name.png" alt="new-gpo-name"></p>
<ol start="57">
<li>Right-click on the newly created GPO and select <code>Edit</code>.</li>
</ol>
<p><img src="./edit-gpo.png" alt="edit-gpo"></p>
<ol start="58">
<li>A <code>Group Policy Management Editor</code> window pops-up. Go to <code>Preferences &gt; Control Panel Settings</code> and select <code>Local Users and Groups</code>. Right-click on the table (empty here), and select <code>New &gt; Local Group</code>.</li>
</ol>
<p><img src="./local-users-and-groups.png" alt="local-users-and-groups"></p>
<ol start="59">
<li>Within the <code>New Local Group Properties</code>, set the <code>Action</code> to be <code>Update</code>. Select the <code>Group name</code> to be <code>Administrators (built-in)</code> from the drop-down menu.</li>
</ol>
<p><img src="./groups-drop-down.png" alt="groups-drop-down"></p>
<ol start="60">
<li>Click on <code>Add</code> under <code>Members</code> table.</li>
</ol>
<p><img src="./add-groupmember.png" alt="add-groupmember"></p>
<ol start="61">
<li>Click on the <code>...</code> button beside name to spawn the <code>Select User, Computer, or Group</code> window.</li>
</ol>
<p><img src="./local-group-member-add-3-button.png" alt="local-group-member-add-3-button"></p>
<ol start="62">
<li>Enter the object name (here <code>ashtrace</code>, a domain-joned user I created earlier). Click on <code>Check Names</code> to retrieve the particular user name in correct format. Click on <code>OK</code>.</li>
</ol>
<p><img src="./select-user-ashtrace.png" alt="select-user-ashtrace"></p>
<p>Click on <code>OK</code> again (Notice that the user name is prefixed by the domain name.)</p>
<p><img src="./select-user-ashtrace-2.png" alt="select-user-ashtrace-2"></p>
<p>Finally, Click on <code>Apply</code> and <code>OK</code> respectively.</p>
<ol start="63">
<li>Validate the GPO by going back to <code>Group Policy Management</code> Window, navigate to the OU and select the GPO created. Visit the <code>Settings</code> tab.</li>
</ol>
<p><img src="./gpo-settings-page.png" alt="gpo-settings-page"></p>
<p>Titles can be expanded through clicks over them, and it can be observed that the GPO updates the membership of the built-in administrators group.</p>
<p><img src="./gpo-settings-page-2.png" alt="gpo-settings-page-2"></p>
<blockquote>
<p>A window-pop with alert from internet-explorer/edge might spawn complaining website trust issues as the setting page renders an HTML file. Go forth and trust the source, by selecting <code>Add</code> in the window itself, to render the contents.</p>
</blockquote>
<h3 id="syncing-group-policy-updates">Syncing group policy updates</h3>
<ol start="64">
<li>
<p>Go to the machine added earlier.</p>
</li>
<li>
<p>Either reboot it, or spawn a command prompt and type <code>gpupdate /force</code>.</p>
</li>
<li>
<p>Once update, open up file explorer. Right-click on <code>This PC</code> and select <code>Manage</code>.</p>
</li>
</ol>
<p><img src="./this-pc-manage.png" alt="this-pc-manage"></p>
<p>Within the <code>Computer Management</code> window, go to <code>Local Users and Groups</code>. Double-click on <code>Groups</code>, followed by a <code>double-click</code> on <code>Administrators</code>.</p>
<p><img src="./administrators-group-members.png" alt="administrators-group-members"></p>
<p>It is evident that <code>LAB\ashtrace</code> is a member of the builtin-administratosr group now, and their credential can be used to exeute task with administrative privileges.</p>
<h2 id="add-a-server-to-ad-lab">Add a Server to AD Lab</h2>
<ol start="66">
<li>Use the copy of the Windows server VHD image we created earlier, to spawn a new VM machine connected to the Virtualbox Host-Only adapter.</li>
</ol>
<blockquote>
<p><strong>NOTE</strong>: If you get UUID conflict run <code>C:\Users\ashtrace\VMs&gt;&quot;C:\Program Files\Oracle\VirtualBox\VBoxManage.exe&quot; internalcommands sethduuid &lt;path-to-vhd-file&gt;</code></p>
</blockquote>
<ol start="67">
<li>
<p>Configure the locale settings and setup the administrator password (reference the steps executed when preparing VM for the DC i.e. steps 1-2-3-4).</p>
</li>
<li>
<p>Once the VM reboots, through the server manager configure a hostname for the VM (reference step 7). I named the server <code>LAB-SRV</code>.</p>
</li>
<li>
<p>After the VM restarts again, configure a static IP address and enter the DC&rsquo;s IP for DNS (reference step 46, use credential setup for lab server to login).</p>
</li>
</ol>
<p><img src="./lab-srv-ip.png" alt="lab-srv-ip"></p>
<ol start="70">
<li>Open file explorer. Right-click on <code>This PC</code>, select <code>Properties</code>. This opens up the <code>About</code> page in <code>Settings</code>. Scroll-down and click on <code>Advanced system settings</code>. In the pop-window go to <code>Computer Name</code> tab and click on <code>Change</code>.</li>
</ol>
<p><img src="./lab-srv-connect-to-domain.png" alt="lab-srv-connect-to-domain"></p>
<ol start="71">
<li>Switch to <code>Domain</code> from <code>Workgroup</code> and enter the domain name (here: <code>LAB.LOCAL</code>), enter the domain administrator credentials. After successful authentication a dialog box with message <code>Welcome to domain &lt;domain name&gt;</code> should appear. Restart the VM when asked.</li>
</ol>
<p><img src="./lab-srv-connect-to-domain-auth.png" alt="lab-srv-connect-to-domain-auth"></p>
<ol start="72">
<li>After reboot, use domain credentials to log onto the server. I used the <code>ashtrace</code> account credentials as it would be part of the built-in administrator group owing the GPO created earlier (Ensure that the LAB-SRV machine is part of the OU to which the GPO has been mapped, if not on the DC, open up <code>Server Manager</code> &gt; go to <code>Active Directory Users and Computers</code> from <code>Computers</code> drag the <code>LAB-SRV</code> machine to the particular OU (<code>LAB-OU &gt; Computers</code> in this case), back on the <code>LAB-SRV</code> machine run <code>gpupdate /force</code> and reboot)</li>
</ol>
<h3 id="configure-iis-service-on-the-newly-added-server">Configure IIS service on the newly added server</h3>
<blockquote>
<p>We briefly enable a second network adapter for the VM and allow access to the Wi-fi network.</p>
</blockquote>
<p><img src="./bridged-network-lab-srv.png" alt="bridged-network-lab-srv"></p>
<ol start="73">
<li>
<p>In the <code>Server Manager</code> Application, select to <code>Manage &gt; Add Roles and Features</code>. Select <code>Role-based or feature-based installation</code> mode and click on <code>Next</code>. Ensure that the server is selected in <code>Server Selection</code> window.</p>
</li>
<li>
<p>Select <code>Web Server IIS</code> in the <code>Server Roles</code> window and click on <code>Add features</code> in the pop-window that appears. Click on <code>Next</code>.</p>
</li>
</ol>
<p><img src="./web-server-iis-role.png" alt="web-server-iis-role"></p>
<ol start="75">
<li>Click on <code>Next</code> in <code>Features</code> window followed by another <code>Next</code>. In the <code>Web Server Role (IIS)</code> window&rsquo;s <code>Role services</code> list select following under <code>Application Development</code> (if you want ASP.NET support) along with the default features selected. Click on <code>Next</code>.</li>
</ol>
<p><img src="./web-server-iis-roles-services.png" alt="web-server-iis-roles-services"></p>
<ol start="76">
<li>
<p>Under <code>Confirmation</code> allow the wizard to restart the VM if needed and click on <code>Install</code>.</p>
</li>
<li>
<p>Once the installation succeeds, visit the server from the workstation added earlier to establish if the IIS service is up and running.</p>
</li>
</ol>
<p><img src="./iis-default-page-on-lab-srv.png" alt="iis-default-page-on-lab-srv"></p>
<h2 id="adding-xdr">Adding XDR</h2>
<p>Wazuh is an open-source XDR. It ships <a href="https://documentation.wazuh.com/current/deployment-options/virtual-machine/virtual-machine.html">OVA</a> image among other installation methods.</p>
<ol start="78">
<li>
<p>Download the OVA file and import it in Virtualbox.</p>
</li>
<li>
<p>Change the network adapter to host-only, change the graphics controller to <code>VMSVGA</code> (under <code>Settings &gt; Display &gt; Graphics Controller</code>) and enable the <code>Enable Hardware Clock in UTC Time</code> feature under <code>Settings &gt; System &gt; Extended Features</code>.</p>
</li>
<li>
<p>Power-up the VM, login using credentials <code>wazuh-user:wazuh</code>.</p>
</li>
</ol>
<h3 id="setup-static-ip-address">Setup static IP address</h3>
<ol start="81">
<li>Find the name of the ethernet interface using <code>ip a</code>.</li>
</ol>
<pre tabindex="0"><code>[wazuh-user@wazuh-server ~]$ ip a
1: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host noprefixroute
       valid_lft forever preferred_lft forever
2: eth0: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:bf:d2:7c brd ff:ff:ff:ff:ff:ff
    altname enp0s17
    inet 192.168.56.107/24 brd 192.168.56.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:febf:d27c/64 scope link proto kernel_ll
       valid_lft forever preferred_lft forever
</code></pre><ol start="82">
<li>Check the status of the ethernet interface to identify the file being used to manage it from <code>systemd-networkd</code> by running <code>networkctl status &lt;interface-name&gt;</code> (here and hereafter the interface-name is <code>eth0</code>)</li>
</ol>
<pre tabindex="0"><code>[wazuh-user@wazuh-server ~]$ networkctl status eth0
● 2: eth0
                     Link File: /usr/lib/systemd/network/99-default.link
                  Network File: /etc/systemd/network/10-cloud-init-eth0.network
                         State: routable (configured)
                  Online state: online
                          Type: ether
                          Path: pci-0000:00:11.0
                        Driver: e1000
                        Vendor: Intel Corporation
                         Model: 82545EM Gigabit Ethernet Controller (Copper) (PRO/1000 MT Single Port Adapter)
             Alternative Names: enp0s17
              Hardware Address: 08:00:27:bf:d2:7c (PCS Systemtechnik GmbH)
                           MTU: 1500 (min: 46, max: 16110)
                         QDisc: fq_codel
  IPv6 Address Generation Mode: eui64
      Number of Queues (Tx/Rx): 1/1
              Auto negotiation: yes
                         Speed: 1Gbps
                        Duplex: full
                          Port: tp
                       Address: 192.168.56.107 (DHCP4 via 192.168.56.100)
                                fe80::a00:27ff:febf:d27c
             Activation Policy: up
           Required For Online: yes
               DHCP4 Client ID: IAID:0x62b7eef0/DUID
             DHCP6 Client DUID: DUID-EN/Vendor:0000ab116c1ecb03a0526b40
</code></pre><ol start="83">
<li>Check the value of <code>Network File</code> attribute (here: <code>/etc/systemd/network/10-cloud-init-eth0.network</code>). Create a file with name <code>&lt;words-between-number-and-interface&gt;.disabled</code> (eg: <code>cloud-init.disabled</code>)</li>
</ol>
<pre tabindex="0"><code>[wazuh-user@wazuh-server ~]$ sudo touch /etc/cloud/cloud-init.disabled
</code></pre><ol start="84">
<li>Remove the file discovered as value of <code>Network File</code> attribute.</li>
</ol>
<pre tabindex="0"><code>[wazuh-user@wazuh-server ~]$ sudo rm /etc/systemd/network/10-cloud-init-eth0.network
</code></pre><ol start="85">
<li>Create a new file <code>/etc/systemd/network/10-static.network</code></li>
</ol>
<pre tabindex="0"><code>[Match]
Name=eth0

[Network]
Address=192.168.56.150/24
Gateway=192.168.56.1
DNS=8.8.8.8
DNS=1.1.1.1
</code></pre><ol start="86">
<li>Restart the <code>systemd-networkd</code> service.</li>
</ol>
<pre tabindex="0"><code>sudo systemctl restart systemd-networkd
</code></pre><ol start="87">
<li>Validate the changes through <code>networkctl status eth0</code>.</li>
</ol>
<h3 id="access-the-wazuh-dashboard">Access the Wazuh dashboard</h3>
<ol start="88">
<li>Visit the URL through IP address configured earlier (here: <code>https://192.168.56.107</code>) and credential <code>admin:admin</code>.</li>
</ol>
<p><img src="./wazuh-dashboard.png" alt="wazuh-dashboard"></p>
<h3 id="deploy-wazuh-agents">Deploy Wazuh agents</h3>
<ol start="89">
<li>Click on <code>Agent Management &gt; Summary</code> from the hamburger menu icon on the top left of the dashboard. For your first agent <code>Deploy new agent</code> page should appear, further agents can be added via clicking on <code>Deploy new agent</code> button.</li>
</ol>
<p><img src="./deploy-new-agent-first-wazuh-agent.png" alt="deploy-new-agent-first-wazuh-agent"></p>
<ol start="90">
<li>Under <code>Select the package to download and install on your system:</code> select <code>Windows: MSI 32/64 bits</code>. Under <code>Server address</code>, add the add IP address configured for this wazuh-server VM.</li>
</ol>
<p><img src="./deploy-new-agent-windows-installer-1.png" alt="deploy-new-agent-windows-installer-1"></p>
<ol start="91">
<li>Skip optional settings, the command under <code>Run the following commands to download and install the agent:</code> fetches the installer from <code>packages.wazuh.com</code> thus for the sake of installation enable a second network adapter on the VMs and provide access to internet through <code>Bridged Adapter</code>.</li>
</ol>
<p><img src="./bridged-adapter.png" alt="bridged-adapter"></p>
<ol start="92">
<li>Log onto the target VM with administrative account (Domain administrator on <code>LAB-DC</code> and local administrator, for e.g. the one created earlier through GPO, on the workstation and server <code>LAB-SRV</code>). Open a PowerShell session with administrative privileges. Copy the command from <code>Run the following commands to download and install the agent:</code> section of the <code>Deploy new agent</code> page and run it in the PowerShell session.</li>
</ol>
<p><img src="./wazuh-agent-installation-command-powershell.png" alt="wazuh-agent-installation-command-powershell"></p>
<ol start="93">
<li>After the command is executed run <code>NET START WazuhSvc</code> from the same powershell session. Through <code>Task Manager &gt; Services</code> it is evident a certian <code>WazuhSvc</code> service was created and is running.</li>
</ol>
<p><img src="./wazuh-svc.png" alt="wazuh-svc"></p>
<p>After a while the agent would be visible on the <code>Agent Management &gt; Summary</code> dashboard (first as <code>Never connected</code> then as <code>Active</code>.)</p>
<p><img src="./agent-management-summary-dashboard-agent-active.png" alt="agent-management-summary-dashboard-agent-active"></p>
<ol start="94">
<li>Repeat the steps to install the agent on other VM machines in the <code>LAB.LOCAL</code> domain. Finally, the <code>Agent Management &gt; Summary</code> should look like this.</li>
</ol>
<p><img src="./agent-management-summary-dashboard-all-agents.png" alt="agent-management-summary-dashboard-all-agents"></p>
<h2 id="finally">Finally</h2>
<ol start="95">
<li>
<p>Agument this lab setup by adding on other servers and configurations like delegation, PKI etc. and do share the guides and resources with me.</p>
</li>
<li>
<p>Eat</p>
</li>
<li>
<p>Sleep</p>
</li>
<li>
<p>Hack</p>
</li>
<li>
<p>Repeat</p>
</li>
<li>
<p>Stay Hydrated</p>
</li>
<li>
<p>Touch Grass</p>
</li>
</ol>
<h2 id="quick-troubleshoot">Quick Troubleshoot</h2>
<ul>
<li>The log of wazuh agent can be viewed from the file <code>C:\Program Files (x86)\ossec-agent\ossec.log</code></li>
</ul>
]]></description>
      
    </item>
    
    
  </channel>
</rss>
