Potential PowerShell HackTool Script by Function Names
Detects known PowerShell offensive tooling functions names in PowerShell scripts. Attackers commonly use out-of-the-box offensive tools without modifying the code. This rule aim is to take advantage of that.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2023/01/17"
3integration = ["windows"]
4maturity = "production"
5min_stack_comments = "Breaking change at 8.14.0 for the Windows Integration."
6min_stack_version = "8.14.0"
7updated_date = "2024/10/28"
8
9[transform]
10[[transform.osquery]]
11label = "Osquery - Retrieve DNS Cache"
12query = "SELECT * FROM dns_cache"
13
14[[transform.osquery]]
15label = "Osquery - Retrieve All Services"
16query = "SELECT description, display_name, name, path, pid, service_type, start_type, status, user_account FROM services"
17
18[[transform.osquery]]
19label = "Osquery - Retrieve Services Running on User Accounts"
20query = """
21SELECT description, display_name, name, path, pid, service_type, start_type, status, user_account FROM services WHERE
22NOT (user_account LIKE '%LocalSystem' OR user_account LIKE '%LocalService' OR user_account LIKE '%NetworkService' OR
23user_account == null)
24"""
25
26[[transform.osquery]]
27label = "Osquery - Retrieve Service Unsigned Executables with Virustotal Link"
28query = """
29SELECT concat('https://www.virustotal.com/gui/file/', sha1) AS VtLink, name, description, start_type, status, pid,
30services.path FROM services JOIN authenticode ON services.path = authenticode.path OR services.module_path =
31authenticode.path JOIN hash ON services.path = hash.path WHERE authenticode.result != 'trusted'
32"""
33
34[rule]
35author = ["Elastic"]
36description = """
37Detects known PowerShell offensive tooling functions names in PowerShell scripts. Attackers commonly use out-of-the-box
38offensive tools without modifying the code. This rule aim is to take advantage of that.
39"""
40from = "now-9m"
41index = ["winlogbeat-*", "logs-windows.powershell*"]
42language = "kuery"
43license = "Elastic License v2"
44name = "Potential PowerShell HackTool Script by Function Names"
45note = """## Triage and analysis
46
47### Investigating Potential PowerShell HackTool Script by Function Names
48
49PowerShell is one of the main tools system administrators use for automation, report routines, and other tasks. This makes it available for use in various environments, and creates an attractive way for attackers to execute code.
50
51Adversaries often exploit PowerShell's capabilities to execute malicious scripts and perform various attacks. This rule identifies known offensive tooling function names in PowerShell scripts, as attackers commonly use out-of-the-box tools without modifying the code. By monitoring these specific function names, the rule aims to detect and alert potential malicious PowerShell activity.
52
53> **Note**:
54> This investigation guide uses the [Osquery Markdown Plugin](https://www.elastic.co/guide/en/security/master/invest-guide-run-osquery.html) introduced in Elastic Stack version 8.5.0. Older Elastic Stack versions will display unrendered Markdown in this guide.
55
56### Possible investigation steps
57
58- Examine the script content that triggered the detection; look for suspicious DLL imports, collection or exfiltration capabilities, suspicious functions, encoded or compressed data, and other potentially malicious characteristics.
59- Investigate the script execution chain (parent process tree) for unknown processes. Examine their executable files for prevalence, whether they are located in expected locations, and if they are signed with valid digital signatures.
60- Examine the script's execution context, such as the user account, privileges, the role of the system on which it was executed, and any relevant timestamps.
61- Investigate other alerts associated with the user/host during the past 48 hours.
62- Evaluate whether the user needs to use PowerShell to complete tasks.
63- Investigate the origin of the PowerShell script, including its source, download method, and any associated URLs or IP addresses.
64- Examine the host for derived artifacts that indicate suspicious activities:
65 - Analyze the script using a private sandboxed analysis system.
66 - Observe and collect information about the following activities in both the sandbox and the alert subject host:
67 - Attempts to contact external domains and addresses.
68 - Use the Elastic Defend network events to determine domains and addresses contacted by the subject process by filtering by the process's `process.entity_id`.
69 - Examine the DNS cache for suspicious or anomalous entries.
70 - $osquery_0
71 - Use the Elastic Defend registry events to examine registry keys accessed, modified, or created by the related processes in the process tree.
72 - Examine the host services for suspicious or anomalous entries.
73 - $osquery_1
74 - $osquery_2
75 - $osquery_3
76 - Retrieve the files' SHA-256 hash values using the PowerShell `Get-FileHash` cmdlet and search for the existence and reputation of the hashes in resources like VirusTotal, Hybrid-Analysis, CISCO Talos, Any.run, etc.
77- Investigate potentially compromised accounts. Analysts can do this by searching for login events (for example, 4624) to the target host after the registry modification.
78
79
80### False positive analysis
81
82- This rule may generate false positives if legitimate scripts or tools used by administrators contain any of the listed function names. These function names are commonly associated with offensive tooling, but they may also be present in benign scripts or tools.
83- To handle these false positives consider adding exceptions - preferably with a combination of full file path and users.
84
85### Related Rules
86
87- PowerShell Invoke-NinjaCopy script - b8386923-b02c-4b94-986a-d223d9b01f88
88- PowerShell Suspicious Discovery Related Windows API Functions - 61ac3638-40a3-44b2-855a-985636ca985e
89- Potential Process Injection via PowerShell - 2e29e96a-b67c-455a-afe4-de6183431d0d
90- PowerShell Keylogging Script - bd2c86a0-8b61-4457-ab38-96943984e889
91
92### Response and Remediation
93
94- Initiate the incident response process based on the outcome of the triage.
95 - If malicious activity is confirmed, perform a broader investigation to identify the scope of the compromise and determine the appropriate remediation steps.
96- Isolate the involved hosts to prevent further post-compromise behavior.
97- If the triage identified malware, search the environment for additional compromised hosts.
98 - Implement temporary network rules, procedures, and segmentation to contain the malware.
99 - Stop suspicious processes.
100 - Immediately block the identified indicators of compromise (IoCs).
101 - Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system.
102- Remove and block malicious artifacts identified during triage.
103- Reimage the host operating system or restore the compromised files to clean versions.
104- Restrict PowerShell usage outside of IT and engineering business units using GPOs, AppLocker, Intune, or similar software.
105- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords for these accounts and other potentially compromised credentials, such as email, business systems, and web services.
106- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
107- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
108- 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).
109"""
110references = [
111 "https://github.com/atc-project/atc-data/blob/master/docs/Logging_Policies/LP_0109_windows_powershell_script_block_log.md",
112 "https://github.com/BC-SECURITY/Empire"
113]
114risk_score = 47
115rule_id = "cde1bafa-9f01-4f43-a872-605b678968b0"
116setup = """## Setup
117
118The 'PowerShell Script Block Logging' logging policy must be enabled.
119Steps to implement the logging policy with Advanced Audit Configuration:
Computer Configuration > Administrative Templates > Windows PowerShell > Turn on PowerShell Script Block Logging (Enable)
1
2Steps to implement the logging policy via registry:
reg add "hklm\SOFTWARE\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging" /v EnableScriptBlockLogging /t REG_DWORD /d 1
1"""
2severity = "medium"
3tags = ["Domain: Endpoint", "OS: Windows", "Use Case: Threat Detection", "Tactic: Execution", "Data Source: PowerShell Logs"]
4timestamp_override = "event.ingested"
5type = "query"
6
7query = '''
8event.category:process and host.os.type:windows and
9 powershell.file.script_block_text : (
10 "Add-DomainGroupMember" or "Add-DomainObjectAcl" or
11 "Add-RemoteConnection" or "Add-ServiceDacl" or
12 "Add-Win32Type" or "Convert-ADName" or
13 "Convert-LDAPProperty" or "ConvertFrom-LDAPLogonHours" or
14 "ConvertFrom-UACValue" or "Copy-ArrayOfMemAddresses" or
15 "Create-NamedPipe" or "Create-ProcessWithToken" or
16 "Create-RemoteThread" or "Create-SuspendedWinLogon" or
17 "Create-WinLogonProcess" or "Emit-CallThreadStub" or
18 "Enable-SeAssignPrimaryTokenPrivilege" or "Enable-SeDebugPrivilege" or
19 "Enum-AllTokens" or "Export-PowerViewCSV" or
20 "Find-AVSignature" or "Find-AppLockerLog" or
21 "Find-DomainLocalGroupMember" or "Find-DomainObjectPropertyOutlier" or
22 "Find-DomainProcess" or "Find-DomainShare" or
23 "Find-DomainUserEvent" or "Find-DomainUserLocation" or
24 "Find-InterestingDomainAcl" or "Find-InterestingDomainShareFile" or
25 "Find-InterestingFile" or "Find-LocalAdminAccess" or
26 "Find-PSScriptsInPSAppLog" or "Find-PathDLLHijack" or
27 "Find-ProcessDLLHijack" or "Find-RDPClientConnection" or
28 "Get-AllAttributesForClass" or "Get-CachedGPPPassword" or
29 "Get-DecryptedCpassword" or "Get-DecryptedSitelistPassword" or
30 "Get-DelegateType" or "New-RelayEnumObject" or
31 "Get-DomainDFSShare" or "Get-DomainDFSShareV1" or
32 "Get-DomainDFSShareV2" or "Get-DomainDNSRecord" or
33 "Get-DomainDNSZone" or "Get-DomainFileServer" or
34 "Get-DomainForeignGroupMember" or "Get-DomainForeignUser" or
35 "Get-DomainGPO" or "Get-DomainGPOComputerLocalGroupMapping" or
36 "Get-DomainGPOLocalGroup" or "Get-DomainGPOUserLocalGroupMapping" or
37 "Get-DomainGUIDMap" or "Get-DomainGroup" or
38 "Get-DomainGroupMember" or "Get-DomainGroupMemberDeleted" or
39 "Get-DomainManagedSecurityGroup" or "Get-DomainOU" or
40 "Get-DomainObject" or "Get-DomainObjectAcl" or
41 "Get-DomainObjectAttributeHistory" or "Get-DomainObjectLinkedAttributeHistory" or
42 "Get-DomainPolicyData" or "Get-DomainSID" or
43 "Get-DomainSPNTicket" or "Get-DomainSearcher" or
44 "Get-DomainSite" or "Get-DomainSubnet" or
45 "Get-DomainTrust" or "Get-DomainTrustMapping" or
46 "Get-DomainUser" or "Get-DomainUserEvent" or
47 "Get-Forest" or "Get-ForestDomain" or
48 "Get-ForestGlobalCatalog" or "Get-ForestSchemaClass" or
49 "Get-ForestTrust" or "Get-GPODelegation" or
50 "Get-GPPAutologon" or "Get-GPPInnerField" or
51 "Get-GPPInnerFields" or "Get-GPPPassword" or
52 "Get-GptTmpl" or "Get-GroupsXML" or
53 "Get-HttpStatus" or "Get-ImageNtHeaders" or
54 "Get-Keystrokes" or "New-SOASerialNumberArray" or
55 "Get-MemoryProcAddress" or "Get-MicrophoneAudio" or
56 "Get-ModifiablePath" or "Get-ModifiableRegistryAutoRun" or
57 "Get-ModifiableScheduledTaskFile" or "Get-ModifiableService" or
58 "Get-ModifiableServiceFile" or "Get-Name" or
59 "Get-NetComputerSiteName" or "Get-NetLocalGroup" or
60 "Get-NetLocalGroupMember" or "Get-NetLoggedon" or
61 "Get-NetRDPSession" or "Get-NetSession" or
62 "Get-NetShare" or "Get-PEArchitecture" or
63 "Get-PEBasicInfo" or "Get-PEDetailedInfo" or
64 "Get-PathAcl" or "Get-PrimaryToken" or
65 "Get-ProcAddress" or "Get-ProcessTokenGroup" or
66 "Get-ProcessTokenPrivilege" or "Get-ProcessTokenType" or
67 "Get-RegLoggedOn" or "Get-RegistryAlwaysInstallElevated" or
68 "Get-RegistryAutoLogon" or "Get-RemoteProcAddress" or
69 "Get-Screenshot" or "Get-ServiceDetail" or
70 "Get-SiteListPassword" or "Get-SitelistField" or
71 "Get-System" or "Get-SystemNamedPipe" or
72 "Get-SystemToken" or "Get-ThreadToken" or
73 "Get-TimedScreenshot" or "Get-TokenInformation" or
74 "Get-TopPort" or "Get-UnattendedInstallFile" or
75 "Get-UniqueTokens" or "Get-UnquotedService" or
76 "Get-VaultCredential" or "Get-VaultElementValue" or
77 "Get-VirtualProtectValue" or "Get-VolumeShadowCopy" or
78 "Get-WMIProcess" or "Get-WMIRegCachedRDPConnection" or
79 "Get-WMIRegLastLoggedOn" or "Get-WMIRegMountedDrive" or
80 "Get-WMIRegProxy" or "Get-WebConfig" or
81 "Get-Win32Constants" or "Get-Win32Functions" or
82 "Get-Win32Types" or "Import-DllImports" or
83 "Import-DllInRemoteProcess" or "Inject-LocalShellcode" or
84 "Inject-RemoteShellcode" or "Install-ServiceBinary" or
85 "Invoke-CompareAttributesForClass" or "Invoke-CreateRemoteThread" or
86 "Invoke-CredentialInjection" or "Invoke-DllInjection" or
87 "Invoke-EventVwrBypass" or "Invoke-ImpersonateUser" or
88 "Invoke-Kerberoast" or "Invoke-MemoryFreeLibrary" or
89 "Invoke-MemoryLoadLibrary" or
90 "Invoke-Mimikatz" or "Invoke-NinjaCopy" or
91 "Invoke-PatchDll" or "Invoke-Portscan" or
92 "Invoke-PrivescAudit" or "Invoke-ReflectivePEInjection" or
93 "Invoke-ReverseDnsLookup" or "Invoke-RevertToSelf" or
94 "Invoke-ServiceAbuse" or "Invoke-Shellcode" or
95 "Invoke-TokenManipulation" or "Invoke-UserImpersonation" or
96 "Invoke-WmiCommand" or "Mount-VolumeShadowCopy" or
97 "New-ADObjectAccessControlEntry" or "New-DomainGroup" or
98 "New-DomainUser" or "New-DynamicParameter" or
99 "New-InMemoryModule" or
100 "New-ThreadedFunction" or "New-VolumeShadowCopy" or
101 "Out-CompressedDll" or "Out-EncodedCommand" or
102 "Out-EncryptedScript" or "Out-Minidump" or
103 "PortScan-Alive" or "Portscan-Port" or
104 "Remove-DomainGroupMember" or "Remove-DomainObjectAcl" or
105 "Remove-RemoteConnection" or "Remove-VolumeShadowCopy" or
106 "Restore-ServiceBinary" or "Set-DesktopACLToAllowEveryone" or
107 "Set-DesktopACLs" or "Set-DomainObject" or
108 "Set-DomainObjectOwner" or "Set-DomainUserPassword" or
109 "Set-ServiceBinaryPath" or "Sub-SignedIntAsUnsigned" or
110 "Test-AdminAccess" or "Test-MemoryRangeValid" or
111 "Test-ServiceDaclPermission" or "Update-ExeFunctions" or
112 "Update-MemoryAddresses" or "Update-MemoryProtectionFlags" or
113 "Write-BytesToMemory" or "Write-HijackDll" or
114 "Write-PortscanOut" or "Write-ServiceBinary" or
115 "Write-UserAddMSI" or "Invoke-Privesc" or
116 "func_get_proc_address" or "Invoke-BloodHound" or
117 "Invoke-HostEnum" or "Get-BrowserInformation" or
118 "Get-DomainAccountPolicy" or "Get-DomainAdmins" or
119 "Get-AVProcesses" or "Get-AVInfo" or
120 "Get-RecycleBin" or "Invoke-BruteForce" or
121 "Get-PassHints" or "Invoke-SessionGopher" or
122 "Get-LSASecret" or "Get-PassHashes" or
123 "Invoke-WdigestDowngrade" or "Get-ChromeDump" or
124 "Invoke-DomainPasswordSpray" or "Get-FoxDump" or
125 "New-HoneyHash" or "Invoke-DCSync" or
126 "Invoke-PowerDump" or "Invoke-SSIDExfil" or
127 "Invoke-PowerShellTCP" or "Add-Exfiltration" or
128 "Do-Exfiltration" or "Invoke-DropboxUpload" or
129 "Invoke-ExfilDataToGitHub" or "Invoke-EgressCheck" or
130 "Invoke-PostExfil" or "Create-MultipleSessions" or
131 "Invoke-NetworkRelay" or "New-GPOImmediateTask" or
132 "Invoke-WMIDebugger" or "Invoke-SQLOSCMD" or
133 "Invoke-SMBExec" or "Invoke-PSRemoting" or
134 "Invoke-ExecuteMSBuild" or "Invoke-DCOM" or
135 "Invoke-InveighRelay" or "Invoke-PsExec" or
136 "Invoke-SSHCommand" or "Find-ActiveUsersWMI" or
137 "Get-SystemDrivesWMI" or "Get-ActiveNICSWMI" or
138 "Remove-Persistence" or "DNS_TXT_Pwnage" or
139 "Execute-OnTime" or "HTTP-Backdoor" or
140 "Add-ConstrainedDelegationBackdoor" or "Add-RegBackdoor" or
141 "Add-ScrnSaveBackdoor" or "Gupt-Backdoor" or
142 "Invoke-ADSBackdoor" or "Add-Persistence" or
143 "Invoke-ResolverBackdoor" or "Invoke-EventLogBackdoor" or
144 "Invoke-DeadUserBackdoor" or "Invoke-DisableMachineAcctChange" or
145 "Invoke-AccessBinary" or "Add-NetUser" or
146 "Invoke-Schtasks" or "Invoke-JSRatRegsvr" or
147 "Invoke-JSRatRundll" or "Invoke-PoshRatHttps" or
148 "Invoke-PsGcatAgent" or "Remove-PoshRat" or
149 "Install-SSP" or "Invoke-BackdoorLNK" or
150 "PowerBreach" or "InstallEXE-Persistence" or
151 "RemoveEXE-Persistence" or "Install-ServiceLevel-Persistence" or
152 "Remove-ServiceLevel-Persistence" or "Invoke-Prompt" or
153 "Invoke-PacketCapture" or "Start-WebcamRecorder" or
154 "Get-USBKeyStrokes" or "Invoke-KeeThief" or
155 "Get-Keystrokes" or "Invoke-NetRipper" or
156 "Get-EmailItems" or "Invoke-MailSearch" or
157 "Invoke-SearchGAL" or "Get-WebCredentials" or
158 "Start-CaptureServer" or "Invoke-PowerShellIcmp" or
159 "Invoke-PowerShellTcpOneLine" or "Invoke-PowerShellTcpOneLineBind" or
160 "Invoke-PowerShellUdp" or "Invoke-PowerShellUdpOneLine" or
161 "Run-EXEonRemote" or "Download-Execute-PS" or
162 "Out-RundllCommand" or "Set-RemoteWMI" or
163 "Set-DCShadowPermissions" or "Invoke-PowerShellWMI" or
164 "Invoke-Vnc" or "Invoke-LockWorkStation" or
165 "Invoke-EternalBlue" or "Invoke-ShellcodeMSIL" or
166 "Invoke-MetasploitPayload" or "Invoke-DowngradeAccount" or
167 "Invoke-RunAs" or "ExetoText" or
168 "Disable-SecuritySettings" or "Set-MacAttribute" or
169 "Invoke-MS16032" or "Invoke-BypassUACTokenManipulation" or
170 "Invoke-SDCLTBypass" or "Invoke-FodHelperBypass" or
171 "Invoke-EventVwrBypass" or "Invoke-EnvBypass" or
172 "Get-ServiceUnquoted" or "Get-ServiceFilePermission" or
173 "Get-ServicePermission" or
174 "Enable-DuplicateToken" or "Invoke-PsUaCme" or
175 "Invoke-Tater" or "Invoke-WScriptBypassUAC" or
176 "Invoke-AllChecks" or "Find-TrustedDocuments" or
177 "Invoke-Interceptor" or "Invoke-PoshRatHttp" or
178 "Invoke-ExecCommandWMI" or "Invoke-KillProcessWMI" or
179 "Invoke-CreateShareandExecute" or "Invoke-RemoteScriptWithOutput" or
180 "Invoke-SchedJobManipulation" or "Invoke-ServiceManipulation" or
181 "Invoke-PowerOptionsWMI" or "Invoke-DirectoryListing" or
182 "Invoke-FileTransferOverWMI" or "Invoke-WMImplant" or
183 "Invoke-WMIObfuscatedPSCommand" or "Invoke-WMIDuplicateClass" or
184 "Invoke-WMIUpload" or "Invoke-WMIRemoteExtract" or "Invoke-winPEAS"
185 ) and
186 not powershell.file.script_block_text : (
187 "sentinelbreakpoints" and "Set-PSBreakpoint"
188 ) and
189 not user.id : ("S-1-5-18" or "S-1-5-19")
190'''
191
192[[rule.filters]]
193[rule.filters.meta]
194negate = true
195[rule.filters.query.wildcard."file.path"]
196"case_insensitive" = true
197"value" = "?:\\\\ProgramData\\\\Microsoft\\\\Windows Defender Advanced Threat Protection\\\\DataCollection\\\\*"
198
199[[rule.threat]]
200framework = "MITRE ATT&CK"
201[[rule.threat.technique]]
202id = "T1059"
203name = "Command and Scripting Interpreter"
204reference = "https://attack.mitre.org/techniques/T1059/"
205[[rule.threat.technique.subtechnique]]
206id = "T1059.001"
207name = "PowerShell"
208reference = "https://attack.mitre.org/techniques/T1059/001/"
209
210
211
212[rule.threat.tactic]
213id = "TA0002"
214name = "Execution"
215reference = "https://attack.mitre.org/tactics/TA0002/"
Triage and analysis
Investigating Potential PowerShell HackTool Script by Function Names
PowerShell is one of the main tools system administrators use for automation, report routines, and other tasks. This makes it available for use in various environments, and creates an attractive way for attackers to execute code.
Adversaries often exploit PowerShell's capabilities to execute malicious scripts and perform various attacks. This rule identifies known offensive tooling function names in PowerShell scripts, as attackers commonly use out-of-the-box tools without modifying the code. By monitoring these specific function names, the rule aims to detect and alert potential malicious PowerShell activity.
Note: This investigation guide uses the Osquery Markdown Plugin introduced in Elastic Stack version 8.5.0. Older Elastic Stack versions will display unrendered Markdown in this guide.
Possible investigation steps
- Examine the script content that triggered the detection; look for suspicious DLL imports, collection or exfiltration capabilities, suspicious functions, encoded or compressed data, and other potentially malicious characteristics.
- Investigate the script execution chain (parent process tree) for unknown processes. Examine their executable files for prevalence, whether they are located in expected locations, and if they are signed with valid digital signatures.
- Examine the script's execution context, such as the user account, privileges, the role of the system on which it was executed, and any relevant timestamps.
- Investigate other alerts associated with the user/host during the past 48 hours.
- Evaluate whether the user needs to use PowerShell to complete tasks.
- Investigate the origin of the PowerShell script, including its source, download method, and any associated URLs or IP addresses.
- Examine the host for derived artifacts that indicate suspicious activities:
- Analyze the script using a private sandboxed analysis system.
- Observe and collect information about the following activities in both the sandbox and the alert subject host:
- Attempts to contact external domains and addresses.
- Use the Elastic Defend network events to determine domains and addresses contacted by the subject process by filtering by the process's
process.entity_id
. - Examine the DNS cache for suspicious or anomalous entries.
- $osquery_0
- Use the Elastic Defend network events to determine domains and addresses contacted by the subject process by filtering by the process's
- Use the Elastic Defend registry events to examine registry keys accessed, modified, or created by the related processes in the process tree.
- Examine the host services for suspicious or anomalous entries.
- $osquery_1
- $osquery_2
- $osquery_3
- Attempts to contact external domains and addresses.
- Retrieve the files' SHA-256 hash values using the PowerShell
Get-FileHash
cmdlet and search for the existence and reputation of the hashes in resources like VirusTotal, Hybrid-Analysis, CISCO Talos, Any.run, etc.
- Investigate potentially compromised accounts. Analysts can do this by searching for login events (for example, 4624) to the target host after the registry modification.
False positive analysis
- This rule may generate false positives if legitimate scripts or tools used by administrators contain any of the listed function names. These function names are commonly associated with offensive tooling, but they may also be present in benign scripts or tools.
- To handle these false positives consider adding exceptions - preferably with a combination of full file path and users.
Related Rules
- PowerShell Invoke-NinjaCopy script - b8386923-b02c-4b94-986a-d223d9b01f88
- PowerShell Suspicious Discovery Related Windows API Functions - 61ac3638-40a3-44b2-855a-985636ca985e
- Potential Process Injection via PowerShell - 2e29e96a-b67c-455a-afe4-de6183431d0d
- PowerShell Keylogging Script - bd2c86a0-8b61-4457-ab38-96943984e889
Response and Remediation
- Initiate the incident response process based on the outcome of the triage.
- If malicious activity is confirmed, perform a broader investigation to identify the scope of the compromise and determine the appropriate remediation steps.
- Isolate the involved hosts to prevent further post-compromise behavior.
- If the triage identified malware, search the environment for additional compromised hosts.
- Implement temporary network rules, procedures, and segmentation to contain the malware.
- Stop suspicious processes.
- Immediately block the identified indicators of compromise (IoCs).
- Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system.
- Remove and block malicious artifacts identified during triage.
- Reimage the host operating system or restore the compromised files to clean versions.
- Restrict PowerShell usage outside of IT and engineering business units using GPOs, AppLocker, Intune, or similar software.
- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords for these accounts and other potentially compromised credentials, such as email, business systems, and web services.
- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
- 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
- Potential PowerShell HackTool Script by Author
- Potential Process Injection via PowerShell
- PowerShell PSReflect Script
- PowerShell Share Enumeration Script
- PowerShell Suspicious Discovery Related Windows API Functions