diff --git a/ismitmlink/LICENSE.txt b/ismitmlink/LICENSE.txt new file mode 100644 index 0000000..851dc0d --- /dev/null +++ b/ismitmlink/LICENSE.txt @@ -0,0 +1,9 @@ +OSI Approved License Logo + +Copyright 2019 Maslin Bossé + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ismitmlink/META-INF/manifest.mf b/ismitmlink/META-INF/manifest.mf new file mode 100644 index 0000000..2475b27 --- /dev/null +++ b/ismitmlink/META-INF/manifest.mf @@ -0,0 +1,26 @@ +Manifest-Version: 1.0 + +Name: bg.js +Digest-Algorithms: MD5 SHA1 SHA256 +MD5-Digest: OBQ4NPzmtRz7SkYLY2WMqA== +SHA1-Digest: PYd/WXm+69bZUzZ5qmlDQao7wj0= +SHA256-Digest: 1Vp9fbokr9to22h8zNbz8H3M9WIbEscVpvsUNgVdYlA= + +Name: cs.js +Digest-Algorithms: MD5 SHA1 SHA256 +MD5-Digest: pehkupzmo2Ixdt7Q68HAPA== +SHA1-Digest: s+CvdyHvxxa2rpcYdfU2vWTLOVc= +SHA256-Digest: XHy7dueo5NAeaW3bJk1TAUKnPoqduHEJujbs0/AP//g= + +Name: manifest.json +Digest-Algorithms: MD5 SHA1 SHA256 +MD5-Digest: v5awKiN/PL3zsCJSWElfGQ== +SHA1-Digest: Bn8tbrcrML8tXh3Ol2DFIp3q1Hk= +SHA256-Digest: +pPySnm5SraoO/eGR+8rl/YYJwX1UmofcBgDNNUGi2Q= + +Name: icons/32.png +Digest-Algorithms: MD5 SHA1 SHA256 +MD5-Digest: 1TJN3KA5ktXGXU6E+e5Hdg== +SHA1-Digest: YqHDBsNcYxB3WHZsVdoS5762NmY= +SHA256-Digest: XlHfAMRaSBShv6gm2dLkSq91JBr3V1GK3tXJ578ef9s= + diff --git a/ismitmlink/META-INF/mozilla.rsa b/ismitmlink/META-INF/mozilla.rsa new file mode 100644 index 0000000..7fa744c Binary files /dev/null and b/ismitmlink/META-INF/mozilla.rsa differ diff --git a/ismitmlink/META-INF/mozilla.sf b/ismitmlink/META-INF/mozilla.sf new file mode 100644 index 0000000..faab99e --- /dev/null +++ b/ismitmlink/META-INF/mozilla.sf @@ -0,0 +1,5 @@ +Signature-Version: 1.0 +MD5-Digest-Manifest: fTcYSTNIMUsCDHgUA2ZP5Q== +SHA1-Digest-Manifest: 0Rl4MIkrg3zYRWxdlfeD2+yM1gM= +SHA256-Digest-Manifest: WxsHr+ZLaRbnGB6m5UdLXtIqhI/XC2SMzMhSbgLfq8s= + diff --git a/ismitmlink/bg.js b/ismitmlink/bg.js new file mode 100644 index 0000000..a3e3bfb --- /dev/null +++ b/ismitmlink/bg.js @@ -0,0 +1,50 @@ +const apiurl = 'https://searxes.danwin1210.me/collab/open/ismitm.php'; +let mymemory = {}; + +function ismitm(f) { + return new Promise((g, b) => { + fetch(apiurl, { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + }, + body: 'f=' + f + }).then(function (r) { + return r.json(); + }).then(function (r) { + if (r[0]) { + g(r[1]); + } else { + b(); + } + }).catch(b); + }); +} + +browser.runtime.onMessage.addListener((request, sender, sendResponse) => { + if (request && sender) { + if (mymemory[request] != undefined) { + let rlt = mymemory[request]; + if (Object.keys(mymemory).length > 800) { + let cnt = 1; + for (let t in mymemory) { + if (cnt > 10) { + break; + } + mymemory[t] = null; + delete mymemory[t]; + cnt++; + } + } + browser.tabs.sendMessage(sender.tab.id, [request, rlt]); + } else { + ismitm(request).then(function (a) { + mymemory[request] = a; + browser.tabs.sendMessage(sender.tab.id, [request, a]); + }, function () { + browser.tabs.sendMessage(sender.tab.id, [request, false]); + }); + } + } +}); \ No newline at end of file diff --git a/ismitmlink/cs.js b/ismitmlink/cs.js new file mode 100644 index 0000000..d19ab5b --- /dev/null +++ b/ismitmlink/cs.js @@ -0,0 +1,31 @@ +if (document.body) { + if (!['searxes.danwin1210.me', 'searxes.nmqnkngye4ct7bgss4bmv5ca3wpa55yugvxen5kz2bbq67lwy6ps54yd.onion'].includes(location.hostname)) { + let cs = (function () { + let s = document.createElement('style'); + document.head.appendChild(s); + return s.sheet; + })(); + if (cs) { + cs.insertRule("a[data-mitm]{text-decoration-line:line-through !important;text-decoration-color:red !important;text-decoration-style:double !important}", 0); + } + let asked = [location.hostname, 'searxes.danwin1210.me']; + document.querySelectorAll("a[href^='http://']:not([data-mitm]),a[href^='https://']:not([data-mitm]),a[href^='//']:not([data-mitm])").forEach(a => { + let aF = (new URL(a.href)).hostname; + if (!/^(.*)\.(onion|i2p|invalid|test|local|localhost|([0-9]{1,3}))$/.test(aF) && !asked.includes(aF)) { + asked.push(aF); + browser.runtime.sendMessage(aF); + } + }); + browser.runtime.onMessage.addListener((request, sender, sendResponse) => { + if (request.length == 2) { + if (request[1]) { + document.querySelectorAll("a[href^='http://" + request[0] + "/']:not([data-mitm]),a[href^='https://" + request[0] + "/']:not([data-mitm]),a[href^='//" + request[0] + "/']:not([data-mitm])").forEach(a => { + a.dataset.mitm = 1; + a.title = 'MITM!'; + }); + } + } + sendResponse(null); + }); + } +} \ No newline at end of file diff --git a/ismitmlink/icons/32.png b/ismitmlink/icons/32.png new file mode 100644 index 0000000..c39e88b Binary files /dev/null and b/ismitmlink/icons/32.png differ diff --git a/ismitmlink/manifest.json b/ismitmlink/manifest.json new file mode 100644 index 0000000..b7142ba --- /dev/null +++ b/ismitmlink/manifest.json @@ -0,0 +1,34 @@ +{ + "manifest_version": 2, + "name": "Are links vulnerable to MITM attack?", + "description": "Scan FQDN using Searxes' API", + "version": "1.0.1", + "author": "Maslin Bossé", + "permissions": [], + "icons": { + "32": "icons/32.png" + }, + "background": { + "scripts": [ + "bg.js" + ] + }, + "content_scripts": [ + { + "matches": [ + "http://*/*", + "https://*/*" + ], + "js": [ + "cs.js" + ], + "run_at": "document_end" + } + ], + "applications": { + "gecko": { + "id": "ismitm@searxes.danwin1210.me", + "strict_min_version": "56.0" + } + } +} \ No newline at end of file