@Jane0sint
Nice work! One thing I was going to share is that with http.header_names you don’t need to include the negation content:!"Referer|0d 0a|";
because bsize:72;
is already restricting any additional data in that buffer. I’m not sure if there is any performance impact so its fine to leave it in there but it’s not required. After updating 2048095 it alerts on the old pcap as well as the new captures.
Sid for the new signature:
2048130 - ET MALWARE [ANY.RUN] DarkCrystal Rat Exfiltration (POST)
Here are a few things I changed:
Instead of using Content-Disposition: form-data; name="0"
I used pcre so that the rule will alert if any single digit name is used.
i.e. I replaced this
content: "|0d 0a|Content-Disposition: form-data|3b| name=|22|0|22 0d 0a|Content-Type: text/plain|0d0a 0d0a|";
with this:
content:"Content|2d|Disposition|3a 20|form|2d|data|3b 20|name|3d 22|";
pcre:"/^(?:[0-9]{1})/R";
content:"|22 0d 0a|Content|2d|Type|3a 20|text|2f|plain"; within:28;
I noticed in the pcap that the name/filename values were identical 40 character strings so I updated your pcre to use a named capture group. A named capture group essentially lets you store a regex match into a variable so that you can use it again without duplicating your pcre pattern.
This is the pcre that I came up with which uses the variable filename
:
pcre:"/^(?P<filename>[a-z0-9]{40})\x22\x3b\x20filename\x3d\x22(?P=filename)\x22/R";
This part will match a 40 character string and store it in the variable filename
pcre:"/^(?P<filename>[a-z0-9]{40}) - matches 68c36a2defa8620c47b3f5dca991c77583292318
And this is how you can access that same value again
filename\x3d\x22(?P=filename)\x22 - which equates to filename="68c36a2defa8620c47b3f5dca991c77583292318"
Ultimately this lets us match exactly on
name="68c36a2defa8620c47b3f5dca991c77583292318"; filename="68c36a2defa8620c47b3f5dca991c77583292318"