1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2025-05-25 09:13:27 +02:00

Detection over navigator and DOMRect getters was possible

This commit is contained in:
kkapsner 2019-05-20 08:45:31 +02:00
parent 79a9034051
commit e0dda5ec0f
4 changed files with 33 additions and 13 deletions

View File

@ -170,8 +170,8 @@
], ],
name: property, name: property,
getterGenerator: function(){ getterGenerator: function(){
const temp = { const temp = eval(`({
get [property](){ get ${property}(){
const registration = getDOMRectRegistration(this); const registration = getDOMRectRegistration(this);
if (registration){ if (registration){
return getFakeDomRect( return getFakeDomRect(
@ -179,24 +179,24 @@
this, this,
registration.prefs, registration.prefs,
registration.notify registration.notify
)[property]; ).${property};
} }
return this[property]; return this.${property};
} }
}; })`);
return Object.getOwnPropertyDescriptor(temp, property).get; return Object.getOwnPropertyDescriptor(temp, property).get;
} }
}; };
if (!readonly){ if (!readonly){
changedGetter.setterGenerator = function(window, original, prefs){ changedGetter.setterGenerator = function(window, original, prefs){
const temp = { const temp = eval(`({
set [property](newValue){ set ${property}(newValue){
const registration = getDOMRectRegistration(this); const registration = getDOMRectRegistration(this);
if (registration){ if (registration){
const fakeDomRect = getFakeDomRect(window, this, prefs, registration.notify); const fakeDomRect = getFakeDomRect(window, this, prefs, registration.notify);
registeredRects.delete(getWrapped(this)); registeredRects.delete(getWrapped(this));
["x", "y", "width", "height"].forEach((prop) => { ["x", "y", "width", "height"].forEach((prop) => {
if (prop === property){ if (prop === "${property}"){
this[prop] = newValue; this[prop] = newValue;
} }
else { else {
@ -208,7 +208,7 @@
original.apply(this, window.Array.from(arguments)); original.apply(this, window.Array.from(arguments));
} }
} }
}; })`);
return Object.getOwnPropertyDescriptor(temp, property).set; return Object.getOwnPropertyDescriptor(temp, property).set;
}; };
} }

View File

@ -20,19 +20,19 @@
objectGetters: [function(window){return window.Navigator && window.Navigator.prototype;}], objectGetters: [function(window){return window.Navigator && window.Navigator.prototype;}],
name: property, name: property,
getterGenerator: function(checker){ getterGenerator: function(checker){
const temp = { const temp = eval(`({
get [property](){ get ${property}(){
return checkerWrapper(checker, this, arguments, function(args, check){ return checkerWrapper(checker, this, arguments, function(args, check){
const {prefs, notify, window, original} = check; const {prefs, notify, window, original} = check;
const originalValue = original.apply(this, window.Array.from(args)); const originalValue = original.apply(this, window.Array.from(args));
const returnValue = navigator.getNavigatorValue(property); const returnValue = navigator.getNavigatorValue("${property}");
if (originalValue !== returnValue){ if (originalValue !== returnValue){
notify("fakedNavigatorReadout"); notify("fakedNavigatorReadout");
} }
return returnValue; return returnValue;
}); });
} }
}; })`);
return Object.getOwnPropertyDescriptor(temp, property).get; return Object.getOwnPropertyDescriptor(temp, property).get;
} }
}; };

View File

@ -24,6 +24,7 @@ Version 0.5.9:
- improved DOMRect performance - improved DOMRect performance
- improved general performance when stack list is disabled - improved general performance when stack list is disabled
- preventing double interception (increased performance and reduced detectability) - preventing double interception (increased performance and reduced detectability)
- detection over navigator and DOMRect getters was possible
known issues: known issues:
- if a data URL is blocked the page action button does not appear - if a data URL is blocked the page action button does not appear

View File

@ -106,6 +106,7 @@ addTest("function code", function(log){
} }
return false; return false;
} }
log("canvas functions");
codeDetected = checkFunctionCode( codeDetected = checkFunctionCode(
CanvasRenderingContext2D.prototype.getImageData, CanvasRenderingContext2D.prototype.getImageData,
"getImageData" "getImageData"
@ -114,10 +115,12 @@ addTest("function code", function(log){
HTMLCanvasElement.prototype.toDataURL, HTMLCanvasElement.prototype.toDataURL,
"toDataURL" "toDataURL"
) || codeDetected; ) || codeDetected;
log("history getter");
codeDetected = checkFunctionCode( codeDetected = checkFunctionCode(
history.__lookupGetter__("length"), history.__lookupGetter__("length"),
"(get )?length" "(get )?length"
) || codeDetected; ) || codeDetected;
log("window getters");
codeDetected = checkFunctionCode( codeDetected = checkFunctionCode(
window.__lookupGetter__("name"), window.__lookupGetter__("name"),
"(get )?name" "(get )?name"
@ -126,6 +129,22 @@ addTest("function code", function(log){
window.__lookupSetter__("name"), window.__lookupSetter__("name"),
"(set )?name" "(set )?name"
) || codeDetected; ) || codeDetected;
log("navigator getters");
Object.keys(navigator.__proto__).forEach(function(property){
if (typeof navigator[property] === "string"){
codeDetected = checkFunctionCode(
navigator.__proto__.__lookupGetter__(property),
"(get )?" + property
) || codeDetected;
}
});
log("DOMRect getters");
["x", "y", "height", "width"].forEach(function(property){
codeDetected = checkFunctionCode(
DOMRect.prototype.__lookupGetter__(property),
"(get )?" + property
) || codeDetected;
});
return codeDetected; return codeDetected;
}); });
addTest("toString modified", function(log){ addTest("toString modified", function(log){