惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Microsoft Azure Blog
Microsoft Azure Blog
大猫的无限游戏
大猫的无限游戏
月光博客
月光博客
V
V2EX
PCI Perspectives
PCI Perspectives
Latest news
Latest news
博客园 - 三生石上(FineUI控件)
C
CERT Recently Published Vulnerability Notes
W
WeLiveSecurity
Last Week in AI
Last Week in AI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
P
Palo Alto Networks Blog
T
The Exploit Database - CXSecurity.com
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
WordPress大学
WordPress大学
V
Vulnerabilities – Threatpost
H
Heimdal Security Blog
Attack and Defense Labs
Attack and Defense Labs
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Hacker News: Ask HN
Hacker News: Ask HN
博客园 - 叶小钗
V
Visual Studio Blog
Jina AI
Jina AI
P
Proofpoint News Feed
罗磊的独立博客
SecWiki News
SecWiki News
J
Java Code Geeks
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
L
LINUX DO - 热门话题
Security Archives - TechRepublic
Security Archives - TechRepublic
The Hacker News
The Hacker News
Hugging Face - Blog
Hugging Face - Blog
N
News and Events Feed by Topic
NISL@THU
NISL@THU
T
Tailwind CSS Blog
T
Tenable Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Recent Announcements
Recent Announcements
H
Hacker News: Front Page
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
T
Tor Project blog
宝玉的分享
宝玉的分享
Help Net Security
Help Net Security
S
Security Affairs
Microsoft Security Blog
Microsoft Security Blog
Google DeepMind News
Google DeepMind News
F
Fortinet All Blogs
G
GRAHAM CLULEY

Mereith's Blog

记一次代理转发问题的排查与解决 PVE DataCenter Manager 端口号跳转错误修复 k8s + jenkins + gitlab 触发器 【转载】没有编程生产力这样的东西 【后续】居然被 ddos 了 居然被 ddos 了 Tagger - 让版本标签管理更简单 openclash 开启后端口转发失效 nextjs 启动时执行代码 买了太多VPS不知道干什么,干脆做个网站 juhost Level-1 测评 VMISS CN - Hong Kong VMISS JP - Tokyo - BGP 测评 VMISS CN - Hong Kong - BGP HomeLab 的终点是 最近在做的事情 因为选择艰难症,自己写了一套开源博客系统 手撸一个nodejs分布式爬虫,还要可视化 HomeLab 分享 我的个人工作流——开源项目推荐 动手写一个超简单的编译器 safari 插件开发 Safari Extensions Preferences 按钮无响应 设置移动端软键盘回车按钮文案 nginx proxy manager 非标准端口反代 Host 不对 监控 k8s ingress 自动添加域名 DNS 解析 使用 ingress 注解给 traefik ingress 添加中间件 使用流水线功能为文章添加固定结尾 为 VanBlog 添加一个小挂件 基于React/umi/egg自建博客系统 如何正确停止 NodeJS 子进程 k8s pod 替换策略 让威联通、pve 共享 ups 实现断电关机 Ubuntu 配置 samba 混合云部署k3s集群(基于wireguard) pve 无法启动 grub lvmid not found error antd Password 关闭自动补全 code-server node not found pve no quorum 错误 || 无法登录 pve Cannot Initiate CMAP Service pve 节点删不干净 PVE 指针(鼠标)漂移 pve 重启网络 Proxmox VE 直通显卡 ProxmoxVE (PVE) 7.0 换源升级 用 SOCAT 端口转发 git 无法 pull 仓库refusing to merge unrelated histories 用 vuepress 搭建私人知识库 js 防抖节流中的 this 与箭头函数 Dockerfile 给 Ubuntu 换源 docker 内访问宿主机 docker 删除无用镜像 css 实现展开收起动画 nginx 301 问题 Node.js 流式编程 关于我重写了三次博客项目这件事 css flex 布局超出隐藏 css 隐藏滚动条 css 文字超出隐藏并显示省略号 css 填充 svg 颜色 css 黑白滤镜 nginx 反代丢端口 docker-compose 部署 matomo 分析系统 基于 strapi 开发应用 strapi 关闭 Content Security Policy nginx 反代 rewite url ssh 通过跳板机访问目标机器 Cent os 7 安装 zsh 5.6 以上版本 win11 任务栏不合并 bash 数组操作 vim 修改文件格式为 unix k8s 集群 control-plane-endpoint 主机名 git https 保存密码 Bash 判断命令存在 & 重定向 python 导出项目依赖 cent os 7 安装 gcc 版本 9 System limit for number of file watchers reached cent os 7 安装 git 2.x css 下划线中间向两边滑动效果 linux 挂载 SMB/CIFS linux 清除 ACL windows 命令行安装 inf 驱动 css 文字不可选择 iperf3 网络测速工具 cent os 换源 k8s 1.21.3 从 docker 迁移到 containerd 解决Nginx安装错误:No package nginx available 问题 从pve的硬盘里导出数据 Errors were encountered while processing adguardhome配合clash pve中使用LXC容器安装OMV LXC直通硬盘 nginx反代模版 docker常用开启容器的命令 PVE的LXC容器中安装Docker ProxmoxVE系统分区相关 基于clash搭建旁路网关 Portainer添加节点 linux声卡设置及录音音 OpenWrt用VLAN PVE换源及去掉订阅提示和改端口
python提前捕捉头脑王者2答案
wanglu@mereith.com (mereith) · 2023-02-17 · via Mereith's Blog

请注意,本文编写于 2025 天前,最后修改于 1204 天前,其中某些信息可能已经过时。

最近和女票玩头脑王者2打发时间,因为比较菜被鄙视了,就想着如何才能用技术来搜索答案。经过查阅资料发现,头脑王者2通过WebSocket通信中会在题目出现前直接发送客户端答案和题目,所以我们只要通过监控数据包提取数据就可以提前知道答案了。

mitmproxy抓包工具

mitmproxy是一个支持HTTP和HTTPS的抓包程序,有类似Fiddler、Charles的功能,并且可以通过python调用来编程实现特定的功能,非常好用。

使用方法参考:App爬虫神器mitmproxy和mitmdump的使用

注意:在电脑上可能因为是本机,在我的win10系统上抓取微信pc客户端小程序的WebSocket通讯失败了,经过测试,在ios系统上添加证书可以正常抓取https,wss等数据,在android系统上,无论是否大于7.0,添加根证书root信任之后也没法正确抓取wss但是https可以,而网上流传的用老版本微信因为微信会提示更新用不了所以也无法使用了,最后只能用我的ios14iphone11抓包。

原理

  1. mitmweb抓取微信小程序的数据流
  2. 分析判断数据流,抓取需要的题目和答案数据
  3. 输出到屏幕上并调用win10的语音朗读读出答案

代码实现

环境

python3.8 mitmproxy (我用pip安装的) msgpack (用来解码序列数据) win32com (调用朗读人)

运行方式

mitmweb --set http2=false -s run.py # 为了抓取成功避免错误需要加上http2=false参数

运行效果

另外一说这个游戏会给你匹配电脑来玩,到最后冲榜一的时候,和我一起的小伙伴根本就没在玩,电脑虚拟了它的数据变成了我的队友,这种情况还有很多,我就觉得不可能玩家啥时候都能匹配到啊,所以这个游戏随便玩玩就好了,不要太认真,非要冲榜请写个自动化操作的,不要自己肝,不值得

代码

from mitmproxy import ctx import mitmproxy.websocket import msgpack import gzip import win32com.client import asyncio games = 0 class ShowAnswers: games = 0 async def say(self,texts): speaker.Speak(texts) def websocket_message(self, flow: mitmproxy.websocket.WebSocketFlow): ctx.log.warn("收到了wss信息。") message = flow.messages[-1] content = message.content if content !=b'\x00'and len(str(content)) >= 10: #排除空的或者无法识别的信息 content = gzip.decompress(content) msg = msgpack.loads(content) try: body = msgpack.loads(msg['body'],strict_map_key=False) msg['body'] = body except: pass #解压读取信息 cmd = msg['cmd'] if cmd == 'Resp_Sync': #处理信息 self.deal_resp_sync(msg) if cmd == "Push_MatchStared": #speaker.Speak("比赛开始啦,么么哒") self.games = self.games +1 def deal_resp_sync(self,msg): body = msg['body'] try: battleInfo = body['battleInfo'] if 'className' in str(battleInfo) and 'province' not in str(battleInfo): #找到正确的包含答案的信息 quizMap = battleInfo['quizMap'] for num,data in quizMap.items(): #获得题目编号和数据 quiz=data['quiz'] className = data['className'] categoryName = data['categoryName'] answers = {} for index in data['answers']: answers[index+1] = data['options'][index] #把答案序号存入answers字典 ctx.log.warn("{}.{}: {}".format(className,categoryName,quiz)) the_answer = "" for index,op in answers.items(): ctx.log.warn("[{}] {}".format(index,op)) the_answer = the_answer+str(index)+'、' #遍历answers字典输出答案 asyncio.get_event_loop().create_task(self.say("第"+the_answer[0:-1]+"个")) ctx.log.info("\n\n") except: pass speaker = win32com.client.Dispatch("SAPI.SpVoice") addons = [ShowAnswers()]