js_reverse/猿人学练习/16js加密表情包+sojson6.0-aa混淆-setInterval定时任务

知识点: sojson6.0aa混淆setInterval定时任务

解题思路

打开控制台,查看请求链接,程序执行setInterval(function(){ debugger; }, 300),定时任务每3毫秒执行一次

同时还存在另外一个setInterval(function(){ console.log(binb2b64(a+'error')); }, 300)

请求

这里利用 Tampermonkey hook函数setInterval

请求

// ==UserScript==
// @name        debugger
// @namespace   http://tampermonkey.net/
// @version     0.1
// @description pass
// @author      ayf
// @run-at      document-start
// @match        *://*.python-spider.com/*
// @grant       none
// ==/UserScript==

(function() {
    var new_setInterval=setInterval;
    window.setInterval=function(a,b){
        if(a.toString().indexOf("debugger")!=-1)
        {
            return null;
        }
        if(a.toString().indexOf("console.log")!=-1)
        {
            return null;
        }
        new_setInterval(a,b);
    }
})();

这样就可以顺利的查看请求地址,发现safe是加密字段

请求

进入断点就可以发现一断aa混淆复制代码破解解决方法

  1. 去掉代码最后一个符号 ('_') 后,放到浏览器里面去直接执行就可以看到源码
  2. 在线调试,在 AAEncode 代码第一行下断点然后一步一步执行最终也会在虚拟机VM里看到源码

请求

结合上下文可以发现aa混淆生成了token,然后又把token赋值给了safe

token = window.localStorage.getItem('token');
request.setRequestHeader("safe", token);

请求

通过控制台可以顺利的打印出加密值

请求

观察加密函数

window.localStorage.setItem('token', window.btoa(a) + ('|') + binb2b64(hex_sha1(window.btoa(core_sha1(a)))) + b64_sha1(a));

这里面

window.btoa(a) -----------> 是函数 btoa
binb2b64(hex_sha1(window.btoa(core_sha1(a)))) -----------> 是函数 core_sha1hex_sha1binb2b64
b64_sha1(a) -----------> 是函数 b64_sha1

进入函数体内

请求

可以看到这段内容jsjiami.com.v6这就是sojson加密

请求

用google插件v_jstools解sojson

请求

最后复制js尝试执行

a = '1678067697';
b64_sha1_a = b64_sha1(a);
console.log(b64_sha1_a);

binb2b64_a = binb2b64(hex_sha1(window.btoa(core_sha1(a))));
console.log(binb2b64_a);

btoa_a = window.btoa(a);
console.log(btoa_a);

发现ReferenceError: window is not defined报错

binb2b64_a = binb2b64(hex_sha1(window.btoa(core_sha1(a))));
ReferenceError: window is not defined

这里需要补一下环境windowwindow.btoa

window = global;
global.Buffer = global.Buffer || require('buffer').Buffer;

if (typeof btoa === 'undefined') {
    global.btoa = function (str) {
        return new Buffer.from(str).toString('base64');
    };
}

if (typeof atob === 'undefined') {
    global.atob = function (b64Encoded) {
        return new Buffer.from(b64Encoded, 'base64').toString();
    };
}

顺利打印出数据

请求