Potential Hex Payload Execution via Command-Line
This rule detects when a process executes a command line containing hexadecimal characters. Malware authors may use hexadecimal encoding to obfuscate their payload and evade detection.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2025/04/29"
3integration = ["endpoint"]
4maturity = "production"
5updated_date = "2025/07/07"
6
7[rule]
8author = ["Elastic"]
9description = """
10This rule detects when a process executes a command line containing hexadecimal characters. Malware authors may use
11hexadecimal encoding to obfuscate their payload and evade detection.
12"""
13from = "now-9m"
14index = ["logs-endpoint.events.process*"]
15language = "eql"
16license = "Elastic License v2"
17name = "Potential Hex Payload Execution via Command-Line"
18note = """ ## Triage and analysis
19
20> **Disclaimer**:
21> This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.
22
23### Investigating Potential Hex Payload Execution via Command-Line
24
25In Linux environments, command-line interfaces are pivotal for executing processes and scripts. Adversaries exploit this by embedding payloads in hexadecimal format to obfuscate their actions, evading detection. The detection rule identifies processes with lengthy command lines containing multiple hex patterns, signaling potential obfuscation. This approach targets defense evasion tactics, leveraging Elastic Defend to flag suspicious executions.
26
27### Possible investigation steps
28
29- Review the process.command_line field to identify the specific hexadecimal patterns and assess if they correspond to known malicious payloads or commands.
30- Examine the process.parent.executable to determine the parent process that initiated the execution, which may provide context on whether the execution is expected or suspicious.
31- Check the user account associated with the process execution to verify if the activity aligns with typical user behavior or if it indicates potential compromise.
32- Investigate the host where the alert was triggered to identify any other related suspicious activities or anomalies that might indicate a broader compromise.
33- Correlate the event with other logs or alerts from the same host or user to identify patterns or repeated attempts at obfuscation and execution.
34
35### False positive analysis
36
37- Legitimate software installations or updates may use hexadecimal encoding in command lines for legitimate purposes. Users can create exceptions for known software update processes by identifying their parent executable paths and excluding them from the rule.
38- System administration scripts or tools that utilize hexadecimal encoding for configuration or data processing might trigger the rule. Review and whitelist these scripts by verifying their source and purpose, then exclude them based on their command line patterns or parent processes.
39- Security tools or monitoring software that perform regular scans or data collection using hexadecimal encoding could be flagged. Confirm these tools' legitimacy and add them to an exception list by specifying their executable paths or command line characteristics.
40- Custom applications developed in-house that use hexadecimal encoding for data handling or communication may be mistakenly identified. Document these applications and exclude them by their unique command line signatures or parent process identifiers.
41
42### Response and remediation
43
44- Isolate the affected system from the network to prevent further spread of the potential threat and to contain any malicious activity.
45- Terminate the suspicious process identified by the detection rule to halt any ongoing malicious execution.
46- Conduct a forensic analysis of the affected system to identify any additional indicators of compromise, such as modified files or unauthorized user accounts.
47- Remove any identified malicious files or scripts from the system to ensure the threat is eradicated.
48- Restore the system from a known good backup if any critical system files or configurations have been altered.
49- Update and patch the system to close any vulnerabilities that may have been exploited by the adversary.
50- Escalate the incident to the security operations center (SOC) or incident response team for further investigation and to determine if additional systems are affected.
51"""
52risk_score = 21
53rule_id = "1d0027d4-6717-4a37-bad8-531d8e9fe53f"
54setup = """## Setup
55
56This rule requires data coming in from Elastic Defend.
57
58### Elastic Defend Integration Setup
59Elastic Defend is integrated into the Elastic Agent using Fleet. Upon configuration, the integration allows the Elastic Agent to monitor events on your host and send data to the Elastic Security app.
60
61#### Prerequisite Requirements:
62- Fleet is required for Elastic Defend.
63- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
64
65#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
66- Go to the Kibana home page and click "Add integrations".
67- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
68- Click "Add Elastic Defend".
69- Configure the integration name and optionally add a description.
70- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
71- Select a configuration preset. Each preset comes with different default settings for Elastic Agent, you can further customize these later by configuring the Elastic Defend integration policy. [Helper guide](https://www.elastic.co/guide/en/security/current/configure-endpoint-integration-policy.html).
72- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
73- Enter a name for the agent policy in "New agent policy name". If other agent policies already exist, you can click the "Existing hosts" tab and select an existing policy instead.
74For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
75- Click "Save and Continue".
76- To complete the integration, select "Add Elastic Agent to your hosts" and continue to the next section to install the Elastic Agent on your hosts.
77For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
78"""
79severity = "low"
80tags = [
81 "Domain: Endpoint",
82 "OS: Linux",
83 "Use Case: Threat Detection",
84 "Tactic: Defense Evasion",
85 "Tactic: Execution",
86 "Data Source: Elastic Defend",
87 "Resources: Investigation Guide",
88]
89timestamp_override = "event.ingested"
90type = "eql"
91query = '''
92process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and
93process.parent.executable != null and
94process.command_line : "*\\x*\\x*\\x*\\x*\\x*\\x*\\x*\\x*\\x*\\x*\\x*\\x*\\x*\\x*" and
95length(process.command_line) > 50
96'''
97
98[[rule.threat]]
99framework = "MITRE ATT&CK"
100
101[[rule.threat.technique]]
102id = "T1027"
103name = "Obfuscated Files or Information"
104reference = "https://attack.mitre.org/techniques/T1027/"
105
106[[rule.threat.technique]]
107id = "T1140"
108name = "Deobfuscate/Decode Files or Information"
109reference = "https://attack.mitre.org/techniques/T1140/"
110
111[rule.threat.tactic]
112id = "TA0005"
113name = "Defense Evasion"
114reference = "https://attack.mitre.org/tactics/TA0005/"
115
116[[rule.threat]]
117framework = "MITRE ATT&CK"
118
119[[rule.threat.technique]]
120id = "T1059"
121name = "Command and Scripting Interpreter"
122reference = "https://attack.mitre.org/techniques/T1059/"
123
124[[rule.threat.technique.subtechnique]]
125id = "T1059.004"
126name = "Unix Shell"
127reference = "https://attack.mitre.org/techniques/T1059/004/"
128
129[[rule.threat.technique]]
130id = "T1204"
131name = "User Execution"
132reference = "https://attack.mitre.org/techniques/T1204/"
133
134[[rule.threat.technique.subtechnique]]
135id = "T1204.002"
136name = "Malicious File"
137reference = "https://attack.mitre.org/techniques/T1204/002/"
138
139[rule.threat.tactic]
140id = "TA0002"
141name = "Execution"
142reference = "https://attack.mitre.org/tactics/TA0002/"
Triage and analysis
Disclaimer: This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.
Investigating Potential Hex Payload Execution via Command-Line
In Linux environments, command-line interfaces are pivotal for executing processes and scripts. Adversaries exploit this by embedding payloads in hexadecimal format to obfuscate their actions, evading detection. The detection rule identifies processes with lengthy command lines containing multiple hex patterns, signaling potential obfuscation. This approach targets defense evasion tactics, leveraging Elastic Defend to flag suspicious executions.
Possible investigation steps
- Review the process.command_line field to identify the specific hexadecimal patterns and assess if they correspond to known malicious payloads or commands.
- Examine the process.parent.executable to determine the parent process that initiated the execution, which may provide context on whether the execution is expected or suspicious.
- Check the user account associated with the process execution to verify if the activity aligns with typical user behavior or if it indicates potential compromise.
- Investigate the host where the alert was triggered to identify any other related suspicious activities or anomalies that might indicate a broader compromise.
- Correlate the event with other logs or alerts from the same host or user to identify patterns or repeated attempts at obfuscation and execution.
False positive analysis
- Legitimate software installations or updates may use hexadecimal encoding in command lines for legitimate purposes. Users can create exceptions for known software update processes by identifying their parent executable paths and excluding them from the rule.
- System administration scripts or tools that utilize hexadecimal encoding for configuration or data processing might trigger the rule. Review and whitelist these scripts by verifying their source and purpose, then exclude them based on their command line patterns or parent processes.
- Security tools or monitoring software that perform regular scans or data collection using hexadecimal encoding could be flagged. Confirm these tools' legitimacy and add them to an exception list by specifying their executable paths or command line characteristics.
- Custom applications developed in-house that use hexadecimal encoding for data handling or communication may be mistakenly identified. Document these applications and exclude them by their unique command line signatures or parent process identifiers.
Response and remediation
- Isolate the affected system from the network to prevent further spread of the potential threat and to contain any malicious activity.
- Terminate the suspicious process identified by the detection rule to halt any ongoing malicious execution.
- Conduct a forensic analysis of the affected system to identify any additional indicators of compromise, such as modified files or unauthorized user accounts.
- Remove any identified malicious files or scripts from the system to ensure the threat is eradicated.
- Restore the system from a known good backup if any critical system files or configurations have been altered.
- Update and patch the system to close any vulnerabilities that may have been exploited by the adversary.
- Escalate the incident to the security operations center (SOC) or incident response team for further investigation and to determine if additional systems are affected.
Related rules
- File Creation in /var/log via Suspicious Process
- Potential Hex Payload Execution via Common Utility
- Base64 Decoded Payload Piped to Interpreter
- Python Path File (pth) Creation
- Python Site or User Customize File Creation