As there is nowadays many spyware and malware out there, it is important to make sure that your own server stays clean.
Therefore I often use the great VirusTotal service to check suspicious files.
For a certain project I wanted to automate this to be able to check some files and URLs in defined time intervals automatically. This can be easily done with the public VirusTotal API.
Unfortunately the link to the PHP implementation provided on the VirusTotal website is down. Therefore I decided to do my own PHP implementation of this API.
You can download a copy of my implementation. The download contains also a small example script explaining how to use it. You’re free to use the implementation in your own projects. Of course, I’d be happy about a small backlink.
In my API implementation not only the default API functions are implemented that are well documented and therefore not explained here, but there are also several helper functions to make life easier which I will explain in the following:
getScanID($result): returns the scan ID of a scan result that you can use to query a scan report later on.
displayResult($result): displays a scan or submission result in a user readable way.
getSubmissionDate($report): returns the submission date of a scan report.
getTotalNumberOfChecks($report): returns the total number of anti-virus checks of a scan report.
getNumberHits($report): returns the number of anti-virus hits (malware) of a scan report.
getReportPermalink($report, $withDate = TRUE): returns the permalink of the scan report. If
$withDate == TRUE, permalink returns exactly the current scan report, otherwise it returns always the most recent scan report.
These helper functions should make it much easier to work with the API results as you don’t need to care about the details of the returned JSON object anymore. Therefore here again the download of my free API implementation.
Did you use the VirusTotal service already yourself?
This post is also available in Deutsch.