Commit 45c764b3 authored by Medicean's avatar Medicean

(Enhance:Core) 支持加载用户自定义解码器

parent 22ca72a7
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
> https://github.com/AntSwordProject/AwesomeEncoder/blob/master/php/aes_256_cfb_zero_padding.js > https://github.com/AntSwordProject/AwesomeEncoder/blob/master/php/aes_256_cfb_zero_padding.js
* 解码器新增 ext 参数, 用于获取 shell 配置和rsa私钥 * 解码器新增 ext 参数, 用于获取 shell 配置和rsa私钥
* 支持加载用户自定义解码器
### 数据管理 ### 数据管理
......
{ {
"name": "antsword", "name": "antsword",
"version": "2.1.1.6", "version": "2.1.1.7",
"description": "中国蚁剑是一款跨平台的开源网站管理工具", "description": "中国蚁剑是一款跨平台的开源网站管理工具",
"main": "app.js", "main": "app.js",
"dependencies": { "dependencies": {
......
...@@ -47,6 +47,11 @@ const antSword = window.antSword = { ...@@ -47,6 +47,11 @@ const antSword = window.antSword = {
* @type {Object} * @type {Object}
*/ */
encoders: {}, encoders: {},
/**
* 自定义解码器
* @type {Object}
*/
decoders: {},
/** /**
* 核心模块 * 核心模块
* @type {Object} * @type {Object}
...@@ -176,6 +181,56 @@ antSword['encoders'] = (function(){ ...@@ -176,6 +181,56 @@ antSword['encoders'] = (function(){
return encoders; return encoders;
})(); })();
// 加载解码器
antSword['decoders'] = (function() {
var decoders = {asp:[], aspx:[], php:[], custom:[]};
var decoders_path = {asp:[], aspx:[], php:[], custom:[]};
let userdecoder_path = path.join(remote.process.env.AS_WORKDIR, 'antData/encoders');
// 初始化
!fs.existsSync(userdecoder_path) ? fs.mkdirSync(userdecoder_path) : null;
['asp', 'aspx', 'php', 'custom'].map((t)=>{
!fs.existsSync(path.join(userdecoder_path, `${t}`))? fs.mkdirSync(path.join(userdecoder_path, `${t}`)):null;
let t_path = path.join(userdecoder_path, `${t}/decoder/`);
!fs.existsSync(t_path) ? fs.mkdirSync(t_path) : null;
let es = fs.readdirSync(t_path);
if(es){
es.map((_)=>{
if(!_.endsWith(".js")){
return
}
decoders[t].push(_.slice(0,-3));
decoders_path[t].push(path.join(t_path, _.slice(0,-3)));
});
}
antSword["core"][t].prototype.user_decoders = decoders_path[t];
});
// // custom
// let es = fs.readdirSync(userdecoder_path);
// if(es){
// es.map((_)=>{
// console.log(_);
// let farr = _.split("#");
// encoders[farr[0]].push(farr[1].slice(0,-3));
// });
// }
// default
// ['asp','aspx','php','custom'].map((t)=>{
// antSword["core"][t].prototype.encoders.map((e)=>{
// encoders[t].push(e);
// });
// encoders[t] = encoders[t].unique();
// });
// fs.readdirSync(path.join(process.env.AS_WORKDIR,'encoder'),(err,f) => {
// if(err || !f) return ;
// console.debug(f);
// let farr = f.split("#");
// encoders[farr[0]].push(farr[1]);
// });
return decoders;
})();
// 加载代理 // 加载代理
const aproxy = { const aproxy = {
mode: antSword['storage']('aproxymode', false, 'noproxy'), mode: antSword['storage']('aproxymode', false, 'noproxy'),
......
...@@ -58,6 +58,9 @@ class Base { ...@@ -58,6 +58,9 @@ class Base {
this.user_encoders.map((_) => { this.user_encoders.map((_) => {
this.parseEncoder(`${_}`); this.parseEncoder(`${_}`);
}); });
this.user_decoders.map((_) => {
this.parseDecoder(`${_}`);
});
} }
/** /**
......
...@@ -413,14 +413,14 @@ eval($cmd);`); ...@@ -413,14 +413,14 @@ eval($cmd);`);
* Create at: ${new Date().format("yyyy/MM/dd hh:mm:ss")} * Create at: ${new Date().format("yyyy/MM/dd hh:mm:ss")}
*/ */
\'use strict\'; \'use strict\';
/* /*
* @param {String} pwd 连接密码 * @param {String} pwd 连接密码
* @param {Array} data 编码器处理前的 payload 数组 * @param {Array} data 编码器处理前的 payload 数组
* @return {Array} data 编码器处理后的 payload 数组 * @return {Array} data 编码器处理后的 payload 数组
*/ */
module.exports = (pwd, data) => { module.exports = (pwd, data) => {
// ########## 请在下方编写你自己的代码 ################### // ########## 请在下方编写你自己的代码 ###################
// 以下代码为 PHP Base64 样例 // 以下代码为 PHP Base64 样例
......
...@@ -294,11 +294,11 @@ class Form { ...@@ -294,11 +294,11 @@ class Form {
switch(c){ switch(c){
case 'php4': case 'php4':
encoders = antSword['core']['php4'].prototype.encoders.concat(antSword['encoders']['php']); encoders = antSword['core']['php4'].prototype.encoders.concat(antSword['encoders']['php']);
decoders = antSword['core'][c].prototype.decoders; decoders = antSword['core']['php4'].prototype.decoders.concat(antSword['decoders']['php']);
break; break;
default: default:
encoders = antSword['core'][c].prototype.encoders.concat(antSword['encoders'][c]); encoders = antSword['core'][c].prototype.encoders.concat(antSword['encoders'][c]);
decoders = antSword['core'][c].prototype.decoders; decoders = antSword['core'][c].prototype.decoders.concat(antSword['decoders'][c]);
break; break;
} }
ret.push({ ret.push({
......
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