Commit aa3d7702 authored by Medicean's avatar Medicean

v2.0:: parse user encoder

parent 9f32a6c6
...@@ -41,7 +41,7 @@ const antSword = window.antSword = { ...@@ -41,7 +41,7 @@ const antSword = window.antSword = {
*/ */
logs: [], logs: [],
/** /**
* 核心模块 * 自定义编码器
* @type {Object} * @type {Object}
*/ */
encoders: {}, encoders: {},
...@@ -127,24 +127,44 @@ antSword['language'] = require('./language/'); ...@@ -127,24 +127,44 @@ antSword['language'] = require('./language/');
// 加载编码 // 加载编码
antSword['encoders'] = (function(){ antSword['encoders'] = (function(){
var encoders = {asp:[],aspx:[],php:[],custom:[]}; var encoders = {asp:[],aspx:[],php:[],custom:[]};
let custom_path = path.join(process.env.AS_WORKDIR,'antData/encoder'); var encoders_path = {asp:[],aspx:[],php:[],custom:[]};
let userencoder_path = path.join(process.env.AS_WORKDIR,'antData/encoders');
// 初始化 // 初始化
!fs.existsSync(custom_path) ? fs.mkdirSync(custom_path) : null; !fs.existsSync(userencoder_path) ? fs.mkdirSync(userencoder_path) : null;
// custom ['asp','aspx','php','custom'].map((t)=>{
let es = fs.readdirSync(custom_path); !fs.existsSync(path.join(userencoder_path, `${t}`))? fs.mkdirSync(path.join(userencoder_path, `${t}`)):null;
let t_path = path.join(userencoder_path, `${t}/encoder/`);
!fs.existsSync(t_path) ? fs.mkdirSync(t_path) : null;
let es = fs.readdirSync(t_path);
if(es){ if(es){
es.map((_)=>{ es.map((_)=>{
let farr = _.split("#"); if(!_.endsWith(".js")){
encoders[farr[0]].push(farr[1].slice(0,-3)); return
});
} }
// default encoders[t].push(_.slice(0,-3));
['asp','aspx','php','custom'].map((t)=>{ encoders_path[t].push(path.join(t_path, _.slice(0,-3)));
antSword["core"][t].prototype.encoders.map((e)=>{
encoders[t].push(e);
}); });
encoders[t] = encoders[t].unique(); }
antSword["core"][t].prototype.user_encoders = encoders_path[t];
}); });
// // custom
// let es = fs.readdirSync(userencoder_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) => { // fs.readdirSync(path.join(process.env.AS_WORKDIR,'encoder'),(err,f) => {
// if(err || !f) return ; // if(err || !f) return ;
// console.debug(f); // console.debug(f);
......
...@@ -34,7 +34,7 @@ class ASP extends Base { ...@@ -34,7 +34,7 @@ class ASP extends Base {
* @return {array} 编码器列表 * @return {array} 编码器列表
*/ */
get encoders() { get encoders() {
return (localStorage.getItem('encoders_asp')||'xxxxdog').split(','); return ['xxxxdog'];
} }
/** /**
......
...@@ -37,7 +37,7 @@ class ASPX extends Base { ...@@ -37,7 +37,7 @@ class ASPX extends Base {
* @return {array} 编码器列表 * @return {array} 编码器列表
*/ */
get encoders() { get encoders() {
return (localStorage.getItem('encoders_aspx')||"base64,hex").split(','); return ["base64","hex"];
} }
/** /**
......
...@@ -51,6 +51,10 @@ class Base { ...@@ -51,6 +51,10 @@ class Base {
](pwd, data); ](pwd, data);
} }
} }
// 解析自定义编码器
this.user_encoders.map((_)=>{
this.parseEncoder(`${_}`);
});
} }
/** /**
......
...@@ -30,7 +30,7 @@ class CUSTOM extends Base { ...@@ -30,7 +30,7 @@ class CUSTOM extends Base {
* @return {array} 编码器列表 * @return {array} 编码器列表
*/ */
get encoders() { get encoders() {
return (localStorage.getItem('encoders_custom')||'base64,hex').split(','); return ['base64','hex'];
} }
/** /**
......
...@@ -35,7 +35,7 @@ class PHP extends Base { ...@@ -35,7 +35,7 @@ class PHP extends Base {
* @return {array} 编码器列表 * @return {array} 编码器列表
*/ */
get encoders() { get encoders() {
return (localStorage.getItem('encoders_php')||"chr,base64").split(','); return ["base64", "chr", "chr16", "rot13"];
} }
/** /**
......
...@@ -196,7 +196,8 @@ class Form { ...@@ -196,7 +196,8 @@ class Form {
_parseTypes(_default = 'php', _encoder = 'default') { _parseTypes(_default = 'php', _encoder = 'default') {
let ret = []; let ret = [];
for (let c in antSword['core']) { for (let c in antSword['core']) {
let encoders = antSword['core'][c].prototype.encoders; // 加载默认编码器和用户自定义编码器
let encoders = antSword['core'][c].prototype.encoders.concat(antSword['encoders'][c]);
ret.push({ ret.push({
text: c.toUpperCase(), value: c, text: c.toUpperCase(), value: c,
selected: c === _default, selected: c === _default,
......
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