HTTP POST Request with Encoded Payload
Description
The following analytic detects HTTP POST requests containing heavily encoded data in the post body, specifically looking for sequences of hex-encoded bytes or base64-encoded strings. It leverages Zeek HTTP logs to identify POST requests where the body contains eight or more consecutive hex escape sequences or sixteen or more consecutive base64 character groups. This activity is significant as adversaries commonly use hex or base64 encoding to obfuscate C2 communication, exfiltrate data, or deliver encoded payloads.
Query · spl
`zeek_http`
method="POST"
post_body="*"
| eval dest_port=coalesce(dest_port, 'id.resp_p'),
dest=coalesce(dest, dest_ip, 'id.resp_h'),
src=coalesce(src, src_ip, 'id.orig_h')
| eval _hex=if(match(post_body, "(?:\\\\x[0-9a-fA-F]{2}){8,}|(?:%[0-9a-fA-F]{2}){8,}"), 1, 0)
| eval _b64=if(match(post_body, "(?:[A-Za-z0-9+/]{4}){16,}={0,2}"), 1, 0)
| where _hex=1 OR _b64=1
| eval encoding_type=case(_hex=1 AND _b64=1, "Hexadecimal + Base64", _hex=1, "Hexadecimal", _b64=1, "Base64")
| stats count min(_time) as firstTime
max(_time) as lastTime
values(encoding_type) as encoding_type
values(post_body) as post_body
by src dest dest_port uri method status_code
| `security_content_ctime(firstTime)`
| `security_content_ctime(lastTime)`
| `http_post_request_with_encoded_payload_filter`
Implementation guide
Zeek HTTP logs must be ingested into Splunk using the latest version of Splunk Add-on for Zeek (https://splunkbase.splunk.com/app/5466).
The "post_body" field must be populated, which requires Zeek to be configured with the HTTP post body extraction policy.
Configure the zeek_http macro to match the sourcetype used by your Zeek add-on.
Known false positives
- Legitimate applications may POST base64-encoded data, particularly APIs that transmit binary content. Review the destination, URI, and post body content to confirm whether the activity is expected.
Analyst notes
Known false positives: Legitimate applications may POST base64-encoded data, particularly APIs that transmit binary content. Review the destination, URI, and post body content to confirm whether the activity is expected.