-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
99 lines (83 loc) · 2.98 KB
/
background.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
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
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Phishing & Scam Manuel DB by Golyat Security
//Created by Golyat Security
//DB Update Date: 01.04.2024
//For Your Cyber Security
//All Rights Reserved
//Golyatsec.com
var domains;
async function updateRules() {
try {
const response = await fetch(chrome.runtime.getURL('/database/phishing_domains.json'));
const data = await response.json();
domains = data.domains;
const rules = domains.map((domain, index) => {
const cleanDomain = domain.replace(/[^\x00-\x7F]/g, '');
return {
id: index + 1,
priority: index + 1,
action: { type: 'block' },
condition: { urlFilter: cleanDomain }
};
});
chrome.declarativeNetRequest.updateDynamicRules({
addRules: rules,
removeRuleIds: []
});
} catch (error) {
console.error("Error updating rules:", error);
}
}
updateRules();
setInterval(updateRules, 24 * 60 * 60 * 1000);
chrome.webRequest.onBeforeRequest.addListener(
function(details) {
const requestedDomain = new URL(details.url).hostname;
if (isPhishingDomain(requestedDomain)) {
return { redirectUrl: chrome.runtime.getURL("/security/blocked.html") };
}
},
{ urls: ["<all_urls>"], types: ["main_frame"] },
["blocking"]
);
function isPhishingDomain(domain) {
return domains.includes(domain);
}
chrome.runtime.onMessage.addListener(function(message) {
if (message.type === "blocked-domain") {
const blockedDomain = message.domain;
chrome.storage.local.set({ "blockedDomain": blockedDomain });
}
});
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Phishing & Scam Automatic DB by USOM
//Created by Golyat Security
//DB Update Rate: Every Hour
//For Your Cyber Security
//All Rights Reserved
//Golyatsec.com
async function checkPhishing(url) {
try {
const response = await fetch('https://www.usom.gov.tr/url-list.txt');
const text = await response.text();
const domains = text.split('\n');
const enteredDomain = new URL(url).hostname;
if (domains.includes(enteredDomain)) {
return true;
} else {
return false;
}
} catch (error) {
console.error("Error checking phishing:", error);
return false;
}
}
chrome.tabs.onUpdated.addListener(async function(tabId, changeInfo, tab) {
if (changeInfo.status === 'complete') {
const isPhishing = await checkPhishing(tab.url);
if (isPhishing) {
chrome.tabs.update(tabId, {url: chrome.runtime.getURL("/security/blocked.html")});
}
}
});
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////