Created
January 1, 2018 13:34
-
-
Save bhaltair/26cbedcd47e0c155b3a8923601b95dec to your computer and use it in GitHub Desktop.
wechat_jump_helper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
import time | |
from Crypto.Cipher import AES | |
import base64 | |
action_data = { | |
"score": 666, | |
"times": 666, | |
"game_data": "{}" | |
} | |
session_id = "SJ8oZTVlMDiFnob7JP3KzJ5xQ3nLK5z0/ROkoqxB46u+2HbpbICBw4fkAr8WqmSmO8kXsWWhUfJE1QrflEEuY3MS/qArKy5LrSn2jUVp0BRAK90rhWJi2jz1dzhaVK44Jv/2FJ45IZGsQ2bSHAEiWw\u003d\u003d" | |
aes_key = session_id[0:16] | |
aes_iv = aes_key | |
cryptor = AES.new(aes_key, AES.MODE_CBC, aes_iv) | |
str_action_data = json.dumps(action_data).encode("utf-8") | |
print("json_str_action_data ", str_action_data) | |
#Pkcs7 | |
length = 16 - (len(str_action_data) % 16) | |
str_action_data += bytes([length])*length | |
cipher_action_data = base64.b64encode(cryptor.encrypt(str_action_data)).decode("utf-8") | |
print("action_data ", cipher_action_data) | |
post_data = { | |
"base_req": { | |
"session_id": session_id, | |
"fast": 1, | |
}, | |
"action_data": cipher_action_data | |
} | |
headers = { | |
"charset": "utf-8", | |
"Accept-Encoding": "gzip", | |
"referer": "https://servicewechat.com/wx7c8d593b2c3a7703/3/page-frame.html", | |
"content-type": "application/json", | |
"User-Agent": "MicroMessenger/6.6.1.1200(0x26060130) NetType/WIFI Language/zh_CN", | |
"Content-Length": "0", | |
"Host": "mp.weixin.qq.com", | |
"Connection": "Keep-Alive" | |
} | |
url = "https://mp.weixin.qq.com/wxagame/wxagame_settlement" | |
response = requests.post(url, json=post_data, headers=headers) | |
print(json.loads(response.text)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment