Skip to content

Instantly share code, notes, and snippets.

@mavam
Last active December 14, 2015 07:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mavam/5050260 to your computer and use it in GitHub Desktop.
Save mavam/5050260 to your computer and use it in GitHub Desktop.
Miniduke C&C detector
@load base/frameworks/notice
module Malware;
export {
redef enum Notice::Type += {
## Miniduke C&C activity.
Miniduke_CC_Activity
};
}
redef record HTTP::Info += {
miniduke: string &optional;
};
function report(c: connection, uri: string)
{
local param = split1(uri, /=/)[2];
local payload = decode_base64(gsub(gsub(param, /-/, "+"), /_/, "/"));
NOTICE([$note=Miniduke_CC_Activity,
$msg=fmt("Miniduke C&C activity: %s", payload),
$conn=c]);
}
event http_request(c: connection, method: string, original_URI: string,
unescaped_URI: string, version: string)
{
if ( /index\.php\?[[:alnum:]]+=([=-_]|[[:alnum:]])+/ in unescaped_URI )
c$http$miniduke = unescaped_URI;
}
event http_message_done(c: connection, is_orig: bool, stat: http_message_stat)
{
if ( is_orig || ! c$http?$miniduke || /image\/gif/ !in c$http$mime_type )
return;
report(c, c$http$miniduke);
delete c$http$miniduke;
}
@mavam
Copy link
Author

mavam commented Mar 3, 2013

Finally got a real PCAP trace to test it...and it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment