Latest alertCVE-2018-11776 in Apache Struts Confirmed Exploited in the WildRead
Search all news in the platform

Detection rule

Win Susp Computer Name Containing Samtheadmin

CriticalTest-data validatedSigmaHQ (community)T1078

Overview

Detects suspicious computer name samtheadmin-{1..100}$ generated by hacktool

Rule id
39698b3f-da92-4bc6-bfb5-645a98386e45
ATT&CK techniques
T1078 Valid Accounts
Severity
Critical
Confidence
Low
Origin
SigmaHQ (community)
SigmaHQ status
test
Used in defense packs
n0n, The Gentlemen, qilin, INC Ransom, Akira, safepay, Play, nightspire

Validation

  1. ExperimentalSyntax checked only. Not yet tested on events.
  2. Test-data validatedMatched positive test events and ignored near-miss events. Not yet run in a production SIEM.
  3. SIEM-validatedRun in a real SIEM, with a recorded result.

2 of 2 positive test events matched; 1 of 1 near-miss events were correctly ignored. Community rule reused unmodified from SigmaHQ. OffSet7 converted it and tested it on synthetic events.

Detection logic and queries

Queries are shown exactly as generated. Test them in your environment before you deploy them.

Sigma

Sigma (YAML) · 39698b3f-da92-4bc6-bfb5-645a98386e45

Download
title: Win Susp Computer Name Containing Samtheadmin
id: 39698b3f-da92-4bc6-bfb5-645a98386e45
status: test
description: Detects suspicious computer name samtheadmin-{1..100}$ generated by hacktool
references:
    - https://twitter.com/malmoeb/status/1511760068743766026
    - https://github.com/helloexp/0day/blob/614227a7b9beb0e91e7e2c6a5e532e6f7a8e883c/00-CVE_EXP/CVE-2021-42287/sam-the-admin/sam_the_admin.py
author: elhoim
date: 2022-09-09
modified: 2023-01-04
tags:
    - attack.initial-access
    - cve.2021-42278
    - cve.2021-42287
    - attack.persistence
    - attack.privilege-escalation
    - attack.stealth
    - attack.t1078
logsource:
    service: security
    product: windows
detection:
    # Not adding an EventID on purpose to try to match on any event in security (including use of account), not just 4741 (computer account created)
    selection1:
        SamAccountName|startswith: 'SAMTHEADMIN-'
        SamAccountName|endswith: '$'
    selection2:
        TargetUserName|startswith: 'SAMTHEADMIN-'
        TargetUserName|endswith: '$'
    condition: 1 of selection*
falsepositives:
    - Unknown
level: critical

QRadar AQL

IBM QRadar AQL (hunting query)Hunting query

Hunting search for the Log Activity tab or the API. It is not a QRadar rule.

AQL search for the Log Activity tab or the API. It is NOT a deployable QRadar rule: real-time detection in QRadar is a CRE (Custom Rule Engine) rule, for which this build only writes a design specification (qradar_cre).

SELECT * FROM events WHERE devicetype=12 AND ((LOWER("SAM Account Name") LIKE 'samtheadmin-%' AND LOWER("SAM Account Name") LIKE '%$') OR (LOWER("Target Username") LIKE 'samtheadmin-%' AND LOWER("Target Username") LIKE '%$'))

QRadar CRE

Design for the QRadar Rule Wizard. It is not importable and has not been tested in QRadar.

Rule name
OffSet7: Win Susp Computer Name Containing Samtheadmin
Rule type
Event rule (Local)
Log source types
Microsoft Windows Security Event Log DSM (Security channel)

Building blocks

  • BB:OffSet7:Win Susp Computer Name Containing Samtheadmin:selection1 (match)
    All test lines must match (AND).
    • SAM Account Name starts with: SAMTHEADMIN-
    • SAM Account Name ends with: $
  • BB:OffSet7:Win Susp Computer Name Containing Samtheadmin:selection2 (match)
    All test lines must match (AND).
    • Target Username starts with: SAMTHEADMIN-
    • Target Username ends with: $

Main rule, option A (building blocks)

  1. when the event(s) were detected by one or more of these log source types: Microsoft Windows Security Event Log DSM (Security channel)
  2. when an event matches the condition built from these building blocks: (ANY of [BB:OffSet7:Win Susp Computer Name Containing Samtheadmin:selection1, BB:OffSet7:Win Susp Computer Name Containing Samtheadmin:selection2])

Main rule, option B (AQL filter test)

  1. when the event matches this AQL filter query: devicetype=12 AND ((LOWER("SAM Account Name") LIKE 'samtheadmin-%' AND LOWER("SAM Account Name") LIKE '%$') OR (LOWER("Target Username") LIKE 'samtheadmin-%' AND LOWER("Target Username") LIKE '%$'))

Rule response

  • Severity 9, credibility 6, relevance 7
  • Ensure the detected event is part of an offense; index offense on Log Source (host) and annotate with the rule title and OffSet7 rule id
  • Respond no more than once per 30 minutes per Log Source (tune per environment)

Limitations

  • QRadar AQL LIKE / CRE string tests are case-sensitive unless the property is lower-cased; the AQL option uses LOWER() where the backend applied it.

Splunk

Splunk SPLSearch

Search for Splunk with Windows/Sysmon field names. A scheduled search or ES correlation search also needs a schedule, time range, throttling and an adaptive response, set in your environment.

source="WinEventLog:Security" ((SamAccountName="SAMTHEADMIN-*" SamAccountName="*$") OR (TargetUserName="SAMTHEADMIN-*" TargetUserName="*$"))

Splunk savedsearches.conf stanzaScheduled search template

Template stanza. Review schedule, alert actions and index/sourcetype for your environment before enabling.

[default]
dispatch.earliest_time = -30d
dispatch.latest_time = now

[Win Susp Computer Name Containing Samtheadmin]
description = Detects suspicious computer name samtheadmin-{1..100}$ generated by hacktool
search = source="WinEventLog:Security" ((SamAccountName="SAMTHEADMIN-*" SamAccountName="*$") OR (TargetUserName="SAMTHEADMIN-*" TargetUserName="*$"))

Microsoft Sentinel

Microsoft Sentinel KQL (ASIM)Hunting query

Hunting query over ASIM-normalized tables. An analytics rule also needs a schedule, entity mapping and alert grouping.

SecurityEvent
| where (SamAccountName startswith "SAMTHEADMIN-" and SamAccountName endswith "$") or (TargetUserName startswith "SAMTHEADMIN-" and TargetUserName endswith "$")

Elastic

Elastic Lucene (ECS)Hunting query

Lucene query over ECS fields (Winlogbeat/Elastic Agent Windows mappings). A detection rule also needs an index pattern, schedule and actions.

winlog.channel:Security AND ((winlog.event_data.SamAccountName:SAMTHEADMIN\-* AND winlog.event_data.SamAccountName:*$) OR (winlog.event_data.TargetUserName:SAMTHEADMIN\-* AND winlog.event_data.TargetUserName:*$))

Elastic EQL (ECS)Hunting query

EQL query over ECS fields. Usable in an Elastic Security EQL rule after review; index pattern and schedule are set per environment.

any where winlog.channel:"Security" and ((winlog.event_data.SamAccountName:"SAMTHEADMIN-*" and winlog.event_data.SamAccountName:"*$") or (winlog.event_data.TargetUserName:"SAMTHEADMIN-*" and winlog.event_data.TargetUserName:"*$"))

Elastic ES|QL (ECS)Hunting query

ES|QL query over ECS fields; the FROM clause uses * and must be narrowed to your indices.

from * metadata _id, _index, _version | where winlog.channel=="Security" and (starts_with(winlog.event_data.SamAccountName, "SAMTHEADMIN-") and ends_with(winlog.event_data.SamAccountName, "$") or starts_with(winlog.event_data.TargetUserName, "SAMTHEADMIN-") and ends_with(winlog.event_data.TargetUserName, "$"))

No working conversion: Microsoft Defender XDR KQL (Defender XDR advanced hunting has no Windows event-log channel tables (Security/System/Application).)

Required telemetry

Log source
product: windows · service: security
Fields used
SamAccountName TargetUserName

False positives

  • Unknown

Investigation and response

No OffSet7 investigation guidance has been written for this rule yet. Start from the false positives above and the ATT&CK technique pages.

References

Author and attribution

Author
elhoim
Source
SigmaHQ · rules/windows/builtin/security/win_security_susp_computer_name.yml
Upstream commit
9688134317a2
Licence
Detection Rule License (DRL) 1.1

Version history

  1. Version 1Imported from SigmaHQ
  2. OffSet7 build · SigmaHQ 9688134317a2

Related rules