-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathwxdump.js
66 lines (57 loc) · 2.07 KB
/
wxdump.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
var CryptoJS = require('crypto-js');
var http = require('http');
var querystring = require('querystring');
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
}
module.exports = {
*beforeSendRequest(requestDetail) {
if (requestDetail.url.indexOf('https://mp.weixin.qq.com/wxagame/wxagame_settlement') === 0) {
var data=JSON.parse(requestDetail.requestData.toString());
var sessionid=data['base_req']['session_id'];
var actiondata=data['action_data'];
actiondata=JSON.parse(decrypt(actiondata,sessionid));
actiondata['score']=Math.round(8000+Math.random()*2000);
var action = [],
musicList = [],
touchList = [];
for(var i=Math.round(10000+Math.random()*2000);i>0;i--){
action.push([Math.random().toFixed(3),(Math.random()*2).toFixed(2),i/5000==0?true:false]);
musicList.push(false);
touchList.push([(250-Math.random()*10).toFixed(4),(670-Math.random()*20).toFixed(4)]);
}
actiondata['game_data']=JSON.stringify({
seed: Date.now(),
action: action,
musicList: musicList,
touchList: touchList,
version: 1
});
console.log(actiondata);
var senddata='{"base_req":{"session_id":"'+sessionid+'","fast":1},"action_data":"'+encrypt(actiondata, sessionid)+'"}';
console.log(senddata);
return {
requestData: senddata
};
}
},
};