“极简壁纸“爬虫JS逆向·实战

文章目录

  • 声明
  • 目标分析
    • 确定目标
    • 目标检索
  • 代码补全
    • 完整代码
  • 爬虫逻辑
    • 完整代码
  • 运行结果

声明

本教程只用于交流学习,不可用于商业用途,不可对目标网站进行破坏性请求,请遵守相关法律法规。

目标分析

确定目标

  • 获取图片下载链接
    在这里插入图片描述

目标检索

  • 并不能搜索到链接明文数据,说明数据是动态渲染的。
    在这里插入图片描述
  • 查看发包,有一个getData很可疑,返回加密数据
    在这里插入图片描述
  • 添加XHR断点,切换页面触发函数

在这里插入图片描述

  • 一步步走,找到密文数据
    在这里插入图片描述
  • 继续跟,找到明文数据,说明解密函数就在其中

在这里插入图片描述

  • 进一步分析,可以找到解密处,json parse之后就从密文变成了明文,可见,这就是解密函数
    在这里插入图片描述

代码补全

  • 复制加密片段,控制台打印,发现_0x1683d3['a']['decipher']就是 _0x58b5da函数
out_data = JSON['parse'](_0x1683d3['a']['decipher'](_0x16dafc['data']['result']))

在这里插入图片描述

ori_code = 'ak+9VCsq4dEdB+UdVPGo8kh5JDEbMHGTCmF/ACXJQ0IgHk+vVwivRFLre9HkhFPP2wTUOEjYP/pK5AyOXezyjt/nZCxMAPEUpmpIjRo2LZiizd7JG1j6Eh/bWp9BcjXF3RMmA03G2kFG5fHTLseyMdL+FT/KvJGhF1T9bwYE1r0bOiIiyTWi/+R3YxD5AnkRS+l/gAV6hZgJ0vuBLeHPQ4WPcc+pZmk5dO4FmTSTrxie+iq1IXGuR0LHvWxbwPZar2X5AVKHgZB92Osn3qACsyKedSE67kDw9WxFzatw98cEpoLETl194ZxgiCrYehMENSU+TghsmJg4ebP3dvXCZ7eTGHrwb2l7XxuhPuDuGIWqGa9NeQCOUOh2OH1qt+64POe7OpsJhcplb9fMyhagkwu2u3RHfC44Bs0OW0KWu/UFms8RT0pC+jQqhQ2dGuOG45ddbTZKGiOVWXmrYwalKsFPvIL3QJhGZbINGYZIE1O5kGLBHFGbB8MVAbD6FMU6p0+B03AnZ0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XV8iP2D0mhT+7YlXglLbePFPoIChhH09v5TPbTZeQOk6dXkPVG6tqyXp9kpRRGUy1SqLhyBPUBYGXOI08MXyj6XbSLA7rlIPcgmmX+0F9oJPnkw5EueSnHkxW47tivnjkK0r5gKofeVZvDjrat9kUK4ALGSA8y9tyN1aw8XmL1pEQ8SUqjc1QdgRvhgsGAKy73cJYQz3AoptmiauEnU540KY9jJhTPpqd89dtTwseok4oQ8+2RxdQltg7D49EohciYUmz1X+KMQen/Ql/VWUM1Fi3f0hMPNPOk2KR/ZXeNVFG4eG7e2KEYN+Ofn1xM9uJdCGSizXo1FEomyvuBhqzfgzj8KE8mGrdfqm7KapQ6ea1P8s7tmFX6+RUYVYRSvnJ8LPorTYBLZ8QeM6iruhGoVlE+My/jrZY3Sc+gkN6z+OY9GGue8WexeWI5WQhHjAflzfSJFjVJXXfSlLmNs5meNxLZynaQCeSP7ee/r/kOP3OJcMBgVxWklirnQUEqqBHE0fAIo17Z7yuf9na0vJYho7lnxTQAJoBormCVhAJ7k4CrUNtU6k2G/xofL5slSTt7hasGil03Cv5OYDclGq0gBcUwFvAajQbUK'
out_data = JSON['parse'](_0x58b5da(ori_code))
console.log(out_data)
  • 下面就是缺什么补什么,直接搜索加进去就好了

有一点需要注意的是,出现 ReferenceError: window is not defined的情况 ,这是浏览器环境缺失,只要在开头添加一个 var window = global;

  • 成功拿到明文数据
    在这里插入图片描述

完整代码

var window = global;
function _0x3ef903(_0x44e9d9) {for (var _0x39da63, _0x53f955, _0x16f530 = '', _0x134aef = 0x0; _0x134aef < _0x44e9d9['length'];)_0x39da63 = _0x44e9d9[_0x134aef],_0x53f955 = 0x0,_0x39da63 >>> 0x7 === 0x0 ? (_0x16f530 += String['fromCharCode'](_0x44e9d9[_0x134aef]),_0x134aef += 0x1) : 0xfc === (0xfc & _0x39da63) ? (_0x53f955 = (0x3 & _0x44e9d9[_0x134aef]) << 0x1e,_0x53f955 |= (0x3f & _0x44e9d9[_0x134aef + 0x1]) << 0x18,_0x53f955 |= (0x3f & _0x44e9d9[_0x134aef + 0x2]) << 0x12,_0x53f955 |= (0x3f & _0x44e9d9[_0x134aef + 0x3]) << 0xc,_0x53f955 |= (0x3f & _0x44e9d9[_0x134aef + 0x4]) << 0x6,_0x53f955 |= 0x3f & _0x44e9d9[_0x134aef + 0x5],_0x16f530 += String['fromCharCode'](_0x53f955),_0x134aef += 0x6) : 0xf8 === (0xf8 & _0x39da63) ? (_0x53f955 = (0x7 & _0x44e9d9[_0x134aef]) << 0x18,_0x53f955 |= (0x3f & _0x44e9d9[_0x134aef + 0x1]) << 0x12,_0x53f955 |= (0x3f & _0x44e9d9[_0x134aef + 0x2]) << 0xc,_0x53f955 |= (0x3f & _0x44e9d9[_0x134aef + 0x3]) << 0x6,_0x53f955 |= 0x3f & _0x44e9d9[_0x134aef + 0x4],_0x16f530 += String['fromCharCode'](_0x53f955),_0x134aef += 0x5) : 0xf0 === (0xf0 & _0x39da63) ? (_0x53f955 = (0xf & _0x44e9d9[_0x134aef]) << 0x12,_0x53f955 |= (0x3f & _0x44e9d9[_0x134aef + 0x1]) << 0xc,_0x53f955 |= (0x3f & _0x44e9d9[_0x134aef + 0x2]) << 0x6,_0x53f955 |= 0x3f & _0x44e9d9[_0x134aef + 0x3],_0x16f530 += String['fromCharCode'](_0x53f955),_0x134aef += 0x4) : 0xe0 === (0xe0 & _0x39da63) ? (_0x53f955 = (0x1f & _0x44e9d9[_0x134aef]) << 0xc,_0x53f955 |= (0x3f & _0x44e9d9[_0x134aef + 0x1]) << 0x6,_0x53f955 |= 0x3f & _0x44e9d9[_0x134aef + 0x2],_0x16f530 += String['fromCharCode'](_0x53f955),_0x134aef += 0x3) : 0xc0 === (0xc0 & _0x39da63) ? (_0x53f955 = (0x3f & _0x44e9d9[_0x134aef]) << 0x6,_0x53f955 |= 0x3f & _0x44e9d9[_0x134aef + 0x1],_0x16f530 += String['fromCharCode'](_0x53f955),_0x134aef += 0x2) : (_0x16f530 += String['fromCharCode'](_0x44e9d9[_0x134aef]),_0x134aef += 0x1);return _0x16f530;
}function _0x3ed467(_0x58f7d4) {for (var _0x4f1bcd = [-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], _0x39eb66 = 0x0, _0x46445e = 0x0, _0x1360a5 = 0x0, _0x596013 = new Array(), _0x411913 = 0x0; _0x411913 < _0x58f7d4['length']; _0x411913++) {_0x39eb66 = _0x39eb66 + 0x1 & 0xff,_0x46445e = (0xff & _0x4f1bcd[_0x39eb66]) + _0x46445e & 0xff;var _0x5e20d4 = _0x4f1bcd[_0x39eb66];_0x4f1bcd[_0x39eb66] = _0x4f1bcd[_0x46445e],_0x4f1bcd[_0x46445e] = _0x5e20d4,_0x1360a5 = (0xff & _0x4f1bcd[_0x39eb66]) + (0xff & _0x4f1bcd[_0x46445e]) & 0xff,_0x596013['push'](_0x58f7d4[_0x411913] ^ _0x4f1bcd[_0x1360a5]);}return _0x596013;
}
function _0x4207c2(_0x2219f6) {for (var _0x9c7ad4 = window['atob'](_0x2219f6), _0x2dd788 = new Int8Array(_0x9c7ad4['length']), _0x7c7af6 = 0x0; _0x7c7af6 < _0x9c7ad4['length']; _0x7c7af6++)_0x2dd788[_0x7c7af6] = _0x9c7ad4['charCodeAt'](_0x7c7af6);return _0x2dd788;
}
function _0x563330(_0x1e29f9) {return _0x3ef903(_0x3ed467(_0x4207c2(_0x1e29f9)));
}

爬虫逻辑

下面就是编写爬虫的 Python代码逻辑

  • 获取加密数据
  • 调用JS解密
  • 根据解密数据下载壁纸

完整代码

import os
import requests
import execjs
import jsondef fetch_wallpaper_data(page=2, size=24):"""从API获取壁纸数据。"""url = 'https://api.zzzmh.cn/bz/v3/getData'payload = {"size": size,"current": page,"sort": 0,"category": 0,"resolution": 0,"color": 0,"categoryId": 0,"ratio": 0}headers = {'Referer': 'https://bz.zzzmh.cn/','User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36'}response = requests.post(url=url, json=payload, headers=headers)return response.json()['result']def compile_js():"""编译JavaScript代码。"""with open('极简壁纸.js', encoding='utf-8') as file:js_code = file.read()return execjs.compile(js_code)def decode_wallpaper_data(js_compiler, data):"""使用编译的JavaScript代码解码壁纸数据。"""return json.loads(js_compiler.call('_0x563330', data))def download_wallpaper(image_data, headers):"""下载并保存壁纸。"""if not os.path.exists('img'):os.mkdir('img')for wallpaper in image_data['list']:num_suffix = '11' if wallpaper['t'] == 1 else '21'img_id = f"{wallpaper['i']}{num_suffix}"img_url = f'https://api.zzzmh.cn/bz/v3/getUrl/{img_id}'img_content = requests.get(url=img_url, headers=headers).contentwith open(f'img/{wallpaper["i"]}.jpg', mode='wb') as file:file.write(img_content)img_filename = f'img/{wallpaper["i"]}.jpg'print(f'已下载壁纸:{img_filename}')def main():wallpaper_data = fetch_wallpaper_data()js_compiler = compile_js()decoded_data = decode_wallpaper_data(js_compiler, wallpaper_data)headers = {'Referer': 'https://bz.zzzmh.cn/','User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36'}download_wallpaper(decoded_data, headers)if __name__ == '__main__':main()

运行结果

在这里插入图片描述

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/456254.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【多模态大模型】视觉大模型SAM:如何使模型能够处理任意图像的分割任务?

SAM&#xff1a;如何使模型能够处理任意图像的分割任务&#xff1f; 核心思想起始问题: 如何使模型能够处理任意图像的分割任务&#xff1f;5why分析5so分析 总结子问题1: 如何编码输入图像以适应分割任务&#xff1f;子问题2: 如何处理各种形式的分割提示&#xff1f;子问题3:…

创新方案|经济下行周期下企业避免杀价内卷侵蚀利润亟需5种创新定价策略

随着通胀持续、全球经济衰退逆风让消费者谨慎支出&#xff0c;绝大多数企业都担心如何刺激购买且保持利润率。在本研究认为&#xff0c;公司不应该简单地调整价格&#xff0c;而应该创造性地借鉴其他行业定价打法&#xff0c;通过创新定价选项的组合&#xff0c;增加向客户计价…

【Web】小白也能看懂的BeginCTF个人wp(全)

纯萌新&#xff0c;贴出自己的wp&#xff0c;一起交流学习QWQ 目录 zupload zupload-pro zupload-pro-plus zupload-pro-plus-max zupload-pro-plus-max-ultra zupload-pro-plus-max-ultra-premium zupload-pro-revenge zupload-pro-plus-enhanced POPgadget sql教…

计算机设计大赛 深度学习+python+opencv实现动物识别 - 图像识别

文章目录 0 前言1 课题背景2 实现效果3 卷积神经网络3.1卷积层3.2 池化层3.3 激活函数&#xff1a;3.4 全连接层3.5 使用tensorflow中keras模块实现卷积神经网络 4 inception_v3网络5 最后 0 前言 &#x1f525; 优质竞赛项目系列&#xff0c;今天要分享的是 &#x1f6a9; *…

Go 中如何检查文件是否存在?可能产生竞态条件?

嗨&#xff0c;大家好&#xff01;本文是系列文章 Go 技巧第十三篇&#xff0c;系列文章查看&#xff1a;Go 语言技巧。 Go 中如何检查文件是否存在呢&#xff1f; 如果你用的是 Python&#xff0c;可通过标准库中 os.path.exists 函数实现。遗憾的是&#xff0c;Go 标准库没有…

打包 iOS 的 IPA 文件

目录 摘要 引言 准备 选择证书类型 创建应用程序 设置应用程序标识和证书 配置构建设置 构建应用程序 导出IPA 签名和导出 代码案例演示 完成 总结 参考资料 摘要 本篇博客将为您介绍如何打包iOS的IPA文件。从APP提交、创建应用程序、设置应用程序标识和证书、配…

23、数据结构/查找相关练习20240205

一、请编程实现哈希表的创建存储数组{12,24,234,234,23,234,23},输入key查找的值&#xff0c;实现查找功能。 代码&#xff1a; #include<stdlib.h> #include<string.h> #include<stdio.h> #include<math.h> typedef struct Node {int data;struct n…

【openwrt】MT7981 5G WiFi MAC地址不生效问题分析及解决方案

问题描述 MT7981 默认sdk 5G MAC地址根据2.4G MAC地址随机生成,我们写到Factory区域的值不生效 问题分析 查看EEPROM MAC位置 查看MTK EEPROM文档MT7981_EEPROM_Content_Introduction_V10_20211207.pdf可以看到EEPROM里面有两个位置可以存放MAC,0x04~0x09 和0x0a~0x0f 查看…

【Ftp客户端】FTPBox starter

Github&#xff1a; https://github.com/lihewei7/ftpbox-spring-boot-starterGitee&#xff1a; https://gitee.com/lihewei7/ftpbox-spring-boot-starter 文章目录 FTPBox是什么&#xff1f;Maven依赖使用APIuploaddownloadexistslistexecuteexecuteWithoutResult 配置单主机…

jquery写表格,通过后端传值,并合并单元格

<!DOCTYPE html> <html> <head><title>Table Using jQuery</title><style>#tableWrapper {width: 100%;height: 200px; /* 设置表格容器的高度 */overflow: auto; /* 添加滚动条 */margin-top: -10px; /* 负的外边距值&#xff0c;根据实际…

基于SSM的便民自行车管理系统的开发与实现(有报告)。Javaee项目。ssm项目。

演示视频&#xff1a; 基于SSM的便民自行车管理系统的开发与实现&#xff08;有报告&#xff09;。Javaee项目。ssm项目。 项目介绍&#xff1a; 采用M&#xff08;model&#xff09;V&#xff08;view&#xff09;C&#xff08;controller&#xff09;三层体系结构&#xff0…

mac检查CPU温度和风扇速度软件:Macs Fan Control Pro 1.5.17中文版

Macs Fan Control Pro for Mac是一款专业的电脑风扇控制工具&#xff0c;旨在帮助Mac用户有效控制电脑的风扇速度&#xff0c;提高电脑的运行效率和稳定性。 软件下载&#xff1a;Macs Fan Control Pro 1.5.17中文版 该软件支持多种风扇控制模式和预设方案&#xff0c;用户可以…