js逆向 扣代码-检测使用环境
标签搜索
侧边栏壁纸
  • 累计撰写 25 篇文章
  • 累计收到 31 条评论

js逆向 扣代码-检测使用环境

z
z
2021-11-06 / 1 评论 / 95 阅读 / 正在检测是否收录...

通过代理对象的方式来修改get set
代理代码

const proxy = function(obj) {
 return new Proxy(obj, {
  set: (target, prop, val) => {
   console.log("SET>>>>", prop, prop, val)
   return Reflect.set(...arguments);
  },
  get: (target, prop, r) => {
   console.log("GET>>>>", prop, prop, target[prop])
   return target[prop]
  },
 })
} 
//假设要对window进行监听
window = proxy(window)

简单的获取第一层

check_array=["document","window","navigator"];
function pr(check_array){
    for(let a = 0;a < check_array.length; a++) {
        eval(check_array[a]+`=new Proxy(`+check_array[a]+`,{
            get:function(k,v){
                console.log("获取了",check_array[a],"里面的",v)
                return k[v];
            }
            })`)
    }
    
}
pr(check_array)

check数组可以添加更多的可能被检测的东东
然后放js最上面跑一下

方法2 深度递归30层

(function () {

    function set_traverse_object(tarrget, obj, recursion_layers) {
        recursion_layers -= 1;
        console.log();
        for (let prop in obj) {
            const value = obj[prop];
            const tg_name = `${tarrget}.${prop.toString()}`;
            const value_type = get_value_type(value);
            if (value && value_type === "object" && recursion_layers >= 1) {
                set_traverse_object(tg_name, value, recursion_layers);
                continue
            }
            if (value && value.toString() !== '[object Object]') {
                console.log(`setter  hook->${tg_name};  value-> ${value};  typeof-> ${value_type}`);
                continue
            }
            console.log(`setter  hook->${tg_name};  value-> ${value};  typeof-> ${value_type}\n`)

        }
    }

    function new_handel(target_name, obj, number) {
        return new Proxy(obj, my_handler(target_name, number))
    }

    function get_value_type(value) {
        if (Array.isArray(value)) {
            return 'Array'
        }
        return typeof value;
    }

    function my_handler(target_name, number) {
        return {
            set: function (obj, prop, value) {
                const value_type = get_value_type(value);
                const tg_name = `${target_name}.${prop.toString()}`;

                if (value && value_type === "object") {
                    set_traverse_object(tg_name, value, number)
                } else {
                    console.log(`setter  hook->${tg_name};  value-> ${value};  typeof-> ${value_type}`)
                }
                return Reflect.set(obj, prop, value);
            },
            get: function (obj, prop) {
                const tg_name = `${target_name}.${prop.toString()}`;
                const value = Reflect.get(obj, prop);
                let value_type = get_value_type(value);
                if (value && value_type === 'object') {
                    return new_handel(tg_name, value, number)
                }
                console.log(`getter  hook->${tg_name};  value-> ${value};  typeof-> ${value_type}\n`);
                return value
            }
        }
    }

    window = new Proxy(window, my_handler(Object.keys({window})[0], 30));
}());
0

评论 (1)

取消
  1. 头像
    Rick
    Windows 10 · Google Chrome

    画图

    回复