Commit aa3d7702 authored by Medicean's avatar Medicean

v2.0:: parse user encoder

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