Techniques
Sample rules
Java Base64 Exception With Process or File Activity
- source: splunk
- technicques:
Description
The analytic finds Base64-related Java argument exceptions near a process spawned by Java or a file created by Java on the same host and JVM PID.
Detection logic
(
`java_hotspot_exceptions`
(
"*Input byte array has wrong*"
OR
"*IllegalArgumentException*"
OR
"*Base64$Decoder*"
OR
"*java/util/Base64*"
)
)
OR
(
`sysmon_linux`
(
(EventID=1 ParentImage="*/java")
OR
(
EventID=11
Image="*/java"
NOT TargetFilename IN ("*/_state/*","*/indices/*")
)
)
)
| rex field=_raw "^\[(?<jvm_event_time_raw>[^\]]+)\]\[(?<jvm_pid_raw>\d+)\]\[(?<jvm_level_raw>[^\]]+)\]\[(?<jvm_tags_raw>[^\]]+)\]\s*(?<jvm_message_raw>.*)"
| eval event_time=_time,
jvm_message=coalesce(jvm_message_raw,jvm_message),
observed_host=coalesce(host,Computer,dest),
process_id=case(
isnotnull(jvm_pid_raw),tostring(jvm_pid_raw),
isnotnull(jvm_pid),tostring(jvm_pid),
EventID==1,tostring(ParentProcessId),
EventID==11,tostring(ProcessId)
)
| where isnotnull(observed_host) AND isnotnull(process_id)
| rex mode=sed field=jvm_message "s/0x[0-9A-Fa-f]{8,16}/0xXXXXXXXXXXXXXXXX/g"
| rex mode=sed field=jvm_message "s/\s+bci\s+\d+\s+/ bci XXX /g"
| rex mode=sed field=jvm_message "s/^\d+\s+/XXXX /g"
| eval has_argument=if(match(jvm_message,"(?i)Input byte array has wrong
|IllegalArgumentException"),1,0),
has_decoder=if(match(jvm_message,"Base64[$]Decoder
|java/util/Base64
|Input byte array has wrong 4-byte ending unit"),1,0),
has_activity=if(EventID==1 OR EventID==11,1,0)
| eval activity=case(
EventID==1,"Java spawned a process",
EventID==11,"Java created a file"
),
process_name=if(EventID==1,Image,null()),
process=if(EventID==1,CommandLine,null()),
file_path=if(EventID==11,TargetFilename,null()),
file_name=if(EventID==11,mvindex(split(TargetFilename,"/"),-1),null())
| bin _time span=1m
| stats count
min(event_time) AS firstTime
max(event_time) AS lastTime
max(has_argument) AS has_argument
max(has_decoder) AS has_decoder
max(has_activity) AS has_activity
values(sourcetype) AS sourcetype
dc(sourcetype) AS dc_sourcetype
values(activity) AS activity
values(jvm_message) AS jvm_message
values(process_name) AS process_name
values(process) AS process
values(file_name) AS file_name
values(file_path) AS file_path
BY _time observed_host process_id
| where has_argument==1 AND has_decoder==1 AND has_activity==1
| rename observed_host AS dest
| eval reason="Java Base64 exception observed with ".mvjoin(activity," and ")
| fields - has_argument has_decoder has_activity activity
| `security_content_ctime(firstTime)`
| `security_content_ctime(lastTime)`
| `java_base64_exception_with_process_or_file_activity_filter`