2019-07-13 02:03:47 +00:00
|
|
|
let apiurl = 'https://api.searxes.eu.org/_/ismitm.php';
|
|
|
|
fetch('http://api.xxf4en4djo7hhvatax2g3lvj2qgvbwi4yeyyzwpo25zcog4ewhsbrdyd.onion/_/ok.php', {
|
2019-05-06 01:44:10 +00:00
|
|
|
method: 'GET',
|
|
|
|
mode: 'cors'
|
|
|
|
}).then(r => r.text()).then(r => {
|
|
|
|
if (r == 'ok') {
|
2019-07-13 02:03:47 +00:00
|
|
|
apiurl = 'http://api.xxf4en4djo7hhvatax2g3lvj2qgvbwi4yeyyzwpo25zcog4ewhsbrdyd.onion/_/ismitm.php';
|
2019-05-06 01:44:10 +00:00
|
|
|
}
|
|
|
|
}).catch(() => {});
|
|
|
|
|
|
|
|
function is_infected(f) {
|
|
|
|
return new Promise((g, b) => {
|
|
|
|
fetch(apiurl, {
|
|
|
|
method: 'POST',
|
|
|
|
mode: 'cors',
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/x-www-form-urlencoded'
|
|
|
|
},
|
|
|
|
body: 'f=' + f
|
|
|
|
}).then(r => r.json()).then(r => {
|
|
|
|
if (r[0]) {
|
|
|
|
g(r[1]);
|
|
|
|
} else {
|
|
|
|
b();
|
|
|
|
}
|
|
|
|
}).catch(b);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function i_already_know_you(f) {
|
|
|
|
if (!/^([a-z0-9_.-]{1,255})\.([a-z]{2,80})$/.test(f)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return new Promise((g, b) => {
|
|
|
|
chrome.storage.local.get(f, (ff) => {
|
|
|
|
if (ff[f]) {
|
|
|
|
if (ff[f] == 'y') {
|
|
|
|
g(1);
|
|
|
|
} else {
|
|
|
|
g(-1);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
g(0);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-08-11 03:48:46 +00:00
|
|
|
function forget_cache_1w() {
|
|
|
|
chrome.storage.local.get(['ign1', 'ign2', 'obs'], (g) => {
|
|
|
|
chrome.storage.local.clear();
|
|
|
|
chrome.storage.local.set({
|
|
|
|
'ign1': (g.ign1 == 'y' ? 'y' : 'n')
|
|
|
|
});
|
|
|
|
chrome.storage.local.set({
|
|
|
|
'ign2': (g.ign2 == 'y' ? 'y' : 'n')
|
|
|
|
});
|
|
|
|
chrome.storage.local.set({
|
|
|
|
'obs': (g.obs == 'y' ? 'y' : 'n')
|
|
|
|
});
|
|
|
|
chrome.storage.local.set({
|
|
|
|
'lastU': Math.round((new Date()).getTime() / 1000)
|
|
|
|
});
|
|
|
|
chrome.storage.local.set({
|
|
|
|
'lastV': (chrome.runtime.getManifest()).version
|
|
|
|
});
|
2019-08-04 23:57:33 +00:00
|
|
|
});
|
2019-05-06 01:44:10 +00:00
|
|
|
setTimeout(function () {
|
2019-08-11 03:48:46 +00:00
|
|
|
forget_cache_1w();
|
2019-08-04 23:57:33 +00:00
|
|
|
}, 604800000);
|
2019-05-06 01:44:10 +00:00
|
|
|
}
|
|
|
|
|
2019-08-04 23:57:33 +00:00
|
|
|
chrome.storage.local.get(['lastU', 'lastV'], (g) => {
|
2019-06-14 07:31:29 +00:00
|
|
|
if (g.lastU) {
|
2019-08-04 23:57:33 +00:00
|
|
|
if (Math.abs(Math.round((new Date()).getTime() / 1000) - g.lastU) > 604800) {
|
2019-08-11 03:48:46 +00:00
|
|
|
chrome.storage.local.get(['ign1', 'ign2', 'obs'], (g) => {
|
|
|
|
chrome.storage.local.clear();
|
|
|
|
chrome.storage.local.set({
|
|
|
|
'ign1': (g.ign1 == 'y' ? 'y' : 'n')
|
|
|
|
});
|
|
|
|
chrome.storage.local.set({
|
|
|
|
'ign2': (g.ign2 == 'y' ? 'y' : 'n')
|
|
|
|
});
|
|
|
|
chrome.storage.local.set({
|
|
|
|
'obs': (g.obs == 'y' ? 'y' : 'n')
|
|
|
|
});
|
|
|
|
chrome.storage.local.set({
|
|
|
|
'lastU': Math.round((new Date()).getTime() / 1000)
|
|
|
|
});
|
2019-06-14 07:31:29 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
chrome.storage.local.set({
|
|
|
|
'lastU': Math.round((new Date()).getTime() / 1000)
|
|
|
|
});
|
|
|
|
}
|
2019-08-04 23:57:33 +00:00
|
|
|
let nowVer = (chrome.runtime.getManifest()).version;
|
|
|
|
if (g.lastV != nowVer) {
|
2019-08-11 03:48:46 +00:00
|
|
|
chrome.storage.local.get(['ign1', 'ign2', 'obs'], (g) => {
|
|
|
|
chrome.storage.local.clear();
|
|
|
|
chrome.storage.local.set({
|
|
|
|
'ign1': (g.ign1 == 'y' ? 'y' : 'n')
|
|
|
|
});
|
|
|
|
chrome.storage.local.set({
|
|
|
|
'ign2': (g.ign2 == 'y' ? 'y' : 'n')
|
|
|
|
});
|
|
|
|
chrome.storage.local.set({
|
|
|
|
'obs': (g.obs == 'y' ? 'y' : 'n')
|
|
|
|
});
|
|
|
|
chrome.storage.local.set({
|
|
|
|
'lastU': Math.round((new Date()).getTime() / 1000)
|
|
|
|
});
|
|
|
|
chrome.storage.local.set({
|
|
|
|
'lastV': (chrome.runtime.getManifest()).version
|
|
|
|
});
|
2019-08-04 23:57:33 +00:00
|
|
|
});
|
|
|
|
}
|
2019-06-14 07:31:29 +00:00
|
|
|
setTimeout(function () {
|
2019-08-11 03:48:46 +00:00
|
|
|
forget_cache_1w();
|
2019-08-04 23:57:33 +00:00
|
|
|
}, 604800000);
|
2019-06-14 07:31:29 +00:00
|
|
|
});
|
2019-05-06 01:44:10 +00:00
|
|
|
|
|
|
|
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
|
2019-08-11 03:48:46 +00:00
|
|
|
if (request && sender) {
|
2019-05-06 01:44:10 +00:00
|
|
|
i_already_know_you(request).then((r) => {
|
|
|
|
if (r == 1 || r == -1) {
|
|
|
|
chrome.tabs.sendMessage(sender.tab.id, [request, ((r == 1) ? true : false)]);
|
|
|
|
}
|
|
|
|
if (r == 0) {
|
|
|
|
is_infected(request).then((a) => {
|
2019-06-14 07:31:29 +00:00
|
|
|
chrome.storage.local.set({
|
|
|
|
[request]: ((a) ? 'y' : 'n')
|
|
|
|
});
|
2019-05-06 01:44:10 +00:00
|
|
|
chrome.tabs.sendMessage(sender.tab.id, [request, a]);
|
|
|
|
}, () => {
|
|
|
|
chrome.tabs.sendMessage(sender.tab.id, [request, false]);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}, () => {});
|
|
|
|
}
|
|
|
|
});
|