Permissions Changed To Run Or Unlock A File
A command makes a file executable (chmod +x or a numeric mode) and runs it in the same line, without a download in that line, or removes the immutable or append-only attribute with chattr -i / -a. The first is the last step of droppers that wrote their binary another way, such as hex-escaped echo chunks; the second unlocks files like ~/.ssh before the attacker overwrites them. Lines that also download are left to the download-and-execute rule, so one dropper command raises one alert.
Tested
Matches all 6 attack events in match.jsonl and none of the 6 look-alike events in nomatch.jsonl. See the test events.
Seen on the honeypot
In the last 30 days (as of 2026-12-05 00:23:53 UTC) this rule fired in 1,289 sessions (11,697 matching commands), first on 2026-11-08 and last on 2026-12-05.
Most common matching command (URLs and IP addresses in it are defanged; the attackers' source IPs are never published):
>/var/.f && chmod 777 /var/.f && /var/.f && cd /var/;
False positives
- Administrators running a script they just made executable, or clearing chattr flags by hand
Sigma
title: Permissions Changed To Run Or Unlock A File
id: 9feb96f8-f354-42ad-9667-a5569b03a61d
status: experimental
description: |
A command makes a file executable (chmod +x or a numeric mode) and runs it in the same line, without a
download in that line, or removes the immutable or append-only attribute with chattr -i / -a. The first
is the last step of droppers that wrote their binary another way, such as hex-escaped echo chunks; the
second unlocks files like ~/.ssh before the attacker overwrites them. Lines that also download are
left to the download-and-execute rule, so one dropper command raises one alert.
references:
- https://attack.mitre.org/techniques/T1222/002/
- https://attack.mitre.org/techniques/T1059/004/
author: Estul Lachin
date: 2026-11-08
tags:
- attack.defense-impairment
- attack.t1222.002
- attack.execution
- attack.t1059.004
logsource:
product: cowrie
detection:
selection:
eventid: cowrie.command.input
chmod_run:
input|re: 'chmod\s+(-[a-zA-Z]+\s+)?([ugoa]*\+[rw]*x|[0-7]*[1357][0-7]*)\s+\S+\s*(;|&&)\s*((ba)?sh\s+)?(\./|/)\S+'
unlock:
input|re: '\bchattr\s+-[a-zA-Z]*[ia]'
download:
input|re: '\b(wget|curl|tftp|ftpget)\b'
condition: selection and (chmod_run or unlock) and not download
falsepositives:
- Administrators running a script they just made executable, or clearing chattr flags by hand
level: medium
Splunk SPL
``` Permissions Changed To Run Or Unlock A File. Generated from rules/chmod_then_execute.yml by tools/build.py; do not edit. ```
index=honeypot sourcetype=cowrie:json eventid="cowrie.command.input"
| rex field=input "(?<inputMatch>chmod\\s+(-[a-zA-Z]+\\s+)?([ugoa]*\\+[rw]*x|[0-7]*[1357][0-7]*)\\s+\\S+\\s*(;|&&)\\s*((ba)?sh\\s+)?(\\./|/)\\S+)"
| eval inputCondition=if(isnotnull(inputMatch), "true", "false")
| rex field=input "(?<inputMatch2>\\bchattr\\s+-[a-zA-Z]*[ia])"
| eval inputCondition2=if(isnotnull(inputMatch2), "true", "false")
| search (inputCondition="true" OR inputCondition2="true")
| regex input!="\\b(wget|curl|tftp|ftpget)\\b"
Microsoft Sentinel KQL
// Permissions Changed To Run Or Unlock A File. Generated from rules/chmod_then_execute.yml by tools/build.py; do not edit.
Cowrie_CL
| where eventid =~ "cowrie.command.input" and (input matches regex "chmod\\s+(-[a-zA-Z]+\\s+)?([ugoa]*\\+[rw]*x|[0-7]*[1357][0-7]*)\\s+\\S+\\s*(;|&&)\\s*((ba)?sh\\s+)?(\\./|/)\\S+" or input matches regex "\\bchattr\\s+-[a-zA-Z]*[ia]") and (not(input matches regex "\\b(wget|curl|tftp|ftpget)\\b"))