Skip to content

Commit

Permalink
Merge pull request Chora10#16 from melodyzx/master
Browse files Browse the repository at this point in the history
0426
  • Loading branch information
Chora10 committed May 11, 2016
2 parents 29280a0 + faa2556 commit b282ecb
Show file tree
Hide file tree
Showing 7 changed files with 180 additions and 136 deletions.
3 changes: 2 additions & 1 deletion src/com/ms509/ui/SetDBDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ private void setComponent()
case "JSP(Eval)":
// System.out.println("jsp");
dbtypes = new String[]{"<T>MYSQL</T><H>localhost</H><U>root</U><P>root</P><L>utf8</L>",
"<T>ORACLE</T><H>localhost:1443/test</H><U>root</U><P>root</P><M>database</M><L>utf8</L>"};
"<T>ORACLE</T><H>localhost:1443/test</H><U>root</U><P>root</P><M>database</M><L>utf8</L>",
"<T>MSSQL</T><H>localhost:1443/test</H><U>root</U><P>root</P><M>database</M><L>utf8</L>"};
// this.jsp();
break;
case "PHP(Eval)":
Expand Down
167 changes: 55 additions & 112 deletions src/com/ms509/ui/panel/ShellPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class ShellPanel extends JPanel {
private int os;
private String path = null;
private String path_bak = null;
private String path_show = null; //用于[/usr/]$显示
private String path_show = null; // 用于[/usr/]$显示
private int command_start;
private int command_stop;
private JToolBar bar;
Expand All @@ -45,6 +45,7 @@ public class ShellPanel extends JPanel {
private Shell core;
private Font shell_font = null;
private int num_t = 0;

public ShellPanel() {
// TODO Auto-generated constructor stub
// 控件初始化
Expand All @@ -62,32 +63,31 @@ public ShellPanel() {
// type = tmp[4];
code = tmp[5];
Safe.PASS = pass; // 初始化PASS常量
// System.out.println(type);
// 初始化脚本类型
switch (tmp[4]) {
case "JSP(Eval)":
// System.out.println("jsp");
type = 0;
// this.jsp();
break;
case "PHP(Eval)":
// System.out.println("php");
type = 1;
// this.php();
break;
case "ASP(Eval)":
// System.out.println("asp");
type = 2;
// this.asp();
break;
case "ASPX(Eval)":
// System.out.println("aspx");
type = 3;
break;
case "Customize": //添加自定义
type = 4;
break;
}

// core = new Shell(path,os,url,code,type1);
// System.out.println("asp11");
//System.out.println("asp11");
System.out.println("os0="+type);
core = new Shell(os, url, code, type);

// /
Expand All @@ -96,17 +96,16 @@ public ShellPanel() {
public void run() {
// 显示网站路径
path = core.GetPath();
System.out.println("path="+path);
System.out.println("path=" + path);
final String tmp = path.substring(0, path.length() - 1);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
if (tmp.indexOf("HTTP/1.")>-1 || tmp.indexOf("/") < 0 && tmp.indexOf("\\") < 0) {
new MessageDialog(tmp,5);
if (tmp.indexOf("HTTP/1.") > -1 || tmp.indexOf("/") < 0 && tmp.indexOf("\\") < 0) {
new MessageDialog(tmp, 5);
console.setEnabled(false);
} else {
try {
shell_doc.insertString(shell_doc.getLength(),
"\n" + path, null);
shell_doc.insertString(shell_doc.getLength(), "\n" + path, null);
} catch (BadLocationException e) {
}
}
Expand All @@ -119,36 +118,12 @@ public void run() {
}
});
thread_getpath.start();
// SwingUtilities.invokeLater(new Runnable(){
//
// @Override
// public void run() {
// // TODO Auto-generated method stub
// status.setText("正在执行...");
// path = core.GetPath();
//
//
// // 显示网站路径
//
// try {
// shell_doc.insertString(shell_doc.getLength(), "\n" + path, null);
// status.setText("完成");
// } catch (BadLocationException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// status.setText("获取shell失败");
// }
// }
//
// });

// 初始化布局和控件
this.setLayout(new GridBagLayout());
GBC gbcinfo = new GBC(0, 0, 6, 1).setFill(GBC.HORIZONTAL).setWeight(
100, 0);
GBC gbcinfo = new GBC(0, 0, 6, 1).setFill(GBC.HORIZONTAL).setWeight(100, 0);
GBC gbcconsole = new GBC(0, 1, 6, 1).setFill(GBC.BOTH).setWeight(0, 10);
GBC gbcbar = new GBC(0, 2, 6, 1).setFill(GBC.HORIZONTAL).setWeight(100,
0);
GBC gbcbar = new GBC(0, 2, 6, 1).setFill(GBC.HORIZONTAL).setWeight(100, 0);

// console.append("\n"+path);

Expand Down Expand Up @@ -203,13 +178,13 @@ public void check_path() {
if (!path.substring(path.length() - 1, path.length()).equals("\\")) {
path = path + "\\";
}
path_show = path +">";
path_show = path + ">";
} else {
Safe.SYSTEMSP = "/";
if (!path.substring(path.length() - 1, path.length()).equals("/")) {
path = path + "/";
}
path_show = "["+path+"]$";
path_show = "[" + path + "]$";
}

}
Expand Down Expand Up @@ -238,19 +213,16 @@ public void keyPressed(KeyEvent arg0) {
if (shell_doc.getLength() <= command_start) {
if (arg0.getKeyCode() == 8) {
try {
String t = shell_doc.getText(
console.getCaretPosition() - 1, 1);
String t = shell_doc.getText(console.getCaretPosition() - 1, 1);
// System.out.println("");
shell_doc.insertString(console.getCaretPosition(), t,
null);
shell_doc.insertString(console.getCaretPosition(), t, null);
} catch (Exception e) {

}
}
}

if (console.getCaretPosition() < command_start
|| console.getSelectionStart() < command_start
if (console.getCaretPosition() < command_start || console.getSelectionStart() < command_start
|| console.getSelectionEnd() < command_start) {
console.setEditable(false);
console.setCaretPosition(shell_doc.getLength());
Expand All @@ -270,19 +242,31 @@ public void keyReleased(KeyEvent arg0) {
command_stop = shell_doc.getLength();
// System.out.print(arg0.getKeyCode());
// System.out.println(path);
if (arg0.getKeyCode() == 10) {
if (arg0.getKeyCode() == 10) { // 判断回车
String tmp_cmd = null;
try {
tmp_cmd = shell_doc.getText(command_start, command_stop
- command_start);
tmp_cmd = shell_doc.getText(command_start, command_stop - command_start);
tmp_cmd = tmp_cmd.replace("\n", "").replace("\r", "");
if (tmp_cmd.equals("cls") || tmp_cmd.equals("clear")) {
if (tmp_cmd.equals("cls") || tmp_cmd.equals("clear")) { // 清空文本显示区域
shell_doc.remove(0, shell_doc.getLength());
shell_doc.insertString(0, "\n" + path, null);
command_start = shell_doc.getLength();

}

else {
else if(tmp_cmd.indexOf("setp")==0) //自定义路径
{
if(tmp_cmd.substring(0,4).equals("setp"))
{
String k = tmp_cmd.substring(5,tmp_cmd.length());
System.out.println("kkk="+k);
core.SetCMD(k);
shell_doc.insertString(shell_doc.getLength(), "\n设置命令路径为:"+k, null);
System.out.println("path="+path);
shell_doc.insertString(shell_doc.getLength(), "\n" + path+">", null);
command_start = shell_doc.getLength();
}
}
else { // 执行命令
// shell_doc.insertString(shell_doc.getLength(), "\n",
// null);
Thread exe = new Thread(new Runnable() {
Expand All @@ -291,66 +275,29 @@ public void keyReleased(KeyEvent arg0) {
@Override
public void run() {
// TODO Auto-generated method stub
SwingUtilities.invokeLater(new Runnable() {

@Override
public void run() {
num_t = 1;
status.setText("正在执行...请稍等");
try {
// Thread.sleep(10000);
execute(path, shell_doc.getText(
command_start, command_stop
- command_start), os, type);
} catch (Exception e) {
// TODO Auto-generated catch block
status.setText("执行失败");

console.setEditable(true);
} finally {
num_t = 0;
}
}
});


num_t = 1;
status.setText("正在执行...请稍等");
try {
// Thread.sleep(10000);
execute(path, shell_doc.getText(command_start, command_stop - command_start), os,
type);
} catch (Exception e) {
// TODO Auto-generated catch block
status.setText("执行失败");

console.setEditable(true);
} finally {
num_t = 0;
}
}

});
if (num_t == 0) {
exe.start();
System.out.println(1);
} else {
System.out.println(0);
}
// SwingUtilities.invokeLater(new Runnable() {
//
// @Override
// public void run() {
// // TODO Auto-generated method stub
// status.setText("正在执行");
//
// try {
// //Thread.sleep(10000);
// execute(path, shell_doc.getText(command_start,
// command_stop - command_start), os, type);
// } catch (Exception e) {
// // TODO Auto-generated catch block
// status.setText("执行失败");
// e.printStackTrace();
// try {
// shell_doc.insertString(shell_doc.getLength(),
// "\n"+path, null);
// } catch (BadLocationException e1) {
// // TODO Auto-generated catch block
// e1.printStackTrace();
// }
// }
// status.setText("完成");
// }
// });
// exe.start();
// execute(path, shell_doc.getText(command_start,
// command_stop - command_start), os, type);
}
last_commands.add(tmp_cmd);
num = last_commands.size();
Expand All @@ -364,10 +311,8 @@ public void run() {
if (arg0.getKeyCode() == KeyEvent.VK_UP) {
console.setCaretPosition(command_start);
try {
shell_doc.remove(command_start, shell_doc.getLength()
- command_start);
shell_doc
.insertString(command_start, key_up_action(), null);
shell_doc.remove(command_start, shell_doc.getLength() - command_start);
shell_doc.insertString(command_start, key_up_action(), null);
} catch (BadLocationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Expand All @@ -379,10 +324,8 @@ public void run() {
if (arg0.getKeyCode() == KeyEvent.VK_DOWN) {
console.setCaretPosition(command_start);
try {
shell_doc.remove(command_start, shell_doc.getLength()
- command_start);
shell_doc.insertString(command_start, key_down_action(),
null);
shell_doc.remove(command_start, shell_doc.getLength() - command_start);
shell_doc.insertString(command_start, key_down_action(), null);
} catch (BadLocationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Expand Down
27 changes: 22 additions & 5 deletions src/com/ms509/util/DataBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ private static void init(String config,int type) {
}

}
if(dbtype.equals("MSSQL"))
{
dbhost = config.substring(config.indexOf("<H>") + 3, config.indexOf("</H>"));
dbuser = config.substring(config.indexOf("<U>") + 3, config.indexOf("</U>"));
dbpass = config.substring(config.indexOf("<P>") + 3, config.indexOf("</P>"));
dbcode = config.substring(config.indexOf("<L>") + 3, config.indexOf("</L>"));
if (config.indexOf("<M>") > 0) {
dbmaster = config.substring(config.indexOf("<M>") + 3, config.indexOf("</M>"));
} else {
dbmaster = "";
}
}
break;
case 1://php
if (dbtype.equals("MYSQL")) {
Expand Down Expand Up @@ -172,11 +184,11 @@ public static String getTables(String url, String pass, String config, int type,
switch(type)
{
case 0: //jsp
if (dbtype.equals("MDB") || dbtype.equals("MSSQL")) {
if (dbtype.equals("MDB") ) {
result = exec_sql(url, pass, config, type, code, "", dbn);
}
else if(dbtype.equals("ORACLE")){
result = exec_sql(url, pass, config, type, code, "oracle_get_tables", dbn);
else if(dbtype.equals("ORACLE")|| dbtype.equals("MSSQL")){
result = exec_sql(url, pass, config, type, code, "get_tables", dbn);
}else
{
result = exec_sql(url, pass, config, type, code, s, dbn);
Expand Down Expand Up @@ -222,12 +234,17 @@ public static String exec_sql(String url, String pass, String config, int type,

}else if(dbtype.equals("MSSQL"))
{
if(sql.equals("get_tables"))
{
action = "O";
}
p1 = Safe.JSP_DB_MSSQL;
p1 = p1.replace("localhost", dbhost).replace("testdb", dbmaster).replace("username", dbuser).replace("userpwd",
p1 = p1.replace("localhost", dbhost).replace("testdb", dbn).replace("username", dbuser).replace("userpwd",
dbpass);
System.out.println(p1);
}else if(dbtype.equals("ORACLE"))
{
if(sql.equals("oracle_get_tables"))
if(sql.equals("get_tables"))
{
action = "O";
}
Expand Down
4 changes: 3 additions & 1 deletion src/com/ms509/util/FileManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ public String doAction(String... args) {
break;
case "readfile":
params = Safe.PASS+"="+Safe.ASP_MAKE.replace("PAYLOAD", Safe.ASP_READFILE)+"&"+Safe.PARAM1+"="+toHexString(path);
System.out.println(params);
break;
case "savefile":
params = Safe.PASS+"="+Safe.ASP_MAKE.replace("PAYLOAD", Safe.ASP_SAVEFILE)+"&"+Safe.PARAM1+"="+toHexString(path)+"&"+Safe.PARAM2+"="+this.makeParam2(data);
Expand Down Expand Up @@ -303,6 +304,7 @@ public String doAction(String... args) {
}
break;
}
System.out.println(params);
break;
case "PHP(Eval)":
switch (action) {
Expand Down Expand Up @@ -398,7 +400,7 @@ public String doAction(String... args) {
}
break;
}
// System.out.println(params);
System.out.println(params);
return Common.send(this.url, params, this.code);
}

Expand Down
Loading

0 comments on commit b282ecb

Please sign in to comment.