Unverified Commit 18c02692 authored by Medicean's avatar Medicean Committed by GitHub

Merge pull request #261 from yzddmr6/master

"编码管理"中支持新增JSP编码器
parents 1a30ec6e ccd2241c
...@@ -104,7 +104,6 @@ class JSP extends Base { ...@@ -104,7 +104,6 @@ class JSP extends Base {
let tagStr = tag.substr(2, tag.length - 3); let tagStr = tag.substr(2, tag.length - 3);
let tagArr = tagStr.split('::'); let tagArr = tagStr.split('::');
let func, retStr; let func, retStr;
console.log(formatter);
if ((tagArr.length > 0) && (func = formatter[tagArr[0]])) { if ((tagArr.length > 0) && (func = formatter[tagArr[0]])) {
// 如果包含有分割标签且该格式化函数存在,则调用该函数进行处理 // 如果包含有分割标签且该格式化函数存在,则调用该函数进行处理
retStr = func(argv[tagArr[1] || '']); retStr = func(argv[tagArr[1] || '']);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -6,6 +6,7 @@ const LANG = antSword['language']['database']; ...@@ -6,6 +6,7 @@ const LANG = antSword['language']['database'];
const LANG_T = antSword['language']['toastr']; const LANG_T = antSword['language']['toastr'];
const dialog = antSword.remote.dialog; const dialog = antSword.remote.dialog;
const fs = require('fs'); const fs = require('fs');
const Decodes = antSword.Decodes;
class JSP { class JSP {
...@@ -69,17 +70,17 @@ class JSP { ...@@ -69,17 +70,17 @@ class JSP {
case 'conn': case 'conn':
this.getDatabases(arr[1]); this.getDatabases(arr[1]);
break; break;
// 获取数据库表名 // 获取数据库表名
case 'database': case 'database':
let _db = arr[1].split(':'); let _db = arr[1].split(':');
this.getTables(_db[0], Buffer.from(_db[1], 'base64').toString()); this.getTables(_db[0], Buffer.from(_db[1], 'base64').toString());
break; break;
// 获取表名字段 // 获取表名字段
case 'table': case 'table':
let _tb = arr[1].split(':'); let _tb = arr[1].split(':');
this.getColumns(_tb[0], Buffer.from(_tb[1], 'base64').toString(), Buffer.from(_tb[2], 'base64').toString()); this.getColumns(_tb[0], Buffer.from(_tb[1], 'base64').toString(), Buffer.from(_tb[2], 'base64').toString());
break; break;
// 生成查询SQL语句 // 生成查询SQL语句
case 'column': case 'column':
let _co = arr[1].split(':'); let _co = arr[1].split(':');
const db = Buffer.from(_co[1], 'base64').toString(); const db = Buffer.from(_co[1], 'base64').toString();
...@@ -728,12 +729,50 @@ class JSP { ...@@ -728,12 +729,50 @@ class JSP {
}); });
} }
parseResult(data) {
// 1.分割数组
const arr = data.split('\n');
// 2.判断数据
if (arr.length < 2) {
return toastr.error(LANG['result']['error']['parse'], LANG_T['error']);
};
// 3.行头
let header_arr = (arr[0]).replace(/,/g, '&#44;').split('\t|\t');
if (header_arr.length === 1) {
return toastr.warning(LANG['result']['error']['noresult'], LANG_T['warning']);
};
if (header_arr[header_arr.length - 1] === '\r') {
header_arr.pop();
};
arr.shift();
// 4.数据
let data_arr = [];
arr.map((_) => {
let _data = _.split('\t|\t');
for (let i = 0; i < _data.length; i++) {
let buff = Buffer.from(_data[i], "base64");
let encoding = Decodes.detectEncoding(buff, { defaultEncoding: "unknown" });
if (encoding == "unknown") {
encoding = this.dbconf['encode'] || '';
}
encoding = encoding != "" ? encoding : this.opt.core.__opts__['encode'];
let text = Decodes.decode(buff, encoding);
_data[i] = antSword.noxss(text);
}
data_arr.push(_data);
});
data_arr.pop();
return {
headers: header_arr,
datas: data_arr
}
}
// 更新SQL执行结果 // 更新SQL执行结果
updateResult(data) { updateResult(data) {
// 1.分割数组 // 1.分割数组
const arr = data.split('\n'); const arr = data.split('\n');
// let arr = []; _arr.map((_) => { arr.push(antSword.noxss(_)); }); // 2.判断数据
// console.log(_arr, arr); 2.判断数据
if (arr.length < 2) { if (arr.length < 2) {
return toastr.error(LANG['result']['error']['parse'], LANG_T['error']); return toastr.error(LANG['result']['error']['parse'], LANG_T['error']);
}; };
...@@ -750,6 +789,16 @@ class JSP { ...@@ -750,6 +789,16 @@ class JSP {
let data_arr = []; let data_arr = [];
arr.map((_) => { arr.map((_) => {
let _data = _.split('\t|\t'); let _data = _.split('\t|\t');
for (let i = 0; i < _data.length; i++) {
let buff = new Buffer.from(_data[i], "base64");
let encoding = Decodes.detectEncoding(buff, { defaultEncoding: "unknown" });
if (encoding == "unknown") {
encoding = this.dbconf['encode'] || '';
}
encoding = encoding != "" ? encoding : this.opt.core.__opts__['encode'];
let text = Decodes.decode(buff, encoding);
_data[i] = antSword.noxss(text, false);
}
data_arr.push(_data); data_arr.push(_data);
}); });
data_arr.pop(); data_arr.pop();
...@@ -795,7 +844,7 @@ class JSP { ...@@ -795,7 +844,7 @@ class JSP {
.core .core
.__opts__ .__opts__
.ip}_${new Date() .ip}_${new Date()
.format("yyyyMMddhhmmss")}.csv`; .format("yyyyMMddhhmmss")}.csv`;
dialog.showSaveDialog({ dialog.showSaveDialog({
title: LANG['result']['dump']['title'], title: LANG['result']['dump']['title'],
defaultPath: filename defaultPath: filename
......
...@@ -100,7 +100,7 @@ class FileManager { ...@@ -100,7 +100,7 @@ class FileManager {
this.isWin = false; this.isWin = false;
} else { } else {
// windows 盘符统一大写 // windows 盘符统一大写
info_path = `${info_path.substr(0,1).toUpperCase()}${info_path.substr(1)}`; info_path = `${info_path.substr(0, 1).toUpperCase()}${info_path.substr(1)}`;
info_drive = info_drive.toUpperCase(); info_drive = info_drive.toUpperCase();
}; };
this.path = info_path; this.path = info_path;
...@@ -145,11 +145,11 @@ class FileManager { ...@@ -145,11 +145,11 @@ class FileManager {
let self = this; let self = this;
if (self.isWin) { // 处理输入为 f:\ 这种情况 if (self.isWin) { // 处理输入为 f:\ 这种情况
p = p.replace(/\\/g, '/'); p = p.replace(/\\/g, '/');
p = p.substr(1, 2) == ":/" ? `${p.substr(0,1).toUpperCase()}${p.substr(1)}` : p; p = p.substr(1, 2) == ":/" ? `${p.substr(0, 1).toUpperCase()}${p.substr(1)}` : p;
} }
let path = this.changePath(p); let path = this.changePath(p);
if (self.isWin) { // 处理输入为 f: 这种情况 if (self.isWin) { // 处理输入为 f: 这种情况
path = path.substr(1, 2) == ":/" ? `${path.substr(0,1).toUpperCase()}${path.substr(1)}` : path; path = path.substr(1, 2) == ":/" ? `${path.substr(0, 1).toUpperCase()}${path.substr(1)}` : path;
} }
let cache; let cache;
...@@ -208,6 +208,8 @@ class FileManager { ...@@ -208,6 +208,8 @@ class FileManager {
this.cache.set(cache_tag, JSON.stringify(data)); this.cache.set(cache_tag, JSON.stringify(data));
}).catch((err) => { }).catch((err) => {
toastr.error((err instanceof Object) ? JSON.stringify(err) : String(err), LANG_T['error']); toastr.error((err instanceof Object) ? JSON.stringify(err) : String(err), LANG_T['error']);
this.folder.cell.progressOff();
this.files.cell.progressOff();
}) })
// this.core.filemanager.dir({ // this.core.filemanager.dir({
...@@ -650,15 +652,15 @@ class FileManager { ...@@ -650,15 +652,15 @@ class FileManager {
fs.unlinkSync(filePath); fs.unlinkSync(filePath);
} }
self.core.download(filePath, self.core.filemanager.download_file({ self.core.download(filePath, self.core.filemanager.download_file({
path: path path: path
}), (_size) => { }), (_size) => {
// 计算进度百分比 // 计算进度百分比
down_size += _size; down_size += _size;
let down_progress = parseInt(parseFloat(down_size / item.size).toFixed(2) * 100); let down_progress = parseInt(parseFloat(down_size / item.size).toFixed(2) * 100);
if (!(down_progress % 5)) { if (!(down_progress % 5)) {
task.update(down_progress + '%'); task.update(down_progress + '%');
}; };
}) })
.then((_size) => { .then((_size) => {
if (_size === item.size) { if (_size === item.size) {
task.success(LANG['download']['task']['success']); task.success(LANG['download']['task']['success']);
...@@ -944,69 +946,69 @@ class FileManager { ...@@ -944,69 +946,69 @@ class FileManager {
icon: 'code', icon: 'code',
type: 'button' type: 'button'
}; };
(_ === ext) ? _opt['selected'] = true: 0; (_ === ext) ? _opt['selected'] = true : 0;
_options.push(_opt); _options.push(_opt);
} }
toolbar.loadStruct([{ toolbar.loadStruct([{
id: 'hinttext', id: 'hinttext',
type: 'text', type: 'text',
text: hinttext text: hinttext
}, },
{ {
id: 'filepath', id: 'filepath',
type: 'buttonInput', type: 'buttonInput',
width: 500, width: 500,
value: antSword.noxss(path), value: antSword.noxss(path),
}, },
{ {
type: 'separator' type: 'separator'
}, },
{ {
type: 'spacer' type: 'spacer'
}, },
{ {
id: 'refresh', id: 'refresh',
type: 'button', type: 'button',
icon: 'refresh', icon: 'refresh',
text: LANG['editor']['toolbar']['refresh'] text: LANG['editor']['toolbar']['refresh']
}, },
{ {
id: 'save', id: 'save',
type: 'button', type: 'button',
icon: 'save', icon: 'save',
text: LANG['editor']['toolbar']['save'] text: LANG['editor']['toolbar']['save']
}, },
{ {
type: 'separator' type: 'separator'
}, },
{ {
id: 'encode', id: 'encode',
type: 'buttonSelect', type: 'buttonSelect',
icon: 'language', icon: 'language',
openAll: true, openAll: true,
text: LANG['editor']['toolbar']['encode'], text: LANG['editor']['toolbar']['encode'],
options: (() => { options: (() => {
let ret = []; let ret = [];
ENCODES.map((_) => { ENCODES.map((_) => {
let _opt_ = { let _opt_ = {
id: `encode_${_}`, id: `encode_${_}`,
text: _, text: _,
icon: 'font', icon: 'font',
type: 'button' type: 'button'
}; };
(_ === self.opts['encode'] ? _opt_['selected'] = true : 0); (_ === self.opts['encode'] ? _opt_['selected'] = true : 0);
ret.push(_opt_); ret.push(_opt_);
}); });
return ret; return ret;
})() })()
}, { }, {
id: 'mode', id: 'mode',
type: 'buttonSelect', type: 'buttonSelect',
icon: 'th-list', icon: 'th-list',
openAll: true, openAll: true,
text: LANG['editor']['toolbar']['mode'], text: LANG['editor']['toolbar']['mode'],
options: _options options: _options
}, },
]); ]);
toolbar.setItemToolTip('hinttext', tooltip); toolbar.setItemToolTip('hinttext', tooltip);
toolbar.attachEvent('onClick', (id) => { toolbar.attachEvent('onClick', (id) => {
......
/** /**
* 中国蚁剑::编码器管理 * 中国蚁剑::编码器管理
* 创建:2017-05-30 * 创建:2017-05-30
* 更新:2018-08-19 * 更新:2020-11-03
* 作者:Virink <virink@outlook.com> * 作者:Virink <virink@outlook.com>
* 作者:Medici.Yan <Medici.Yan@gmail.com> * 作者:Medici.Yan <Medici.Yan@gmail.com>
* 作者:yzddMr6 <yzddmr6@gmail.com>
*/ */
const LANG = antSword['language']['settings']['encoders']; const LANG = antSword['language']['settings']['encoders'];
...@@ -59,6 +60,11 @@ class Encoders { ...@@ -59,6 +60,11 @@ class Encoders {
icon: 'file-code-o', icon: 'file-code-o',
type: 'button', type: 'button',
text: "PHP" text: "PHP"
}, {
id: 'new_jsp',
icon: 'file-code-o',
type: 'button',
text: "JSP"
}, { }, {
type: 'separator' type: 'separator'
}, { }, {
...@@ -129,6 +135,9 @@ class Encoders { ...@@ -129,6 +135,9 @@ class Encoders {
case "new_aspx": case "new_aspx":
that.createEncoder(id); that.createEncoder(id);
break; break;
case "new_jsp":
that.createEncoder(id);
break;
case "new_php": case "new_php":
case "new_php_rsa": case "new_php_rsa":
that.createEncoder(id); that.createEncoder(id);
...@@ -177,6 +186,7 @@ class Encoders { ...@@ -177,6 +186,7 @@ class Encoders {
combobox.put("asp", "ASP"); combobox.put("asp", "ASP");
combobox.put("aspx", "ASPX"); combobox.put("aspx", "ASPX");
combobox.put("php", "PHP"); combobox.put("php", "PHP");
combobox.put("jsp", "JSP");
combobox.put("custom", "CUSTOM"); combobox.put("custom", "CUSTOM");
grid.attachEvent("onEditCell", function (stage, rId, cInd, nValue, oValue) { grid.attachEvent("onEditCell", function (stage, rId, cInd, nValue, oValue) {
...@@ -208,7 +218,7 @@ class Encoders { ...@@ -208,7 +218,7 @@ class Encoders {
break break
case 2: case 2:
// type // type
if (nValue != "asp" && nValue != "aspx" && nValue != "php" && nValue != "custom") { if (nValue != "asp" && nValue != "aspx" && nValue != "php" && nValue != "jsp"&& nValue != "custom") {
toastr.error(LANG['message']["etype_error"], LANG_T['error']); toastr.error(LANG['message']["etype_error"], LANG_T['error']);
return return
} }
...@@ -747,12 +757,14 @@ module.exports = { ...@@ -747,12 +757,14 @@ module.exports = {
asp: [], asp: [],
aspx: [], aspx: [],
php: [], php: [],
jsp: [],
custom: [] custom: []
}; };
var encoders_path = { var encoders_path = {
asp: [], asp: [],
aspx: [], aspx: [],
php: [], php: [],
jsp: [],
custom: [] custom: []
}; };
let userencoder_path = path.join(remote.process.env.AS_WORKDIR, 'antData/encoders'); let userencoder_path = path.join(remote.process.env.AS_WORKDIR, 'antData/encoders');
...@@ -794,12 +806,14 @@ module.exports = { ...@@ -794,12 +806,14 @@ module.exports = {
asp: [], asp: [],
aspx: [], aspx: [],
php: [], php: [],
jsp: [],
custom: [] custom: []
}; };
var decoders_path = { var decoders_path = {
asp: [], asp: [],
aspx: [], aspx: [],
php: [], php: [],
jsp: [],
custom: [] custom: []
}; };
let userdecoder_path = path.join(remote.process.env.AS_WORKDIR, 'antData/encoders'); let userdecoder_path = path.join(remote.process.env.AS_WORKDIR, 'antData/encoders');
......
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