text code block:( `zeek_http_request_headers` header_name IN ( "AUTHORIZATION", "HTTP2-SETTINGS", "CONTENT-TYPE", "CONTENT-DISPOSITION", "PRIORITY", "X-CONSOLEANNOTATOR", "X-CONNECT-AUTHORIZATION", "X-CSRF-TOKEN" ) header_value="*=*" truncated=false ) OR ( `zeek_http_post_body` body="*=*" truncated=false ) OR ( `zeek_http_uri` uri IN ("*=*","*%3D*","*%3d*") ) OR ( `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=5 Image="*/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 jvm_pid=coalesce(jvm_pid_raw,jvm_pid), jvm_tags=coalesce(jvm_tags_raw,jvm_tags), jvm_message=coalesce(jvm_message_raw,jvm_message) | eval event_time=_time, is_network=if(isnotnull('id.resp_h'),1,0) | eval observed_target=if(is_network=1,'id.resp_h',coalesce(dest,host,dest_ip)) | eval request_value=case( isnotnull(header_name),header_value, isnotnull(body),body, is_network=1,urldecode(uri) ), carrier=case( isnotnull(header_name),header_name, isnotnull(body),"POST body", is_network=1,"URI" ) | where is_network=0 OR len(request_value)>=65 | eval malformed_b64=if( is_network=1 AND match(request_value,"(?<![A-Za-z0-9+/_-])(?:(?:[A-Za-z0-9+/]{64})+(?:[A-Za-z0-9+/]{0,2}=|[A-Za-z0-9+/]?==)|(?:[A-Za-z0-9_-]{64})+(?:[A-Za-z0-9_-]{0,2}=|[A-Za-z0-9_-]?==))(?![A-Za-z0-9+/_=-])"), 1,0 ), scripted_b64=if( is_network=1 AND isnotnull(body) AND like(body,"%Base64.getDecoder()%") AND like(body,"%new byte[65]%") AND like(body,"%[64] = (byte)61%"), 1,0 ) | eval event_kind=case( is_network=1 AND (malformed_b64=1 OR scripted_b64=1),"request", isnotnull(jvm_pid) AND like(jvm_tags,"%exceptions%"),"jvm", EventID=1 OR EventID=5 OR EventID=11,"sysmon" ) | eval java_pid=case( event_kind="request","network", event_kind="jvm",tostring(jvm_pid), EventID=1,tostring(ParentProcessId), EventID=5 OR EventID=11,tostring(ProcessId) ), request_uid=if(event_kind="request",uid."@".printf("%.6f",event_time),"-") | where isnotnull(event_kind) AND isnotnull(observed_target) AND isnotnull(java_pid) AND isnotnull(request_uid) | eval argument_error=if(event_kind="jvm" AND match(jvm_message,"(?i)IllegalArgumentException|Input byte array has wrong"),1,0), decoder_evidence=if(event_kind="jvm" AND match(jvm_message,"Base64[$]Decoder|java/util/Base64|Input byte array has wrong"),1,0), shell_child=if(EventID=1 AND match(Image,"/(ash|bash|csh|dash|eshell|fish|ion|ksh|mksh|rbash|sh|tcsh|zsh)$"),1,0), child_process=if(EventID=1,1,0), file_created=if(EventID=11,1,0), java_terminated=if(EventID=5,1,0), suspicious_file=if(EventID=11 AND match(TargetFilename,"(?i)(?:[.](?:jsp|sh|so)$|/(?:tmp|var/tmp|dev/shm|webapps)/)"),1,0) | eval request_marker=case( event_kind="request" AND scripted_b64=1,"scripted_decoder_trigger", event_kind="request" AND malformed_b64=1,"malformed_base64_request" ), src_ip=if(event_kind="request",'id.orig_h',null()), request_uri=if(event_kind="request",uri,null()), http_method=if(event_kind="request",method,null()), child_image=if(EventID=1,Image,null()), created_file=if(EventID=11,TargetFilename,null()) | bin _time span=1s | stats min(event_time) AS first_seen max(event_time) AS last_seen max(argument_error) AS argument_error max(decoder_evidence) AS decoder_evidence max(shell_child) AS shell_child max(child_process) AS child_process max(file_created) AS file_created max(java_terminated) AS java_terminated max(suspicious_file) AS suspicious_file values(src_ip) AS src_ips values(request_uri) AS uris values(http_method) AS methods values(carrier) AS carriers values(request_marker) AS request_markers values(child_image) AS child_images values(created_file) AS created_files BY _time observed_target java_pid request_uid event_kind | rename observed_target AS dest | `get_asset(dest)` | eval target=coalesce(dest_asset_id,dest), bucket=floor(first_seen/15) | eval request_json=if( event_kind="request", json_object( "uid",request_uid, "time",first_seen, "src",mvindex(src_ips,0), "dest",dest, "uri",mvindex(uris,0), "method",mvindex(methods,0), "carrier",mvjoin(carriers,","), "marker",mvjoin(request_markers,",") ), null() ), bucket=if( event_kind="request", mvappend(tostring(bucket-1),tostring(bucket),tostring(bucket+1),tostring(bucket+2)), bucket ) | mvexpand bucket | eventstats values(request_json) AS candidate_requests BY target bucket | where event_kind!="request" AND isnotnull(candidate_requests) | mvexpand candidate_requests | eval request_uid=spath(candidate_requests,"uid"), request_time=tonumber(spath(candidate_requests,"time")), src=spath(candidate_requests,"src"), request_dest=spath(candidate_requests,"dest"), uri=spath(candidate_requests,"uri"), method=spath(candidate_requests,"method"), carrier=spath(candidate_requests,"carrier"), request_marker=spath(candidate_requests,"marker") | where (event_kind="jvm" AND last_seen>=request_time-3 AND first_seen<=request_time+15) OR (event_kind="sysmon" AND last_seen>=request_time-3 AND first_seen<=request_time+30) | stats min(request_time) AS request_time min(eval(if(argument_error=1,first_seen,null()))) AS exception_time max(last_seen) AS last_seen max(argument_error) AS argument_error max(decoder_evidence) AS decoder_evidence max(shell_child) AS shell_child max(child_process) AS child_process max(file_created) AS file_created max(java_terminated) AS java_terminated max(suspicious_file) AS suspicious_file values(src) AS src values(request_dest) AS dest_ips values(uri) AS uri values(method) AS method values(carrier) AS carrier values(request_marker) AS request_markers values(child_images) AS child_images values(created_files) AS created_files BY target request_uid java_pid | where argument_error=1 AND decoder_evidence=1 | eval dest=mvindex(dest_ips,0), exception_delay=round(exception_time-request_time,3), confidence=case( shell_child>0 OR suspicious_file>0,"high", child_process>0 OR file_created>0 OR java_terminated>0,"medium", true(),"low" ), asset_id=target, firstTime=request_time, lastTime=last_seen | fields - argument_error decoder_evidence shell_child child_process file_created java_terminated suspicious_file dest_ips | sort 0 - firstTime | `security_content_ctime(firstTime)` | `security_content_ctime(lastTime)` | `http_base64_activity_with_jvm_errors_filter`
View this rule on Splunk
This rule was sourced from the official Splunk public repository. View the original rule on GitHub(external, opens in a new tab or window).