Detection rules › Elastic
Potential Reverse Shell via Java
Identifies the execution of a shell process from a Java JAR application post an incoming network connection. This behavior may indicate a reverse shell activity via malicious Java application.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Execution | |
| Command & Control |
Rule body
[rule]
description = """
Identifies the execution of a shell process from a Java JAR application post an incoming network connection. This
behavior may indicate a reverse shell activity via malicious Java application.
"""
id = "15c94c07-07ec-4e68-a623-e690be3d9d6b"
license = "Elastic License v2"
name = "Potential Reverse Shell via Java"
os_list = ["windows"]
version = "1.0.12"
query = '''
sequence with maxspan=1s
[network where process.pid != 4 and
event.action in ("connection_accepted", "connection_attempted") and
process.name in~ ("java.exe", "javaw.exe")] by process.entity_id
[process where event.action == "start" and process.parent.name : "java.exe" and
process.parent.args : "-jar" and
process.parent.executable :
("?:\\Program Files\\Java\\jre*\\bin\\java.exe",
"?:\\Program Files (x86)\\Java\\jre*\\bin\\java.exe",
"?:\\Program Files\\AdoptOpenJDK\\jdk-*\\bin\\java.exe",
"?:\\Program Files (x86)\\AdoptOpenJDK\\jdk-*\\bin\\java.exe") and
process.name in~ ("cmd.exe", "powershell.exe", "conhost.exe")] by process.parent.entity_id
'''
min_endpoint_version = "8.7.0"
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 0
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 1
[[optional_actions]]
action = "rollback"
field = "process.entity_id"
state = 0
[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1059"
name = "Command and Scripting Interpreter"
reference = "https://attack.mitre.org/techniques/T1059/"
[threat.tactic]
id = "TA0002"
name = "Execution"
reference = "https://attack.mitre.org/tactics/TA0002/"
[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1071"
name = "Application Layer Protocol"
reference = "https://attack.mitre.org/techniques/T1071/"
[threat.tactic]
id = "TA0011"
name = "Command and Control"
reference = "https://attack.mitre.org/tactics/TA0011/"
[internal]
min_endpoint_version = "8.7.0"
Stages and Predicates
Ordered sequence: each step below must occur in order within 1s, correlated by process.entity_id, process.parent.entity_id.
Stage 1: network
[network where process.pid != 4 and
event.action in ("connection_accepted", "connection_attempted") and
process.name in~ ("java.exe", "javaw.exe")] by process.entity_id
Stage 2: process
[process where event.action == "start" and process.parent.name : "java.exe" and
process.parent.args : "-jar" and
process.parent.executable :
("?:\\Program Files\\Java\\jre*\\bin\\java.exe",
"?:\\Program Files (x86)\\Java\\jre*\\bin\\java.exe",
"?:\\Program Files\\AdoptOpenJDK\\jdk-*\\bin\\java.exe",
"?:\\Program Files (x86)\\AdoptOpenJDK\\jdk-*\\bin\\java.exe") and
process.name in~ ("cmd.exe", "powershell.exe", "conhost.exe")] by process.parent.entity_id
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
event.action | eq |
| field:"EventType" kind:eq value:"start" |
event.action | in |
| field:"EventType" kind:in |
process.name | in |
| field:"process_name" kind:in |
process.parent.args | wildcard |
| field:"process.parent.args" kind:wildcard value:"-jar" |
process.parent.executable | wildcard |
| field:"ParentImage" kind:wildcard |
process.parent.name | wildcard |
| field:"parent_process_name" kind:wildcard value:"java.exe" |
process.pid | ne |
| field:"process_id" kind:ne value:"4" |