0
0
mirror of https://codeberg.org/crimeflare/cloudflare-tor synced 2024-11-10 03:12:49 +00:00

Upload files to 'addon_firefox/bcma'

This commit is contained in:
surveillanceeconomy 2019-05-29 12:06:51 +00:00
parent 200caeef6c
commit 3bb801d058
5 changed files with 27 additions and 61 deletions

View File

@ -1,22 +1,12 @@
/* /*
"Welcome to PRISM 2.0" "Welcome to PRISM 2.0"
*/ */
var cf_flag_ok = 'icons/cf_0.png'; const cf_flag_ok = 'icons/cf_0.png';
var cf_flag_ng = 'icons/cf_1.png'; const cf_flag_ng = 'icons/cf_1.png';
var force_whitelist = ['searxes.eu.org', 'thunderbird.net', 'mozilla.org', 'archive.org', 'cloudflare.com', 'cloudflareapps.com', 'cloudflare-dns.com', 'cloudflarestatus.com', 'cloudflareapi.com', 'cloudflare-ipfs.com', 'cloudflare-quic.com']; const force_whitelist = ['searxes.eu.org', 'thunderbird.net', 'mozilla.org', 'archive.org', 'cloudflare.com', 'cloudflareapps.com', 'cloudflare-dns.com', 'cloudflarestatus.com', 'cloudflareapi.com', 'cloudflare-ipfs.com', 'cloudflare-quic.com'];
var cfdomains = []; let my_cf_collection = [];
var known_cf_domains = []; let my_cf_ignore = [];
let my_action = 2;
fetch('bcmadata.txt',{method:'GET'}).then(function (b) {
return b.text();
}).then(function (b) {
cfdomains = b.split("\n").filter(v=>v!='');
known_cf_domains = cfdomains;
});
var my_cf_collection = [];
var my_cf_ignore = [];
var my_action = 2;
function onError(e) { function onError(e) {
console.log(`BCMA: Error:${e}`); console.log(`BCMA: Error:${e}`);
@ -603,8 +593,8 @@ function get_realdomain(w) {
} }
function update_icon(tid, url) { function update_icon(tid, url) {
var _nu = new URL(url); let _nu = new URL(url);
var cf_hostname = _nu.hostname; let cf_hostname = _nu.hostname;
if ((_nu.protocol != 'http:' && _nu.protocol != 'https:') || cf_hostname.length < 1) { if ((_nu.protocol != 'http:' && _nu.protocol != 'https:') || cf_hostname.length < 1) {
browser.browserAction.setIcon({ browser.browserAction.setIcon({
tabId: tid, tabId: tid,
@ -620,17 +610,17 @@ function update_icon(tid, url) {
}); });
return; return;
} }
if (known_cf_domains.includes(cf_hostname) || my_cf_collection.includes(cf_hostname)) { if (my_cf_collection.includes(cf_hostname)) {
if (my_action == 3) { if (my_action == 3) {
browser.tabs.executeScript(tid, { browser.tabs.executeScript(tid, {
matchAboutBlank: true, matchAboutBlank: true,
runAt: 'document_end', runAt: 'document_end',
code: "if (location.hostname=='%%CFHOST%%'||location.hostname.endsWith('.%%CFHOST%%')){if (!document.title.startsWith('[!!MITM!!]') && (typeof _bcma_bdr)=='undefined'){document.title='[!!MITM!!]'+document.title;function _bcma_bdr(){document.body.style = 'border:4px dashed #' + ['e74c3c', '9b59b6', '3498db', '17a589', '196f3d', 'f4d03f', 'f39c12', 'd35400'][Math.floor(Math.random() * 8)] + ' !important';setTimeout(_bcma_bdr,4860);};_bcma_bdr();}}".replace('%%CFHOST%%', cf_hostname).replace('%%CFHOST%%', cf_hostname) code: "if (location.hostname=='%%CFHOST%%'||location.hostname.endsWith('.%%CFHOST%%')){if (!document.title.startsWith('[!!MITM!!]') && (typeof _bcma_bdr)=='undefined'){document.title='[!!MITM!!]'+document.title;function _bcma_bdr(){document.body.style = 'border:4px dashed #' + ['e74c3c', '9b59b6', '3498db', '17a589', '196f3d', 'f4d03f', 'f39c12', 'd35400'][Math.floor(Math.random() * 8)] + ' !important';setTimeout(_bcma_bdr,4900);};_bcma_bdr();}}".replace('%%CFHOST%%', cf_hostname).replace('%%CFHOST%%', cf_hostname)
}); });
browser.tabs.executeScript(tid, { browser.tabs.executeScript(tid, {
matchAboutBlank: true, matchAboutBlank: true,
runAt: 'document_idle', runAt: 'document_idle',
code: "if (location.hostname=='%%CFHOST%%'||location.hostname.endsWith('.%%CFHOST%%')){if (!document.title.startsWith('[!!MITM!!]') && (typeof _bcma_bdr)=='undefined'){document.title='[!!MITM!!]'+document.title;function _bcma_bdr(){document.body.style = 'border:4px dashed #' + ['e74c3c', '9b59b6', '3498db', '17a589', '196f3d', 'f4d03f', 'f39c12', 'd35400'][Math.floor(Math.random() * 8)] + ' !important';setTimeout(_bcma_bdr,4860);};_bcma_bdr();}}".replace('%%CFHOST%%', cf_hostname).replace('%%CFHOST%%', cf_hostname) code: "if (location.hostname=='%%CFHOST%%'||location.hostname.endsWith('.%%CFHOST%%')){if (!document.title.startsWith('[!!MITM!!]') && (typeof _bcma_bdr)=='undefined'){document.title='[!!MITM!!]'+document.title;function _bcma_bdr(){document.body.style = 'border:4px dashed #' + ['e74c3c', '9b59b6', '3498db', '17a589', '196f3d', 'f4d03f', 'f39c12', 'd35400'][Math.floor(Math.random() * 8)] + ' !important';setTimeout(_bcma_bdr,4900);};_bcma_bdr();}}".replace('%%CFHOST%%', cf_hostname).replace('%%CFHOST%%', cf_hostname)
}); });
} }
browser.browserAction.setIcon({ browser.browserAction.setIcon({
@ -678,11 +668,11 @@ browser.webRequest.onHeadersReceived.addListener(function (wr) {
if (force_whitelist.includes(wr_hostname)) { if (force_whitelist.includes(wr_hostname)) {
return; return;
} }
var cf_is = (known_cf_domains.includes(wr_hostname) || my_cf_collection.includes(wr_hostname)) ? true : false; var cf_is = (my_cf_collection.includes(wr_hostname)) ? true : false;
if (!cf_is) { if (!cf_is) {
var cf_headers = wr.responseHeaders, var cf_headers = wr.responseHeaders,
cf_v_name, cf_v_value; cf_v_name, cf_v_value;
for (var i = 0; i < cf_headers.length; i++) { for (let i = 0; i < cf_headers.length; i++) {
cf_v_name = cf_headers[i]['name'].toLowerCase(); cf_v_name = cf_headers[i]['name'].toLowerCase();
cf_v_value = (cf_headers[i]['value'] != undefined) ? cf_headers[i]['value'].toLowerCase() : ''; cf_v_value = (cf_headers[i]['value'] != undefined) ? cf_headers[i]['value'].toLowerCase() : '';
if (cf_v_name == 'server' && cf_v_value.includes('cloudflare')) { if (cf_v_name == 'server' && cf_v_value.includes('cloudflare')) {
@ -702,6 +692,10 @@ browser.webRequest.onHeadersReceived.addListener(function (wr) {
if (cf_is) { if (cf_is) {
if (my_cf_collection.length > 500) { if (my_cf_collection.length > 500) {
my_cf_collection.shift(); my_cf_collection.shift();
my_cf_collection.shift();
my_cf_collection.shift();
my_cf_collection.shift();
my_cf_collection.shift();
} }
if (!my_cf_collection.includes(wr_hostname)) { if (!my_cf_collection.includes(wr_hostname)) {
my_cf_collection.push(wr_hostname); my_cf_collection.push(wr_hostname);
@ -720,7 +714,7 @@ browser.webRequest.onHeadersReceived.addListener(function (wr) {
} }
if (my_action == 2) { if (my_action == 2) {
return { return {
redirectUrl: 'https://web.archive.org/web/' + wr.url.split('?')[0] redirectUrl: 'https://web.archive.org/web/' + wr.url
}; };
} }
} }
@ -761,7 +755,7 @@ browser.webRequest.onBeforeRequest.addListener(function (wr) {
if (force_whitelist.includes(wr_hostname)) { if (force_whitelist.includes(wr_hostname)) {
return; return;
} }
var cf_is = (known_cf_domains.includes(wr_hostname) || my_cf_collection.includes(wr_hostname)) ? true : false; var cf_is = (my_cf_collection.includes(wr_hostname)) ? true : false;
if (cf_is) { if (cf_is) {
console.log('BCMA: Block Cloudflare BR', wr_hostname); console.log('BCMA: Block Cloudflare BR', wr_hostname);
if (my_action == 0 || my_action == 1) { if (my_action == 0 || my_action == 1) {
@ -777,7 +771,7 @@ browser.webRequest.onBeforeRequest.addListener(function (wr) {
} }
if (my_action == 2) { if (my_action == 2) {
return { return {
redirectUrl: 'https://web.archive.org/web/' + wr.url.split('?')[0] redirectUrl: 'https://web.archive.org/web/' + wr.url
}; };
} }
} }
@ -788,20 +782,12 @@ browser.webRequest.onBeforeRequest.addListener(function (wr) {
browser.runtime.onMessage.addListener(function (a, b, c) { browser.runtime.onMessage.addListener(function (a, b, c) {
if (a[0] == 'cf') { if (a[0] == 'cf') {
c(['ok', JSON.stringify(my_cf_collection), JSON.stringify(my_cf_ignore), (known_cf_domains.length == 0) ? false : true, my_action]); c(['ok', JSON.stringify(my_cf_collection), JSON.stringify(my_cf_ignore), my_action]);
} }
if (a[0] == 'erosman') { if (a[0] == 'erosman') {
my_cf_collection = []; my_cf_collection = [];
c(['destroy']); c(['destroy']);
} }
if (a[0] == 'bi') {
if (a[1] == 'y') {
known_cf_domains = cfdomains;
} else {
known_cf_domains = [];
}
c(['ok']);
}
if (a[0] == 'ta') { if (a[0] == 'ta') {
if (a[1] == '0') { if (a[1] == '0') {
my_action = 0; my_action = 0;

View File

@ -2,7 +2,7 @@
"manifest_version": 2, "manifest_version": 2,
"name": "Block Cloudflare MITM Attack", "name": "Block Cloudflare MITM Attack",
"description": "Submit to global surveillance or resist. The choice is yours.", "description": "Submit to global surveillance or resist. The choice is yours.",
"version": "1.0.1905.1", "version": "1.0.1906.1",
"author": "Project BCMA", "author": "Project BCMA",
"homepage_url": "https://trac.torproject.org/projects/tor/ticket/24351", "homepage_url": "https://trac.torproject.org/projects/tor/ticket/24351",
"permissions": [ "permissions": [

View File

@ -4,12 +4,8 @@
<link rel="stylesheet" href="style.css"> <link rel="stylesheet" href="style.css">
</head> </head>
<body style="display:none"> <body style="display:none">
Temporary configurations <i>Temporary</i> configurations
<hr> <hr>
<b>&#9758; Built-in Cloudflare list (.com only)</b> <small>(powered by <a href="https://searxes.danwin1210.me/" target="_blank">Searxes</a>)</small><br>
<label><input type="radio" id="bi0" name="bi" value="0"> Use built-in list</label> <small>(Default)</small><br>
<label><input type="radio" id="bi1" name="bi" value="1"> Don't use built-in list</label><br>
<br>
<b>&#9822; Take Action</b><br> <b>&#9822; Take Action</b><br>
<label><input type="radio" id="ta0" name="ta" value="0"> Block request immediately <small>(first-party + third-party)</small></label><br> <label><input type="radio" id="ta0" name="ta" value="0"> Block request immediately <small>(first-party + third-party)</small></label><br>
<label><input type="radio" id="ta1" name="ta" value="1"> Block request immediately <small>(third-party only / ignore first-party)</small></label><br> <label><input type="radio" id="ta1" name="ta" value="1"> Block request immediately <small>(third-party only / ignore first-party)</small></label><br>
@ -17,7 +13,7 @@
<label><input type="radio" id="ta3" name="ta" value="3"> Notify only</label><br> <label><input type="radio" id="ta3" name="ta" value="3"> Notify only</label><br>
<br> <br>
<b>&#9997; Your Cloudflare Domain collection</b> <small>(Last 500)</small><br> <b>&#9997; Your Cloudflare Domain collection</b> <small>(Last 500)</small><br>
<small>(please share with <a href="https://notabug.org/themusicgod1/cloudflare-tor/" target="_blank">cloudflare-tor@notabug</a>)</small><br> <small>(please share with <a href="https://notabug.org/crimeflare/cloudflare-tor/" target="_blank">cloudflare-tor@crimeflare</a>)</small><br>
<textarea cols="50" rows="12" id="t" wrap="off" spellcheck="false" placeholder="Cloudflare domains"></textarea> <textarea cols="50" rows="12" id="t" wrap="off" spellcheck="false" placeholder="Cloudflare domains"></textarea>
<br> <br>
<button type="button" id="exp">[ &#8659; Export ]</button> <button type="button" id="exp">[ &#8659; Export ]</button>

View File

@ -7,14 +7,7 @@ document.addEventListener('DOMContentLoaded', function () {
if (r[0] == 'ok') { if (r[0] == 'ok') {
document.getElementById('t').value = JSON.parse(r[1]).join("\n"); document.getElementById('t').value = JSON.parse(r[1]).join("\n");
document.getElementById('g').value = JSON.parse(r[2]).join("\n"); document.getElementById('g').value = JSON.parse(r[2]).join("\n");
if (r[3]) { switch (r[3]) {
document.getElementById('bi0').checked = true;
document.getElementById('bi1').checked = false;
} else {
document.getElementById('bi0').checked = false;
document.getElementById('bi1').checked = true;
}
switch (r[4]) {
case 1: case 1:
document.getElementById('ta0').checked = false; document.getElementById('ta0').checked = false;
document.getElementById('ta1').checked = true; document.getElementById('ta1').checked = true;
@ -67,16 +60,6 @@ document.getElementById('clr').addEventListener('click', function () {
document.getElementById('t').value = ''; document.getElementById('t').value = '';
}, onError); }, onError);
}); });
document.getElementById('bi0').addEventListener('click', function () {
if (this.checked) {
browser.runtime.sendMessage(['bi', 'y']).then(function (r) {}, onError);
}
});
document.getElementById('bi1').addEventListener('click', function () {
if (this.checked) {
browser.runtime.sendMessage(['bi', 'n']).then(function (r) {}, onError);
}
});
document.getElementById('ta0').addEventListener('click', function () { document.getElementById('ta0').addEventListener('click', function () {
if (this.checked) { if (this.checked) {
browser.runtime.sendMessage(['ta', '0']).then(function (r) {}, onError); browser.runtime.sendMessage(['ta', '0']).then(function (r) {}, onError);

View File

@ -13,7 +13,8 @@ button {
border: 0; border: 0;
overflow: hidden; overflow: hidden;
outline: none; outline: none;
outline-style: none outline-style: none;
cursor: pointer
} }
body { body {