File tree Expand file tree Collapse file tree 4 files changed +61
-1
lines changed
src/main/java/org/joychou/controller Expand file tree Collapse file tree 4 files changed +61
-1
lines changed Original file line number Diff line number Diff line change 11.idea /
22.DS_Store
33target /
4+ * .iml
Original file line number Diff line number Diff line change 55 <configuration />
66 </facet >
77 </component >
8- <component name =" NewModuleRootManager" LANGUAGE_LEVEL =" JDK_1_6 " >
8+ <component name =" NewModuleRootManager" LANGUAGE_LEVEL =" JDK_1_8 " >
99 <output url =" file://$MODULE_DIR$/target/classes" />
1010 <output-test url =" file://$MODULE_DIR$/target/test-classes" />
1111 <content url =" file://$MODULE_DIR$" >
Original file line number Diff line number Diff line change 1+ package org .joychou .controller ;
2+
3+ import org .springframework .stereotype .Controller ;
4+ import org .springframework .web .bind .annotation .RequestMapping ;
5+ import org .springframework .web .bind .annotation .ResponseBody ;
6+
7+ import javax .servlet .http .HttpServletRequest ;
8+ import java .io .BufferedInputStream ;
9+ import java .io .BufferedReader ;
10+ import java .io .InputStreamReader ;
11+
12+ /**
13+ * author: JoyChou ([email protected] ) 14+ * date: 2018.05.24
15+ * desc: java xxe vuls code
16+ * fix: filter parameters
17+ */
18+
19+ @ Controller
20+ @ RequestMapping ("/rce" )
21+ public class Rce {
22+
23+ @ RequestMapping ("/exec" )
24+ @ ResponseBody
25+ public String CommandExec (HttpServletRequest request ){
26+ String cmd = request .getParameter ("cmd" ).toString ();
27+ Runtime run = Runtime .getRuntime ();
28+ try {
29+ Process p = run .exec (cmd );
30+ BufferedInputStream in = new BufferedInputStream (p .getInputStream ());
31+ BufferedReader inBr = new BufferedReader (new InputStreamReader (in ));
32+ String lineStr ;
33+ while ((lineStr = inBr .readLine ()) != null )
34+ return lineStr ;
35+ if (p .waitFor () != 0 ) {
36+ if (p .exitValue () == 1 )
37+ return "command exec failed" ;
38+ }
39+ inBr .close ();
40+ in .close ();
41+ } catch (Exception e ) {
42+ e .printStackTrace ();
43+ return "Except" ;
44+ }
45+ return "Cmd exec success." ;
46+ }
47+ }
48+
Original file line number Diff line number Diff line change 11package org .joychou .controller ;
22
3+ import com .sun .corba .se .impl .ior .OldJIDLObjectKeyTemplate ;
34import org .springframework .stereotype .*;
45import org .springframework .web .bind .annotation .*;
56import javax .servlet .http .HttpServletRequest ;
67import org .w3c .dom .Document ;
78import org .xml .sax .helpers .XMLReaderFactory ;
89import org .xml .sax .XMLReader ;
910import java .io .StringReader ;
11+ import java .net .URL ;
12+
1013import org .xml .sax .InputSource ;
14+
15+ import javax .xml .bind .JAXBContext ;
16+ import javax .xml .bind .Unmarshaller ;
1117import javax .xml .parsers .DocumentBuilder ;
1218import javax .xml .parsers .DocumentBuilderFactory ;
1319import javax .xml .parsers .SAXParserFactory ;
1420import javax .xml .parsers .SAXParser ;
21+ import javax .xml .transform .stream .StreamSource ;
22+
1523import org .xml .sax .helpers .DefaultHandler ;
1624import org .apache .commons .digester3 .Digester ;
1725
@@ -104,4 +112,7 @@ public static String xxe_DocumentBuilder(HttpServletRequest request) {
104112 return "except" ;
105113 }
106114 }
115+
116+
117+
107118}
You can’t perform that action at this time.
0 commit comments