Startup/Logon Script added to Group Policy Object

Detects the modification of Group Policy Objects (GPO) to add a startup/logon script to users or computer objects.

Elastic rule (View on GitHub)

 1[metadata]
 2creation_date = "2021/11/08"
 3integration = ["system", "windows"]
 4maturity = "production"
 5min_stack_comments = "New fields added: required_fields, related_integrations, setup"
 6min_stack_version = "8.3.0"
 7updated_date = "2023/10/23"
 8
 9[rule]
10author = ["Elastic"]
11description = "Detects the modification of Group Policy Objects (GPO) to add a startup/logon script to users or computer objects."
12false_positives = ["Legitimate Administrative Activity"]
13index = ["winlogbeat-*", "logs-system.*", "logs-windows.*"]
14language = "kuery"
15license = "Elastic License v2"
16name = "Startup/Logon Script added to Group Policy Object"
17note = """## Triage and analysis
18
19### Investigating Startup/Logon Script added to Group Policy Object
20
21Group Policy Objects (GPOs) can be used by attackers to instruct arbitrarily large groups of clients to execute specified commands at startup, logon, shutdown, and logoff. This is done by creating or modifying the `scripts.ini` or `psscripts.ini` files. The scripts are stored in the following paths:
22  - `<GPOPath>\\Machine\\Scripts\\`
23  - `<GPOPath>\\User\\Scripts\\`
24
25#### Possible investigation steps
26
27- This attack abuses a legitimate mechanism of Active Directory, so it is important to determine whether the activity is legitimate and the administrator is authorized to perform this operation.
28- Retrieve the contents of the `ScheduledTasks.xml` file, and check the `<Command>` and `<Arguments>` XML tags for any potentially malicious commands or binaries.
29- Investigate other alerts associated with the user/host during the past 48 hours.
30- Scope which objects may be compromised by retrieving information about which objects are controlled by the GPO.
31
32### False positive analysis
33
34- Verify if the execution is legitimately authorized and executed under a change management process.
35
36### Related rules
37
38- Group Policy Abuse for Privilege Addition - b9554892-5e0e-424b-83a0-5aef95aa43bf
39- Scheduled Task Execution at Scale via GPO - 15a8ba77-1c13-4274-88fe-6bd14133861e
40
41### Response and remediation
42
43- Initiate the incident response process based on the outcome of the triage.
44- The investigation and containment must be performed in every computer controlled by the GPO, where necessary.
45- Remove the script from the GPO.
46- Check if other GPOs have suspicious scripts attached.
47- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
48- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
49"""
50references = [
51    "https://github.com/atc-project/atc-data/blob/master/docs/Logging_Policies/LP_0025_windows_audit_directory_service_changes.md",
52    "https://github.com/atc-project/atc-data/blob/f2bbb51ecf68e2c9f488e3c70dcdd3df51d2a46b/docs/Logging_Policies/LP_0029_windows_audit_detailed_file_share.md",
53    "https://labs.f-secure.com/tools/sharpgpoabuse",
54]
55risk_score = 47
56rule_id = "16fac1a1-21ee-4ca6-b720-458e3855d046"
57setup = """## Setup
58
59The 'Audit Detailed File Share' audit policy must be configured (Success Failure).
60Steps to implement the logging policy with Advanced Audit Configuration:

Computer Configuration > Policies > Windows Settings > Security Settings > Advanced Audit Policies Configuration > Audit Policies > Object Access > Audit Detailed File Share (Success,Failure)

1
2The 'Audit Directory Service Changes' audit policy must be configured (Success Failure).
3Steps to implement the logging policy with Advanced Audit Configuration:

Computer Configuration > Policies > Windows Settings > Security Settings > Advanced Audit Policies Configuration > Audit Policies > DS Access > Audit Directory Service Changes (Success,Failure)

 1"""
 2severity = "medium"
 3tags = [
 4    "Domain: Endpoint",
 5    "OS: Windows",
 6    "Use Case: Threat Detection",
 7    "Tactic: Privilege Escalation",
 8    "Data Source: Active Directory",
 9    "Resources: Investigation Guide",
10    "Use Case: Active Directory Monitoring"
11]
12timestamp_override = "event.ingested"
13type = "query"
14
15query = '''
16(
17 event.code:5136 and winlog.event_data.AttributeLDAPDisplayName:(gPCMachineExtensionNames or gPCUserExtensionNames) and
18   winlog.event_data.AttributeValue:(*42B5FAAE-6536-11D2-AE5A-0000F87571E3* and
19                                      (*40B66650-4972-11D1-A7CA-0000F87571E3* or *40B6664F-4972-11D1-A7CA-0000F87571E3*))
20)
21or
22(
23 event.code:5145 and winlog.event_data.ShareName:\\\\*\\SYSVOL and
24   winlog.event_data.RelativeTargetName:(*\\scripts.ini or *\\psscripts.ini) and
25   (message:WriteData or winlog.event_data.AccessList:*%%4417*)
26)
27'''
28
29
30[[rule.threat]]
31framework = "MITRE ATT&CK"
32[[rule.threat.technique]]
33id = "T1484"
34name = "Domain Policy Modification"
35reference = "https://attack.mitre.org/techniques/T1484/"
36[[rule.threat.technique.subtechnique]]
37id = "T1484.001"
38name = "Group Policy Modification"
39reference = "https://attack.mitre.org/techniques/T1484/001/"
40
41
42[[rule.threat.technique]]
43id = "T1547"
44name = "Boot or Logon Autostart Execution"
45reference = "https://attack.mitre.org/techniques/T1547/"
46
47
48[rule.threat.tactic]
49id = "TA0004"
50name = "Privilege Escalation"
51reference = "https://attack.mitre.org/tactics/TA0004/"

Triage and analysis

Investigating Startup/Logon Script added to Group Policy Object

Group Policy Objects (GPOs) can be used by attackers to instruct arbitrarily large groups of clients to execute specified commands at startup, logon, shutdown, and logoff. This is done by creating or modifying the scripts.ini or psscripts.ini files. The scripts are stored in the following paths:

  • <GPOPath>\Machine\Scripts\
  • <GPOPath>\User\Scripts\

Possible investigation steps

  • This attack abuses a legitimate mechanism of Active Directory, so it is important to determine whether the activity is legitimate and the administrator is authorized to perform this operation.
  • Retrieve the contents of the ScheduledTasks.xml file, and check the <Command> and <Arguments> XML tags for any potentially malicious commands or binaries.
  • Investigate other alerts associated with the user/host during the past 48 hours.
  • Scope which objects may be compromised by retrieving information about which objects are controlled by the GPO.

False positive analysis

  • Verify if the execution is legitimately authorized and executed under a change management process.
  • Group Policy Abuse for Privilege Addition - b9554892-5e0e-424b-83a0-5aef95aa43bf
  • Scheduled Task Execution at Scale via GPO - 15a8ba77-1c13-4274-88fe-6bd14133861e

Response and remediation

  • Initiate the incident response process based on the outcome of the triage.
  • The investigation and containment must be performed in every computer controlled by the GPO, where necessary.
  • Remove the script from the GPO.
  • Check if other GPOs have suspicious scripts attached.
  • Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
  • Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).

References

Related rules

to-top