Skip to content

Instantly share code, notes, and snippets.

@sweet-zone
Created January 1, 2018 15:16
Show Gist options
  • Save sweet-zone/6aa5fe9beed32617539d71e6af84e377 to your computer and use it in GitHub Desktop.
Save sweet-zone/6aa5fe9beed32617539d71e6af84e377 to your computer and use it in GitHub Desktop.
跳一跳刷分 Nodejs 版
const crypto = require('crypto')
const axios = require('axios')
const url = 'https://mp.weixin.qq.com/wxagame/wxagame_settlement'
const sessionId = 'your session id'
function getActionData(key, content, iv) {
const clearEncoding = 'utf8'
const cipherEncoding = 'base64'
let cipherChunks = []
let cipher = crypto.createCipheriv('aes-128-cbc', key, iv)
cipher.setAutoPadding(true)
cipherChunks.push(cipher.update(content, clearEncoding, cipherEncoding))
cipherChunks.push(cipher.final(cipherEncoding))
return cipherChunks.join('')
}
function jumpjump(score, times, sessionId) {
const AES_KEY = sessionId.substring(0, 16)
const content = JSON.stringify({
score: score,
times: times
})
const AES_IV = AES_KEY
const actionData = getActionData(AES_KEY, content, AES_IV)
const postData = {
base_req: {
session_id: sessionId,
fast: 1,
},
action_data: actionData
}
axios({
method: 'post',
url: url,
data: postData,
timeout: 1000,
headers: {
Accept: '*/*',
'Accept-Language': 'zh-cn',
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Mobile/14E304 MicroMessenger/6.6.1 NetType/WIFI Language/zh_CN")',
'Content-Length': 680,
'Content-Type': 'application/json',
'Refer': 'https://servicewechat.com/wx7c8d593b2c3a7703/5/page-frame.html',
'Host': 'mp.weixin.qq.com',
'Connection': 'keep-alive'
}
}).then((res) => {
console.log(res.data)
}).catch((e) => {
console.log(e)
})
}
jumpjump(2018, 40, sessionId)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment