为了防止这个网站被各位爬崩,我连夜用Python下载了上万张壁纸(附网站JS逆向解密)

每当一个网站崩溃,在座的各位都有一定的责任。


当一个爬虫教程不火的时候还好,火起来了,就到了考验网站服务器的时候了,上一次茶杯狐就是这样,还好人家顽强…

 

好了话不多说,直接开始。

首先就是必备的软件和模块

环境使用

Python 3.8
Pycharm

 

模块使用

requests --> pip install requests
execjs --> pip install PyExecJS
json

 

前两个是第三方模块,要手动安装一下,键盘按住win + R 输入cmd 输入安装命令 pip install 模块名 (如果你觉得安装速度比较慢, 你可以切换国内镜像源)

代码部分

获取加密数据

# 请求头
headers = {
    'Referer':'https://bz.zzzmh.cn/',
    'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36'
}
# 请求链接
url = 'https://api.zzzmh.cn/bz/v3/getData'
for page in range(1, 11):
    # 请求参数
    data = {
        "size":24,
        "current":page,
        "sort":0,
        "category":0,
        "resolution":0,
        "color":0,
        "categoryId":0,"ratio":0
    }
    # 发送请求
    response = requests.post(url=url, json=data, headers=headers)
    # 获取响应json数据
    json_data = response.json()
    # 解析数据, 提取加密数据内容
    # 我还录制了详细的视频讲解,跟源码一起打包好了
    # 都放在这个抠裙了 872937351
    result = json_data['result']

 

通过python代码调用js代码获取明文数据

# 读取js代码文件
f = open('壁纸.js', 'r', encoding='utf-8').read()
# 编译js文件内容
js_code = execjs.compile(f)
# 调用js代码函数 --> 函数名传入字符串
data = js_code.call('_0xc7dd1', result)
# json字符串数据转成json字典数据
info = json.loads(data)
# 解析数据, 提取图片ID
for index in info['list']:
    # 提取图片ID
    img_id = index['i']
    # 图片链接: https://api.zzzmh.cn/bz/v3/getUrl/61ac5e440dac4d97a6624e05044c407421
    t = index['t']
    if t == 2:
        img_url = f'https://api.zzzmh.cn/bz/v3/getUrl/{img_id}21'
    elif t == 1:
        img_url = f'https://api.zzzmh.cn/bz/v3/getUrl/{img_id}11'
    # 获取图片数据内容
    img_content = requests.get(url=img_url, headers=headers).content
    with open(f'img\\{img_id}.jpg', mode='wb') as img:
        img.write(img_content)
    print(img_url)

 

JS逆向部分

var window = global;
 
function _0x4e58da(_0x3d1ba4) {
    let _0x481fd7, _0x1af3a1, _0x7ac69c = '';
    for (var _0x1074ee = 0x0; _0x1074ee < _0x3d1ba4['length'];)
        _0x481fd7 = _0x3d1ba4[_0x1074ee],
            _0x1af3a1 = 0x0,
            _0x481fd7 >>> 0x7 === 0x0 ? (_0x7ac69c += String['fromCharCode'](_0x3d1ba4[_0x1074ee]),
                _0x1074ee += 0x1) : 0xfc === (0xfc & _0x481fd7) ? (_0x1af3a1 = (0x3 & _0x3d1ba4[_0x1074ee]) << 0x1e,
                _0x1af3a1 |= (0x3f & _0x3d1ba4[_0x1074ee + 0x1]) << 0x18,
                _0x1af3a1 |= (0x3f & _0x3d1ba4[_0x1074ee + 0x2]) << 0x12,
                _0x1af3a1 |= (0x3f & _0x3d1ba4[_0x1074ee + 0x3]) << 0xc,
                _0x1af3a1 |= (0x3f & _0x3d1ba4[_0x1074ee + 0x4]) << 0x6,
                _0x1af3a1 |= 0x3f & _0x3d1ba4[_0x1074ee + 0x5],
                _0x7ac69c += String['fromCharCode'](_0x1af3a1),
                _0x1074ee += 0x6) : 0xf8 === (0xf8 & _0x481fd7) ? (_0x1af3a1 = (0x7 & _0x3d1ba4[_0x1074ee]) << 0x18,
                _0x1af3a1 |= (0x3f & _0x3d1ba4[_0x1074ee + 0x1]) << 0x12,
                _0x1af3a1 |= (0x3f & _0x3d1ba4[_0x1074ee + 0x2]) << 0xc,
                _0x1af3a1 |= (0x3f & _0x3d1ba4[_0x1074ee + 0x3]) << 0x6,
                _0x1af3a1 |= 0x3f & _0x3d1ba4[_0x1074ee + 0x4],
                _0x7ac69c += String['fromCharCode'](_0x1af3a1),
                _0x1074ee += 0x5) : 0xf0 === (0xf0 & _0x481fd7) ? (_0x1af3a1 = (0xf & _0x3d1ba4[_0x1074ee]) << 0x12,
                _0x1af3a1 |= (0x3f & _0x3d1ba4[_0x1074ee + 0x1]) << 0xc,
                _0x1af3a1 |= (0x3f & _0x3d1ba4[_0x1074ee + 0x2]) << 0x6,
                _0x1af3a1 |= 0x3f & _0x3d1ba4[_0x1074ee + 0x3],
                _0x7ac69c += String['fromCharCode'](_0x1af3a1),
                _0x1074ee += 0x4) : 0xe0 === (0xe0 & _0x481fd7) ? (_0x1af3a1 = (0x1f & _0x3d1ba4[_0x1074ee]) << 0xc,
                _0x1af3a1 |= (0x3f & _0x3d1ba4[_0x1074ee + 0x1]) << 0x6,
                _0x1af3a1 |= 0x3f & _0x3d1ba4[_0x1074ee + 0x2],
                _0x7ac69c += String['fromCharCode'](_0x1af3a1),
                _0x1074ee += 0x3) : 0xc0 === (0xc0 & _0x481fd7) ? (_0x1af3a1 = (0x3f & _0x3d1ba4[_0x1074ee]) << 0x6,
                _0x1af3a1 |= 0x3f & _0x3d1ba4[_0x1074ee + 0x1],
                _0x7ac69c += String['fromCharCode'](_0x1af3a1),
                _0x1074ee += 0x2) : (_0x7ac69c += String['fromCharCode'](_0x3d1ba4[_0x1074ee]),
                _0x1074ee += 0x1);
    return _0x7ac69c;
}
 
function _0x3b44b8(_0x4f208f) {
    let _0x238f61 = [-0x6f, 0x34, 0x5b, 0x41, -0x41, 0x74, 0x77, 0x6a, -0x79, -0x52, -0x5, 0x50, 0x33, 0x61, 0x44, -0x53, -0x70, -0x33, 0x17, -0x2e, -0x22, -0x72, -0x37, -0xb, -0x7f, 0x5a, 0x21, 0x16, -0x1f, 0x32, -0x11, 0x14, -0x2c, 0xf, -0x5e, -0x7b, 0x76, -0x17, -0x3d, 0x72, 0x47, -0x68, -0x7e, -0x75, -0x51, -0x36, -0x12, -0x6e, -0x4, -0x5f, -0x5b, 0x5e, -0x50, -0xe, 0x78, 0x69, 0x55, 0x68, -0x56, -0x6c, 0x43, 0x19, 0x65, 0x6c, 0x10, -0x69, 0x6f, -0xa, 0x75, -0x49, 0x4d, 0x59, -0x1d, -0x62, -0x44, 0x70, 0x6b, -0x1, 0x56, 0x79, 0x58, -0x65, -0x7c, 0x45, -0x1e, -0x8, -0x71, -0x4a, -0x76, 0x39, -0x19, 0xc, -0x73, -0x6a, 0x5f, 0x7f, 0x54, 0x7c, -0x66, -0x1c, 0x49, 0x2b, -0x3c, 0x1c, 0x2e, 0x73, 0x1e, 0x7a, -0x4b, 0x7d, -0x43, -0x4d, 0x3, -0x7, -0x35, -0xd, 0x35, 0x4e, -0x48, 0x1, 0xb, -0x47, -0x27, -0x4f, -0x3, 0x13, 0x29, 0x7e, -0x2b, -0x7d, -0x1b, 0x22, 0x3f, 0x8, 0x48, -0x23, -0x29, -0x3f, 0x3c, -0x18, 0x66, 0x2f, -0x77, -0x67, -0x16, 0x2d, 0x3b, 0x40, -0x60, 0x31, 0x53, -0x6b, -0x78, -0x39, -0x46, 0x0, -0x26, -0x54, -0x28, 0x18, 0xe, 0x30, 0x1d, 0x2c, -0x24, -0x2f, 0x38, -0x5c, 0x26, 0x25, 0x4, -0x32, 0x67, 0xa, -0x59, 0x37, 0x71, -0x1a, 0x6e, 0x36, 0x24, -0x14, -0x4e, -0xc, -0x74, 0x46, -0x25, 0x5, -0x3e, -0x4c, -0x30, -0x40, 0x4f, 0x64, 0x28, 0x6, -0x3a, -0x5a, -0x13, -0x9, 0x27, 0x5d, -0x63, 0x15, 0x7, 0x1a, -0x2, 0x1b, -0x2d, 0x51, 0x3a, -0x7a, 0x4c, -0x42, 0x2, 0x5c, -0x2a, 0x62, -0x10, 0x9, 0x3d, 0x3e, -0xf, 0x63, -0x15, 0x1f, -0x38, 0x57, 0x11, -0x34, -0x45, -0x21, -0x3b, -0x55, 0x42, 0x4a, 0x12, -0x5d, -0x80, -0x57, -0x20, 0x2a, 0x20, -0x58, 0x6d, 0x60, 0xd, -0x6, 0x4b, -0x64, -0x31, 0x23, -0x61, 0x52, -0x6d, 0x7b]
        , _0x50bcf2 = 0x0
        , _0x1d05b1 = 0x0
        , _0x53f98c = 0x0
        , _0x14fbfd = new Array();
    for (let _0x3fc84b = 0x0; _0x3fc84b < _0x4f208f['length']; _0x3fc84b++) {
        _0x50bcf2 = _0x50bcf2 + 0x1 & 0xff,
            _0x1d05b1 = (0xff & _0x238f61[_0x50bcf2]) + _0x1d05b1 & 0xff;
        const _0x1d2346 = _0x238f61[_0x50bcf2];
        _0x238f61[_0x50bcf2] = _0x238f61[_0x1d05b1],
            _0x238f61[_0x1d05b1] = _0x1d2346,
            _0x53f98c = (0xff & _0x238f61[_0x50bcf2]) + (0xff & _0x238f61[_0x1d05b1]) & 0xff,
            _0x14fbfd['push'](_0x4f208f[_0x3fc84b] ^ _0x238f61[_0x53f98c]);
    }
    return _0x14fbfd;
}
 
function _0x1fa292(_0x4f3d95) {
    const _0x4c382b = window['atob'](_0x4f3d95)
        , _0x177f05 = new Int8Array(_0x4c382b['length']);
    for (let _0x293dd4 = 0x0; _0x293dd4 < _0x4c382b['length']; _0x293dd4++)
        _0x177f05[_0x293dd4] = _0x4c382b['charCodeAt'](_0x293dd4);
    return _0x177f05;
}
 
function _0xc7dd1(_0x5e36f6) {
    return _0x4e58da(_0x3b44b8(_0x1fa292(_0x5e36f6)));
}
 
// 复制一段JS代码, 100%会报错
data = 'ak+9VCsq4dEdB+UdVfGo8kh5JDEbMHGTCmF/AyXJQ0IgHk+nVAivRFLre97uhVPP2wTUOBnZbv5IuV3YW+bwj9+zZH1PAv9Or2kY0RpnIZr4lt+bG1j6Eh/bWp9BcjXF3RMjC0vP2kFG5fHQKseyMdL+FT/KupHyRVatagYMiuxNP3d+nDairLInNhH7UX9BGrgs1gN6hZgJ0vuBLeHPQ4WPcc6hZmE5dO4FmTeUoRye+iq1IXGqQRLD7mFdlfQPomT5BlSK28AoibAgjaoF6HbNf3oz7UDw9WxFzatw98cEpoLETFx74ZxgiCrYeRIFPCU+TghsmJ01erL2IPbCYeXARHrxOmohXx6hbLrqGdX8GaUeKwrRUOh2OH1qt+64POe7OpsIhcZl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OadQkBhk00AAyXT/YtA8Su8+tW1UltdqltFzRKNZ6qWcVnZqxOBVzdZsEFUwVDMtR0Cc9CQljGJyfnF3ZIaNLAFI5I2nGte35JUtFJ34touAJKQ+ISc2mB6JwPutvpLXV8iP2D0mhT+b8kWwlLbePFPoQPgBH09v5TPbjdLgKl7tG5bAS146yQ8NFxSkTHzgX6LEuGORNWGCDU08MXyj6XbSLA7rlIPcgvlH2xF9oJPnk15EOWSnHkxW4753203Efkrstb8/CcZvTprfN2wRW4A+DGVM27snYnbV8XmL1pEQ8SUqjc1QdgRvphtmAKy73cJYcy0goptmiauEnU4dhaMInMgDPmrY44dtSnseUk5dc5/GF0Ilhn1OH6okohciYUmz1X+KMQen/QlfRQUM1Fi3f0h8LDPOk2KR/ZXbgOEGgXTOO5cUoOqeLjhklmucJHRS+2Dd5CEoi1ueBjqzfgzj8KE8mGrdfqm7KapQ6ea1P8s7tmFHO8RUYVYRSvzM1YYozQbBaP9Qbd6nDvgzBBmkyLmqLtY4PWK7wkbfn+OY9GGue8WexeWI5WQhHjAflzfSJFjVJWU/KlLmNs5mffl+YmzaZUf3mhLOnu/hOM37ENYE8VxT92iLiDBBz/VXE0fAIo17Z7yuf9na0vJIBh4130SwAJoBormCVhAJ7k4CrUNtU6k2G/xofL5slSTt7hasGil03Cv5OYDclGq0gBcUwFvAajQbUK'
console.log(_0xc7dd1(data))

 

好了,今天的分享就到这里结束了,咱们下次见。

热门相关:我真没想重生啊   宴先生缠得要命   我家影后超甜的   茅山神婿   萌宝来袭:总裁爹地,宠上天