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