Skip to content

Commit

Permalink
Merge pull request Chora10#21 from melodyzx/master
Browse files Browse the repository at this point in the history
20160623 17:06
  • Loading branch information
Chora10 authored Jun 23, 2016
2 parents d5c4795 + 0f0ff7d commit aad900c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 33 deletions.
27 changes: 5 additions & 22 deletions src/com/ms509/ui/panel/ShellPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ public ShellPanel() {
}

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

// /
Expand All @@ -102,7 +100,6 @@ public void run() {
// 显示网站路径
path = core.GetPath();
check_path();
System.out.println("path=" + path);
final String tmp = path.substring(0, path.length() - 1);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
Expand Down Expand Up @@ -163,7 +160,6 @@ public void run() {

shell_font = new Font("幼圆", Font.BOLD, 12);
console.setFont(new Font("幼圆", Font.BOLD, 12));
// System.out.println("start=" + shell_doc.getLength());
command_start = shell_doc.getLength();
}

Expand Down Expand Up @@ -200,7 +196,6 @@ private class textareaFocus extends FocusAdapter {
@Override
public void focusGained(FocusEvent e) {
// TODO Auto-generated method stub
// System.out.println("text console get focus");
console.requestFocus();
console.setCaretPosition(shell_doc.getLength());
}
Expand All @@ -212,12 +207,10 @@ private class textareaKey extends KeyAdapter {
@Override
public void keyPressed(KeyEvent arg0) {
// TODO Auto-generated method stub
System.out.println("arg0="+arg0.getKeyCode());
if (shell_doc.getLength() <= command_start && !arg0.isControlDown()) {
if (arg0.getKeyCode() == 8) {
try {
String t = shell_doc.getText(console.getCaretPosition() - 1, 1);
// System.out.println("");
shell_doc.insertString(console.getCaretPosition(), t, null);
} catch (Exception e) {

Expand Down Expand Up @@ -247,8 +240,6 @@ public void keyPressed(KeyEvent arg0) {
@Override
public void keyReleased(KeyEvent arg0) {
command_stop = shell_doc.getLength();
// System.out.print(arg0.getKeyCode());
// System.out.println(path);
if (arg0.getKeyCode() == 10) { // 判断回车
String tmp_cmd = null;
try {
Expand All @@ -269,10 +260,8 @@ 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();
}
Expand Down Expand Up @@ -305,9 +294,7 @@ public void run() {
});
if (num_t == 0) {
exe.start();
System.out.println(1);
} else {
System.out.println(0);
}
}
last_commands.add(tmp_cmd);
Expand All @@ -328,7 +315,7 @@ public void run() {
// TODO Auto-generated catch block
e.printStackTrace();
}
// System.out.println("shang");

}

// 翻看命令记录(下)
Expand All @@ -341,7 +328,7 @@ public void run() {
// TODO Auto-generated catch block
e.printStackTrace();
}
// System.out.println("xia");

}

}
Expand All @@ -358,13 +345,13 @@ public void execute(String pa, String command, int os, int type) {

path = result[1];
// check_path();
// System.out.println("path=" + path + "\n");

check_path();
shell_doc.insertString(shell_doc.getLength(), "\n" + path_show, null);
command_start = shell_doc.getLength();
console.setCaretPosition(shell_doc.getLength());
status.setText("完成");
// System.out.println("caret text");

} catch (Exception e) {
// TODO Auto-generated catch block
status.setText("执行失败");
Expand All @@ -378,11 +365,9 @@ public void execute(String pa, String command, int os, int type) {
public String key_up_action() {
num = num - 1;
String last_command = null;
// System.out.println(num);
if (num >= 0) {
if (num >= 0 && !last_commands.isEmpty()) {
last_command = last_commands.get(num);
last_command = last_command.replace("\n", "").replace("\r", "");
// System.out.println(last_command);
return last_command;
} else {
return "";
Expand All @@ -394,11 +379,9 @@ public String key_up_action() {
public String key_down_action() {
num = num + 1;
String last_command = null;
// System.out.println(num);
if (num < last_commands.size() && num >= 0) {
last_command = last_commands.get(num);
last_command = last_command.replace("\n", "").replace("\r", "");
// System.out.println(last_command);
return last_command;
} else if (num < 0) {
num = 0;
Expand Down
12 changes: 1 addition & 11 deletions src/com/ms509/util/Shell.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private String[] execute_asp(String command) {
} catch (Exception e) {

}
System.out.println(params);
//System.out.println(params);
return re;
}

Expand Down Expand Up @@ -149,7 +149,6 @@ private String[] execute_aspx(String command) {
String[] index_datas = Common.send(url, params, code).split("\t");
re[0] = Arrays.toString(index_datas);
re[0] = re[0].substring(re[0].indexOf("[") + 1, re[0].indexOf("[S]"));
System.out.println(params);
String path = Arrays.toString(index_datas).substring(Arrays.toString(index_datas).indexOf("[S]") + 3,
Arrays.toString(index_datas).indexOf("[E]"));
re[1] = path;
Expand Down Expand Up @@ -191,11 +190,9 @@ private String[] execute_php(String command) {
}
tmp = (new BASE64Encoder().encode(z12)).toString() + "&"+Safe.PARAM2+"=" + (new BASE64Encoder().encode(z22)).toString();
params = Common.makeParams(Safe.PHP_MAKE, Safe.PHP_SHELL, tmp);
System.out.println("params_php="+params);
String[] index_datas = Common.send(url, params, code).split("\t");
String result = null;
result = Arrays.toString(index_datas);
System.out.println("phpresult="+result);
re[0] = result.substring(result.indexOf("[") + 1, result.indexOf("[S]"));
re[1] = Arrays.toString(index_datas).substring(Arrays.toString(index_datas).indexOf("[S]") + 3,
Arrays.toString(index_datas).indexOf("[E]"));
Expand Down Expand Up @@ -251,13 +248,11 @@ private String[] execute_jsp(String command) {
String[] index_datas = Common.send(url, params, code).split("\t");
String result = null;
result = Arrays.toString(index_datas);
System.out.println(result);
re[0] = result.substring(result.indexOf("[") + 1, result.indexOf("[S]"));
if(result.indexOf("[E]")+3<(result.length()-1))
{
String erroroutput = result.substring(result.indexOf("[E]") + 3, (result.length()-1));
re[0] = re[0] + erroroutput;
System.out.println("r0="+re[0]);
}
re[1] = Arrays.toString(index_datas).substring(Arrays.toString(index_datas).indexOf("[S]") + 3,
Arrays.toString(index_datas).indexOf("[E]"));
Expand Down Expand Up @@ -287,13 +282,10 @@ private String[] execute_cus(String command) {
//params = Common.makeParams(Safe.CUS_MAKE, Safe.CUS_SHELL,URLEncoder.encode(z1),URLEncoder.encode(z2),URLEncoder.encode(pa));
params = Safe.PASS+"=1&"+Safe.ACTION+"="+Safe.CUS_SHELL+"&"+Safe.PARAM1+"="+URLEncoder.encode(z1)+"&"+Safe.PARAM2+"="
+URLEncoder.encode(z2)+"&"+Safe.PARAM3+"="+URLEncoder.encode(pa);
System.out.println("cusshell="+params);
String[] index_datas = Common.send(url, params, code).split("\t");
String result = Arrays.toString(index_datas);
System.out.println("res="+result);
String spl = Safe.CUS_SHELL_SPL;
String spr = Safe.CUS_SHELL_SPR;
System.out.println("spl="+spl+"|"+spr);
re[0] = result.substring(result.indexOf("[") + 1, result.indexOf(spl));
re[1] = Arrays.toString(index_datas).substring(Arrays.toString(index_datas).indexOf(spl) + spl.length(),
Arrays.toString(index_datas).indexOf(spr));
Expand Down Expand Up @@ -352,11 +344,9 @@ public String GetPath() {
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("init shell="+params);
String[] index_datas = Common.send(url, params, code).split("\t");
String webroot = index_datas[0];
pa = webroot;
System.out.println(pa);
if (webroot.contains(":")) // windows系统
{
Safe.SYSTEMSP = "\\";
Expand Down

0 comments on commit aad900c

Please sign in to comment.