-
Notifications
You must be signed in to change notification settings - Fork 22
/
post_vt.php
53 lines (43 loc) · 1.34 KB
/
post_vt.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
<?php
/*****************************
* Set your VirusTotal API key
*****************************/
$api_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
// ---
// ---
// ---
require_once 'handlers/error.php';
require_once 'handlers/exception.php';
require_once 'logger.php';
set_error_handler('error_handler');
set_exception_handler('exception_handler');
if ($argc < 2) {
throw new Exception('Invalid arguments');
}
$file_path = $argv[1];
$cfile = curl_file_create($file_path);
$post = ['apikey' => $api_key, 'file' => $cfile];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.virustotal.com/vtapi/v2/file/scan');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');
curl_setopt($ch, CURLOPT_USERAGENT, "gzip, EKTotal");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$result = curl_exec($ch);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$vt_url = '';
if ($status_code === 200) {
$json = json_decode($result, true);
$vt_url = $json['permalink'];
$vt_url = explode('analysis/', $vt_url);
if (count($vt_url) === 2) {
$vt_url = $vt_url[0] . 'analysis/';
} else {
$vt_url = '';
}
} else {
$vt_url = '';
}
curl_close($ch);
exit(0);