JavaScript

JS解密:处理 jQuery 代码混淆破解中国空气质量在线网站

2020-06-25  本文已影响0人  dex0423

1. 前言

2. 分析

image.png image.png image.png image.png image.png

3. 反混淆

image.png
function getServerData(method, object, callback, period) {
        const key = hex_md5(method + JSON.stringify(object));
        const data = getDataFromLocalStorage(key, period);
        if (!data) {
            var param = getParam(method, object);   //这段代码就是获取参数的代码
            $.ajax({
                url: '../apinew/aqistudyapi.php',
                data: {
                    d: param
                },
                type: "post",
                success: function (data) {
                    data = decodeData(data);
                    obj = JSON.parse(data);
                    if (obj.success) {
                        if (period > 0) {
                            obj.result.time = new Date().getTime();
                            localStorageUtil.save(key, obj.result)
                        }
                        callback(obj.result)
                    } else {
                        console.log(obj.errcode, obj.errmsg)
                    }
                }
            })
        } else {
            callback(data)
        }
    }
function getPostParamCode (method, city, type, startTime, endTime){
    var param = {};
    param.city = city;
    param.type = type;
    param.startTime = startTime;
    param.endTime = endTime;
    return getParam(method, param);
    }
import execjs

# Params
method = 'GETDETAIL'
city = '北京'
type = 'HOUR'
start_time = '2018-01-25 00:00:00'
end_time = '2018-01-25 23:00:00'

# Compile javascript
file = 'aqi.js'
ctx = execjs.compile(open(file=file, encoding='utf-8').read())

# js = 'getPostParamCode("{}", "{}", "{}", "{}", "{}")'.format(method, city, type, start_time, end_time)
# params = ctx.call('getPostParamCode', method, city, type, start_time, end_time)
# print(params)

#发起post请求
url = 'https://www.aqistudy.cn/apinew/aqistudyapi.php'
response_text = requests.post(url, data={'d': params}).text
print(response_text)
上一篇 下一篇

猜你喜欢

热点阅读