2017 © Pedro Peláez
 

library virus-total-api

Very simple VirusTotal api wrapper for Laravel 5

image

moay/virus-total-api

Very simple VirusTotal api wrapper for Laravel 5

  • Wednesday, March 25, 2015
  • by Moay
  • Repository
  • 1 Watchers
  • 5 Stars
  • 2,722 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 1 Open issues
  • 1 Versions
  • 1 % Grown

The README.md

virus-total-api

Very simple VirusTotal API wrapper for Laravel 5. This package wraps the VirusTotal API in to very simple methods in order to allow you to very easily perform a virus scan or malware scan on URLs or files. Please be aware, that there are some limits to the public API. See their docs: https://www.virustotal.com/documentation/public-api/, (*1)

Installation

Installation is super simple. Use Composer to require this package:, (*2)

    "require": {
        "moay/virus-total-api": "dev-master"
    }

After having pulled the repo via composer update, you will have to add this to your Laravel providers in app/config/app.php (within the providers array):, (*3)

'moay\VirusTotalApi\VirusTotalApiServiceProvider',

In order to access the API, you need a VirusTotal API key. Get one at their website and publish the package settings:, (*4)

php artisan vendor:publish

This will publish a file named virus-total-api to your app/config directory. Insert your API key there to make it work., (*5)

Usage

Usage is super simple. Let's imagine a simple controller:, (*6)

<?php namespace app\Http\Controllers;

// Include the alias, else it won't work
use VirusTotal;

class Simplecontroller extends Controller {

    public function example()
    {
        // Let's scan google for malware
        $googleResults = VirusTotal::scanUrl('http://google.de');

        // Let's scan a file for malware
        $fileResults = VirusTotal::scanFile('/my/absolute/filename.txt');

        //Let's scan a file for malware via its URL
        $remoteFileResults = VirusTotal::scanFileViaUrl('http://somecooldomain.com/filename.txt');
    }

}

This is it, there are no more methods to learn. Please be aware of the access rate limits of the API. Read more about the returned stuff over at https://www.virustotal.com/documentation/public-api/, (*7)

The wrapper will add a success variable to the returned array to indicate whether or not the API request was successful. If you did exceed your API quota for the current minute or you did not provide a valid API, it will be set to false., (*8)

Using the results

A quick example to handle the returned stuff., (*9)

<?php namespace app\Http\Controllers;

use VirusTotal;

class Simplecontroller extends Controller {

    public function anotherExample()
    {
        // Let's scan google for malware
        $googleResults = VirusTotal::scanUrl('http://google.de');

        if($googleResults['success'])
        {
            // Let's check if there was a virus detected
            if($googleResults['positives']>0)
            {
                // There was a virus - do something about it!
            }
        }
        elseif($googleResults['error'] == 'rate limit exceeded')
        {
            // Reschedule the scan
            ...
        }
    }

}

The Versions

25/03 2015

dev-master

9999999-dev

Very simple VirusTotal api wrapper for Laravel 5

  Sources   Download

MIT

The Requires

 

by Avatar Moay