The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Webservice::VirusTotal - Interface for accessing the VirusTotal APIv2

SYNOPSIS

        use Webservice::VirusTotal;

        my $VT=Webservice::VirusTotal->new();

        $VT->apikey("YourAPIKeyHere");
        $VT->conn_cache(1);

        my ($infected, $description) = $VT->scan("/tmp/file.txt");

        if (!defined $infected)
        {
                my $error = (defined $description) ? $description : "Unknown error";
                croak("An error occured: $error\n");
        } elsif ($infected) {
                print "Virus found: $description\n";
        } else {
                print "File didn't have any detected virus..\n";
        }

DESCRIPTION

This is a simple to use interface to the VirusTotal API (v2) for checking viruses against multiple Anti-Virus databases.

METHODS

new ( [ debug => [0|1] ], [ allowlong => [0|1] ] )

Create a new Webservice::VirusTotal object, with optional configuration options:

debug

True or false to output debug data (default: 0)

allowlong

True or false to allow or disallow long filename support (default: 0)

When set to false Webservice::VirusTotal will assume any filename over 64 characters long with no '/' char is actually file data. When set to True this limit is increased to 256 chars.

Note: Any file name including '..' will automatically be treated as filedata rather than as a filename to prevent many hack attempts. Of course /etc/passwd is not caught along with a whole host of other file-path hacks, so becarful with your implementation!

debug ( 0 | 1 )

Will turn off/on debug information (default: off)

conn_proxy ( $proxystring )

Sets the URL of a proxy server to use for requests.

apiagent ( $agentstring )

Sets the string to use as a User-Agent when connecting to the VirusTotal API

conn_cache ( 0 | 1 )

Will turn off/on use of LWP:ConnCache (default: off)

allowlong ( 0 | 1 )

Will turn off/on whether to allow long (upto 256) characters before assuming the bytes passed are actually a file to scan.

cache ( $handler )

Pass an external connection cache handler to LWP (normally you wouldn't use this instead just setting conn_cache() to true.)

cache_check ( )

Will prune dead connections from the connection cache (if any) will return true if conn_cache is not set.

cache_limit ( $limit )

Sets the maximum number of cached connections in the connection cache.

reportapi ( $report_API_URL )

Sets/Gets the report API URL (default: https://www.virustotal.com/vtapi/v2/file/report )

scanapi ( $scan_API_URL )

Sets/Gets the file subission API URL (default: https://www.virustotal.com/vtapi/v2/file/scan )

apikey ( $apikey )

Sets/Gets the API key to use when connecting to VirusTotal you MUST set this or the API will return an Error and the module will Croak.

timeout ( $timeout )

Sets/Gets the connection timeout in seconds (default: 30 seconds)

scan ( $file )

Invoke a connection to the API and will sent the file specified by $file, or if the file does not appear to be a filename ( > 64 bytes ) will write it to a temporary file and submit that.

NOTE: This is not thread safe! The tempfile created uses the process-id.

DEPENDENCIES

LWP::UserAgent, JSON, Digest::MD5, Digest::SHA, List::Util, Carp

AUTHOR

Michelle Sullivan, <cpan@sorbs.net>

BUGS

Please report any bugs or feature requests to bug-webservice-virustotal at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WebService-VirusTotal. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc WebService::VirusTotal

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

Copyright (c) 2013 Michelle Sullivan, SORBS & Proofpoint Inc.

This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:

http://www.perlfoundation.org/artistic_license_2_0

Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.

If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license.

This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.

This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed.

Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.