Skip to content

Instantly share code, notes, and snippets.

@dcode
Created September 4, 2014 03:01
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 dcode/3228e2d83ec18d3cd813 to your computer and use it in GitHub Desktop.
Save dcode/3228e2d83ec18d3cd813 to your computer and use it in GitHub Desktop.
global ext_map: table[string] of string = {
["application/x-dosexec"] = "exe",
["text/plain"] = "txt",
["image/jpeg"] = "jpg",
["image/png"] = "png",
["text/html"] = "html",
} &default ="";
event file_new(f: fa_file)
{
local ext = "";
if ( f?$mime_type )
ext = ext_map[f$mime_type];
local fname = fmt("%s-%s.%s", f$source, f$id, ext);
# Extract any outbound file
for ( c in f?$conns )
if ( c?$conn?$local_orig )
Files::add_analyzer(f, Files::ANALYZER_EXTRACT, [$extract_filename=fname]);
# Extract any inbound file that hits on interesting types
if ( f?$mime_type !in ext_map )
return;
Files::add_analyzer(f, Files::ANALYZER_EXTRACT, [$extract_filename=fname]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment