Detection rules › Elastic

Potential Reverse Shell via Java

Time window
1s
Sequence by
process.entity_id, process.parent.entity_id
Source
github.com/elastic/protections-artifacts

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

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.

FieldKindValuesSearch
event.actioneq
  • start corpus 391 (elastic 391)
field:"EventType" kind:eq value:"start"
event.actionin
  • connection_accepted corpus 6 (elastic 6)
  • connection_attempted corpus 73 (elastic 73)
field:"EventType" kind:in
process.namein
  • cmd.exe corpus 121 (elastic 92, splunk 29)
  • conhost.exe corpus 12 (elastic 11, splunk 1)
  • java.exe corpus 2 (elastic 1, splunk 1)
  • javaw.exe corpus 9 (elastic 9)
  • powershell.exe corpus 184 (elastic 140, splunk 44)
field:"process_name" kind:in
process.parent.argswildcard
  • -jar corpus 4 (elastic 4)
field:"process.parent.args" kind:wildcard value:"-jar"
process.parent.executablewildcard
  • ?:\Program Files (x86)\AdoptOpenJDK\jdk-*\bin\java.exe
  • ?:\Program Files (x86)\Java\jre*\bin\java.exe
  • ?:\Program Files\AdoptOpenJDK\jdk-*\bin\java.exe
  • ?:\Program Files\Java\jre*\bin\java.exe
field:"ParentImage" kind:wildcard
process.parent.namewildcard
  • java.exe corpus 3 (elastic 2, kusto 1)
field:"parent_process_name" kind:wildcard value:"java.exe"
process.pidne
  • 4 transforms: number corpus 44 (elastic 44)
field:"process_id" kind:ne value:"4"