{"id":4781,"date":"2023-05-11T07:00:00","date_gmt":"2023-05-11T07:00:00","guid":{"rendered":"http:\/\/www.sumologic.com\/blog\/threat-labs-kubernetes-home-lab"},"modified":"2025-05-08T19:10:55","modified_gmt":"2025-05-09T03:10:55","slug":"threat-labs-kubernetes-home-lab","status":"publish","type":"blog","link":"https:\/\/www.sumologic.com\/blog\/threat-labs-kubernetes-home-lab","title":{"rendered":"Building a Kubernetes purple teaming lab"},"content":{"rendered":"\n<section class=\"e-stn e-stn-fc090504d8c495877f2d795d392908e318d4e1f9 e-stn--glossary-inner-content e-stn--table-of-content\"><div class=\"container\">\n<div class=\"wp-block-b3rg-row e-row row\">\n<div class=\"wp-block-b3rg-column e-col e-col-5b1830f2290e10551cf9d734cb4bbf0c927d83ba e-col--content-wrapper  col-sm-12 col-lg-12 col-xl-12\">\n<div class=\"e-div e-div-5d2e7848f6f43526612539018ddf29050777aacf e-div--card-btn-link\"><div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1400\" height=\"400\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/blog-Kubernetes-Purple-Teaming-Lab-header-1.png\" alt=\"Sumo Logic Threat Labs\" class=\"wp-image-4737\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-e9ed7c00166e93aaa88371d25b81a7c0\">Kubernetes, and containerization in general, has a wealth of benefits for many teams operating cloud-native applications. From a threat detection standpoint, however, it is often difficult for newcomers to this space to gain the relevant hands-on experience without trampling over production environments. <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-0a6e2014d9472f6dec298b4600988736\">The Sumo Logic team has previously authored articles on <a href=\"https:\/\/www.sumologic.com\/blog\/kubernetes-devsecops\/\">Kubernetes DevSecOps vulnerabilities and best practices<\/a> as well as <a href=\"https:\/\/www.sumologic.com\/blog\/kubernetes-logs\/\">Kubernetes logging and monitoring<\/a>. Now, let\u2019s extend this work and outline how to set up a Kubernetes home lab. <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-402e8d7ba14f96f7bdfc46541f7c367c\">We will provision and configure this lab, send the relevant telemetry to a free Sumo Logic instance and track our testing activities using the awesome <a href=\"https:\/\/sra.io\/vectr\/\" target=\"_blank\" rel=\"noopener\">Vectr tool<\/a>. <\/p>\n\n\n\n<h2 class=\"wp-block-heading has-eigengrau-color has-text-color has-link-color wp-elements-8f1995a7336b39c5835408d2a422696e\" id=\"what_is_purple_teaming?_\"><strong>What is purple teaming? <\/strong><\/h2>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-8a31f2bdcf446d27cf4059bf0a00e9d7\">Before diving head first into the tooling, attacks &amp; defenses, we should pause for a moment and outline what purple teaming is and why it&#8217;s a powerful tool for developing defenses for complex applications and networks. <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-8ee716d968f9d0b0ab1bfcd1252dfbee\">Within the information security community, colors have been ascribed to the attack\/defense spectrum. With those on the attacking end (penetration testers, red teamers) being associated with the red color and those on the defending end (SOC analysts, threat hunters) being associated with the blue color.<\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-87dc47275e3391c0dad637e44e654048\">This dichotomy between red and blue is often blurry, as some red teamers may want to perform threat hunting to hone their evasion skills and some SOC analysts may want to understand how an attack tool works in order to craft more comprehensive detection logic. <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-8fe26c44a585137092f0d105296d23a0\">It should come as no surprise then, that purple teaming is a mix of both blue and red aspects of the cyber security spectrum. Purple teaming engagements and exercises can come in many flavors and may lean more to one side of the red-blue spectrum than the other, depending on how the exercise is laid out and who the recipient of the engagement is. <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-7705fe9cf60402b8864a757cee7f8958\">Overall, however, purple teaming generally encompasses the dynamic of collaboratively attacking a system, checking the results of the attack, tracking the related metrics and then iterating; all with the goal of improving system security, response and resiliency. <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-0762e6ce18b2004bfdde1db2fae183e3\">Some additional resources on purple teaming can be found <a href=\"https:\/\/github.com\/scythe-io\/purple-team-exercise-framework\" target=\"_blank\" rel=\"noopener\">here<\/a> and <a href=\"https:\/\/www.lares.com\/the-pillars-of-adversarial-collaboration\/\" target=\"_blank\" rel=\"noopener\">here<\/a>. <\/p>\n\n\n\n<h2 class=\"wp-block-heading has-eigengrau-color has-text-color has-link-color wp-elements-4fcb15168fa6d26560d6c96433389522\" id=\"tooling_overview\"><strong>Tooling overview<\/strong><\/h2>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-ed4e2d81bdc5af5990cd440e941088ea\">Before getting into the various techniques, tactics and procedures (TTPs) as well as technical details, let us step back for a moment and do a quick overview of all the tooling involved and highlight the function that each piece performs.&nbsp;<\/p>\n\n\n\n<table>\n<tbody>\n<tr>\n<td width=\"25%\">\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-73f064020ef4fd14cc77d5ca10c4ed4a\"><strong>Tool<\/strong><\/p>\n\n\n\n<\/td>\n<td>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-384f068fe323f0b17371330eaa133032\"><strong>Purpose<\/strong><\/p>\n\n\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-cb6cd9406ce7463abde850d3296a3cb6\"><a href=\"https:\/\/ubuntu.com\/download\/desktop\" target=\"_blank\" rel=\"noopener\">Ubuntu 20.04 virtual machine<\/a><\/p>\n\n\n\n<\/td>\n<td>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-53a61dcc4b7e1856dbb520cdd8e2f6ac\">This virtual machine will be running our Kubernetes cluster as well as various other logging tools in addition to Vectr itself.<\/p>\n\n\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-e2640b522cdd781730ab0dcdc8145acb\"><a href=\"https:\/\/www.docker.com\/\" target=\"_blank\" rel=\"noopener\">Docker<\/a><\/p>\n\n\n\n<\/td>\n<td>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-0a0e424e3f590d1e1e135191fdaaf07a\"><a href=\"https:\/\/www.sumologic.com\/glossary\/docker\/\">Docker<\/a> will act as our Kubernetes driver and will host our Vectr instance, all on the same virtual machine.<\/p>\n\n\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-03982d88de1fca4cc350f7b05ad8c7b7\"><a href=\"https:\/\/minikube.sigs.k8s.io\/docs\/\" target=\"_blank\" rel=\"noopener\">Minikube<\/a><\/p>\n\n\n\n<\/td>\n<td>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-c83d8a3324810c247ad209f03eaceec2\">Minikube will make it possible for us to run a Kubernetes instance on our virtual machine.<\/p>\n\n\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-87271b5f6a0901b0eb22c23ec064a2ec\"><a href=\"https:\/\/www.sumologic.com\/\">Sumo Logic<\/a><\/p>\n\n\n\n<\/td>\n<td>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-cf7b658668045fa294e93e08cc97ab6c\">A free Sumo Logic account will be used in order to monitor our Kubernetes installation.<\/p>\n\n\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-0b1524536b761f8deed4a8bfa95c45ba\"><a href=\"https:\/\/linux.die.net\/man\/8\/auditd\" target=\"_blank\" rel=\"noopener\">Auditd<\/a> + <a href=\"https:\/\/github.com\/threathunters-io\/laurel\" target=\"_blank\" rel=\"noopener\">Laurel<\/a><\/p>\n\n\n\n<\/td>\n<td>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-3516e0617a9f30fa146d7de695f941b4\">We will be using an auditd configuration file on our virtual machine in order to get host-level telemetry from our Kubernetes cluster. Laurel will be used to transform these auditd logs into JSON format so that they are easier to work with and query.<\/p>\n\n\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-220f09a9b2200fb59266de577478e7f4\"><a href=\"https:\/\/vectr.io\/\" target=\"_blank\" rel=\"noopener\">Vectr<\/a><\/p>\n\n\n\n<\/td>\n<td>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-f7003226bae60c82abc7d3fead2179d4\">Vectr will be used to track our purple teaming activities on our local Kubernetes cluster. <\/p>\n\n\n\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n\n\n\n<h2 class=\"wp-block-heading has-eigengrau-color has-text-color has-link-color wp-elements-e1a7ab4f0947e053dffa2aaea25f2f65\" id=\"virtual_machine_setup_\"><strong>Virtual machine setup <\/strong><\/h2>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-c933f375e485a7d5d3425c0e69a48d98\">Now that you have all the tools to follow along, let\u2019s dive in and get it all set up. <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-6714ffd6793253ed246874674c1b2962\">Please note that throughout these instructions, a virtual machine with an ARM architecture is used, if the virtual machine you are running is not ARM, then please adjust the relevant installation instructions to match your particular architecture. At time of writing, Vectr does not support ARM architectures. If you wish to run all the tooling outlined in this blog on one virtual machine, then we recommend a x64\/amd64 architecture.  <\/p>\n\n\n\n<h3 class=\"wp-block-heading has-eigengrau-color has-text-color has-link-color wp-elements-508f628ef9104aff47d4ee0fe2894edb\" id=\"docker_install\"><strong>Docker install<\/strong><\/h3>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-fd9560585db3c7a35ebd28750507977e\">In order to install Docker, we will be following the <a href=\"https:\/\/docs.docker.com\/engine\/install\/ubuntu\/\" target=\"_blank\" rel=\"noopener\">official instructions<\/a>. <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-b4bae3a35c3e54f8c0033472a079d9d6\">We first install the necessary dependencies: <\/p>\n\n\n\n<pre>sudo apt-get update\r\nsudo apt-get install \r\n    ca-certificates \r\n    curl \r\n    gnupg<\/pre>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-3844eeabaa7da184ea29522a41430357\">We then add the Docker repo GPG keys: <\/p>\n\n\n\n<pre>sudo install -m 0755 -d \/etc\/apt\/keyrings\r\ncurl -fsSL https:<em>\/\/download.docker.com\/linux\/ubuntu\/gpg | sudo gpg --dearmor -o \/etc\/apt\/keyrings\/docker.gpg<\/em>\r\nsudo chmod a+r \/etc\/apt\/keyrings\/docker.gpg<\/pre>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-d7b2ce265b949a66ebe6c08b5a6e1398\">Following this, we set up the relevant Docker repos &#8211; note that the below command should be architecture agnostic. <\/p>\n\n\n\n<pre>echo \r\n  \"deb [arch=\"$(dpkg --<\/strong>print<\/strong>-architecture)\" signed-by=\/etc\/apt\/keyrings\/docker.gpg] &lt;a href=\"https:\/\/download.docker.com\/linux\/ubuntu\" class=\"redactor-autoparser-object\"&gt;https:\/\/download.docker.com\/li...&lt;\/a&gt; \r\n  \"$(. \/etc\/os-release && echo \"$VERSION_CODENAME\")\" stable\" | \r\n  sudo tee \/etc\/apt\/sources.list.d\/docker.list &gt; \/dev\/<strong>null<\/strong> \r\n<strong>apt-get update<\/strong><\/pre>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-d86f1e2ea64cb31e3600a8414eb8fd7c\">Finally, we install the relevant Docker packages: <\/p>\n\n\n\n<pre>sudo apt-get <strong>install<\/strong> docker-ce docker-ce-cli containerd.io docker-buildx-<strong>plugin<\/strong> docker-compose-<strong>plugin<\/strong><\/pre>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-59f1b466d6b16067c5e877147944917d\">If all went well during the installation, you should be able to run: docker -v and see something similar to the following: <\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"958\" height=\"168\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/1-k8-image14.png\" alt=\"Kubernetes purple teaming lab - image 1\" class=\"wp-image-4738\" title=\"\"><\/figure>\n<\/div>\n\n\n<h3 class=\"wp-block-heading has-eigengrau-color has-text-color has-link-color wp-elements-4502fa91c5146827365af6b650245550\" id=\"minikube_install\"><strong>Minikube install<\/strong><\/h3>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-368655329e710eafb6534d542bc2a193\">Next up, we\u2019ll be installing Minikube. We will follow the <a href=\"https:\/\/minikube.sigs.k8s.io\/docs\/start\/\" target=\"_blank\" rel=\"noopener\">official instructions<\/a> to perform the installation.<\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-b94be2a40b9a8153ddf497b9f73e1c72\">The instructions are interactive here, and you can click the relevant buttons to match your particular architectures and virtual machine setups. <\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1999\" height=\"1232\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/2-k8-image29.png\" alt=\"Installation\" class=\"wp-image-4739\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-81d07f42236978893cede58c5be3f095\">In our case, we will be using the Linux operating system, ARM64 architecture, and will be using the binary installer type, so the command here is:<\/p>\n\n\n\n<pre>curl -LO &lt;a href=\"https:\/\/storage.googleapis.com\/minikube\/releases\/latest\/minikube-linux-arm64\" class=\"redactor-autoparser-object\" target=\"_blank\"&gt;https:\/\/storage.googleapis.com\/minikube\/releases\/latest\/minikube-linux-arm64&lt;\/a&gt;\r\nsudo install minikube-linux-arm64 \/usr\/local\/bin\/minikube<\/pre>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-28e579da814887211fdfa92778534a6d\">Prior to starting Minikube, we need to add our current user to the Docker group:<\/p>\n\n\n\n<pre>sudo usermod -aG docker $<strong>USER<\/strong> <strong>&& newgrp<\/strong> docker<\/pre>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-e39baec67ff46bb98deb228618faa88e\">Now we are ready to start Minikube using: minikube start<\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-9156259567ccdfc2276653331c5515b2\">If all goes well, you should see something similar to:<\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1999\" height=\"726\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/3-k8-image45.png\" alt=\"\" class=\"wp-image-4740\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-95dd8db69802769f8952e08905b49639\">In order to interact with our Minikube cluster, we also need to install kubectl. <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-89a5d3e16de8155390ca2bd618378d3a\">Minikube can do this for you with the following command: <\/p>\n\n\n\n<pre>minikube kubectl <em>-- get po -A<\/em><\/pre>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-4225892ea4343caeb2accdf4272acb67\">We can then alias this minikube version of kubectl to just kubectl to make it easier for us: <\/p>\n\n\n\n<pre><strong>alias<\/strong> <strong>kubectl<\/strong>=\"minikube kubectl --\"<\/pre>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-2d6b70d1e291042ba4b309a7331c48a3\">Now we should be able to do a: <span class=\"code2\">kubectl get nodes<\/span> in order to see the minikube control plane running.<\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1342\" height=\"156\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/4-k8-image6.png\" alt=\"\" class=\"wp-image-4741\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-6df1874a28e9bc80b40a7a593cdc66cf\">Very cool! We now have a virtual machine provisioned with Docker installed as well as a local Kubernetes instance ready for our testing. <\/p>\n\n\n\n<h3 class=\"wp-block-heading has-eigengrau-color has-text-color has-link-color wp-elements-d151aac6033d5aefc26f9acf742a68ef\" id=\"auditd_setup\"><strong>Auditd setup<\/strong><\/h3>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-9e531f5dc4bbb216baba5779966ceab6\">As a next step, let\u2019s instrument our Ubuntu host with some host-level telemetry using Auditd and Laurel. <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-ac7f9d83eea830e0878de513033bbb5c\">We first install auditd using the following command: <span class=\"code2\">sudo apt-get install auditd<\/span><\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-e2ed7a145d18db6533c09f8318adb705\">If we do a <span class=\"code2\">service auditd status<\/span>, we should see output similar to the following: <\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1999\" height=\"214\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/5-k8-image32.png\" alt=\"\" class=\"wp-image-4742\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-8aa6ff4b684efe88ed4652ef6ee031e6\">Next, we need to tell auditd what we want it to log and here we will be using <a href=\"https:\/\/twitter.com\/cyb3rops\" target=\"_blank\" rel=\"noopener\">Florian Roth\u2019s<\/a> awesome <a href=\"https:\/\/github.com\/Neo23x0\/auditd\/blob\/master\/audit.rules\" target=\"_blank\" rel=\"noopener\">auditd configuration file<\/a>. <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-15c94c0c474885c10b07855c7adbf83d\">We can start by making a backup of the existing rules file: <\/p>\n\n\n\n<pre>cp \/etc\/audit\/rules.d \/etc\/audit\/rules.d.bak<\/pre>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-9adc578d9924503ef77b8315e4348a21\">Then, we can go ahead and change the auditd rules. To do so, use sudo to open up <span class=\"code2\">\/etc\/audit\/rules.d\/audit.rules<\/span> with your favorite text editor (no nano versus vim arguments here!) and replace the contents of the <span class=\"code2\"><strong>audit<\/strong>.rules<\/span> file on your Ubuntu machine with the <span class=\"code2\"><strong>audit<\/strong>.rules<\/span> linked above. <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-5e0cf3a59189e7f28c3adf42c8250469\">Once that is done, restart auditd using sudo service auditd restart<\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-07b7b12fce3109946e7bb5f7da9f81d4\">To ensure that auditd is working properly, you can use: <span class=\"code2\">tail -f \/var\/<strong>log<\/strong>\/audit\/audit.<strong>log<\/strong><\/span> &#8211; we can hit ctrl+c to stop the tailing.<\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-13fbd5829f59bf48aa50c7c72d21d784\">If you take a closer look at the auditd log format, it may look overwhelming at first, as a simple cat command looks like this when logged by auditd: <\/p>\n\n\n\n<pre>type=SYSCALL msg=audit(1681912914.195:1053): arch=c00000b7 syscall=56 success=yes exit=3 a0=ffffffffffffff9c a1=ffffef61a793 a2=0 a3=0 items=1 ppid=3102 pid=4453 auid=1000 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts1 ses=2 comm=\"cat\" exe=\"\/usr\/bin\/cat\" subj=unconfined key=\"auditlog\"ARCH=aarch64 SYSCALL=openat AUID=\"parallels\" UID=\"root\" GID=\"root\" EUID=\"root\" SUID=\"root\" FSUID=\"root\" EGID=\"root\" SGID=\"root\" FSGID=\"root\"<\/pre>\n\n\n\n<h3 class=\"wp-block-heading has-eigengrau-color has-text-color has-link-color wp-elements-91a12bfddc4207e39ad6d200cd91b84f\" id=\"laurel_setup_\"><strong>Laurel setup <\/strong><\/h3>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-333c810fbe4c74dbb1af755e7f7eab46\">In order to make these logs easier to work with, we will be using <a href=\"https:\/\/github.com\/threathunters-io\/laurel\" target=\"_blank\" rel=\"noopener\">Laurel<\/a>.<\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-9352c15ff30bb336618bcc5dfa004519\">We start by downloading the relevant Laurel binary: <\/p>\n\n\n\n<pre>wget &lt;a href=\"https:\/\/github.com\/threathunters-io\/laurel\/releases\/download\/v0.5.1\/laurel-v0.5.1-aarch64-musl.tar.gz\" class=\"redactor-autoparser-object\" target=\"_blank\"&gt;https:\/\/github.com\/threathunters-io\/laurel\/releases\/download\/v0.5.1\/laurel-v0.5.1-aarch64-musl.tar.gz&lt;\/a&gt;<\/pre>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-34e893d3bcc9ea6958a3169e097a6649\">We then untar the archive: <\/p>\n\n\n\n<pre><strong>tar<\/strong> <strong>xzf<\/strong> <strong>laurel-v0.5.1-aarch64-musl.tar.gz<\/strong><\/pre>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-e9ed46415212b824b48a6b77f14f2424\">And copy it to the proper directory: <\/p>\n\n\n\n<pre>sudo install -m755 laurel \/usr\/local\/sbin\/laurel<\/pre>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-0965152bd4780c7c5f8e10b527bf318d\">Next up we need to create a user for Laurel: <\/p>\n\n\n\n<pre>sudo useradd --system --home-dir \/var\/log\/laurel --create-home _laurel<\/pre>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-6c7addb14f69391d7f0dd053bf90a38e\">Next, we need to create a Laurel configuration file, an example is provided <a href=\"https:\/\/github.com\/threathunters-io\/laurel\/blob\/v0.5.1\/etc\/laurel\/config.toml\" target=\"_blank\" rel=\"noopener\">here<\/a><\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-ff05fd102a2aa737f888a41737ae5a8c\">We can do this with the following commands: <\/p>\n\n\n\n<pre>sudo mkdir \/etc\/laurel <\/pre>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-1325202b0d5d44897faeae45071276a6\">Followed by:<\/p>\n\n\n\n<pre>sudo wget &lt;a href=\"https:\/\/raw.githubusercontent.com\/threathunters-io\/laurel\/v0.5.1\/etc\/laurel\/config.toml\" class=\"redactor-autoparser-object\" target=\"_blank\"&gt;https:\/\/raw.githubusercontent.com\/threathunters-io\/laurel\/v0.5.1\/etc\/laurel\/config.toml&lt;\/a&gt; -O \/etc\/laurel\/config.toml<\/pre>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-cc239cbcc670d7bc1b0c6ce42aabe893\">Next, open the config.toml file that we just downloaded and change the value on line 20 to match your Ubuntu user.<\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-5b0cd9b31113238cf4cedb0b3ecc9f4a\">Finally, we need to tell auditd to use Laurel as a plugin, we can do this with the following command: <\/p>\n\n\n\n<pre>sudo wget &lt;a href=\"https:\/\/raw.githubusercontent.com\/threathunters-io\/laurel\/v0.5.1\/etc\/audit\/plugins.d\/laurel.conf\" class=\"redactor-autoparser-object\" target=\"_blank\"&gt;https:\/\/raw.githubusercontent.com\/threathunters-io\/laurel\/v0.5.1\/etc\/audit\/plugins.d\/laurel.conf&lt;\/a&gt; -O \/etc\/audit\/plugins.d\/laurel.conf<\/pre>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-7520040f503c2c38c0ea45c96f0870f4\">We now need to restart auditd:<\/p>\n\n\n\n<pre>sudo pkill -HUP auditd<\/pre>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-a57ad0b6630a1a4b6e2cf5e60fa15123\">Before we take a look at our fresh Laurel logs, let\u2019s install the jq utility: <span class=\"code2\">sudo apt <strong>install<\/strong> jq<\/span><\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-40ee43ab3d4358f88fbb8c7944738e34\">Now we can browse to <span class=\"code2\">\/var\/log\/laurel<\/span> and run: <span class=\"code2\">cat audit.log | jq<\/span><\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-23bcc790858dccfee1c9fcaa2922e5e8\">Wow, we ran a lot of commands so far! <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-5f8f1f911c6974546d4f9ec00781a7a8\">To recap, we\u2019ve set up an Ubuntu virtual machine with Docker and Minikube in order to operationalize a local Kubernetes cluster and to have a Docker base for the installation of Vectr. We\u2019ve also instrumented this Linux host with telemetry in the form of an auditd configuration file and have transformed that telemetry into JSON format using Laurel. <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-3218b86053356fa33755fb24e29ede6a\">Next up, let\u2019s install Vectr on this same host so that we can track and monitor our purple teaming journey.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-eigengrau-color has-text-color has-link-color wp-elements-5062fd94189d53625f97dbd1628ee226\" id=\"vectr_setup\"><strong>Vectr setup<\/strong><\/h3>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-f34463f0a36907880eb37d7d02cee5cb\"><strong>Please note that at time of writing, only x64 platforms are supported for Vectr installations.<\/strong><\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-d01c1b1143e9459915cddc39270e293c\">Vectr is a fully dockerized application, so we can grab the latest release from the <a href=\"https:\/\/github.com\/SecurityRiskAdvisors\/VECTR\" target=\"_blank\" rel=\"noopener\">Vectr GitHub repository<\/a>. <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-67d46182810253e348eb96ad4cc08452\">The full instructions can also be found <a href=\"https:\/\/docs.vectr.io\/Installation\/\" target=\"_blank\" rel=\"noopener\">here<\/a><\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-3cf485fa58d702d26fc3cf44b1753f50\">Once the Vectr release has been downloaded and unzipped to the appropriate directory, you should have a structure that looks like this: <\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1999\" height=\"743\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/6-k8-image22.png\" alt=\"\" class=\"wp-image-4743\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-d82357b7ff94efde861e716816cf30bc\">Next up, open up the .env file with your favorite text editor and change the VECTR_HOSTNAME variable to match your virtual machine&#8217;s IP address. While here, you can also go ahead and change the MongoDB passwords and JWS\/JWE keys as well.<\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1999\" height=\"1162\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/7-k8-image8.png\" alt=\"\" class=\"wp-image-4744\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-bd3947426ff3c48ea40f2eea027d0f7c\">Once we save the .env file, we can go ahead and bring up the various Vectr containers by doing a: <span class=\"code2\">sudo docker-compose up -d<\/span> within the <span class=\"code2\">\/<strong>opt<\/strong>\/vectr<\/span> directory. <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-5b73bedc3bb34fd9cec0c523ca2ec64c\">docker-compose should have been installed in earlier steps as part of our dependencies, but if it is not, you can run: <span class=\"code2\">sudo apt <strong>install<\/strong> docker-compose<\/span><\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-cc6c553eeb16236dadff201ce599e1a0\">You should now see various containers being pulled and spun up: <\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"616\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/8-k8-image23.png\" alt=\"\" class=\"wp-image-4745\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-f9b2b9225a3cd5d58291aa88131d4371\">Once all the containers are built, you should be able to browse to <a href=\"https:\/\/virtualmachineipaddress:8081\" target=\"_blank\">https:\/\/virtualmachineIPAddress:8081<\/a> and put in the default credentials which can be found within the Vectr install instructions, from here, we can create a database for our testing activities. <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-eeddaf51af9350b219939f45f6086a4a\">Navigate to the \u201cEnvironment\u201d button in Vectr, and click on \u201cSelect Active Environment\u201d then the + button and create an environment for our testing:<\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1072\" height=\"1088\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/9-k8-image17.png\" alt=\"\" class=\"wp-image-4746\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-42b6942c6aa22838e4ca6fa779d02ce4\">We should now see a fresh Vectr screen waiting for us: <\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1999\" height=\"462\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/10-k8-image41.png\" alt=\"\" class=\"wp-image-4747\" title=\"\"><\/figure>\n<\/div>\n\n\n<h3 class=\"wp-block-heading has-eigengrau-color has-text-color has-link-color wp-elements-7c21f3f039403b46385bf54cce0a7b4b\" id=\"recap\"><strong>Recap<\/strong><\/h3>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-aa2a95dcb21abc92403f64a68d3fa78a\">Prior to proceeding, we thought it would be wise to recap what we\u2019ve built thus far and to provide a high level overview of all the moving pieces: <\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1999\" height=\"1050\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/11-k8-image46.png\" alt=\"\" class=\"wp-image-4748\" title=\"\"><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading has-eigengrau-color has-text-color has-link-color wp-elements-3a6df37ccbe7bd1dd6a25767b3c7ad75\" id=\"sumo_logic_setup_and_collection\"><strong>Sumo Logic setup and collection<\/strong><\/h2>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-1a9e929902286e8a677b53cbf5065161\">Now that we have our Kubernetes set up, and have a host that is generating telemetry, we need to go ahead and send that telemetry to Sumo Logic.<\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-48a1adb5dff77bfd9a89ceca802cbbec\">We can spin up a free trial via <a href=\"https:\/\/www.sumologic.com\/sign-up\/\">this link<\/a> &#8211; once you sign up you should receive an email asking you to activate your account.<\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-5d7fed2f73c6dac5dd14d600d11ed8b8\">Once your account is activated you can click through the relevant wizards and you should be greeted with a blank Sumo Logic page: <\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1999\" height=\"711\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/12-k8-image15.png\" alt=\"\" class=\"wp-image-4749\" title=\"\"><\/figure>\n<\/div>\n\n\n<h3 class=\"wp-block-heading has-eigengrau-color has-text-color has-link-color wp-elements-af5781a24b27f49708f43168759bfdc8\" id=\"kubernetes_monitoring\"><strong>Kubernetes monitoring<\/strong><\/h3>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-b61da0a1efb4f072a777bec7bfcaa5e4\">In order to set up monitoring of our Kubernetes cluster, navigate to the \u201cApp Catalog\u201d section in the bottom left hand side the menu pane and then click on Kubernetes:<\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1999\" height=\"944\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/13-k8-image28.png\" alt=\"\" class=\"wp-image-4750\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-0cebd7b80384543856ff065df19067cc\">Once in the Kubernetes App Catalog menu, go ahead and click on \u201cAdd Integration\u201d &#8211; once you click on this, you should see step by step instructions: <\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1999\" height=\"1436\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/14-k8-image39.png\" alt=\"\" class=\"wp-image-4751\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-d89d8af5674caae82fc86cc4efc6d868\">If helm is not installed on your virtual machine, you can install it with the following commands: <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-62cfd5e5ed928d7744a6a0bd572636b9\">Helm will allow us to deploy the necessary components for logging and monitoring via a \u201cchart\u201d &#8211; for more information about Helm, check out <a href=\"https:\/\/helm.sh\/\" target=\"_blank\" rel=\"noopener\">their documentation<\/a>.<\/p>\n\n\n\n<pre>curl -fsSL -o get_helm.sh &lt;a href=\"https:\/\/raw.githubusercontent.com\/helm\/helm\/main\/scripts\/get-helm-3\" class=\"redactor-autoparser-object\" target=\"_blank\"&gt;https:\/\/raw.githubusercontent....&lt;\/a&gt;\r\nchmod 700 get_helm.sh\r\n.\/get_helm.sh<\/pre>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-352e76d2da637eff318a9c0542d09fd8\">Once helm is installed, we can follow the instructions on the Sumo Logic App Catalog page &#8211; note that the minikube cluster needs to be started prior to performing these steps: minikube start<\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-492e9ee9ce9b033510270fafc4d735e6\">Before running the helm upgrade command, we will set the sumologic.setup.monitors.enabled field to true.<\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-11928277e1c916f67d320e14ffd6d6a5\">By default, the Helm chart installs three replicas for the various collection pods, however, since our cluster is small and non-production we will be changing this value to just one.<\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-d8065afe99b4711099f3d35a54d75385\">To do this, we need to copy the contents of this file: <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-fcdb1bb711bcf9169cf5a4e80f0486a0\"><a href=\"https:\/\/raw.githubusercontent.com\/SumoLogic\/sumologic-kubernetes-collection\/main\/deploy\/helm\/sumologic\/values.yaml\" target=\"_blank\" rel=\"noopener\">https:\/\/raw.githubusercontent.com\/SumoLogic\/sumologic-kubernetes-collection\/main\/deploy\/helm\/sumologic\/values.yaml<\/a><\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-f2596d680a772dc8f44ede3aee1766fc\">To our Ubuntu host and find the lines with \u201creplicaCount\u201d in them and change the values from 3 to 1<\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-2127db5d34577d565d27f4563264bca4\">Then, we will need to add one line to the command that the Kubernetes onboarding wizard gives you:<\/p>\n\n\n\n<pre>helm upgrade --install my-release sumologic\/sumologic \r\n  --namespace=default \r\n  --create-namespace \r\n  --set sumologic.accessId=suuxOoW071wSiB \r\n  --set sumologic.accessKey=&lt;snip&gt; \r\n  --set sumologic.clusterName=&lt;cluster name&gt; \r\n  --set sumologic.collectorName=&lt;collector name&gt; \r\n  --set sumologic.setup.monitors.enabled=false \r\n  -f path\/to\/user_values.yaml<\/pre>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-3b13b1c328606d7989c4a57f2b32fde5\">Once the wizard completes, you should see something similar to the following: <\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1999\" height=\"389\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/15-k8-image3.png\" alt=\"\" class=\"wp-image-4752\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-fa7c4c179b1239318d7f5df96d2892e6\">Note that if the helm repo or wizard fails, you can try to add some more CPU and RAM to your Minikube setup:<\/p>\n\n\n\n<pre>minikube stop\r\nminikube config set memory 4192\r\nminikube config set cpus 4\r\nminikube start \u2014nodes 2<\/pre>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-0dfd2c1238bac8b55dc08bc4858ca56f\">After a few minutes the process should complete and the wizard should finish successfully. <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-9adbb5c76944dffbf1e9e8cac318a23c\">Right now, there is not much happening with our cluster so there isn\u2019t much data to look at. <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-2e68eb5725e2145805aae1a01f0f404c\">Let\u2019s change that and spin up a basic Ubuntu pod, using the following YAML:<\/p>\n\n\n\n<pre>apiVersion: v1\r\nkind: Pod\r\nmetadata:\r\n  name: ubuntu\r\n  labels:\r\n    app: ubuntu\r\nspec:\r\n  containers:\r\n  - image: ubuntu\r\n    command:\r\n      - \"sleep\"\r\n      - \"604800\"\r\n    imagePullPolicy: IfNotPresent\r\n    name: ubuntu\r\n  restartPolicy: Always<\/pre>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1674\" height=\"1202\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/16-k8-image2.png\" alt=\"\" class=\"wp-image-4753\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-a945b0658ae21b3bd3759239407445d8\">If you are wondering what the \u201cbatcat\u201d command is, it is utilizing the awesome \u201cbat\u201d utility which can be found <a href=\"https:\/\/github.com\/sharkdp\/bat\" target=\"_blank\" rel=\"noopener\">here<\/a><\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-4520d24acc88a75272b01772ca3f61ed\">Within your Sumo Logic screen, you can now click on New \u2192 Log Search: <\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1376\" height=\"990\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/17-k8-image36.png\" alt=\"\" class=\"wp-image-4754\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-5659b9a8ceacbc20fc48401abb0c2a4f\">Once on the log search screen, we can take a look at the logs for our pod creation, we don\u2019t know what we\u2019re looking for just yet, so we\u2019ll just type in \u201cubuntu\u201d in the search bar to get us an idea of what the data looks like: <\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1999\" height=\"1958\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/18-k8-image33.png\" alt=\"\" class=\"wp-image-4755\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-c523280aa6c5bc9ce7d01fa29eb8eac8\">Nice! Even if you aren\u2019t a Kubernetes or threat hunting expert, this very simple query already gives you a good idea of the types of data that are available to you. <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-8d4bfeb3facb09b86142ddcef63ab9c4\">We can see the container being pulled, created and started all in our Kubernetes <a href=\"https:\/\/www.sumologic.com\/glossary\/telemetry\/\">telemetry<\/a>.<\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-2fbb09a15f2a00bba19a84bfb8fa0331\">Let\u2019s complete our setup with one final step, installing a Sumo Logic collector to grab our Laurel logs off this host. <\/p>\n\n\n\n<h3 class=\"wp-block-heading has-eigengrau-color has-text-color has-link-color wp-elements-33708d6a3ac67f55e040c76f67e62d7a\" id=\"host_monitoring\"><strong>Host monitoring<\/strong><\/h3>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-180a0eb47f5ae9829b00450857a2eb3c\">Let\u2019s start by navigating to the collection menu in Sumo Logic, and clicking on \u201cAdd Collector\u201d<br><br><\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1999\" height=\"1271\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/19-k8-image16.png\" alt=\"\" class=\"wp-image-4756\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-7e6bb4a76da69da13d189f335e47db6e\">Next, click on \u201cInstalled Collector\u201d and choose the collector that matches your system architecture <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-61be44af4ef95e4afa88dce8a2a85f29\">On our testing ARM VM, we could use the following command: <\/p>\n\n\n\n<pre>wget &lt;a href=\"https:\/\/collectors\" class=\"redactor-autoparser-object\" target=\"_blank\"&gt;https:\/\/collectors&lt;\/a&gt;.<strong>ca<\/strong>.sumologic.<strong>com<\/strong>\/rest\/download\/linux\/aarch\/64 -O SumoCollector_linux_arm64_19_418-7.<strong>sh<\/strong><\/pre>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-bd57d677c73869de7824cedf0a453492\">Before running the script, let\u2019s generate a token to be used for the installation. Back within the Sumo Logic UI, navigate to the \u201cToken\u201d section and create one.<\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1999\" height=\"1345\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/20-k8-image37.png\" alt=\"\" class=\"wp-image-4757\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-bf824acbff700077acbeb32ee4947edb\">Once you have your token, we can now install the collector using the following command:<\/p>\n\n\n\n<pre> SumoCollector_linux_arm64_19_418-7.sh -<strong>q<\/strong> -Vsumo.token_and_url=&lt;your_token&gt;<\/pre>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-dafcd6ee8d823d5618fec3fe147780bd\">Note that the name of the file may change depending on your architecture.<\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-775123ca519b8053e34498bee876c0c2\">Back in the Sumo UI &#8211; you should now see the minikube collector below the Kubernetes collectors we set up in earlier steps:<\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1999\" height=\"1536\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/21-k8-image7.png\" alt=\"\" class=\"wp-image-4758\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-c136c945bc6e1f154155b60ff127be24\">Now we need to tell our collector to ingest the Laurel logs. We can do so by clicking the \u201cAdd\u2026\u201d button next to the collector, then \u201cAdd Source\u201d and then \u201cLocal File\u201d<\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1050\" height=\"1999\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/22-k8-image30.png\" alt=\"\" class=\"wp-image-4759\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-b0cb902b983f642e064da3086028b2bb\">After a few minutes, we should see some Laurel logs trickling in:<\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1999\" height=\"1993\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/23-k8-image10.png\" alt=\"\" class=\"wp-image-4760\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-2e1610679eb6ab09ab8cbde0bc3f462d\">At this point, we have a local Kubernetes cluster setup on a virtual machine. We are sending telemetry from this Kubernetes cluster to a Sumo Logic instance and are also monitoring the host that the cluster is running on via auditd and are using Laurel to transform these auditd logs into JSON format. <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-5bf349d5dde9fd9e7cce18bb8b981b7e\">Now we are ready for the fun stuff, testing out some attacks on our Kubernetes cluster! <\/p>\n\n\n\n<h2 class=\"wp-block-heading has-eigengrau-color has-text-color has-link-color wp-elements-fff954121823c9f6c719119426235a48\" id=\"the_ttps:_attacks_and_detections_for_kubernetes\"><strong>The TTPs: attacks and detections for Kubernetes<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading has-eigengrau-color has-text-color has-link-color wp-elements-45dc92d2cb03848f6cab85ce0216ed7c\" id=\"t1610_\u2013_deploy_container\"><strong>T1610 \u2013 deploy container<\/strong><\/h3>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-e393ca34b581218e96f95c96619865b5\">To dip our toes into the Kubernetes threat detection world, let us build on our basic example of starting an Ubuntu pod, and look at the MITRE \u201c<a href=\"https:\/\/attack.mitre.org\/techniques\/T1610\/\" target=\"_blank\" rel=\"noopener\">Deploy Container<\/a>\u201d category.<\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-d5854509deea15658ab0439d6df7bacf\">If your Ubuntu container is still deployed, go ahead and delete with <span class=\"code2\">kubectl <strong>delete<\/strong> -f ubuntu.yaml<\/span><\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-587a9e88c9891d5f730b817d65ab5220\">We\u2019ll then go ahead and recreate the pod: <span class=\"code2\">kubectl apply -f ubuntu.yaml<\/span><\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-4c7d777451eb55a96904c783f4edb028\">Now let\u2019s look at the following query in Sumo Logic: <\/p>\n\n\n\n<pre>_collector=\"kubernetes-2023-04-20T12:54:16.324Z\"\r\n| %\"object.reason\" <strong>as<\/strong> reason\r\n| %\"object.involvedobject.kind\" <strong>as<\/strong> object_kind\r\n| %\"object.involvedobject.name\" <strong>as<\/strong> object_name\r\n| where reason = \"Created\"\r\n| values(object_kind) <strong>as<\/strong> kinds,values(object_name) <strong>as<\/strong> names<\/pre>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-d4a01ffc4f8ebec87090036c0253f482\">This will show us what kinds of objects are created within our cluster along with their names. You should see something similar to: <\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1490\" height=\"1110\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/24-k8-image31.png\" alt=\"\" class=\"wp-image-4761\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-f99fa72398a278cd44507813797f3fff\">We see our Ubuntu pod hanging out at the bottom, let\u2019s clean the query up a little bit and filter out the system pods as well as the pods necessary for the Sumo Logic collection to take place:<\/p>\n\n\n\n<pre>_collector=\"kubernetes-2023-04-20T12:54:16.324Z\"\r\n| %\"object.reason\" <strong>as<\/strong> reason\r\n| %\"object.involvedobject.kind\" <strong>as<\/strong> object_kind\r\n| %\"object.involvedobject.name\" <strong>as<\/strong> object_name\r\n| <strong>where<\/strong> reason = \"Created\"\r\n| <strong>where<\/strong> !(object_name matches \/(coredns|etcd|<strong>my<\/strong>-release|kube-|storage-provisioner)\/)\r\n| values(object_kind) <strong>as<\/strong> kinds,values(object_name) <strong>as<\/strong> names<\/pre>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-048f786d99c9b163fb30898731b0b051\">Through some regular expression tweaking on line 6 of our query, we exclude pods that we may not want to see in this particular detection logic, and now we should be left with only our Ubuntu pod showing up in the search results. We highly recommend a regular <a href=\"https:\/\/regex101.com\/\" target=\"_blank\" rel=\"noopener\">expression testing site<\/a> of some kind as a resource to aid you in crafting any type of regular expressions. <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-e849333ab7ab53544d6233d29bcfd8f6\">That\u2019s pretty cool, but didn\u2019t we spend a bunch of time setting up host logging as well, and can that be used to provide us some additional coverage? Great question; yes it absolutely can!<\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-7f008b4069764610f26cb1b7a34f7b53\">We may not be super familiar with auditd and Laurel, but we know that when we created our Ubuntu pod, we used a yaml file called \u201cubuntu.yaml\u201d so let\u2019s start there with a super quick search: <\/p>\n\n\n\n<pre>_collector=\"minikube\" ubuntu.yaml<\/pre>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1999\" height=\"1133\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/25-k8-image43.png\" alt=\"\" class=\"wp-image-4762\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-3f66e2cdaaaf9b6e57efeff87f1de231\">After rolling up our proverbial sleeves and getting a handle on the data, we can craft the following query which is annotated: <\/p>\n\n\n\n<pre>_collector=\"minikube\" \r\n| %\"syscall.comm\" as binary_name \/\/renaming fields for ease of <strong>use<\/strong>\r\n| %\"proctitle.argv\" <strong>as<\/strong> command_line \/\/renaming <strong>fields<\/strong> <strong>for<\/strong> ease <strong>of<\/strong> <strong>use<\/strong>\r\n| <strong>where<\/strong> binary_name = \"kubectl\" \/\/looking <strong>for<\/strong> the kubectl binary used \r\n| <strong>where<\/strong> command_line matches \/<strong>apply<\/strong>\/ \/\/matching <strong>on<\/strong> the \"apply\" verb\r\n| <strong>where<\/strong> !(command_line matches \/\/etc\/kubernetes\/) \/\/<strong>excluding<\/strong> <strong>some<\/strong> <strong>system<\/strong> <strong>events<\/strong>\r\n| <strong>values<\/strong>(command_line)<\/pre>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-b6f22d1d563100c446fd370955c6af5c\">And looking at the results, we see our <a href=\"https:\/\/www.sumologic.com\/blog\/kubectl-logs\/\">kubectl<\/a> apply command: <\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1999\" height=\"746\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/26-k8-image12-v2.png\" alt=\"\" class=\"wp-image-4763\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-7fc67f3f1560de371b03f6ea3dc40770\">This is a great example of why host logs are important for cloud native technologies such as Kubernetes &#8211; of course this assumes that your cluster is not hosted within a cloud service of some kind. <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-319c1c5cc456d9937e0d83f4a85158e3\">In our instance, however, we were able to gain visibility into a container being deployed in the environment from both the host and Kubernetes level &#8211; sweet! <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-42f76ebd81ca266ac92b0a2333fa292b\">Let\u2019s not forget to track these executions in Vectr. <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-707d220902541ab3b5e9178e1ba5e07f\">We can navigate to the environment we set up earlier and click on the \u201cCreate New &#8221; button on the right hand side within the Vectr UI and create a new Assessment:<\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1999\" height=\"369\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/27-k8-image40.png\" alt=\"\" class=\"wp-image-4764\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-203435da567220ffd5a0f793d4494c1d\">Once within the assessment, we can click on \u201cAssessment Actions\u201d and click on \u201cCreate New Campaign\u201d &#8211; so the overall structure here is an Environment, which contains an assessment, which contains a campaign, with the campaign containing our test cases. <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-d205dc772837a1d727a3caeab55e7fa5\">From the campaign menu, click on \u201cCampaign Actions \u2192 New Test Case\u201d:<\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1999\" height=\"168\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/28-k8-image13.png\" alt=\"\" class=\"wp-image-4765\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-bf72c1ff45c46400166d661e2c53a17b\">We can then enter the details of our test case: <\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1999\" height=\"1329\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/29-k8-image35.png\" alt=\"\" class=\"wp-image-4766\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-bfcb09e804b8768cee3bcc0571f3da42\">It should be noted that Vectr provides a ton of options for tracking, including tracking time to alert and various sources &#8211; here we are just scratching the surface to get some basic metrics of our executions. <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-74fb82443d6789eb945bdbf5e86b94c6\">Once we click on \u201cSave\u201d we should see our first test case in Vectr. <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-6eb9a886253cd89ebe885f978c3d86ff\">Recall, we did two executions\/variations of the same technique, so we can clone this test case to track our host-based detection as well. <\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1999\" height=\"1026\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/30-k8-image27.png\" alt=\"\" class=\"wp-image-4767\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-ebd3fa372b540d91954df817b65ee8ec\">Once you click the clone button, you will see a window pop up with customizable parameters: <\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1999\" height=\"734\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/31-k8-image44.png\" alt=\"\" class=\"wp-image-4768\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-01110ab9412e0a1dbbf87f4e2b8325ca\">We can then rename this second test to something like \u201cDeploy Container &#8211; Host Based\u201d<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-eigengrau-color has-text-color has-link-color wp-elements-1c94b1e345322dbf3ca5c306e974b54c\" id=\"t1609_\u2013_container_administration_command\"><strong>T1609 \u2013 Container administration command<\/strong><\/h3>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-efd71f4e657a80490b5476ddf3d2f8db\">Let\u2019s look at another example, continuing to use our deployed Ubuntu pod and perform a kubectl exec command in order to get a bash shell into our pod. <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-00364797cc53e560186e81955c9a5b6b\">Before running the command, we need to add the following entry into our audit.rules auditd configuration file so that we log the appropriate telemetry: <span class=\"code2\">-w \/usr\/local\/bin\/minikube -p x -k minikube<\/span> and then restart auditd: <\/p>\n\n\n\n<pre>sudo pkill -HUP auditd<\/pre>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-7d1cb8f90e52fd8a320ee7bbca071c64\">Now we can run our command: <\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1999\" height=\"111\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/32-k8-image1.png\" alt=\"\" class=\"wp-image-4769\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-ae7554f7474e3fe83f789bfa0ac883ee\">We take a look at the Kubernetes logs and fail to find any telemetry at this level, so lets pivot to the host level with the following query: <\/p>\n\n\n\n<pre>_collector=\"minikube\" \r\n| %\"syscall.comm\" <strong>as<\/strong> binary_name \/\/renaming fields <strong>for<\/strong> ease of use\r\n| %\"proctitle.argv\" <strong>as<\/strong> command_line \/\/renaming fields <strong>for<\/strong> ease of use\r\n| where binary_name = \"minikube\" \/\/looking <strong>for<\/strong> minikube here <strong>as<\/strong> we aliased kubectl <strong>earlier<\/strong> - normally this would just <strong>be<\/strong> kubectl\r\n| values(command_line) <strong>as<\/strong> command_line,values(binary_name) <strong>as<\/strong> binary_name<\/pre>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-46ae89c04365dfa4828237899eb8cf68\">And we get our results: <\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1999\" height=\"914\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/26-k8-image12.png\" alt=\"\" class=\"wp-image-4770\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-f59c94d9b2dcf94c187ee2f3def3a554\">Now that we know what command line value to look for, let\u2019s tighten up our query a little bit, using some regular expressions. <\/p>\n\n\n\n<pre>_collector=\"minikube\" \r\n| %\"syscall.comm\" <strong>as<\/strong> binary_name \/\/renaming fields <strong>for<\/strong> ease of use\r\n| %\"proctitle.argv\" <strong>as<\/strong> command_line \/\/renaming fields <strong>for<\/strong> ease of use\r\n| where binary_name = \"minikube\" \/\/looking <strong>for<\/strong> minikube here <strong>as<\/strong> we aliased kubectl <strong>earlier<\/strong> - normally this would just <strong>be<\/strong> kubectl\r\n| where command_line matches \/exec|tty|stdin\/ \/\/looking <strong>for<\/strong> <strong>a<\/strong> <strong>command<\/strong> line that conains exec, tty or stdin \r\n| values(command_line) <strong>as<\/strong> command_line,values(binary_name) <strong>as<\/strong> binary_name<\/pre>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-3f7eb1bc69df5e0a15895910d19693dc\">Now we can go ahead and add this execution to our Vectr for tracking purposes. <\/p>\n\n\n\n<h3 class=\"wp-block-heading has-eigengrau-color has-text-color has-link-color wp-elements-45a1928ee00c34fda1783abe4efc022c\" id=\"t1613_-_container_and_resource_discovery\"><strong>T1613 &#8211; Container and resource discovery<\/strong><\/h3>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-65175f158ec826394bf7d14d441623bc\">Discovery and enumeration type techniques are often difficult to detect as administrators and developers may run these types of commands as part of their normal workflows. Let\u2019s run some basic Kubernetes enumeration commands on our local Minikube cluster:<\/p>\n\n\n\n<pre>kubectl config get-users\r\nkubectl config get-clusters\r\nkubectl auth can-i --list\r\nkubectl get roles\r\nkubectl get secrets\r\nkubectl get serviceaccounts\r\nkubectl get deployments\r\nkubectl get pods -A<\/pre>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-54aac816786912517d7e45e4d7547f5f\">Now let\u2019s modify a query we used earlier in order to get a sense of how the telemetry looks:<\/p>\n\n\n\n<pre>_collector=\"minikube\" \r\n| %\"syscall.comm\" <strong>as<\/strong> binary_name \/\/renaming fields <strong>for<\/strong> ease of use\r\n| %\"proctitle.argv\" <strong>as<\/strong> command_line \/\/renaming fields <strong>for<\/strong> ease of use\r\n| where binary_name = \"minikube\" \/\/looking <strong>for<\/strong> minikube here <strong>as<\/strong> we aliased kubectl <strong>earlier<\/strong> - normally this would just <strong>be<\/strong> kubectl\r\n| values(command_line) <strong>as<\/strong> command_line,values(binary_name) <strong>as<\/strong> binary_name<\/pre>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-46ae89c04365dfa4828237899eb8cf68\">And we get our results: <\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1676\" height=\"738\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/34-k8-image5.png\" alt=\"\" class=\"wp-image-4771\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-23b4f66789affd154912ab055828fa75\">We see the command line values with \u201cminikube\u201d followed by \u201ckubectl\u201d as Minikube uses its own version of kubectl &#8211; recall that we created an alias that mapped minikube kubectl to just kubectl in earlier steps. In production environments, this command line would show up as just \u201ckubectl\u201d <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-3794d22ffc367402e52a75310633079b\">In order to find this activity, we can do some string matching on things like \u201cauth can-i\u201d or \u201ckubectl get\u201d &#8211; however, we probably do not want to find normal or day-to-day administrative activity. <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-31a215575c9f7d02eefc5377b5e4a035\">Another approach we can take is to slice up our data by time slices and score each of these commands, summing up the score based on the time slice. Our hypothesis here is that threat actors might perform a bunch of enumeration in a short time period, whereas a developer or administrator may not exhibit such behavior. <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-895901bd46437818d831d9b980e0fca5\">Let\u2019s take a look at what this looks like in query format:<\/p>\n\n\n\n<pre>_collector=\"minikube\" \r\n\r\n\/\/ Initialize variables\r\n| 0 as score\r\n| \"\" as messageQualifiers\r\n| \"\" as messageQualifiers1\r\n| \"\" as messageQualifiers2\r\n\r\n\/\/ Setting our time slice\r\n| timeslice 1h\r\n\r\n\/\/ Renaming some fields for ease of <strong>use<\/strong>\r\n| %\"syscall.comm\" <strong>as<\/strong> binary_name \r\n| %\"proctitle.argv\" <strong>as<\/strong> command_line\r\n\r\n\/\/ <strong>Only<\/strong> looking <strong>at<\/strong> the aliased minikube binary \r\n| <strong>where<\/strong> binary_name = \"minikube\" \/\/looking <strong>for<\/strong> minikube here <strong>as<\/strong> we aliased kubectl earlier - normally this would just be kubectl\r\n\r\n\/\/ Setting our qualifiers, we look <strong>for<\/strong> can-i, <strong>get<\/strong> <strong>or<\/strong> config, we can <strong>add<\/strong> more qualiifers here depending <strong>on<\/strong> the environment\r\n| <strong>if<\/strong>(command_line matches \/(can-i)\/,<strong>concat<\/strong>(messageQualifiers, \"Kubectl auth enumeration: \",command_line,\"nBy Binary: \" ,binary_name,\"n# score: 3n\"),\"\") <strong>as<\/strong> messageQualifiers\r\n| <strong>if<\/strong>(command_line matches \/(<strong>get<\/strong>)\/,<strong>concat<\/strong>(messageQualifiers1, \"Kubectl cluster enumeration: \",command_line,\"nBy Binary: \" ,binary_name,\"n# score: 3n\"),\"\") <strong>as<\/strong> messageQualifiers1\r\n| <strong>if<\/strong>(command_line matches \/(config)\/,<strong>concat<\/strong>(messageQualifiers2, \"Kubectl config enumeration: \",command_line,\"nBy Binary: \" ,binary_name,\"n# score: 3n\"),\"\") <strong>as<\/strong> messageQualifiers2\r\n\r\n\/\/ Putting our qualifiers together \r\n| <strong>concat<\/strong>(messageQualifiers,messageQualifiers1,messageQualifiers2) <strong>as<\/strong> q \/\/Concact all the qualifiers together\r\n\r\n\/\/ Extracting the score <strong>from<\/strong> the qualifiers \r\n| <strong>parse<\/strong> regex <strong>field<\/strong>=q \"score:s(?&lt;score&gt;-?d+)\" multi \r\n\r\n\/\/<strong>Only<\/strong> <strong>return<\/strong> results <strong>if<\/strong> there <strong>is<\/strong> a qualifier <strong>of<\/strong> <strong>some<\/strong> kind\r\n| <strong>where<\/strong> !isEmpty(q) \r\n\r\n\/\/<strong>Return<\/strong> our <strong>full<\/strong> qualifiers <strong>and<\/strong> <strong>sum<\/strong> the score <strong>by<\/strong> timeslice\r\n| <strong>values<\/strong>(q) <strong>as<\/strong> qualifiers,<strong>sum<\/strong>(score) <strong>as<\/strong> score <strong>by<\/strong> _timeslice <\/pre>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-d84f2848b6d9b7273e579d90ec7f1205\">Looking  at the results, we can see our numerous enumeration commands bubbled up with a score of 33, which is much higher than our \u201cnormal\u201d administrative activity which occurred on the previous day with a score of 12.<\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-1f266d3a0883b014921dca41d8a75230\">Please keep in mind that all the parameters and scoring within these queries can be tweaked depending on your particular set ups and architecture. <\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1999\" height=\"1458\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/35-k8-image20.png\" alt=\"\" class=\"wp-image-4772\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-c6d95d1fd8a271b6d4fc3148dd96ee98\">Let\u2019s not forget to add this execution to our Vectr tracking.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-eigengrau-color has-text-color has-link-color wp-elements-ef89671e04f36d52348e947475039b1c\" id=\"t1496_-_resource_hijacking\"><strong>T1496 &#8211; Resource hijacking<\/strong><\/h3>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-829134794b978741995a6c60288e5e53\">Once threat actors compromise a Kubernetes cluster, often a deployment of some kind of crypto currency miner follows. <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-82043e14af11a1d27ece42bea9dcaaa5\">This kind of technique is difficult to replicate in a home lab environment, as we probably do not want to be deploying coin miners on our virtual machines. <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-7d37daa3dd5607829edc7fbfc49cf26e\">However, we can exhaust the resources of our Kubernetes cluster in other ways \u2013 before we dive in it needs to be noted that this technique is not recommended to execute unless you are comfortable with maxing out resources on whatever compute platform your Minikube cluster is running on. <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-d40ff6f420524d46189aaf403b6d6385\"><strong>It goes without saying that this is not recommended for production or even test environments. <\/strong><\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-e31bb2eb3371df81fd0ba51c22a689b3\">Although we all want to avoid stress, we can use the \u201c<a href=\"https:\/\/linux.die.net\/man\/1\/stress\" target=\"_blank\" rel=\"noopener\">stress<\/a>\u201d Linux utility in order to stress test the CPU on a Kubernetes pod &#8211; we can also create a deployment that goes ahead and creates many replicas of these pods, all running the stress utility in order to generate a high CPU load on our Kubernetes cluster. <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-b2f0490322f545365bbe3c8b2132eb75\">Here is what the YAML looks like:<\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1999\" height=\"1014\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/36-k8-image24.png\" alt=\"\" class=\"wp-image-4773\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-b1adf2199d133c89febaac5a8bd7278d\">If you choose to deploy this on your cluster, you will need to give it some time for all the replicas to spin up. <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-94557be030fb4f45dfdbcfc61e0f46f7\">After waiting for a few minutes, we can navigate back to Sumo Logic and take a look at some dashboards that were provisioned for us when we set up the Kubernetes monitoring solution: <\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1999\" height=\"1111\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/37-k8-image19.png\" alt=\"\" class=\"wp-image-4774\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-2085365481f449476d86650fa7528c91\">Once you navigate to the \u201cKubernetes &#8211; Cluster\u201d page, you should see the CPU usage chart well into the red: <\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1999\" height=\"604\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/38-k8-image25.png\" alt=\"\" class=\"wp-image-4775\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-6631da7d94fd1d78423490c84f2d327a\">As a final step, we can click the \u201cbell\u201d icon on the top of the Sumo Logic menu to see some alerts waiting for us:<\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1999\" height=\"434\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/39-k8-image9.png\" alt=\"\" class=\"wp-image-4776\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-c5014d26ce371ca2804a46960d08ef44\">Clicking into the \u201cKubernetes &#8211; Node CPU Utilization High\u201d alert will bring us to the following screen where we can see some additional information: <\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1916\" height=\"1999\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/40-k8-image11.png\" alt=\"\" class=\"wp-image-4777\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-3aa44fb23d35a3290ed3c6ad90a8e79f\">We can go ahead and add this test case to our Vectr campaign. <\/p>\n\n\n\n<h2 class=\"wp-block-heading has-eigengrau-color has-text-color has-link-color wp-elements-b691229fc5226d9cdd1db3277ce72d0c\" id=\"vectr_wrap-up\"><strong>Vectr wrap-up<\/strong><\/h2>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-e438907980eb403589b543da258fa8f6\">At this point, we should have five test cases in our Vectr instance, with the escalation path looking something like this: <\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1782\" height=\"1108\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/41-k8-image21.png\" alt=\"\" class=\"wp-image-4778\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-c06b102254cc100d729b8d0c220926bc\">If we navigate to \u201cReporting \u2192 MITRE ATT&amp;CK Coverage\u201d within Vectr: <\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1999\" height=\"1030\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/42-k8-image34.png\" alt=\"\" class=\"wp-image-4779\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-0abdf1963e5728a442c473d101740731\">We should be greeted with a nice MITRE ATT&amp;CK matrix showing us our test cases:<\/p>\n\n\n<div class=\"e-img \">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1999\" height=\"677\" src=\"http:\/\/www.sumologic.com\/wp-content\/uploads\/43-k8-image18.png\" alt=\"\" class=\"wp-image-4780\" title=\"\"><\/figure>\n<\/div>\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-126a4bd7961ce66e05afeb3634e66615\">From here, we can click the red \u201c&amp;\u201d symbol on the top right and export this layer into a JSON file which can then be loaded into the <a href=\"https:\/\/mitre-attack.github.io\/attack-navigator\/\" target=\"_blank\" rel=\"noopener\">MITRE ATT&amp;CK Navigator<\/a><\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-46583f84d34e38f3fde5b58c343266da\">Now you know how to set up a local Kubernetes cluster with host and Kubernetes cluster level visibility, with all the telemetry being fed into a free Sumo Logic instance. We have also used Vectr to track and report on our test cases.<\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-b20d40edd185a388b45986802a408a2f\">This setup used freely available tooling all hosted on a local virtual machine, this type of setup may be preferable for many folks who do not want to be on the hook for potentially large cloud bills. <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-64437af7862eb44e1888f6338084e091\">This type of environment also provides users with the ability to snapshot and recover a virtual machine in order to try out various configurations and threat detection use cases. <\/p>\n\n\n\n<p class=\"has-delft-blue-color has-text-color has-link-color wp-elements-3436a10bca8f5cf0d1e39ed96f3f9901\"><a href=\"https:\/\/www.sumologic.com\/solutions\/kubernetes\/\">Learn more about how Sumo Logic can help you with your Kubernetes monitoring<\/a>.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div><\/section>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":32,"featured_media":0,"template":"","meta":{"_acf_changed":false,"show_custom_date":false,"custom_date":"","featured":false,"featured_image":0,"learn_more_label":"","image_alt_text":"","learn_more_type":"","show_popup":false,"learn_more_link_file":0,"event_date":false,"event_start_date":"","event_end_date":"","place_holder_image_url":"","post_reading_time":"17","notification_enabled":false,"notification_text":"","notification_logo":"","notification_expiration_time":0,"is_enable_transparent_header":false,"selected_taxonomy_terms":{"blog-category":[127],"blog-tag":[]},"selected_primary_terms":[],"learn_more_link":[],"featured_page_list":[],"notification_enabled_post_list":[],"_gspb_post_css":"","_relevanssi_hide_post":"","_relevanssi_hide_content":"","_relevanssi_pin_for_all":"","_relevanssi_pin_keywords":"","_relevanssi_unpin_keywords":"","_relevanssi_related_keywords":"","_relevanssi_related_include_ids":"","_relevanssi_related_exclude_ids":"","_relevanssi_related_no_append":"","_relevanssi_related_not_related":"","_relevanssi_related_posts":"71501,4668,71369","_relevanssi_noindex_reason":"","inline_featured_image":false,"footnotes":""},"blog-category":[127],"blog-tag":[],"class_list":["post-4781","blog","type-blog","status-publish","hentry","blog-category-secops-security"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.sumologic.com\/wp-json\/wp\/v2\/blog\/4781","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sumologic.com\/wp-json\/wp\/v2\/blog"}],"about":[{"href":"https:\/\/www.sumologic.com\/wp-json\/wp\/v2\/types\/blog"}],"author":[{"embeddable":true,"href":"https:\/\/www.sumologic.com\/wp-json\/wp\/v2\/users\/32"}],"version-history":[{"count":3,"href":"https:\/\/www.sumologic.com\/wp-json\/wp\/v2\/blog\/4781\/revisions"}],"predecessor-version":[{"id":26813,"href":"https:\/\/www.sumologic.com\/wp-json\/wp\/v2\/blog\/4781\/revisions\/26813"}],"wp:attachment":[{"href":"https:\/\/www.sumologic.com\/wp-json\/wp\/v2\/media?parent=4781"}],"wp:term":[{"taxonomy":"blog-category","embeddable":true,"href":"https:\/\/www.sumologic.com\/wp-json\/wp\/v2\/blog-category?post=4781"},{"taxonomy":"blog-tag","embeddable":true,"href":"https:\/\/www.sumologic.com\/wp-json\/wp\/v2\/blog-tag?post=4781"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}