1-je veux que mon code Nessus.java est exécuté lorssque j'appuis sur le boutton html ok .Je souhaiterais que tu teste ce deux code et tu va comprendre mieuxCode HTML:index.html <html> <head> <script type="text/javascript"> function verif() { if((f.log.value)!==(f.pass.value)) { alert("mot de pass et login invaldes" ) } else if((f.log.value=="" ) && (f.pass.value=="" )) { alert("le login et mot de pass sont vide" ); } else if ((f.log.value="admin" ) && (f.pass.value="admin" )) { if (f.liste[0].selected) alert("Nesus" ) else window.open('nmap.html') } obj=new packages.com.outil.scan.Nessus(); } </script> </head> <body background="kali-linux.jpg"> <div><h1><center><font Color="#FFFF00"><marquee >Bienvenue dans Ma Plateforme</font></h1></center></marquee></div> <center> <form name="f"> <table> <TR><TD align='right'><font Color="#FFFF00">Votre Login</font></TD><TD><INPUT size=12 name='log'></TD></TR> <TR><TD align='right'><font Color="#FFFF00">Votre mot de passe</font></TD><TD><INPUT type=password size=12 name='pass'></TD></TR> <tr><td><font Color="#FFFF00">Choisir une outil</font></td> <td> <select name="liste"> <option value="Nessus">Nessus</option> <option value="Nmap">Nmap</option> </select> </td> </tr> <tr><td></td><td> <p> <input type="submit" value="ok" onclick=verif()> <input type="reset" value="Annuler" ></p> </td></tr> </table> </form> </center> </body> </html> Nessus.java package com.outil.scan; import java.io.BufferedReader; import java.io.InputStreamReader; public class Nessus { public static void main(String[] args) { Nessus obj = new Nessus(); //in mac oxs String command = "/etc/init.d/nessusd start"; String command1= "iceweasel www.google.fr" ; //in windows //String command = "ping -n 3 " + domainName; String output = obj.executeCommand(command); System.out.println(output); } private String executeCommand(String command1) { StringBuffer output = new StringBuffer(); Process p; Runtime r = Runtime.getRuntime(); try { r.exec(" iceweasel https://kali:8834/html5.html#/scans" ); p = Runtime.getRuntime().exec(command1); p.waitFor(); BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream())); String line = ""; while ((line = reader.readLine())!= null) { output.append(line + "\n" ); } } catch (Exception e) { e.printStackTrace(); } return output.toString(); } }
2- comme pour mon premier demande (éxècute le code java dans boutton html) mais je souhaiterais que le résultat de nmap.java est affiche dans le textareaCode HTML:code nmap.html <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body background="kali-linux.jpg"> <div><h1><center><font Color="#FFFF00">Nmap</font></h1></center></div> <center><textarea cols="60" rows="20"></textarea></center><p></p> <center><input type="submit" value="Valider"></center> </body> </html> code nmap.java package com.outil.scan; import java.io.BufferedReader; import java.io.InputStreamReader; public class Nmap { public static void main(String[] args) { Nmap obj = new Nmap(); //in mac oxs String command = "nmap 192.168.1.2 "; //in windows //String command = "ping -n 3 " + domainName; String output = obj.executeCommand(command); System.out.println(output); } private String executeCommand(String command) { StringBuffer output = new StringBuffer(); Process p; try { p = Runtime.getRuntime().exec(command); p.waitFor(); BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream())); String line = ""; while ((line = reader.readLine())!= null) { output.append(line + "\n" ); } } catch (Exception e) { e.printStackTrace(); } return output.toString(); } }
et merci pour votre collaboration
-----