-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.php
executable file
·55 lines (48 loc) · 1.83 KB
/
app.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
use \FileRun\WebLinks;
class custom_virustotal extends \FileRun\Files\Plugin
{
static $localeSection = 'Custom Actions: Scan for Virus';
function init()
{
$this->settings = [
[
'key' => 'APIKey',
'title' => self::t('VirusTotal API Key'),
'comment' => '<a href="https://support.virustotal.com/hc/en-us/articles/115002088769-Please-give-me-an-API-key" target="_blank">Getting a Virus Total API Key</a>'
]
];
$this->JSconfig = [
'title' => self::t("Scan for Virus"),
'icon' => 'customizables/plugins/virustotal/icons/icon.png',
'popup' => true,
'width' => 800, 'height' => 450,
'requires' => ['preview']
];
}
function isDisabled()
{
return (strlen(self::getSetting('APIKey')) == 0);
}
function run()
{
$size = \FM::getFileSize($this->data['fullPath']);
if ($size <= 31457280) {
$fileName = $this->data['fullPath'];
$vt_key = self::getSetting('APIKey');
$hash = hash_file('sha256', $fileName);
$vt_json = file_get_contents("https://www.virustotal.com/vtapi/v2/file/report?apikey=$vt_key&resource=$hash");
$vt_json_result = json_decode($vt_json, true);
if ($vt_json_result['response_code'] == 0) {
require_once('class/virustotal.class.php');
$vt = new virustotal(self::getSetting('APIKey'));
$vt->checkFile($this->data['fullPath']);
}
$this->logAction();
require $this->path . "/display/display.php";
} else {
require $this->path . "/display/display_error.php";
$this->logAction();
}
}
}