From 84f7df7daaa23d40f2519f79101442eda59663a2 Mon Sep 17 00:00:00 2001 From: zzz <534700646@qq.com> Date: Thu, 20 Jun 2024 10:32:08 +0800 Subject: [PATCH 1/3] add test cmd --- java-sec-code.iml | 14 -------- src/main/java/org/joychou/cmd/testRun.java | 40 ++++++++++++++++++++++ src/main/resources/application.properties | 4 +-- 3 files changed, 42 insertions(+), 16 deletions(-) delete mode 100644 java-sec-code.iml create mode 100644 src/main/java/org/joychou/cmd/testRun.java diff --git a/java-sec-code.iml b/java-sec-code.iml deleted file mode 100644 index 5c58c92b..00000000 --- a/java-sec-code.iml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/main/java/org/joychou/cmd/testRun.java b/src/main/java/org/joychou/cmd/testRun.java new file mode 100644 index 00000000..bd8389e7 --- /dev/null +++ b/src/main/java/org/joychou/cmd/testRun.java @@ -0,0 +1,40 @@ +package org.joychou.cmd; + +import org.joychou.util.WebUtils; + +import java.io.IOException; + +public class testRun { + public static void main(String[] args) throws IOException { + String filepath = "/tmp; open /System/Applications/Calculator.app"; + String[] cmdList = new String[]{"sh", "-c", "ls -la " + filepath}; + //String[] cmdList = new String[]{"cmd.exe", "-c", "dir " + filepath}; + ProcessBuilder builder = new ProcessBuilder(cmdList); + builder.redirectErrorStream(true); + Process process = builder.start(); + String result = WebUtils.convertStreamToString(process.getInputStream()); + System.out.println(result); + } + +// public static void main(String[] args) throws IOException { +// String path = "ls-l; /System/Applications/Calculator.app"; +// String[] cmd = { "open", path }; +// +// Runtime.getRuntime().exec(cmd); +// } + +// public static void main(String[] args) throws IOException, InterruptedException { +// String path = "/System/Applications/Calculator.app/Contents/MacOS/"; +// String[] cmd1 = { "ls", "-l", path }; +// +// ProcessBuilder pb1 = new ProcessBuilder(cmd1); +// Process process1 = pb1.start(); +// process1.waitFor(); +// +// String[] cmd2 = { "open", "/System/Applications/Calculator.app" }; +// +// ProcessBuilder pb2 = new ProcessBuilder(cmd2); +// Process process2 = pb2.start(); +// process2.waitFor(); +// } +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 326a2b76..fd8897e8 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,7 +1,7 @@ spring.datasource.url=jdbc:mysql://localhost:3306/java_sec_code?allowPublicKeyRetrieval=true&useSSL=false&serverTimezone=UTC spring.datasource.username=root -spring.datasource.password=woshishujukumima +spring.datasource.password=zzz@2160 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver mybatis.mapper-locations=classpath:mapper/*.xml # mybatis SQL log @@ -56,4 +56,4 @@ joychou.no.need.login.url = /css/**, /js/**, /xxe/**, /rce/**, /deserialize/**, # Fake aksk. Simulate actuator info leak. jsc.accessKey.id=LTAI5tSAEPX3Z5N2Yt8ogc2y -jsc.accessKey.secret=W1Poxj09wN0Zu6dDsS0on3SIUhOhK7 \ No newline at end of file +jsc.accessKey.secret=W1Poxj09wN0Zu6dDsS0on3SIUhOhK7 From 245db17574c1ccefd62d066e4a6e367e1df0b8e4 Mon Sep 17 00:00:00 2001 From: zzz <534700646@qq.com> Date: Thu, 20 Jun 2024 10:32:32 +0800 Subject: [PATCH 2/3] add test cmd --- src/main/java/org/joychou/cmd/testRun.java | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/src/main/java/org/joychou/cmd/testRun.java b/src/main/java/org/joychou/cmd/testRun.java index bd8389e7..df861eb5 100644 --- a/src/main/java/org/joychou/cmd/testRun.java +++ b/src/main/java/org/joychou/cmd/testRun.java @@ -16,25 +16,4 @@ public static void main(String[] args) throws IOException { System.out.println(result); } -// public static void main(String[] args) throws IOException { -// String path = "ls-l; /System/Applications/Calculator.app"; -// String[] cmd = { "open", path }; -// -// Runtime.getRuntime().exec(cmd); -// } - -// public static void main(String[] args) throws IOException, InterruptedException { -// String path = "/System/Applications/Calculator.app/Contents/MacOS/"; -// String[] cmd1 = { "ls", "-l", path }; -// -// ProcessBuilder pb1 = new ProcessBuilder(cmd1); -// Process process1 = pb1.start(); -// process1.waitFor(); -// -// String[] cmd2 = { "open", "/System/Applications/Calculator.app" }; -// -// ProcessBuilder pb2 = new ProcessBuilder(cmd2); -// Process process2 = pb2.start(); -// process2.waitFor(); -// } } From d44f300bcd803489a01d85b4379fe43051f9ffbf Mon Sep 17 00:00:00 2001 From: zzz <534700646@qq.com> Date: Tue, 6 Aug 2024 17:06:36 +0800 Subject: [PATCH 3/3] first commit bei fen --- .../java/org/joychou/controller/TestXXE.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/main/java/org/joychou/controller/TestXXE.java diff --git a/src/main/java/org/joychou/controller/TestXXE.java b/src/main/java/org/joychou/controller/TestXXE.java new file mode 100644 index 00000000..5773270d --- /dev/null +++ b/src/main/java/org/joychou/controller/TestXXE.java @@ -0,0 +1,30 @@ +package org.joychou.controller; + +import org.dom4j.Document; +import org.dom4j.Node; +import org.dom4j.io.SAXReader; + +import java.io.StringReader; + +public class TestXXE { + public static void main(String[] args) { + String xml = "\n" + + " ]>\n" + + "\n" + + "\n" + + "&xxe;\n" + + "test\n" + + "test\n" + + "\n" + + ""; + + try { + SAXReader reader = new SAXReader(); + Document document = reader.read(new StringReader(xml)); + Node node = document.selectSingleNode("//kpserver/Input/Nsrsbh_JX"); + System.out.println(node.getText()); + } catch (Exception e) { + e.printStackTrace(); + } + } +}