{
    "id": "38913201-1474-4ca5-a2f5-0d7e0f548a9e",
    "name": "Effectively Using the ELK Stack",
    "slug": "effectively-using-the-elk-stack",
    "status": "published",
    "lab_type": "pta",
    "is_sample": false,
    "duration_in_seconds": 1800,
    "metadata": {
        "courses": [
            "e999ee53-2459-4411-a3f3-a560fbcf4c86",
            "5c7838a9-c6c4-4062-a3b2-ec2e908c19f2"
        ],
        "pta_sdn": "260",
        "collections": [],
        "pta_namespace": "my.ine",
        "learning_paths": [],
        "has_published_parent": true
    },
    "session": null,
    "company": "a491bc32-c056-4946-9169-cc053387bada",
    "created": "2022-07-18T16:15:47.467412Z",
    "modified": "2025-06-30T21:12:03.470343Z",
    "is_beta": false,
    "lab_objectives": [],
    "main_learning_area": "3e1aa06f-2e9f-4789-b50d-aa027ad8dcfa",
    "learning_areas": [
        {
            "id": "3e1aa06f-2e9f-4789-b50d-aa027ad8dcfa",
            "name": "Cyber Security",
            "slug": "cyber-security"
        }
    ],
    "categories": [],
    "tags": [],
    "difficulty": "professional",
    "is_web_access": false,
    "is_lab_experience": false,
    "is_featured": false,
    "cve": null,
    "severity": null,
    "year": null,
    "classification": null,
    "is_trackable": false,
    "cpe_credits": null,
    "is_skill_check": false,
    "external_url": "",
    "solution_video": null,
    "explanation_video": null,
    "description": "# Effectively Using ELK\n\n## LAB 9\n\n# Scenario\n\nThe organization you work for is evaluating a customized [ELK stack](https://www.elastic.co/elk-stack) as a SIEM solution to enhance its intrusion detection capabilities. The SOC manager tasked you with getting familiar with the ELK stack and its detection capabilities. He also tasked you with translating common attacker behavior into ELK searches.\n\n**Note**: Credits to [Teymur Kheirkhabarov](https://twitter.com/HeirhabarovT) for the dataset this lab uses and some of the detection techniques covered.\n\n# Learning Objectives\n\nThe learning objective of this lab, is to get familiar with ELK stack's architecture and detection capabilities.\n\n# Introduction To ELK\n\n[Elastic](https://www.elastic.co/)'s ELK is an open source stack that consists of three applications (Elasticsearch, Logstash and Kibana) working in synergy to provide users with end-to-end search and visualization capabilities to analyze and investigate log file sources in real time.\n\nELK's architecture, at a high level, is the following.\n\n![ELK Stack Architecture](https://assets.ine.com/cybersecurity-lab-images/37b8b3a1-190c-4056-95b9-ae9de63cd8d1/image3.png)\n\nOn demanding/data-heavy environments, ELK's architecture can be reinforced by Kafka, RabbitMQ and Redis for buffering and resilience and by ngnix for security.\n\n![](https://assets.ine.com/cybersecurity-lab-images/37b8b3a1-190c-4056-95b9-ae9de63cd8d1/image4.png)\n\nLet's dive into all of ELK's components.\n\n-   **Elasticsearch** is a NoSQL database based on the Lucene search engine and built with RESTful APIs. It is essentially the index, store and query application of the ELK stack. It provides users with the capability to perform advanced queries and analytics operations against the log file records processed by Logstash.\n\n-   **Logstash** is the tool responsible for the collection, transformation and transport of log file records. The great thing about Logstash is that it can unify data from disparate sources and also normalize them. Logstash has three areas of function.\n1.  **Process input** of the log file records from remote locations into a machine understandable format. Logstash can receive records through a [variety of ways](https://www.elastic.co/guide/en/logstash/current/input-plugins.html) such as reading from a flat file, reading events from a TCP socket or directly reading syslog messages. When Logstash completes processing input it proceeds to the next function.\n    \n2.  [**Transform and enrich log records**](https://www.elastic.co/guide/en/logstash/current/filter-plugins.html). Logstash provides users with numerous methods to make changes to the format (and even content) of a log record. Specifically, filter plugins exist that can perform intermediary processing on an event (most of the times based on a predefined condition).         Once a log record is transformed Logstash processes it.\n    \n3.  **Send log records** to Elasticsearch by utilizing any of the [output plugins](https://www.elastic.co/guide/en/logstash/current/output-plugins.html).\n-   **Kibana** is the tool used for visualizing the Elasticsearch documents. Through Kibana users can view the data stored in Elasticsearch and perform queries against them. It also facilitates the understanding of query results through tables, charts and custom dashboards.\n\n**Note**: **Beats** is an additional download that should be installed in every remote location for its logs to be shipped to the Logstash component.\n\n**ELK's Search:**\n\nAs incident responders, chances are that we will spend the majority of our ELK-time inside Kibana. For this reason, we will focus on submitting searches through Kibana.\n\n![](https://assets.ine.com/cybersecurity-lab-images/37b8b3a1-190c-4056-95b9-ae9de63cd8d1/image5.png)\n\n- [x] Kibana searches are usually formatted as *FieldName:SearchTerm*. Fields and search terms are case sensitive.\n\n- [x] Boolean operators like AND, OR are supported (and are sometimes implied).\n\n- [x] Wildcards and free text searches can be used, but use sparingly.\n\nIn this lab's context, we will focus on basic Kibana operations and searches that will help you to better organize and analyze what ELK has ingested.\n\n# Recommended tools\n\n-   ELK\n\n-   Use a Firefox browser to connect to Kibana [**http://demo.ine.local:5601**](http://demo.ine.local:5601/)",
    "description_html": "<h1>Effectively Using ELK</h1>\n<h2>LAB 9</h2>\n<h1>Scenario</h1>\n<p>The organization you work for is evaluating a customized <a href=\"https://www.elastic.co/elk-stack\">ELK stack</a> as a SIEM solution to enhance its intrusion detection capabilities. The SOC manager tasked you with getting familiar with the ELK stack and its detection capabilities. He also tasked you with translating common attacker behavior into ELK searches.</p>\n<p><strong>Note</strong>: Credits to <a href=\"https://twitter.com/HeirhabarovT\">Teymur Kheirkhabarov</a> for the dataset this lab uses and some of the detection techniques covered.</p>\n<h1>Learning Objectives</h1>\n<p>The learning objective of this lab, is to get familiar with ELK stack's architecture and detection capabilities.</p>\n<h1>Introduction To ELK</h1>\n<p><a href=\"https://www.elastic.co/\">Elastic</a>'s ELK is an open source stack that consists of three applications (Elasticsearch, Logstash and Kibana) working in synergy to provide users with end-to-end search and visualization capabilities to analyze and investigate log file sources in real time.</p>\n<p>ELK's architecture, at a high level, is the following.</p>\n<p><img alt=\"ELK Stack Architecture\" src=\"https://assets.ine.com/cybersecurity-lab-images/37b8b3a1-190c-4056-95b9-ae9de63cd8d1/image3.png\" /></p>\n<p>On demanding/data-heavy environments, ELK's architecture can be reinforced by Kafka, RabbitMQ and Redis for buffering and resilience and by ngnix for security.</p>\n<p><img alt=\"\" src=\"https://assets.ine.com/cybersecurity-lab-images/37b8b3a1-190c-4056-95b9-ae9de63cd8d1/image4.png\" /></p>\n<p>Let's dive into all of ELK's components.</p>\n<ul>\n<li>\n<p><strong>Elasticsearch</strong> is a NoSQL database based on the Lucene search engine and built with RESTful APIs. It is essentially the index, store and query application of the ELK stack. It provides users with the capability to perform advanced queries and analytics operations against the log file records processed by Logstash.</p>\n</li>\n<li>\n<p><strong>Logstash</strong> is the tool responsible for the collection, transformation and transport of log file records. The great thing about Logstash is that it can unify data from disparate sources and also normalize them. Logstash has three areas of function.</p>\n</li>\n<li>\n<p><strong>Process input</strong> of the log file records from remote locations into a machine understandable format. Logstash can receive records through a <a href=\"https://www.elastic.co/guide/en/logstash/current/input-plugins.html\">variety of ways</a> such as reading from a flat file, reading events from a TCP socket or directly reading syslog messages. When Logstash completes processing input it proceeds to the next function.</p>\n</li>\n<li>\n<p><a href=\"https://www.elastic.co/guide/en/logstash/current/filter-plugins.html\"><strong>Transform and enrich log records</strong></a>. Logstash provides users with numerous methods to make changes to the format (and even content) of a log record. Specifically, filter plugins exist that can perform intermediary processing on an event (most of the times based on a predefined condition).         Once a log record is transformed Logstash processes it.</p>\n</li>\n<li>\n<p><strong>Send log records</strong> to Elasticsearch by utilizing any of the <a href=\"https://www.elastic.co/guide/en/logstash/current/output-plugins.html\">output plugins</a>.</p>\n</li>\n<li><strong>Kibana</strong> is the tool used for visualizing the Elasticsearch documents. Through Kibana users can view the data stored in Elasticsearch and perform queries against them. It also facilitates the understanding of query results through tables, charts and custom dashboards.</li>\n</ul>\n<p><strong>Note</strong>: <strong>Beats</strong> is an additional download that should be installed in every remote location for its logs to be shipped to the Logstash component.</p>\n<p><strong>ELK's Search:</strong></p>\n<p>As incident responders, chances are that we will spend the majority of our ELK-time inside Kibana. For this reason, we will focus on submitting searches through Kibana.</p>\n<p><img alt=\"\" src=\"https://assets.ine.com/cybersecurity-lab-images/37b8b3a1-190c-4056-95b9-ae9de63cd8d1/image5.png\" /></p>\n<ul>\n<li>\n<p>[x] Kibana searches are usually formatted as <em>FieldName:SearchTerm</em>. Fields and search terms are case sensitive.</p>\n</li>\n<li>\n<p>[x] Boolean operators like AND, OR are supported (and are sometimes implied).</p>\n</li>\n<li>\n<p>[x] Wildcards and free text searches can be used, but use sparingly.</p>\n</li>\n</ul>\n<p>In this lab's context, we will focus on basic Kibana operations and searches that will help you to better organize and analyze what ELK has ingested.</p>\n<h1>Recommended tools</h1>\n<ul>\n<li>\n<p>ELK</p>\n</li>\n<li>\n<p>Use a Firefox browser to connect to Kibana <a href=\"http://demo.ine.local:5601/\"><strong>http://demo.ine.local:5601</strong></a></p>\n</li>\n</ul>",
    "tasks": "# Tasks\n\n## Task 1: Add any fields you see fit to enhance your understanding of the data\n\nOnce you connect to Kibana you will notice that you are presented with a documents table that consists of two columns only. Add any fields you consider helpful so that you gain a better understanding of the events gathered.\n\n## Task 2: Create an actionable visualization\n\nExperiment with Kibana's visualizations. First, identify all users included in the dataset and then try to create a visualization that will enable you to quickly identify suspicious or anomalous behavior. Choose any behavior you want to detect.... (for which you have data of course).\n\n## Task 3: Create a search to identify files that are named like system processes\n\nIt is a known fact that attackers try to blend in by naming their malware like legitimate Windows processes. Create an ELK search to identify this behavior.\n\n**Hint**: Obviously such files will not reside where their legitimate counterparts are located, but elsewhere.\n\n## Task 4: Create a search to identify suspicious services interacting with an executable from the Windows folder\n\nThe addition of a new service is something worth analyzing. Attackers oftentimes leverage Windows services for both exploitation and persistence purposes.\n\nIt is not uncommon to see attacker-derived services interacting with an executable from the Windows folder. Create an ELK search to identify this behavior.\n\n**Hint**: Identify Windows Security Log Event IDs and Windows Event IDs related to service creation. Check the following too. <https://github.com/palantir/windows-event-forwarding/tree/master/AutorunsToWinEventLog>\n\n## Task 5: Create a search to identify suspicious code injection\n\nAttackers are known for performing code injection against running processes for exploitation or evasion purposes. Create an ELK search to identify this behavior, leveraging the available data.\n\n**Hint**: Carefully go through the following resource (especially the detection part) <https://attack.mitre.org/techniques/T1055/>. Combine what you read in the aforementioned resource with one related Sysmon Event ID.\n\n## Task 6: Create a search to identify possible privilege escalation via weak service permissions\n\nIt is not uncommon in Windows environments to see services running with SYSTEM privileges. It is also not uncommon to see such services having lax permissions. Specifically, oftentimes untrusted groups (or users) have privileged access to a service or permissions over the folder where the binary of the service is stored.\n\nAttackers are known to leverage such lax service permissions to escalate their privileges.\n\n**Hints**:\n\n1.  Focus on the **sc** executable (which is related to creating, configuring and deleting Windows services) and the *start* or *sdshow* options (used when an attacker wants more granular details about a service's permissions)\n\n2.  To launch their own executable (with higher privileges) attackers will have to tamper with another **sc** option. Try to think which option is that...\n\n## Task 7: Create a search to identify possible Windows session hijacking\n\nBy design, a privileged Windows user who can perform command execution with SYSTEM-level privileges can hijack any currently logged in user's RDP session, without being prompted to enter his/her credentials. This behavior and its root cause are described in the following resource <http://www.korznikov.com/2017/03/0-day-or-feature-privilege-escalation.html>.\n\nCreate a search to identify possible Windows session hijacking through the behavior described above.\n\n**Hint**: The Windows executable that attackers leverage to perform the above is **tscon**.\n\n## Task 8: Create a search to identify the whoami command being executed with System privileges\n\nWhen attackers gain access to a system they usually execute commands such as *whoami* to identify their level of access. You can leverage this attacker routine to detect intrusions.\n\nCreate a search to detect the *whoami* command being executed with SYSTEM-level privileges.\n\n## Task 9: Create a search to identify LSASS loading a library not signed by Microsoft\n\nBy the time a user logs in to a Windows system the Local Security Authority Subsystem Service (LSASS) process's memory is filled with user and other credentials. As you can imagine, the LSASS process is a process worth monitoring.\n\nCreate a search to identify LSASS loading a library not signed by Microsoft.\n\n**Hint**: Sysmon contains an Event ID that can assist in monitoring the DLLs being loaded by a specific process.",
    "tasks_html": "<h1>Tasks</h1>\n<h2>Task 1: Add any fields you see fit to enhance your understanding of the data</h2>\n<p>Once you connect to Kibana you will notice that you are presented with a documents table that consists of two columns only. Add any fields you consider helpful so that you gain a better understanding of the events gathered.</p>\n<h2>Task 2: Create an actionable visualization</h2>\n<p>Experiment with Kibana's visualizations. First, identify all users included in the dataset and then try to create a visualization that will enable you to quickly identify suspicious or anomalous behavior. Choose any behavior you want to detect.... (for which you have data of course).</p>\n<h2>Task 3: Create a search to identify files that are named like system processes</h2>\n<p>It is a known fact that attackers try to blend in by naming their malware like legitimate Windows processes. Create an ELK search to identify this behavior.</p>\n<p><strong>Hint</strong>: Obviously such files will not reside where their legitimate counterparts are located, but elsewhere.</p>\n<h2>Task 4: Create a search to identify suspicious services interacting with an executable from the Windows folder</h2>\n<p>The addition of a new service is something worth analyzing. Attackers oftentimes leverage Windows services for both exploitation and persistence purposes.</p>\n<p>It is not uncommon to see attacker-derived services interacting with an executable from the Windows folder. Create an ELK search to identify this behavior.</p>\n<p><strong>Hint</strong>: Identify Windows Security Log Event IDs and Windows Event IDs related to service creation. Check the following too. <a href=\"https://github.com/palantir/windows-event-forwarding/tree/master/AutorunsToWinEventLog\">https://github.com/palantir/windows-event-forwarding/tree/master/AutorunsToWinEventLog</a></p>\n<h2>Task 5: Create a search to identify suspicious code injection</h2>\n<p>Attackers are known for performing code injection against running processes for exploitation or evasion purposes. Create an ELK search to identify this behavior, leveraging the available data.</p>\n<p><strong>Hint</strong>: Carefully go through the following resource (especially the detection part) <a href=\"https://attack.mitre.org/techniques/T1055/\">https://attack.mitre.org/techniques/T1055/</a>. Combine what you read in the aforementioned resource with one related Sysmon Event ID.</p>\n<h2>Task 6: Create a search to identify possible privilege escalation via weak service permissions</h2>\n<p>It is not uncommon in Windows environments to see services running with SYSTEM privileges. It is also not uncommon to see such services having lax permissions. Specifically, oftentimes untrusted groups (or users) have privileged access to a service or permissions over the folder where the binary of the service is stored.</p>\n<p>Attackers are known to leverage such lax service permissions to escalate their privileges.</p>\n<p><strong>Hints</strong>:</p>\n<ol>\n<li>\n<p>Focus on the <strong>sc</strong> executable (which is related to creating, configuring and deleting Windows services) and the <em>start</em> or <em>sdshow</em> options (used when an attacker wants more granular details about a service's permissions)</p>\n</li>\n<li>\n<p>To launch their own executable (with higher privileges) attackers will have to tamper with another <strong>sc</strong> option. Try to think which option is that...</p>\n</li>\n</ol>\n<h2>Task 7: Create a search to identify possible Windows session hijacking</h2>\n<p>By design, a privileged Windows user who can perform command execution with SYSTEM-level privileges can hijack any currently logged in user's RDP session, without being prompted to enter his/her credentials. This behavior and its root cause are described in the following resource <a href=\"http://www.korznikov.com/2017/03/0-day-or-feature-privilege-escalation.html\">http://www.korznikov.com/2017/03/0-day-or-feature-privilege-escalation.html</a>.</p>\n<p>Create a search to identify possible Windows session hijacking through the behavior described above.</p>\n<p><strong>Hint</strong>: The Windows executable that attackers leverage to perform the above is <strong>tscon</strong>.</p>\n<h2>Task 8: Create a search to identify the whoami command being executed with System privileges</h2>\n<p>When attackers gain access to a system they usually execute commands such as <em>whoami</em> to identify their level of access. You can leverage this attacker routine to detect intrusions.</p>\n<p>Create a search to detect the <em>whoami</em> command being executed with SYSTEM-level privileges.</p>\n<h2>Task 9: Create a search to identify LSASS loading a library not signed by Microsoft</h2>\n<p>By the time a user logs in to a Windows system the Local Security Authority Subsystem Service (LSASS) process's memory is filled with user and other credentials. As you can imagine, the LSASS process is a process worth monitoring.</p>\n<p>Create a search to identify LSASS loading a library not signed by Microsoft.</p>\n<p><strong>Hint</strong>: Sysmon contains an Event ID that can assist in monitoring the DLLs being loaded by a specific process.</p>",
    "published_date": "2020-10-20T15:32:25Z",
    "solutions": "# SOLUTIONS\n\n**Kali Machine**\n\n![1](https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/1.jpg)\n\nBelow, you can find solutions for every task of this lab. Remember though, that you can follow your own strategy (which may be different from the one explained in the following lab.\n\n## Task 1: Add any fields you see fit to enhance your understanding of the data\n\nOnce you are connected to Kibana, first change the time picker to **Last 15 years** and then submit an empty search. You should come across the following.\n\n![2](https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/2.jpg)\n\n\nAs we can see, the documents (or events if you like) table consists of two columns only. We can enhance our understanding of the gathered events by adding more fields. To do so, we simply click on **Available Fields** and then click the add button that appears next to each field upon mouse hover.\n\n![3](https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/3.jpg)\n\nA good start would be adding the **event_id** field and the **computer_name** field. Then, the results will look like the ones depicted below.\n\n![4](https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/4.jpg)\n\nGo through each available field and experiment with how documents/events are presented until you feel comfortable enough to start your analysis.\n\nAt any time, you can remove an added field simply by hovering over it and pressing the remove button that appears.\n\n![5](https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/5.jpg)\n\n## Task 2: Create an actionable visualization\n\nTo identify all users included in the dataset you can start by submitting an empty search, expanding **Available Fields** and then inspecting the **event_data.User** field. If you do you so will come across the below.\n\n![6](https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/6.jpg)\n\nDo you notice that *500 records* message? This is because, by default, results are limited to 500 records. You can change that by going to the **Management** tab and then clicking **Advanced Settings**, but let's create a visualization instead.\n\nTo do so, click on the **Visualize** tab and press the button with the cross.\n\n![7](https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/7.jpg)\n\nThen, click on **Data Table**.\n\n![8](https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/8.jpg)\n\nNow, click on the **logstash-*** index...\n\n![9](https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/9.jpg)\n\nand submit the search below.\n\n```\nevent_data.User:*\n```\n\nThe search above can be translated as **winlog.event_data.User:\"exists\"**. This means that it will provide us with all the documents that contain the specified field. To identify all users, we need to create an aggregation. To create one, click the **Split Rows** tab and choose **Terms** from the Aggregation drop-down menu. On the **Field** drop-down menu choose **winlog.event_data.User.keyword**. Finally, click the play button on your upper right.\n\n![10](https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/10.jpg)\n\nYou should now see the below\n\n![11](https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/11.jpg)\n\nThese results above do not contain all users, but only five of them. Why so? This is because of the default **Size** of the aggregation we created being five. To see all users we can specify a larger size like fifty (50) and then press the play button once again.\n\n![12](https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/12.jpg)\n\nYou can save this visualization if you like by pressing **Save** on your upper right and specifying a name.\n\nIf we would like a more actionable visualization we can focus, for example, on the [Windows Security Log Event ID 4776](https://docs.microsoft.com/en-us/windows/security/threat-protection/auditing/event-4776) and the [Windows Security Log Event ID 4625](https://docs.microsoft.com/en-us/windows/security/threat-protection/auditing/event-4625) events. Both of them can be used to identify unsuccessful logins.\n\nSuppose that we want to be able to see when unsuccessful login attempts occurred.\n\nFirst we have to create the appropriate ELK search.\n\nOne viable search is the below.\n\n```\n(event_id:4776 AND -keywords:\"Audit Success\") OR event_id:4625\n```\nEvent ID 4625 is related solely to unsuccessful login attempts, but Event ID 4776 is related to computers attempting to validate the credentials for an account. When a successful login attempt occurs the corresponding Event ID 4776 document will contain an \"*Audit Success*\" keyword and an Error Code \"*0x00*\" (see below).\n\n![12_1](https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/12_1.png)\n\nObviously we want those out, hence the *AND -keywords:\"Audit Success\"* part of the search.\n\nTo create such a visualization we click **Visualize,** we press the button with the cross and we choose **Area**\n\n![12_2](https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/12_2.png)\n\nThen, we click on the **logstash-*** index, we submit the search above and we click on **X-Axis**.\n\nThere, we choose **Date Histogram** on the **Aggregation** drop-down menu, **@timestamp** on the **Field** drop down menu and **Monthly** on the **Interval** drop-down menu. If you do so and press the play button, you should see the following.\n\n![12_3](https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/12_3.png)\n\n## Task 3: Create a search to identify files that are named like system processes\n\nThe important fields to focus on are **event_data.Image** and **event_data.TargetFilename**.\n\nA viable search to detect files that are named like legitimate Windows processes but are located in a path other than the expected one is the below.\n\n```\n( event_data.Image:(\"*\\\\rundll32.exe\" \"*\\\\svchost.exe\" \n\"*\\\\wmiprvse.exe\" \"*\\\\wmiadap.exe\" \"*\\\\smss.exe\" \"*\\\\wininit.exe\" \"*\\\\taskhost.exe\" \"*\\\\lsass.exe\" \"*\\\\winlogon.exe\" \"*\\\\csrss.exe\" \"*\\\\services.exe\" \"*\\\\svchost.exe\" \"*\\\\lsm.exe\" \"*\\\\conhost.exe\" \"*\\\\dllhost.exe\" \"*\\\\dwm.exe\" \"*\\\\spoolsv.exe\" \"*\\\\wuauclt.exe\" \"*\\\\taskhost.exe\" \"*\\\\taskhostw.exe\" \"*\\\\fontdrvhost.exe\" \"*\\\\searchindexer.exe\" \"*\\\\searchprotocolhost.exe\" \"*\\\\searchfilterhost.exe\" \"*\\\\sihost.exe\") AND -event_data.Image:(\"*\\\\system32\\\\*\" \"*\\\\syswow64\\\\*\" \"*\\\\winsxs\\\\*\") ) OR ( event_data.TargetFilename:(\"*\\\\rundll32.exe\" \"*\\\\svchost.exe\" \"*\\\\wmiprvse.exe\" \"*\\\\wmiadap.exe\" \"*\\\\smss.exe\" \"*\\\\wininit.exe\" \"*\\\\taskhost.exe\" \"*\\\\lsass.exe\" \"*\\\\winlogon.exe\" \"*\\\\csrss.exe\" \"*\\\\services.exe\" \"*\\\\svchost.exe\" \"*\\\\lsm.exe\" \"*\\\\conhost.exe\" \"*\\\\dllhost.exe\" \"*\\\\dwm.exe\" \"*\\\\spoolsv.exe\" \"*\\\\wuauclt.exe\" \"*\\\\taskhost.exe\" \"*\\\\taskhostw.exe\" \"*\\\\fontdrvhost.exe\" \"*\\\\searchindexer.exe\" \"*\\\\searchprotocolhost.exe\" \"*\\\\searchfilterhost.exe\" \"*\\\\sihost.exe\") AND -event_data.TargetFilename:(\"*\\\\system32\\\\*\" \"*\\\\syswow64\\\\*\" \"*\\\\winsxs\\\\*\") )\n```\n\n*AND -event_data.Image* is excluding the expected paths.\n\n*event_data.TargetFilename* is used in case the file included in the event_data.Image field interacted with another file. For example, if PowerShell downloaded a file named 65536.exe you would see the below.\n\n\u200b\t**event_data.Image**: C:\\\\Windows\\\\SysWOW64\\\\WindowsPowerShell\\\\v1.0\\\\powershell.exe\n\n\u200b\t**event_data.TargetFilename**: C:\\\\Users\\\\PhisedUser\\\\AppData\\\\Local\\\\Temp\\\\65536.exe\n\nIf you submit the search above, you should see 6 hits.\n\n![13](https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/13.jpg)\n\nIf you are not able to see the exact same result representation, you can add the respective fields by following the steps mentioned in task 1.\n\n## Task 4: Create a search to identify suspicious services interacting with an executable from the Windows folder\n\nWhen it comes to suspicious service detection the [Windows Security Log Event ID 4697](https://docs.microsoft.com/en-us/windows/security/threat-protection/auditing/event-4697) and the [Windows Event ID 7045](https://logrhythm.com/blog/detecting-rogue-processes-in-the-services-session/) events will prove useful. The same applies for Autoruns logs.\n\nA viable search to identify suspicious services interacting with an executable from the windows folder is the following.\n\n```\n(event_id:(\"4697\" \"7045\") OR (log_name:Autoruns AND event_data.Category:Services) ) AND \nevent_data.CommandLine.keyword:/.*%[s|S][y|Y][s|S][t|T][e|E][m|M][r|R][o|O][o|O][t|T]%\\\\[^\\\\]*\\.exe/ AND -event_data.CommandLine:(*paexe* *psexesvc* *winexesvc* *remcomsvc*)\n```\n\n*event_id:(\"4697\" \"7045\")* is used to identify services being installed.\n\n*log_name:Autoruns AND event_data.Category:Services* is used to identify auto-start services detected by the [Autoruns](https://docs.microsoft.com/en-us/sysinternals/downloads/autoruns) MS tool. [*event_data.Category:Services* is used to limit the Autorun-derived documents to those only related to services]\n\n``-event_data.CommandLine:(*paexe* *psexesvc* *winexesvc* *remcomsvc*)`` excludes services that interact with expected Windows executables inside the Windows folder.\n\nIf you submit the search above, you should see 7 hits.\n\n![14](https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/14.jpg)\n\n## Task 5: Create a search to identify suspicious code injection\n\nSysmon contains a *CreateRemoteThread* event (Event ID 8) that detects when a process creates a thread in another process. Malware usually do that so that the target process can load a malicious DLL (whose path is written in the virtual address space of the target process) or a malicious portable executable.\n\n![](https://assets.ine.com/cybersecurity-lab-images/37b8b3a1-190c-4056-95b9-ae9de63cd8d1/image22.png)\n\nIt should be noted that remote threads can be created on a Windows system for legitimate purposes as well. Such an example is *EtwpNotificationThread*, which is related to threads (thread entry points actually) being \"created\" in the context of a process, so that certain tasks can be performed on behalf of the kernel.\n\nTo conclude the task, a viable search to identify suspicious code injection (based on Sysmon's Event ID 8) is the following.\n\n```\nevent_id:8 AND source_name:\"Microsoft-Windows-Sysmon\" AND -(event_data.SourceImage:\"*\\\\VBoxTray.exe\" AND event_data.TargetImage:\"*\\\\csrss.exe\") AND -(event_data.StartFunction:EtwpNotificationThread AND event_data.SourceImage:\"*\\\\rundll32.exe\")\n```\nIf you submit the search above, you should see 53 hits.\n\n![15](https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/15.jpg)\n\nIf you are not able to see the exact same result representation, you can add the respective fields by following the steps mentioned in task 1.\n\n[*wce*](https://www.ampliasecurity.com/research/wcefaq.html) that you see on the **event_data.SourceImage** field is a known [Credential Dumping](https://attack.mitre.org/techniques/T1003/) tool that targets the Local Security Authority Subsystem Service (LSASS) process (whose memory contains a variety of credentials).\n\n## Task 6: Create a search to identify possible privilege escalation via weak service permissions\n\nAs mentioned in this task's description attackers will interact with the **sc** Windows executable in order to identify if a service has weak permissions and if they have any kind of privileged access over it.\n\nIf they have enough privileges, attackers may also attempt to specify an executable of their own to be executed by the insufficiently secure service. This can be done again through the **sc** executable and the **config** option (binPath = <path to attacker executable> will go next).\n\nWe can search for possible privilege escalation via weak service permissions as follows.\n\n```\nevent_data.Image:\"*\\\\sc.exe\" AND (event_data.CommandLine:(*start* *sdshow*) OR (event_data.CommandLine:*config* AND event_data.CommandLine:*binPath*)) AND event_data.IntegrityLevel:Medium\n```\n*event_data.IntegrityLevel:Medium* ensures that we don't get results from privileged users (such as admins) performing legitimate service tasks.\n\nIf you submit the search above, you should see 3 hits.\n\n![16](https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/16.jpg)\n\nIf you are not able to see the exact same result representation, you can add the respective fields by following the steps mentioned in task 1.\n\n## Task 7: Create a search to identify possible Windows session hijacking\n\nAs already mentioned in this task's description we can focus on any **tscon** invocation. More specifically, we are interested in any **tscon** invocation with SYSTEM-level privileges.\n\nA viable search to identify possible Windows session hijacking via the described attacker technique is the below.\n\n```\nevent_data.Image:\"*\\\\tscon.exe\" AND event_data.User:\"NT AUTHORITY\\\\SYSTEM\"\n```\n\nAlternatively, you can use the following search.\n\n```\nevent_data.Image:\"*\\\\tscon.exe\" AND (event_data.LogonId:0x3e7 OR event_data.SubjectLogonId:0x3e7 OR event_data.User:\"NT AUTHORITY\\\\SYSTEM\")\n```\nIf you submit any of the searches above, you should see 1 hit.\n\n![17](https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/17.jpg)\n\nIf you are not able to see the exact same result representation, you can add the respective fields by following the steps mentioned in task 1.\n\n## Task 8: Create a search to identify the whoami command being executed with System privileges\n\nIt is quite trivial to create a search to detect the whoami command being executed with SYSTEM-level privileges.\n\nA viable search is the following.\n\n```\nevent_data.Image:\"*\\\\whoami.exe\" AND (event_data.LogonId:0x3e7 OR event_data.SubjectLogonId:0x3e7 OR event_data.User:\"NT AUTHORITY\\\\SYSTEM\")\n```\nThe LogonIds used in this and the previous tasks are usually met when SYSTEM-level access is involved.\n\nIf you submit the search above, you should see 4 hits.\n\n![18](https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/18.jpg)\n\nIf you are not able to see the exact same result representation, you can add the respective fields by following the steps mentioned in task 1.\n\n## Task 9: Create a search to identify LSASS loading a library not signed by Microsoft\n\nSysmon's *Event ID 7: Image loaded* can be used to monitor the DLLs being loaded by a specific process. Thankfully this event contains information about the library's signature in its data (*Signature* entry).\n\nA viable search to identify LSASS loading a library not signed by Microsoft is the following.\n\n```\nevent_id:7 AND event_data.Image:\"*\\\\lsass.exe\" AND -event_data.Signature:*Microsoft*\n```\nIf you submit the search above, you should see 54 hits.\n\n![19](https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/19.jpg)\n\nIf you are not able to see the exact same result representation, you can add the respective fields by following the steps mentioned in task 1.\n\nThe DLL being loaded (*wceaux.dll*) is the one the credential dumping tool you identified in task 5 uses to gather or alter credentials.\n\n**Additional Resources:**\n\n1.  <https://speakerdeck.com/felipead/elasticsearch-workshop>\n\n2.  <https://drive.google.com/file/d/0B2S_IOa0MiOHWndxWFRiUHNoNW8/view>",
    "solutions_html": "<h1>SOLUTIONS</h1>\n<p><strong>Kali Machine</strong></p>\n<p><img alt=\"1\" src=\"https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/1.jpg\" /></p>\n<p>Below, you can find solutions for every task of this lab. Remember though, that you can follow your own strategy (which may be different from the one explained in the following lab.</p>\n<h2>Task 1: Add any fields you see fit to enhance your understanding of the data</h2>\n<p>Once you are connected to Kibana, first change the time picker to <strong>Last 15 years</strong> and then submit an empty search. You should come across the following.</p>\n<p><img alt=\"2\" src=\"https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/2.jpg\" /></p>\n<p>As we can see, the documents (or events if you like) table consists of two columns only. We can enhance our understanding of the gathered events by adding more fields. To do so, we simply click on <strong>Available Fields</strong> and then click the add button that appears next to each field upon mouse hover.</p>\n<p><img alt=\"3\" src=\"https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/3.jpg\" /></p>\n<p>A good start would be adding the <strong>event_id</strong> field and the <strong>computer_name</strong> field. Then, the results will look like the ones depicted below.</p>\n<p><img alt=\"4\" src=\"https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/4.jpg\" /></p>\n<p>Go through each available field and experiment with how documents/events are presented until you feel comfortable enough to start your analysis.</p>\n<p>At any time, you can remove an added field simply by hovering over it and pressing the remove button that appears.</p>\n<p><img alt=\"5\" src=\"https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/5.jpg\" /></p>\n<h2>Task 2: Create an actionable visualization</h2>\n<p>To identify all users included in the dataset you can start by submitting an empty search, expanding <strong>Available Fields</strong> and then inspecting the <strong>event_data.User</strong> field. If you do you so will come across the below.</p>\n<p><img alt=\"6\" src=\"https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/6.jpg\" /></p>\n<p>Do you notice that <em>500 records</em> message? This is because, by default, results are limited to 500 records. You can change that by going to the <strong>Management</strong> tab and then clicking <strong>Advanced Settings</strong>, but let's create a visualization instead.</p>\n<p>To do so, click on the <strong>Visualize</strong> tab and press the button with the cross.</p>\n<p><img alt=\"7\" src=\"https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/7.jpg\" /></p>\n<p>Then, click on <strong>Data Table</strong>.</p>\n<p><img alt=\"8\" src=\"https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/8.jpg\" /></p>\n<p>Now, click on the <strong>logstash-</strong>* index...</p>\n<p><img alt=\"9\" src=\"https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/9.jpg\" /></p>\n<p>and submit the search below.</p>\n<pre class=\"codehilite\"><code>event_data.User:*</code></pre>\n\n<p>The search above can be translated as <strong>winlog.event_data.User:\"exists\"</strong>. This means that it will provide us with all the documents that contain the specified field. To identify all users, we need to create an aggregation. To create one, click the <strong>Split Rows</strong> tab and choose <strong>Terms</strong> from the Aggregation drop-down menu. On the <strong>Field</strong> drop-down menu choose <strong>winlog.event_data.User.keyword</strong>. Finally, click the play button on your upper right.</p>\n<p><img alt=\"10\" src=\"https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/10.jpg\" /></p>\n<p>You should now see the below</p>\n<p><img alt=\"11\" src=\"https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/11.jpg\" /></p>\n<p>These results above do not contain all users, but only five of them. Why so? This is because of the default <strong>Size</strong> of the aggregation we created being five. To see all users we can specify a larger size like fifty (50) and then press the play button once again.</p>\n<p><img alt=\"12\" src=\"https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/12.jpg\" /></p>\n<p>You can save this visualization if you like by pressing <strong>Save</strong> on your upper right and specifying a name.</p>\n<p>If we would like a more actionable visualization we can focus, for example, on the <a href=\"https://docs.microsoft.com/en-us/windows/security/threat-protection/auditing/event-4776\">Windows Security Log Event ID 4776</a> and the <a href=\"https://docs.microsoft.com/en-us/windows/security/threat-protection/auditing/event-4625\">Windows Security Log Event ID 4625</a> events. Both of them can be used to identify unsuccessful logins.</p>\n<p>Suppose that we want to be able to see when unsuccessful login attempts occurred.</p>\n<p>First we have to create the appropriate ELK search.</p>\n<p>One viable search is the below.</p>\n<p><pre class=\"codehilite\"><code>(event_id:4776 AND -keywords:\"Audit Success\") OR event_id:4625</code></pre>\nEvent ID 4625 is related solely to unsuccessful login attempts, but Event ID 4776 is related to computers attempting to validate the credentials for an account. When a successful login attempt occurs the corresponding Event ID 4776 document will contain an \"<em>Audit Success</em>\" keyword and an Error Code \"<em>0x00</em>\" (see below).</p>\n<p><img alt=\"12_1\" src=\"https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/12_1.png\" /></p>\n<p>Obviously we want those out, hence the <em>AND -keywords:\"Audit Success\"</em> part of the search.</p>\n<p>To create such a visualization we click <strong>Visualize,</strong> we press the button with the cross and we choose <strong>Area</strong></p>\n<p><img alt=\"12_2\" src=\"https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/12_2.png\" /></p>\n<p>Then, we click on the <strong>logstash-</strong>* index, we submit the search above and we click on <strong>X-Axis</strong>.</p>\n<p>There, we choose <strong>Date Histogram</strong> on the <strong>Aggregation</strong> drop-down menu, <strong>@timestamp</strong> on the <strong>Field</strong> drop down menu and <strong>Monthly</strong> on the <strong>Interval</strong> drop-down menu. If you do so and press the play button, you should see the following.</p>\n<p><img alt=\"12_3\" src=\"https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/12_3.png\" /></p>\n<h2>Task 3: Create a search to identify files that are named like system processes</h2>\n<p>The important fields to focus on are <strong>event_data.Image</strong> and <strong>event_data.TargetFilename</strong>.</p>\n<p>A viable search to detect files that are named like legitimate Windows processes but are located in a path other than the expected one is the below.</p>\n<pre class=\"codehilite\"><code>( event_data.Image:(\"*\\\\rundll32.exe\" \"*\\\\svchost.exe\" \n\"*\\\\wmiprvse.exe\" \"*\\\\wmiadap.exe\" \"*\\\\smss.exe\" \"*\\\\wininit.exe\" \"*\\\\taskhost.exe\" \"*\\\\lsass.exe\" \"*\\\\winlogon.exe\" \"*\\\\csrss.exe\" \"*\\\\services.exe\" \"*\\\\svchost.exe\" \"*\\\\lsm.exe\" \"*\\\\conhost.exe\" \"*\\\\dllhost.exe\" \"*\\\\dwm.exe\" \"*\\\\spoolsv.exe\" \"*\\\\wuauclt.exe\" \"*\\\\taskhost.exe\" \"*\\\\taskhostw.exe\" \"*\\\\fontdrvhost.exe\" \"*\\\\searchindexer.exe\" \"*\\\\searchprotocolhost.exe\" \"*\\\\searchfilterhost.exe\" \"*\\\\sihost.exe\") AND -event_data.Image:(\"*\\\\system32\\\\*\" \"*\\\\syswow64\\\\*\" \"*\\\\winsxs\\\\*\") ) OR ( event_data.TargetFilename:(\"*\\\\rundll32.exe\" \"*\\\\svchost.exe\" \"*\\\\wmiprvse.exe\" \"*\\\\wmiadap.exe\" \"*\\\\smss.exe\" \"*\\\\wininit.exe\" \"*\\\\taskhost.exe\" \"*\\\\lsass.exe\" \"*\\\\winlogon.exe\" \"*\\\\csrss.exe\" \"*\\\\services.exe\" \"*\\\\svchost.exe\" \"*\\\\lsm.exe\" \"*\\\\conhost.exe\" \"*\\\\dllhost.exe\" \"*\\\\dwm.exe\" \"*\\\\spoolsv.exe\" \"*\\\\wuauclt.exe\" \"*\\\\taskhost.exe\" \"*\\\\taskhostw.exe\" \"*\\\\fontdrvhost.exe\" \"*\\\\searchindexer.exe\" \"*\\\\searchprotocolhost.exe\" \"*\\\\searchfilterhost.exe\" \"*\\\\sihost.exe\") AND -event_data.TargetFilename:(\"*\\\\system32\\\\*\" \"*\\\\syswow64\\\\*\" \"*\\\\winsxs\\\\*\") )</code></pre>\n\n<p><em>AND -event_data.Image</em> is excluding the expected paths.</p>\n<p><em>event_data.TargetFilename</em> is used in case the file included in the event_data.Image field interacted with another file. For example, if PowerShell downloaded a file named 65536.exe you would see the below.</p>\n<p>\u200b   <strong>event_data.Image</strong>: C:\\Windows\\SysWOW64\\WindowsPowerShell\\v1.0\\powershell.exe</p>\n<p>\u200b   <strong>event_data.TargetFilename</strong>: C:\\Users\\PhisedUser\\AppData\\Local\\Temp\\65536.exe</p>\n<p>If you submit the search above, you should see 6 hits.</p>\n<p><img alt=\"13\" src=\"https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/13.jpg\" /></p>\n<p>If you are not able to see the exact same result representation, you can add the respective fields by following the steps mentioned in task 1.</p>\n<h2>Task 4: Create a search to identify suspicious services interacting with an executable from the Windows folder</h2>\n<p>When it comes to suspicious service detection the <a href=\"https://docs.microsoft.com/en-us/windows/security/threat-protection/auditing/event-4697\">Windows Security Log Event ID 4697</a> and the <a href=\"https://logrhythm.com/blog/detecting-rogue-processes-in-the-services-session/\">Windows Event ID 7045</a> events will prove useful. The same applies for Autoruns logs.</p>\n<p>A viable search to identify suspicious services interacting with an executable from the windows folder is the following.</p>\n<pre class=\"codehilite\"><code>(event_id:(\"4697\" \"7045\") OR (log_name:Autoruns AND event_data.Category:Services) ) AND \nevent_data.CommandLine.keyword:/.*%[s|S][y|Y][s|S][t|T][e|E][m|M][r|R][o|O][o|O][t|T]%\\\\[^\\\\]*\\.exe/ AND -event_data.CommandLine:(*paexe* *psexesvc* *winexesvc* *remcomsvc*)</code></pre>\n\n<p><em>event_id:(\"4697\" \"7045\")</em> is used to identify services being installed.</p>\n<p><em>log_name:Autoruns AND event_data.Category:Services</em> is used to identify auto-start services detected by the <a href=\"https://docs.microsoft.com/en-us/sysinternals/downloads/autoruns\">Autoruns</a> MS tool. [<em>event_data.Category:Services</em> is used to limit the Autorun-derived documents to those only related to services]</p>\n<p><code>-event_data.CommandLine:(*paexe* *psexesvc* *winexesvc* *remcomsvc*)</code> excludes services that interact with expected Windows executables inside the Windows folder.</p>\n<p>If you submit the search above, you should see 7 hits.</p>\n<p><img alt=\"14\" src=\"https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/14.jpg\" /></p>\n<h2>Task 5: Create a search to identify suspicious code injection</h2>\n<p>Sysmon contains a <em>CreateRemoteThread</em> event (Event ID 8) that detects when a process creates a thread in another process. Malware usually do that so that the target process can load a malicious DLL (whose path is written in the virtual address space of the target process) or a malicious portable executable.</p>\n<p><img alt=\"\" src=\"https://assets.ine.com/cybersecurity-lab-images/37b8b3a1-190c-4056-95b9-ae9de63cd8d1/image22.png\" /></p>\n<p>It should be noted that remote threads can be created on a Windows system for legitimate purposes as well. Such an example is <em>EtwpNotificationThread</em>, which is related to threads (thread entry points actually) being \"created\" in the context of a process, so that certain tasks can be performed on behalf of the kernel.</p>\n<p>To conclude the task, a viable search to identify suspicious code injection (based on Sysmon's Event ID 8) is the following.</p>\n<p><pre class=\"codehilite\"><code>event_id:8 AND source_name:\"Microsoft-Windows-Sysmon\" AND -(event_data.SourceImage:\"*\\\\VBoxTray.exe\" AND event_data.TargetImage:\"*\\\\csrss.exe\") AND -(event_data.StartFunction:EtwpNotificationThread AND event_data.SourceImage:\"*\\\\rundll32.exe\")</code></pre>\nIf you submit the search above, you should see 53 hits.</p>\n<p><img alt=\"15\" src=\"https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/15.jpg\" /></p>\n<p>If you are not able to see the exact same result representation, you can add the respective fields by following the steps mentioned in task 1.</p>\n<p><a href=\"https://www.ampliasecurity.com/research/wcefaq.html\"><em>wce</em></a> that you see on the <strong>event_data.SourceImage</strong> field is a known <a href=\"https://attack.mitre.org/techniques/T1003/\">Credential Dumping</a> tool that targets the Local Security Authority Subsystem Service (LSASS) process (whose memory contains a variety of credentials).</p>\n<h2>Task 6: Create a search to identify possible privilege escalation via weak service permissions</h2>\n<p>As mentioned in this task's description attackers will interact with the <strong>sc</strong> Windows executable in order to identify if a service has weak permissions and if they have any kind of privileged access over it.</p>\n<p>If they have enough privileges, attackers may also attempt to specify an executable of their own to be executed by the insufficiently secure service. This can be done again through the <strong>sc</strong> executable and the <strong>config</strong> option (binPath = <path to attacker executable> will go next).</p>\n<p>We can search for possible privilege escalation via weak service permissions as follows.</p>\n<p><pre class=\"codehilite\"><code>event_data.Image:\"*\\\\sc.exe\" AND (event_data.CommandLine:(*start* *sdshow*) OR (event_data.CommandLine:*config* AND event_data.CommandLine:*binPath*)) AND event_data.IntegrityLevel:Medium</code></pre>\n<em>event_data.IntegrityLevel:Medium</em> ensures that we don't get results from privileged users (such as admins) performing legitimate service tasks.</p>\n<p>If you submit the search above, you should see 3 hits.</p>\n<p><img alt=\"16\" src=\"https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/16.jpg\" /></p>\n<p>If you are not able to see the exact same result representation, you can add the respective fields by following the steps mentioned in task 1.</p>\n<h2>Task 7: Create a search to identify possible Windows session hijacking</h2>\n<p>As already mentioned in this task's description we can focus on any <strong>tscon</strong> invocation. More specifically, we are interested in any <strong>tscon</strong> invocation with SYSTEM-level privileges.</p>\n<p>A viable search to identify possible Windows session hijacking via the described attacker technique is the below.</p>\n<pre class=\"codehilite\"><code>event_data.Image:\"*\\\\tscon.exe\" AND event_data.User:\"NT AUTHORITY\\\\SYSTEM\"</code></pre>\n\n<p>Alternatively, you can use the following search.</p>\n<p><pre class=\"codehilite\"><code>event_data.Image:\"*\\\\tscon.exe\" AND (event_data.LogonId:0x3e7 OR event_data.SubjectLogonId:0x3e7 OR event_data.User:\"NT AUTHORITY\\\\SYSTEM\")</code></pre>\nIf you submit any of the searches above, you should see 1 hit.</p>\n<p><img alt=\"17\" src=\"https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/17.jpg\" /></p>\n<p>If you are not able to see the exact same result representation, you can add the respective fields by following the steps mentioned in task 1.</p>\n<h2>Task 8: Create a search to identify the whoami command being executed with System privileges</h2>\n<p>It is quite trivial to create a search to detect the whoami command being executed with SYSTEM-level privileges.</p>\n<p>A viable search is the following.</p>\n<p><pre class=\"codehilite\"><code>event_data.Image:\"*\\\\whoami.exe\" AND (event_data.LogonId:0x3e7 OR event_data.SubjectLogonId:0x3e7 OR event_data.User:\"NT AUTHORITY\\\\SYSTEM\")</code></pre>\nThe LogonIds used in this and the previous tasks are usually met when SYSTEM-level access is involved.</p>\n<p>If you submit the search above, you should see 4 hits.</p>\n<p><img alt=\"18\" src=\"https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/18.jpg\" /></p>\n<p>If you are not able to see the exact same result representation, you can add the respective fields by following the steps mentioned in task 1.</p>\n<h2>Task 9: Create a search to identify LSASS loading a library not signed by Microsoft</h2>\n<p>Sysmon's <em>Event ID 7: Image loaded</em> can be used to monitor the DLLs being loaded by a specific process. Thankfully this event contains information about the library's signature in its data (<em>Signature</em> entry).</p>\n<p>A viable search to identify LSASS loading a library not signed by Microsoft is the following.</p>\n<p><pre class=\"codehilite\"><code>event_id:7 AND event_data.Image:\"*\\\\lsass.exe\" AND -event_data.Signature:*Microsoft*</code></pre>\nIf you submit the search above, you should see 54 hits.</p>\n<p><img alt=\"19\" src=\"https://assets.ine.com/content/threat-hunting-professional/Effectively_Using_the_ELK_Stack/19.jpg\" /></p>\n<p>If you are not able to see the exact same result representation, you can add the respective fields by following the steps mentioned in task 1.</p>\n<p>The DLL being loaded (<em>wceaux.dll</em>) is the one the credential dumping tool you identified in task 5 uses to gather or alter credentials.</p>\n<p><strong>Additional Resources:</strong></p>\n<ol>\n<li>\n<p><a href=\"https://speakerdeck.com/felipead/elasticsearch-workshop\">https://speakerdeck.com/felipead/elasticsearch-workshop</a></p>\n</li>\n<li>\n<p><a href=\"https://drive.google.com/file/d/0B2S_IOa0MiOHWndxWFRiUHNoNW8/view\">https://drive.google.com/file/d/0B2S_IOa0MiOHWndxWFRiUHNoNW8/view</a></p>\n</li>\n</ol>",
    "flags": [],
    "min_points_to_pass": null,
    "access_type": "default",
    "user_status": "unstarted",
    "user_lab_status": null,
    "user_status_modified": null,
    "user_flags": [],
    "global_running_session": null
}