Potential Hex Payload Execution

This rule detects potential hex payload execution on Linux systems. Adversaries may use hex encoding to obfuscate payloads and evade detection mechanisms.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2024/11/04"
  3integration = ["endpoint", "crowdstrike", "sentinel_one_cloud_funnel"]
  4maturity = "production"
  5updated_date = "2025/03/20"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10This rule detects potential hex payload execution on Linux systems. Adversaries may use hex encoding to obfuscate
 11payloads and evade detection mechanisms.
 12"""
 13from = "now-9m"
 14index = [
 15    "logs-endpoint.events.process*",
 16    "logs-crowdstrike.fdr*",
 17    "logs-sentinel_one_cloud_funnel.*",
 18    "endgame-*",
 19]
 20language = "eql"
 21license = "Elastic License v2"
 22name = "Potential Hex Payload Execution"
 23note = """## Triage and analysis
 24
 25> **Disclaimer**:
 26> 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.
 27
 28### Investigating Potential Hex Payload Execution
 29
 30Hex encoding is often used in Linux environments to obfuscate data, making it harder for security tools to detect malicious payloads. Adversaries exploit this by encoding their payloads in hex to bypass security measures. The detection rule identifies suspicious processes like `xxd`, `python`, `php`, and others that use hex-related functions, signaling potential obfuscation attempts. By monitoring these patterns, the rule helps uncover hidden threats.
 31
 32### Possible investigation steps
 33
 34- Review the process details, including the process name and command line arguments, to confirm if the execution aligns with typical hex decoding or encoding activities.
 35- Check the parent process of the suspicious process to understand the context of how the process was initiated and whether it was expected or part of a legitimate workflow.
 36- Investigate the user account associated with the process execution to determine if the activity is consistent with the user's normal behavior or if the account may have been compromised.
 37- Examine the network activity associated with the process to identify any potential data exfiltration or communication with known malicious IP addresses.
 38- Look for any related file modifications or creations around the time of the process execution to identify if the decoded payload was written to disk or executed further.
 39- Cross-reference the alert with other security tools or logs, such as Crowdstrike or SentinelOne, to gather additional context or corroborating evidence of malicious activity.
 40
 41### False positive analysis
 42
 43- Development and testing environments may frequently use hex encoding functions for legitimate purposes. To reduce noise, consider excluding processes running on known development servers from the rule.
 44- System administrators might use hex encoding tools like `xxd` for data conversion tasks. Identify and whitelist these routine administrative scripts to prevent false alerts.
 45- Automated scripts or applications that process data in hex format for encoding or decoding purposes can trigger this rule. Review and exclude these scripts if they are verified as non-malicious.
 46- Security tools or monitoring solutions themselves might use hex encoding for data analysis. Ensure these tools are recognized and excluded from triggering the rule.
 47- Regularly review and update the exclusion list to adapt to changes in the environment and ensure that only verified non-threatening behaviors are excluded.
 48
 49### Response and remediation
 50
 51- Isolate the affected system from the network to prevent further spread of potentially malicious payloads.
 52- Terminate any suspicious processes identified by the detection rule, such as those involving `xxd`, `python`, `php`, `ruby`, `perl`, or `lua` with hex-related functions.
 53- Conduct a thorough scan of the isolated system using updated antivirus and anti-malware tools to identify and remove any malicious payloads or remnants.
 54- Review and analyze system logs and process execution history to determine the scope of the compromise and identify any additional affected systems.
 55- Restore the system from a known good backup if malicious activity is confirmed and cannot be fully remediated.
 56- Implement additional monitoring on the affected system and network to detect any recurrence of similar obfuscation attempts.
 57- Escalate the incident to the security operations center (SOC) or incident response team for further investigation and to assess the need for broader organizational response measures."""
 58risk_score = 21
 59rule_id = "0c1e8fda-4f09-451e-bc77-a192b6cbfc32"
 60setup = """## Setup
 61
 62This rule requires data coming in from Elastic Defend.
 63
 64### Elastic Defend Integration Setup
 65Elastic 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.
 66
 67#### Prerequisite Requirements:
 68- Fleet is required for Elastic Defend.
 69- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
 70
 71#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
 72- Go to the Kibana home page and click "Add integrations".
 73- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
 74- Click "Add Elastic Defend".
 75- Configure the integration name and optionally add a description.
 76- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
 77- 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).
 78- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
 79- 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.
 80For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
 81- Click "Save and Continue".
 82- 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.
 83For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
 84"""
 85severity = "low"
 86tags = [
 87    "Domain: Endpoint",
 88    "OS: Linux",
 89    "Use Case: Threat Detection",
 90    "Tactic: Defense Evasion",
 91    "Tactic: Execution",
 92    "Data Source: Elastic Defend",
 93    "Data Source: Crowdstrike",
 94    "Data Source: SentinelOne",
 95    "Data Source: Elastic Endgame",
 96    "Resources: Investigation Guide",
 97]
 98timestamp_override = "event.ingested"
 99type = "eql"
100
101query = '''
102process where host.os.type == "linux" and event.type == "start" and
103  event.action in ("exec", "exec_event", "start", "ProcessRollup2") and
104  (
105    (process.name == "xxd" and process.args like ("-r*", "-p*")) or
106    (process.name like "python*" and process.command_line like "*fromhex*" and process.command_line like ("*decode*", "*encode*")) or
107    (process.name like "php*" and process.command_line like "*hex2bin*") or
108    (process.name like "ruby*" and process.command_line like "*].pack(\"H*\")*") or
109    (process.name like "perl*" and process.command_line like "*pack(\"H*\",*") or
110    (process.name like "lua*" and process.command_line like "*tonumber(cc, 16)*")
111  )
112'''
113
114
115[[rule.threat]]
116framework = "MITRE ATT&CK"
117[[rule.threat.technique]]
118id = "T1027"
119name = "Obfuscated Files or Information"
120reference = "https://attack.mitre.org/techniques/T1027/"
121
122[[rule.threat.technique]]
123id = "T1140"
124name = "Deobfuscate/Decode Files or Information"
125reference = "https://attack.mitre.org/techniques/T1140/"
126
127
128[rule.threat.tactic]
129id = "TA0005"
130name = "Defense Evasion"
131reference = "https://attack.mitre.org/tactics/TA0005/"
132[[rule.threat]]
133framework = "MITRE ATT&CK"
134[[rule.threat.technique]]
135id = "T1059"
136name = "Command and Scripting Interpreter"
137reference = "https://attack.mitre.org/techniques/T1059/"
138[[rule.threat.technique.subtechnique]]
139id = "T1059.004"
140name = "Unix Shell"
141reference = "https://attack.mitre.org/techniques/T1059/004/"
142
143
144[[rule.threat.technique]]
145id = "T1204"
146name = "User Execution"
147reference = "https://attack.mitre.org/techniques/T1204/"
148[[rule.threat.technique.subtechnique]]
149id = "T1204.002"
150name = "Malicious File"
151reference = "https://attack.mitre.org/techniques/T1204/002/"
152
153
154
155[rule.threat.tactic]
156id = "TA0002"
157name = "Execution"
158reference = "https://attack.mitre.org/tactics/TA0002/"
...
toml

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.

Hex encoding is often used in Linux environments to obfuscate data, making it harder for security tools to detect malicious payloads. Adversaries exploit this by encoding their payloads in hex to bypass security measures. The detection rule identifies suspicious processes like xxd, python, php, and others that use hex-related functions, signaling potential obfuscation attempts. By monitoring these patterns, the rule helps uncover hidden threats.

  • Review the process details, including the process name and command line arguments, to confirm if the execution aligns with typical hex decoding or encoding activities.
  • Check the parent process of the suspicious process to understand the context of how the process was initiated and whether it was expected or part of a legitimate workflow.
  • Investigate the user account associated with the process execution to determine if the activity is consistent with the user's normal behavior or if the account may have been compromised.
  • Examine the network activity associated with the process to identify any potential data exfiltration or communication with known malicious IP addresses.
  • Look for any related file modifications or creations around the time of the process execution to identify if the decoded payload was written to disk or executed further.
  • Cross-reference the alert with other security tools or logs, such as Crowdstrike or SentinelOne, to gather additional context or corroborating evidence of malicious activity.
  • Development and testing environments may frequently use hex encoding functions for legitimate purposes. To reduce noise, consider excluding processes running on known development servers from the rule.
  • System administrators might use hex encoding tools like xxd for data conversion tasks. Identify and whitelist these routine administrative scripts to prevent false alerts.
  • Automated scripts or applications that process data in hex format for encoding or decoding purposes can trigger this rule. Review and exclude these scripts if they are verified as non-malicious.
  • Security tools or monitoring solutions themselves might use hex encoding for data analysis. Ensure these tools are recognized and excluded from triggering the rule.
  • Regularly review and update the exclusion list to adapt to changes in the environment and ensure that only verified non-threatening behaviors are excluded.
  • Isolate the affected system from the network to prevent further spread of potentially malicious payloads.
  • Terminate any suspicious processes identified by the detection rule, such as those involving xxd, python, php, ruby, perl, or lua with hex-related functions.
  • Conduct a thorough scan of the isolated system using updated antivirus and anti-malware tools to identify and remove any malicious payloads or remnants.
  • Review and analyze system logs and process execution history to determine the scope of the compromise and identify any additional affected systems.
  • Restore the system from a known good backup if malicious activity is confirmed and cannot be fully remediated.
  • Implement additional monitoring on the affected system and network to detect any recurrence of similar obfuscation attempts.
  • Escalate the incident to the security operations center (SOC) or incident response team for further investigation and to assess the need for broader organizational response measures.

Related rules

to-top