[JavaScript] 纯文本查看 复制代码
var http = require('http');
var md5 = require('md5-node');
var hex_md5 = require('md5-node');
var querystring = require('querystring');
var tmoney, tstar, pmoney, gk, xj, jnw;
const AnyProxy = require('anyproxy');
const options = {
port: 8001,
rule: {
summary: 'Rule to modify request data',
*beforeSendResponse(requestDetail, responseDetail) {
if (requestDetail.url.indexOf('downloadRecord') != -1) {
var newResponse = Object.assign({},
responseDetail.response);
var str = newResponse.body.toString();
var all = JSON.parse(str);
var re = JSON.parse(all.record);
var id = JSON.parse(re.openid).openid;
var rere = JSON.parse(re.recordItemBag);
function jiami(e, t, i) {
i || (i = 100 + Math.floor(900 * Math.random()));
var o = e + 100 + i;
try {
var a = md5(o + id + t);
}
catch(err) {};
return "t" + (a.charAt(17) + a.charAt(3) + a.charAt(27) + a.charAt(11) + a.charAt(23)) + i + e;
}
try {
rere = {
coin: {
building_1_group: {
incomeSum: tmoney,
nodesCount: 3,
endPos: {
x: -500,
y: 150
}
}
},
star: {
building_1_group: {
incomeSum: parseInt(10000) + parseInt(tstar),
nodesCount: 4,
endPos: {
x: -200,
y: 150
}
},
building_2_group: {
incomeSum: parseInt( - 10000),
nodesCount: 5,
endPos: {
x: -200,
y: -150
}
}
}
};
n = hex_md5(JSON.stringify(rere) + id);
rere.checkSign = n.charAt(9) + n.charAt(16) + n.charAt(7) + n.charAt(21) + n.charAt(22);
re.recordItemBag = JSON.stringify(rere);
} catch(err) {};
xj = parseInt(xj);
try {
if (xj != 0) {
mail = {
mailList: ['mail_1', 'mail_2', 'mail_3', 'mail_4', 'mail_5', 'mail_6', 'mail_7', 'mail_8', 'mail_9', 'mail_10', 'mail_11', 'mail_12', 'mail_13', 'mail_14', 'mail_15', 'mail_16', 'mail_17', 'mail_18', 'mail_19', 'mail_20', 'mail_21', 'mail_22', 'mail_23', 'mail_24', 'mail_25', 'mail_26', 'mail_27', 'mail_28', 'mail_29', 'mail_30', 'mail_31', 'mail_32', 'mail_33', 'mail_34', 'mail_35', 'mail_36', 'mail_37', 'mail_38', 'mail_39', 'mail_40', 'mail_41', 'mail_42', 'mail_43', 'mail_44', 'mail_45', 'mail_46', 'mail_47', 'mail_48', 'mail_49', 'mail_50', 'mail_51', 'mail_52', 'mail_53', 'mail_54', 'mail_55', 'mail_56']
}
g = hex_md5(JSON.stringify(mail.mailList) + id);
mail.sign = g.charAt(17) + g.charAt(3) + g.charAt(27) + g.charAt(11) + g.charAt(23);
re.mailData = JSON.stringify(mail);
}
} catch(err) {};
try {
if (pmoney != 0) {
re.money_plate = jiami(parseInt(pmoney), 'money_plate');
}
} catch(err) {};
gk = parseInt(gk);
try {
if (gk != 0) {
for (var i = 1; i < 85; i++) {
var str = 'customer_unlock_customer_' + i;
re[str] = jiami(1, str);
}
for (var i = 1; i < 7; i++) {
var str = 'customer_unlock_booth_customer_' + i;
re[str] = jiami(1, str);
}
for (var i = 1; i < 10; i++) {
var str = 'customer_unlock_npc_' + i;
re[str] = jiami(1, str);
}
re.customer_unlock_customer_spring_1 = jiami(1, 'customer_unlock_customer_spring_1');
re.customer_unlock_customer_spring_2 = jiami(1, 'customer_unlock_customer_spring_2');
re.customer_unlock_customer_summer_1 = jiami(1, 'customer_unlock_customer_summer_1');
re.customer_unlock_customer_summer_2 = jiami(1, 'customer_unlock_customer_summer_2');
re.customer_unlock_customer_autumn_1 = jiami(1, 'customer_unlock_customer_autumn_1');
re.customer_unlock_customer_autumn_2 = jiami(1, 'customer_unlock_customer_autumn_2');
re.customer_unlock_customer_winter_1 = jiami(1, 'customer_unlock_customer_winter_1');
re.customer_unlock_customer_winter_2 = jiami(1, 'customer_unlock_customer_winter_2');
re.customer_unlock_customer_community = jiami(1, 'customer_unlock_customer_community');
re.customer_unlock_customer_community2 = jiami(1, 'customer_unlock_customer_community2');
}
} catch(err) {};
all.record = JSON.stringify(re);
newResponse.body = JSON.stringify(all);
return {
response: newResponse
};
}
}
},
webInterface: {
enable: true,
webPort: 8002
},
throttle: 10000,
forceProxyHttps: true,
wsIntercept: false,
silent: false
};
const proxyServer = new AnyProxy.ProxyServer(options);
proxyServer.start();
var postHTML = '<html><head><meta charset="utf-8"><title>Dong Wu Xiu Gai</title></head>' + '<body>' + '<form method="post">' + 'YuGan<input name="tmoney"><br>' + 'XingXing<input name="tstar"><br>' + 'PanZi<input name="pmoney"><br>' + 'GuKe<input name="gk"><br>' + 'XinJian<input name="xj"><br>' + '<input type="submit">' + '</form>' + '</body></html>';
http.createServer(function(req, res) {
var body = "";
console.log(req.url);
req.on('data',
function(chunk) {
body += chunk;
//console.log("chunk:",chunk);
});
req.on('end',
function() {
body = querystring.parse(body);
console.log("body:", body);
res.writeHead(200, {
'Content-Type': 'text/html; charset=utf8'
});
if (body.tmoney) {
tmoney = body.tmoney;
console.log(tmoney);
};
if (body.tstar) {
tstar = body.tstar;
console.log(tstar);
};
if (body.pmoney) {
pmoney = body.pmoney;
console.log(pmoney);
};
if (body.gk) {
gk = body.gk;
};
if (body.xj) {
xj = body.xj;
};
if ((body.tstar) || (body.tmoney) || (body.pmoney)) {
res.write('Success YuGan:' + tmoney + ',XingXing:' + tstar + ',PanZi:' + pmoney + ',XinJian:' + xj + ',GuKe' + gk + '.')
} else {
res.write(postHTML);
};
res.end();
});
}).listen(8003);