当前位置:   article > 正文

原神抢码,米游社抢码-首发_原神抢码辅助器

原神抢码辅助器

本文章仅供学习使用-侵权请联系删除_2023年3月14日08:17:06

本来在深渊12层打不过的我偶然在刷到了一个dy的直播间,看到主播在抢码上号帮忙打深渊还号称痛苦号打不满不送原石的旗号我就决定扫码试试,在直播间内使用了两部手机互相扫码在扫了一下午的码后发现根本抢不到二维码心态崩溃后我就想着写一个脚本来帮我抢码(本人py小白),终于在又白忙活了一下的后终于决定抱着学习的态度写一个程序来帮我进行抢码的操作!

原理讲解

  1. 进行屏幕区域的截图(用来获取二维码)

  1. 将获取到的二维码进行解析

  1. 将解析后的内容截取出ticket

  1. 最后发送给米哈游的服务器

在抢码登陆中一共分为两步

第一步抢码

第二步登陆

哈哈听起来像废话,我们首先会进行二维码扫码的认主,先确定这个二维码的主人是谁只要确认好这个主人后就算等待几分钟再确认登陆也没有问题。

  1. # 抢码开始
  2. def Request(ticket):
  3. conn = http.client.HTTPSConnection("api-sdk.mihoyo.com")
  4. payload = json.dumps({
  5. "app_id": 4,
  6. "device": "",
  7. "ticket": ticket
  8. })
  9. headers = {}
  10. conn.request("POST", "/hk4e_cn/combo/panda/qrcode/scan", payload, headers)
  11. res = conn.getresponse()
  12. data = res.read()
  13. data = json.loads(data.decode("utf-8"))
  14. retcode = data["retcode"]
  15. return retcode

我们先进行二维码的认主 ticket这个参数为二维码解析后的参数自行获取

  1. # 确认登陆
  2. def ConfirmRequest(ticket):
  3. conn = http.client.HTTPSConnection("api-takumi.miyoushe.com")
  4. payload = ''
  5. headers = {
  6. 'DS': '',
  7. 'cookie': '',
  8. 'x-rpc-client_type': '',
  9. 'x-rpc-app_version': '',
  10. 'x-rpc-sys_version': '',
  11. 'x-rpc-channel': '',
  12. 'x-rpc-device_id': '',
  13. 'x-rpc-device_fp': '',
  14. 'x-rpc-device_name': '',
  15. 'x-rpc-device_model': '',
  16. 'Referer': ' https://app.mihoyo.co'
  17. }
  18. conn.request("GET", "/auth/api/getGameToken?uid=0000000",
  19. payload, headers)
  20. res = conn.getresponse()
  21. data = res.read()
  22. # print(data.decode("utf-8"))
  23. data = json.loads(data.decode("utf-8"))
  24. token = data["data"]["game_token"]
  25. conn = http.client.HTTPSConnection("api-sdk.mihoyo.com")
  26. payload = json.dumps({
  27. "app_id": 4,
  28. "device": "",
  29. "payload": {
  30. "proto": "Account",
  31. "raw": f"{{\"uid\":\"0000000\",\"token\":\"{token}\"}}"
  32. },
  33. "ticket": ticket
  34. })
  35. headers = {
  36. 'DS': '',
  37. 'cookie': '',
  38. 'x-rpc-client_type': '',
  39. 'x-rpc-app_version': '',
  40. 'x-rpc-sys_version': '',
  41. 'x-rpc-channel': 'xiaomi',
  42. 'x-rpc-device_id': '',
  43. 'x-rpc-device_fp': '',
  44. 'x-rpc-device_name': '',
  45. 'x-rpc-device_model': '',
  46. 'Referer': ' https://app.mihoyo.com',
  47. 'Content-Type': 'application/json'
  48. }
  49. conn.request("POST", "/hk4e_cn/combo/panda/qrcode/confirm",
  50. payload, headers)
  51. res = conn.getresponse()

然后再进行二维码的确认来进行游戏内的确认登陆

启动后会在 屏幕中间显示一个300x300像素的框放入二维码后直接扫码登陆

由于自己学习就不做成品和优化了

好了废话不多说了这里只提供思路参数在米游社扫码时抓包即可获取,有需要的自行阅读吧

  1. import cv2
  2. from pyzbar.pyzbar import decode
  3. import pyzbar.pyzbar as pyzbar
  4. import numpy as np
  5. from PIL import ImageGrab
  6. import time
  7. import tkinter as tk
  8. import threading
  9. import re
  10. import http.client
  11. import json
  12. # 显示框框 启动线程
  13. def my_function():
  14. import juxing
  15. my_thread = threading.Thread(target=my_function)
  16. my_thread.start()
  17. # 获取坐标
  18. root = tk.Tk()
  19. win_width = 300
  20. win_height = 300
  21. screen_width = root.winfo_screenwidth()
  22. screen_height = root.winfo_screenheight()
  23. x_pos = (screen_width // 2) - (win_width // 2)
  24. y_pos = (screen_height // 2) - (win_height // 2)
  25. # 设置扫描区域左上角的坐标和宽高
  26. left, top, width, height = x_pos, y_pos, win_width, win_height
  27. right = left + width
  28. bottom = top + height
  29. # 创建窗口并设置窗口名称
  30. cv2.namedWindow("QR Code Scanner", cv2.WINDOW_NORMAL)
  31. cv2.resizeWindow("QR Code Scanner", win_width, win_height)
  32. # 抢码开始
  33. def Request(ticket):
  34. conn = http.client.HTTPSConnection("api-sdk.mihoyo.com")
  35. payload = json.dumps({
  36. "app_id": 4,
  37. "device": "",
  38. "ticket": ticket
  39. })
  40. headers = {}
  41. conn.request("POST", "/hk4e_cn/combo/panda/qrcode/scan", payload, headers)
  42. res = conn.getresponse()
  43. data = res.read()
  44. data = json.loads(data.decode("utf-8"))
  45. retcode = data["retcode"]
  46. return retcode
  47. # 确认登陆
  48. def ConfirmRequest(ticket):
  49. conn = http.client.HTTPSConnection("api-takumi.miyoushe.com")
  50. payload = ''
  51. headers = {
  52. 'DS': '',
  53. 'cookie': '',
  54. 'x-rpc-client_type': '2',
  55. 'x-rpc-app_version': '2.46.1',
  56. 'x-rpc-sys_version': '9',
  57. 'x-rpc-channel': '',
  58. 'x-rpc-device_id': '',
  59. 'x-rpc-device_fp': '',
  60. 'x-rpc-device_name': '',
  61. 'x-rpc-device_model': '',
  62. 'Referer': ' https://app.mihoyo.co'
  63. }
  64. conn.request("GET", "/auth/api/getGameToken?uid=0000000",
  65. payload, headers)
  66. res = conn.getresponse()
  67. data = res.read()
  68. # print(data.decode("utf-8"))
  69. data = json.loads(data.decode("utf-8"))
  70. token = data["data"]["game_token"]
  71. conn = http.client.HTTPSConnection("api-sdk.mihoyo.com")
  72. payload = json.dumps({
  73. "app_id": 4,
  74. "device": "",
  75. "payload": {
  76. "proto": "Account",
  77. "raw": f"{{\"uid\":\"0000000\",\"token\":\"{token}\"}}"
  78. },
  79. "ticket": ticket
  80. })
  81. headers = {
  82. 'DS': '',
  83. 'cookie': '',
  84. 'x-rpc-client_type': '2',
  85. 'x-rpc-app_version': '2.46.1',
  86. 'x-rpc-sys_version': '9',
  87. 'x-rpc-channel': ' xiaomi',
  88. 'x-rpc-device_id': '',
  89. 'x-rpc-device_fp': '',
  90. 'x-rpc-device_name': '',
  91. 'x-rpc-device_model': '',
  92. 'Referer': ' https://app.mihoyo.com',
  93. 'Content-Type': 'application/json'
  94. }
  95. conn.request("POST", "/hk4e_cn/combo/panda/qrcode/confirm",
  96. payload, headers)
  97. res = conn.getresponse()
  98. # data = res.read()
  99. # print(data.decode("utf-8"))
  100. while True:
  101. # 截取指定区域的屏幕截图
  102. screenshot = cv2.cvtColor(
  103. np.array(ImageGrab.grab(bbox=(left, top, right, bottom))),
  104. cv2.COLOR_BGR2RGB
  105. )
  106. # 将截图转换为灰度图像
  107. gray = cv2.cvtColor(screenshot, cv2.COLOR_RGB2GRAY)
  108. # 尝试使用pyzbar库识别二维码
  109. codes = decode(gray, symbols=[pyzbar.ZBarSymbol.QRCODE])
  110. # 如果找到了二维码,输出其内容
  111. if codes:
  112. print(codes[0].data.decode())
  113. pattern = r"ticket=([a-f0-9]+)"
  114. match = re.search(pattern, codes[0].data.decode())
  115. # 正则请求地址
  116. if match:
  117. start_time = time.time()
  118. # 进入抢码
  119. retcode = Request(match.group(1))
  120. end_time = time.time()
  121. if retcode == 0:
  122. # 计算代码执行时间
  123. elapsed_time = end_time - start_time
  124. # 输出执行时间
  125. print("抢码成功耗时 %.3f 秒" % elapsed_time)
  126. # 确认登陆
  127. ConfirmRequest(match.group(1))
  128. time.sleep(1)
  129. # 等待一段时间再继续扫描
  130. time.sleep(0.05)
  131. # 在窗口中显示截图
  132. cv2.imshow("QR Code Scanner", screenshot)
  133. # 检查是否按下了键盘上的任意键
  134. if cv2.waitKey(1) != -1:
  135.     break
  136. # 关闭窗口
  137. cv2.destroyAllWindows()

下面是显示框部分的代码

  1. import tkinter as tk
  2. # 创建一个Tkinter窗口
  3. root = tk.Tk()
  4. # 隐藏窗口标题栏和边框
  5. root.overrideredirect(True)
  6. # 将窗口置顶
  7. root.wm_attributes("-topmost", True)
  8. # 设置窗口大小和位置
  9. win_width = 300
  10. win_height = 300
  11. screen_width = root.winfo_screenwidth()
  12. screen_height = root.winfo_screenheight()
  13. x_pos = (screen_width // 2) - (win_width // 2)
  14. y_pos = (screen_height // 2) - (win_height // 2)
  15. root.geometry('{}x{}+{}+{}'.format(win_width, win_height, x_pos, y_pos))
  16. # 将窗口背景设为透明
  17. root.attributes('-transparentcolor', 'white')
  18. # 将窗口的画布设为透明
  19. canvas = tk.Canvas(root, bg='white', highlightthickness=0)
  20. canvas.pack(fill='both', expand=True)
  21. # 绘制一个绿色空心正方形
  22. canvas.create_rectangle(5, 5, win_width-5, win_height-5, outline='red', width=2)
  23. # 进入循环让窗口保持打开状态
  24. root.mainloop()

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/188656
推荐阅读
相关标签
  

闽ICP备14008679号