Detection rules › Elastic

Persistence via BITS SetNotifyCmdLine Method

Source
github.com/elastic/protections-artifacts

Identifies suspicious execution from the Windows Background Intelligent Transfer Service (BITS) service via BITS SetNotifyCmdLine method. This method specifies a program to execute when a BITS job enters the BG_JOB_STATE_ERROR or BG_JOB_STATE_TRANSFERRED state. This feature can be abused to maintain stealthy persistence on an infected system.

MITRE ATT&CK coverage

TacticTechniques
Persistence

Rule body

[rule]
description = """
Identifies suspicious execution from the Windows Background Intelligent Transfer Service (BITS) service via BITS
SetNotifyCmdLine method. This method specifies a program to execute when a BITS job enters the BG_JOB_STATE_ERROR or
BG_JOB_STATE_TRANSFERRED state. This feature can be abused to maintain stealthy persistence on an infected system.
"""
id = "3400fac0-3978-4cc5-a82d-69d08625c3ad"
license = "Elastic License v2"
name = "Persistence via BITS SetNotifyCmdLine Method"
os_list = ["windows"]
reference = [
    "https://blog.menasec.net/2021/05/hunting-for-suspicious-usage-of.html",
    "https://docs.microsoft.com/en-us/windows/win32/api/bits1_5/nf-bits1_5-ibackgroundcopyjob2-setnotifycmdline",
    "https://www.elastic.co/security-labs/bits-and-bytes-analyzing-bitsloth",
]
version = "1.0.30"

query = '''
process where event.action == "start" and

 /* child process of the BITS service */
 process.parent.name == "svchost.exe" and process.parent.args == "BITS" and

 (
  /* commonly abused trusted programs */
  process.pe.original_file_name in ("cscript.exe", "wscript.exe", "PowerShell.EXE", "Cmd.Exe", "MSHTA.EXE", "RUNDLL32.EXE",
  "REGSVR32.EXE", "MSBuild.exe", "InstallUtil.exe", "RegAsm.exe", "wmic.exe", "CMSTP.EXE", "wuauclt.exe", "CertUtil.exe") or

  /* programs unsigned or with untrusted code signature status running from users home folder */
  (process.code_signature.trusted != true and process.executable : "?:\\Users\\*") or

  /* suspicious paths */
   process.executable : ("?:\\Users\\Public\\*", "?:\\ProgramData\\*", "?:\\Users\\*\\AppData\\*", "?:\\Windows\\Microsoft.NET\\*")
  )

  /* false positives */
  and not (process.code_signature.subject_name :
                    ("YANDEX LLC", "McAfee, LLC", "AVG Technologies USA, Inc.", "Reason Cybersecurity Inc.") and
           process.code_signature.trusted == true) and
  not (process.name : "wmic.exe" and process.args : "MSFT_MpComputerStatus" and process.args : "get") and
  not (process.name : "rundll32.exe" and process.args :  "?:\\Program Files (x86)\\PCPitstop\\Super Shield\\*") and
  not process.hash.sha256 in ("65aee904ab6008a25963a85941039baae02e9a120e338ad2635ec4be9ddf2e73",
                              "867a86be9ab8dfa8f2d4997dd7f4df584709f9677d35efa94ddf0d2be224351a",
                              "fbdbf5f13818503b5d311c233af6467f5f9a462418bcc4558c1561df0c033d7c",
                              "bca7e687a39ac52d8ddb0e95f0886ba3d194ff55a11cdf09fc2b0da9ebbad572",
                              "11d659e714ff6d393a30c6c560062e82587b50462aeb33db3dda508009d3ed76",
                              "5aff8a288cbb22900a0c21088ca5af4447d492ebc35caed757e93a2ccdfa4455")
'''

min_endpoint_version = "7.15.0"
optional_actions = []
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 0

[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1197"
name = "BITS Jobs"
reference = "https://attack.mitre.org/techniques/T1197/"


[threat.tactic]
id = "TA0003"
name = "Persistence"
reference = "https://attack.mitre.org/tactics/TA0003/"

[internal]
min_endpoint_version = "7.15.0"

Stages and Predicates

Stage 1: process

process where event.action == "start" and
 process.parent.name == "svchost.exe" and process.parent.args == "BITS" and
 (
  process.pe.original_file_name in ("cscript.exe", "wscript.exe", "PowerShell.EXE", "Cmd.Exe", "MSHTA.EXE", "RUNDLL32.EXE",
  "REGSVR32.EXE", "MSBuild.exe", "InstallUtil.exe", "RegAsm.exe", "wmic.exe", "CMSTP.EXE", "wuauclt.exe", "CertUtil.exe") or
  (process.code_signature.trusted != true and process.executable : "?:\\Users\\*") or
   process.executable : ("?:\\Users\\Public\\*", "?:\\ProgramData\\*", "?:\\Users\\*\\AppData\\*", "?:\\Windows\\Microsoft.NET\\*")
  )
  and not (process.code_signature.subject_name :
                    ("YANDEX LLC", "McAfee, LLC", "AVG Technologies USA, Inc.", "Reason Cybersecurity Inc.") and
           process.code_signature.trusted == true) and
  not (process.name : "wmic.exe" and process.args : "MSFT_MpComputerStatus" and process.args : "get") and
  not (process.name : "rundll32.exe" and process.args :  "?:\\Program Files (x86)\\PCPitstop\\Super Shield\\*") and
  not process.hash.sha256 in ("65aee904ab6008a25963a85941039baae02e9a120e338ad2635ec4be9ddf2e73",
                              "867a86be9ab8dfa8f2d4997dd7f4df584709f9677d35efa94ddf0d2be224351a",
                              "fbdbf5f13818503b5d311c233af6467f5f9a462418bcc4558c1561df0c033d7c",
                              "bca7e687a39ac52d8ddb0e95f0886ba3d194ff55a11cdf09fc2b0da9ebbad572",
                              "11d659e714ff6d393a30c6c560062e82587b50462aeb33db3dda508009d3ed76",
                              "5aff8a288cbb22900a0c21088ca5af4447d492ebc35caed757e93a2ccdfa4455")

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
process.argseqMSFT_MpComputerStatusexcludes:process.args field:"process.args" value:"MSFT_MpComputerStatus"
process.argseqgetexcludes:process.args field:"process.args" value:"get"
process.nameeqwmic.exeexcludes:process.name field:"process.name" value:"wmic.exe"
process.argsstarts_with?:\Program Files (x86)\PCPitstop\Super Shield\excludes:process.args field:"process.args" value:"?:\Program Files (x86)\PCPitstop\Super Shield\"
process.nameeqrundll32.exeexcludes:process.name field:"process.name" value:"rundll32.exe"
process.code_signature.subject_nameeqYANDEX LLC, McAfee, LLC, AVG Technologies USA, Inc., Reason Cybersecurity Inc.excludes:process.code_signature.subject_name
process.code_signature.trustedeqtrueexcludes:process.code_signature.trusted field:"process.code_signature.trusted" value:"true"
process.hash.sha256in11d659e714ff6d393a30c6c560062e82587b50462aeb33db3dda508009d3ed76, 5aff8a288cbb22900a0c21088ca5af4447d492ebc35caed757e93a2ccdfa4455, 65aee904ab6008a25963a85941039baae02e9a120e338ad2635ec4be9ddf2e73, 867a86be9ab8dfa8f2d4997dd7f4df584709f9677d35efa94ddf0d2be224351a, bca7e687a39ac52d8ddb0e95f0886ba3d194ff55a11cdf09fc2b0da9ebbad572, fbdbf5f13818503b5d311c233af6467f5f9a462418bcc4558c1561df0c033d7cexcludes:process.hash.sha256

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
event.actioneq
  • start corpus 391 (elastic 391)
field:"EventType" kind:eq value:"start"
process.code_signature.trustedne
  • true transforms: boolean corpus 8 (elastic 8)
field:"process.code_signature.trusted" kind:ne value:"true"
process.executablewildcard
  • ?:\ProgramData\* corpus 17 (elastic 17)
  • ?:\Users\* corpus 18 (elastic 18)
  • ?:\Users\*\AppData\* corpus 12 (elastic 12)
  • ?:\Users\Public\* corpus 4 (elastic 4)
  • ?:\Windows\Microsoft.NET\* corpus 5 (elastic 5)
field:"Image" kind:wildcard
process.parent.argseq
  • BITS
field:"process.parent.args" kind:eq value:"BITS"
process.parent.nameeq
  • svchost.exe corpus 19 (elastic 12, splunk 5, kusto 2)
field:"parent_process_name" kind:eq value:"svchost.exe"
process.pe.original_file_namein
  • CMSTP.EXE corpus 11 (elastic 6, sigma 5)
  • CertUtil.exe corpus 30 (sigma 14, elastic 10, splunk 6)
  • Cmd.Exe corpus 81 (sigma 43, elastic 21, splunk 17)
  • InstallUtil.exe corpus 21 (elastic 11, sigma 6, splunk 4)
  • MSBuild.exe corpus 20 (elastic 15, splunk 4, sigma 1)
  • MSHTA.EXE corpus 40 (elastic 21, sigma 13, splunk 6)
  • PowerShell.EXE corpus 138 (sigma 84, splunk 30, elastic 24)
  • REGSVR32.EXE corpus 37 (sigma 17, elastic 15, splunk 5)
  • RUNDLL32.EXE corpus 78 (sigma 35, elastic 22, splunk 21)
  • RegAsm.exe corpus 14 (elastic 7, sigma 6, splunk 1)
  • cscript.exe corpus 32 (sigma 17, elastic 15)
  • wmic.exe corpus 80 (sigma 38, elastic 24, splunk 18)
  • wscript.exe corpus 38 (elastic 21, sigma 17)
  • wuauclt.exe corpus 5 (elastic 3, sigma 2)
field:"OriginalFileName" kind:in