-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathdetectPhish.js
38 lines (36 loc) · 1.18 KB
/
detectPhish.js
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
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
if (request.message === "page_loaded") {
fetchReport(request.tabUrl, request.screenshotUrl);
}
}
);
function fetchReport(tabUrl, screenshotUrl) {
let apiUrl = 'https://www.virustotal.com/vtapi/v2/url/report?apikey=f41739bc86b087f6e417ead57411aa6b4f9fe706534eed53036db7dea185aa90';
apiUrl = apiUrl + '&resource=' + tabUrl;
fetch(apiUrl, {
method: 'GET',
headers: new Headers()
})
.then((res) => res.json())
.then((data) => checkReport(data, tabUrl, screenshotUrl));
}
function checkReport(data, tabUrl, screenshotUrl) {
if (data.positives > 0) {
const scans = [];
for (key in data.scans) {
if (data.scans[key].detected == true) {
scans.push(key);
}
}
chrome.runtime.sendMessage({
"message": "open_new_tab",
"url": "warn.html",
"positives": data.positives,
"scans": scans,
"positives": data.positives,
"tabUrl": tabUrl,
"screenshotUrl": screenshotUrl
});
}
}