-
Notifications
You must be signed in to change notification settings - Fork 60
/
virustotal-ng.cna
142 lines (102 loc) · 2.79 KB
/
virustotal-ng.cna
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# VirusTotal Notifications
# Checks VirusTotal for your IOC
import java.net.URLEncoder;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
global('@global_maldomains');
@global_maldomains = @();
sub sendhttp{
$method = $1;
$url = $2;
$body = $3 . "\r\n";
$USER_AGENT = "Mozilla/5.0";
$urlobj = [new URL: $url];
$con = [$urlobj openConnection];
[$con setRequestMethod: $method];
[$con setRequestProperty: "User-Agent", $USER_AGENT];
[$con setDoOutput: true];
$wr = [new DataOutputStream: [$con getOutputStream]];
[$wr writeBytes: $body];
[$wr flush];
[$wr close];
$responseCode = [$con getResponseCode];
$in = [new BufferedReader: [new InputStreamReader: [$con getInputStream]]];
$inputLine = "";
$response = "";
$inputLine = [$in readLine];
$response = $response . $inputLine . "\r\n";
while ($inputLine ne ""){
$inputLine = [$in readLine];
$response = $response . $inputLine . "\r\n";
}
[$in close];
return $response;
}
sub pushover {
$token = "TOKEN";
$user = "USER";
$title = $1;
$message = $2;
$body = "token=" . $token . "&user=" . $user . "&title=" . $title . "&message=" . $message;
sendhttp("POST", "https://api.pushover.net/1/messages.json", $body);
}
sub vtdomain {
$api = "VTAPIKEY";
$domain = $1;
$params = "?apikey=" . $api . "&resource=" . $domain;
$url = "https://www.virustotal.com/vtapi/v2/url/report" . $params;
return sendhttp("GET", $url, "");
}
sub domains{
@domains = @();
$a = listeners();
foreach $b ($a) {
$c = listener_info($b);
$host = $c["host"];
if ($host !isin @domains){
add(@domains, $host, -1);
}
$beacons = $c["beacons"];
@beacons_list = split(", ",$beacons);
foreach $beacon (@beacons_list){
if ($beacon !isin @domains){
add(@domains, $beacon, -1);
}
}
}
@vtmaldomains = @();
foreach $domain (@domains){
$res = vtdomain($domain);
if ("{\"scan_id\"" isin $res){
# Domain seen in VT
if ("\"positives\": 0" isin $res){
# Undetected
elog("\cD[VT] Clean: \c9" . $domain);
}
else{
add(@vtmaldomains, $domain, -1);
}
}
else{
elog("\cD[VT] Not found: \c9" . $domain);
}
}
return @vtmaldomains;
}
on heartbeat_10m {
@maldom = domains();
foreach $domain (@maldom){
if ($domain !isin @global_maldomains){
add(@global_maldomains, $domain, -1);
$time = formatDate(dstamp(ticks()), "yyyy.MM.dd 'at' HH:mm:ss z");
elog("\cD[VT] New malicious domain added: \c4" . $domain);
pushover("[VT] " . $domain . " MALICIOUS", $domain . " is classed as malicious");
}
}
}
on ready {
elog("VirusTotal notifications are now configured");
}