I am trying to build a SpamAssassin test that uses ClamAV's CLI tool, sigtool, to detect when an attached MS Office legacy file like an .xls or .doc that MAY have a macro, actually has an executable macro.
It is easy enough to call sigtool in perl and pass it a filename to be scanned like this
my $filename = "email_attach";
my $scan = `/usr/bin/sigtool --vba="$filename"`;
if ($scan =~ /autoopen/i ) {
print "Scanning $file: INFECTED VBA\n";
}
However, as a SpamAssassin test I already have the email attachments in memory as variables passed to my test. So I do not want to take the time to write each attachment to disk and then tell sigtool to go read it.
I have researched the entire Ch 16 of Programming Perl and Perl Cookbook on Interprocess Communications and Process Management and Communication, and there is a TON of info there, but I did not see anything that addressed streaming your internal perl program data as input to an external application that is looking for a path/filename to be passed as a command line argument.
Thank you for any thoughts on how to accomplish this. Or if anyone knows of a simpler way to detect a VBA macro or executable in the MS Office legacy files, that would be fine as well.