proxy-hack-collection
window.Math.random (Use object property)
window.Math.floor
// Override window.Math with a custom object
window.Math = {
PI: 3.14, // Custom value
random: () => 0.5, // Custom random function
floor: (num) => Math.floor(num), // Delegate to original Math.floor
// Add or modify methods as needed
};
console.log(Math.random());
window.Math.random (Use handler.get)
// Create a Proxy to wrap the Math object
window.Math = new Proxy(window.Math, {
get(target, prop) {
if (prop === 'random') {
return () => 0.5; // Override Math.random
}
return target[prop]; // Delegate to original Math
}
});
console.log(Math.random());
window.Math.random (Use handler.apply)
window.Math.random = new Proxy(window.Math.random, {
apply(target, thisArg, argumentsList) {
console.log('target',target);
console.log('thisArg',thisArg);
return -999;
}
});
console.log(Math.random());
document.write (Use handler.apply)
document.__proto__.__proto__.write=new Proxy(document.__proto__.__proto__.write, {
apply(target, thisArg, argumentsList) {
//console.log('target',target);
//console.log('thisArg',thisArg);
return target.call(thisArg,"Successfully Hacked!!!");
}
});
document.write("test");
document.write (Use handler.apply & Reflect.apply)
document.__proto__.__proto__.write=new Proxy(document.__proto__.__proto__.write, {
apply(target, thisArg, argumentsList) {
//console.log('target',target);
//console.log('thisArg',thisArg);
return Reflect.apply(target, thisArg, argumentsList);
}
});
document.write("test");
window.Proxy (Use dummy function)
let proxyCount=0;
const OriginalProxy=Proxy;
window.Proxy=function(...args){
proxyCount++;
return new OriginalProxy(...args);
};
console.log(proxyCount); // Track number of Proxies created
window.Proxy (Use handler.apply)
let proxyCount=0;
const OriginalProxy=Proxy;
window.Proxy=new Proxy(window.Proxy, {
apply(target, thisArg, argumentsList) {
//console.log('target',target);
//console.log('thisArg',thisArg);
console.log("Successfully Hacked!!!");
return Reflect.apply(target, thisArg, argumentsList);
}
});
console.log(proxyCount); // Track number of Proxies created