> For the complete documentation index, see [llms.txt](https://karim-ashraf.gitbook.io/karim_ashraf_space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://karim-ashraf.gitbook.io/karim_ashraf_space/writeups/hack-the-box-tracks/soc-analyst-path-2024/2.-security-monitoring-and-siem-fundamentals/siem-visualization-example-4-users-added-or-removed-from-a-local-group.md).

# SIEM Visualization Example 4: Users Added or Removed from a Local Group

In this example, we will create a **SIEM visualization** to monitor **user additions or removals** from the local "Administrators" group within a specific timeframe (March 5th, 2023, to the present). This type of monitoring is critical for detecting unauthorized changes to privileged groups, which could indicate malicious activity or misconfigurations.

***

## **Step 1: Accessing the Dashboard**

1. **Spawn the Target System**:
   * Navigate to the bottom of the section and click on **"Click here to spawn the target system!"**.
2. **Access Kibana**:
   * Open your browser and navigate to `http://[Target IP]:5601`.
   * Click on the side navigation toggle and select **"Dashboard"**.
3. **Edit the Prebuilt Dashboard**:
   * A prebuilt dashboard should be visible. Click on the **"pencil"/edit icon** to modify it.
4. **Create a New Visualization**:
   * Click on **"Create visualization"** to begin building the new visualization.

<figure><img src="https://1176031639-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNQ7A82FmDjR05oHeIjks%2Fuploads%2FVwgV92FODhrSKeXnWBz8%2Fimage.png?alt=media&amp;token=0bb2667a-6299-4e47-bf81-fe05f5e0a8e3" alt=""><figcaption></figcaption></figure>

***

## **Step 2: Configuring the Visualization**

**Key Elements to Configure**

1. **Filter Data**:
   * Use the **filter option** to narrow down the data to only include events related to user additions or removals from the local "Administrators" group.
   * Add the following filters:
     * `event.code: (4732 OR 4733)` (Windows event IDs for adding/removing members from security-enabled local groups).
     * `group.name.keyword: Administrators` (Ensures the action involves the "Administrators" group).
     * `@timestamp >= "2023-03-05T00:00:00.000Z"` (Limits the data to events occurring from March 5th, 2023, onward).
2. **Select the Index Pattern**:
   * In the **Index pattern** field, specify `windows*` to focus on Windows-related logs.
3. **Verify Fields**:
   * Use the **search bar** to confirm the presence of fields like:
     * `winlog.event_data.MemberSid.keyword` (The SID of the user being added/removed).
     * `group.name.keyword` (The name of the group involved in the action).
     * `event.action.keyword` (Indicates whether the user was added or removed).
     * `host.name.keyword` (The machine where the action occurred).
4. **Choose Visualization Type**:
   * From the dropdown menu, select **"Table"** as the visualization type.

<figure><img src="https://1176031639-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNQ7A82FmDjR05oHeIjks%2Fuploads%2FEunCwlEug5OJR0hnwLkh%2Fimage.png?alt=media&amp;token=12c711b1-5821-40e1-8aea-c1952296eb2c" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1176031639-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNQ7A82FmDjR05oHeIjks%2Fuploads%2F1ZZMnh1AdJbjqiB0wyiC%2Fimage.png?alt=media&amp;token=01ad2784-555c-43d5-b62d-1fae0554c56b" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1176031639-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNQ7A82FmDjR05oHeIjks%2Fuploads%2FYQw33562LMxTHZBqJy1Q%2Fimage.png?alt=media&amp;token=0cd86b28-3737-4d54-abf0-627b732f09e1" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1176031639-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNQ7A82FmDjR05oHeIjks%2Fuploads%2FzkMczFFcfmsLtrdTx4wK%2Fimage.png?alt=media&amp;token=e9873a84-bce7-4d3f-bc82-cc725dc9cf36" alt=""><figcaption></figcaption></figure>

***

## **Step 3: Building the Table Visualization**

1. **Configure Rows**:
   * Click on **"Rows"** and configure the following fields to enhance understanding:
     * **Field**: `winlog.event_data.MemberSid.keyword` (Which user was added/removed?).
     * **Field**: `group.name.keyword` (To which group was the addition/removal performed? Double-check that it is the "Administrators" group).
     * **Field**: `event.action.keyword` (Was the user added or removed?).
     * **Field**: `host.name.keyword` (On which machine did the action occur?).
2. **Add Metrics**:
   * Click on **"Metrics"** and select **"Count"** as the metric.
   * The table will populate with data showing the count of additions/removals per user, group, and machine.
3. **Save the Visualization**:
   * Click on **"Save and return"** to add the visualization to the dashboard..

<figure><img src="https://1176031639-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNQ7A82FmDjR05oHeIjks%2Fuploads%2FnEMRuksnKER44DbEDeDK%2Fimage.png?alt=media&amp;token=cbb58864-9e06-478c-94d3-37e9b4024d9b" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1176031639-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNQ7A82FmDjR05oHeIjks%2Fuploads%2FvFD48CZMvbSHEnNiXKKf%2Fimage.png?alt=media&amp;token=c2676dd0-63d6-4986-946e-b3ac55e93e8d" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1176031639-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNQ7A82FmDjR05oHeIjks%2Fuploads%2FAqiznSlNtWA7PvYn9XBj%2Fimage.png?alt=media&amp;token=0d66d6d9-a9c6-494c-adbe-d4bbcbe47db7" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1176031639-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNQ7A82FmDjR05oHeIjks%2Fuploads%2F1MYvCOUS4QDU6EuOFtHp%2Fimage.png?alt=media&amp;token=037b04bb-531f-4b95-834b-4da10e0f13b5" alt=""><figcaption></figcaption></figure>

***

## **Step 4: Final Visualization**

After completing the configuration, the final visualization will include:

1. **Columns**:
   * **User**: Displays the SID of the user being added or removed (`winlog.event_data.MemberSid.keyword`).
   * **Group**: Shows the name of the group involved in the action (`group.name.keyword`).
   * **Action**: Indicates whether the user was added or removed (`event.action.keyword`).
   * **Machine**: Displays the hostname where the action occurred (`host.name.keyword`).
   * **Count**: The number of times the event has occurred (based on the specified timeframe).
2. **Filters**:
   * Only events with `event.code: (4732 OR 4733)`, `group.name.keyword: Administrators`, and `@timestamp >= "2023-03-05T00:00:00.000Z"` are included.
3. **Sorting**:
   * Sort the table by the timestamp (`@timestamp`) in descending order to prioritize recent events
   * .

     <figure><img src="https://1176031639-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNQ7A82FmDjR05oHeIjks%2Fuploads%2FjWXnd63DM7g4JEA86LgM%2Fimage.png?alt=media&amp;token=f245297b-1b11-4ef4-bfc4-238306b806be" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1176031639-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNQ7A82FmDjR05oHeIjks%2Fuploads%2F8iryWX9DKN47HVTQDbY5%2Fimage.png?alt=media&amp;token=07282015-f982-410d-a4ae-7c9135b18cd1" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1176031639-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNQ7A82FmDjR05oHeIjks%2Fuploads%2F6kLk8BchpmidTar6wcPm%2Fimage.png?alt=media&amp;token=7a68b3b4-a935-4f61-b1e0-da2badb38710" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1176031639-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNQ7A82FmDjR05oHeIjks%2Fuploads%2FaVmmReqaDLWSvxVGiiZm%2Fimage.png?alt=media&amp;token=2fdb68ad-4988-43ab-8851-5698ccdbbde2" alt=""><figcaption></figcaption></figure>

***

## **Step 5: Review and Save**

1. **Review the Dashboard**:
   * Navigate back to the **Dashboard** page to view the new visualization.
   * Ensure that the table displays accurate and actionable insights.
2. **Save the Dashboard**:
   * Click on the **"Save"** button to save your progress.

***

## **Key Takeaways**

1. **Monitor Privileged Group Changes**:
   * Changes to the local "Administrators" group can have significant security implications. Monitoring these changes helps detect unauthorized access or privilege escalation attempts.
2. **Leverage Event Logs**:
   * The `event.code: 4732` and `event.code: 4733` logs provide critical information about additions and removals from security-enabled local groups.
3. **Visualization Enhances Clarity**:
   * Using a table visualization allows SOC analysts to quickly identify patterns, such as repeated additions/removals on specific machines or involving specific users.
4. **Best Practices**:
   * Use `.keyword` fields for aggregations to ensure accurate results.
   * Regularly refine filters to exclude irrelevant data and reduce noise.
   * Combine visualizations into dashboards for a comprehensive view of security events.

***

## **Example Use Case**

* **Scenario**: An attacker gains administrative privileges by adding their account to the local "Administrators" group. This generates an event with `event.code: 4732` and `group.name.keyword: Administrators`.
* **Action**: The SOC team can use this visualization to:
  * Identify unauthorized additions to privileged groups.
  * Investigate the source of the change (e.g., specific machines or users).
  * Revert unauthorized changes and strengthen access controls.

By following these steps, you can create a robust visualization for monitoring user additions or removals from the local "Administrators" group, enabling your SOC team to proactively detect and respond to potential threats.
