Created
September 4, 2014 03:01
-
-
Save dcode/3228e2d83ec18d3cd813 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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