var CryptoJS = require('crypto-js') var request = require('request-promise') // export function testEncription(msg, fullKey) { // var fullKey = fullKey.slice(0, 16) // var key = CryptoJS.enc.Utf8.parse(fullKey) // var iv = CryptoJS.enc.Utf8.parse(fullKey) // var passWord = CryptoJS.AES.encrypt(msg, key, { iv: iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 }) // var base64 = passWord.toString() // console.log('passWord', passWord) // console.log('sessionId', sessionId) // console.log('key', key) // console.log('base64', base64) // var bytes = CryptoJS.AES.decrypt(base64, key, { // iv: iv // }); // console.log('bytes', bytes) // var plaintext = CryptoJS.enc.Utf8.stringify(bytes); // console.log('plaintext', plaintext) // } function encrypt(text, originKey) { var originKey = originKey.slice(0, 16), key = CryptoJS.enc.Utf8.parse(originKey), iv = CryptoJS.enc.Utf8.parse(originKey), msg = JSON.stringify(text); var ciphertext = CryptoJS.AES.encrypt(msg, key, { iv: iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 }); return ciphertext.toString(); } function decrypt(text, originKey) { var originKey = originKey.slice(0, 16), key = CryptoJS.enc.Utf8.parse(originKey), iv = CryptoJS.enc.Utf8.parse(originKey) var bytes = CryptoJS.AES.decrypt(text, key, { iv: iv }); var plaintext = CryptoJS.enc.Utf8.stringify(bytes) return plaintext } var version = 5, score = 1000, // change session_id session_id = 'xxxxx' var headers = { 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_2_1 like Mac OS X) AppleWebKit/604.4.7 (KHTML, like Gecko) Mobile/15C153 MicroMessenger/6.6.1 NetType/WIFI Language/zh_CN', 'Referer': 'https://servicewechat.com/wx7c8d593b2c3a7703/' + version + '/page-frame.html', 'Accept-Language': 'zh-cn' } console.log(headers) var base_req = { 'base_req': { 'session_id': session_id, 'fast': 1 } } request({ method: 'POST', url: 'https://mp.weixin.qq.com/wxagame/wxagame_getfriendsscore', headers: headers, json: true, body: base_req }).then(function (response) { console.log(response.my_user_info) var times = response.my_user_info.times + 1 var action = [], musicList = [], touchList = [] for (var i = 0; i < score; i++) { action.push([0.752, 1.32, false]) musicList.push(false) touchList.push([185, 451]) } // "{"seed":1514756173427,"action":[[0.852,1.02,false],[0.452,1.84,false],[0.998,0.72,false],[0.506,1.7,false],[0.55,1.63,false],[0.821,1.09,false],[0.706,1.29,false],[0.634,1.46,false],[0.517,1.7,false],[0.564,1.6,false],[0.895,0.95,false],[0.645,1.46,false],[0.315,2.11,true],[0.516,1.7,false],[0.138,2.45,false],[0.163,2.41,false]],"musicList":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"touchList":[[155,421],[155,421],[155,421],[155,421],[155,421],[155,421],[155,421],[155,421],[155,421],[155,421],[155,421],[155,421],[155,421],[155,421],[161,420],[161,420]],"version":1}" console.log(score, times, action.length, musicList.length, touchList.length) var data = { score: score, times: times, game_data: JSON.stringify({ seed: Date.now(), action: action, musicList: musicList, touchList: touchList, version: 1 }) } request({ method: 'POST', url: 'https://mp.weixin.qq.com/wxagame/wxagame_settlement', headers: headers, json: true, body: { base_req: base_req, action_data: encrypt(data, session_id) } }).then(function (response) { console.log(response) }).catch(function (error) { console.log(error) }) }).catch(function (error) { console.log('something crash') })