salut
j'ai creé une plateforme avec JApplet form et voici le code de ma plateforme
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package pfe1;
import java.util.HashMap;
import javax.swing.JOptionPane;
/**
*
* @author root
*/
public class index extends javax.swing.JApplet {
/**
* Initializes the applet index
*/
@Override
public void init() {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/ [...] /plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(index.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(index.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(index.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(index.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the applet */
try {
java.awt.EventQueue.invokeAndWait(new Runnable() {
public void run() {
initComponents();
}
});
} catch (Exception ex) {
ex.printStackTrace();
}
}
/**
* This method is called from within the init() method to initialize the
* form. WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked" )
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
bindingGroup = new org.jdesktop.beansbinding.BindingGroup();
jLabel1 = new javax.swing.JLabel();
login = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
pass = new javax.swing.JPasswordField();
outil = new javax.swing.JComboBox();
jLabel6 = new javax.swing.JLabel();
org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, new javax.swing.JLabel(), org.jdesktop.beansbinding.ObjectProperty.create(), this, org.jdesktop.beansbinding.BeanProperty.create("visible" ));
bindingGroup.addBinding(binding);
getContentPane().setLayout(null);
jLabel1.setForeground(java.awt.Color.orange);
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText("Bienvennue dans Ma Plateforme " );
jLabel1.setBorder(null);
jLabel1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
jLabel1.setMaximumSize(new java.awt.Dimension(400, 40));
jLabel1.setName("" ); // NOI18N
getContentPane().add(jLabel1);
jLabel1.setBounds(230, 20, 320, 60);
jLabel1.getAccessibleContext().setAccessibleDescription("" );
login.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
loginActionPerformed(evt);
}
});
getContentPane().add(login);
login.setBounds(360, 120, 160, 26);
jLabel2.setForeground(java.awt.Color.orange);
jLabel2.setText("Login" );
getContentPane().add(jLabel2);
jLabel2.setBounds(290, 120, 36, 30);
jLabel3.setForeground(java.awt.Color.orange);
jLabel3.setText("Password" );
getContentPane().add(jLabel3);
jLabel3.setBounds(280, 180, 70, 16);
jLabel4.setForeground(java.awt.Color.orange);
jLabel4.setText("choisir l'outil" );
getContentPane().add(jLabel4);
jLabel4.setBounds(240, 230, 100, 16);
jButton1.setText("Valider" );
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
getContentPane().add(jButton1);
jButton1.setBounds(350, 290, 80, 28);
jButton2.setText("Annuler" );
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
getContentPane().add(jButton2);
jButton2.setBounds(450, 290, 90, 28);
getContentPane().add(pass);
pass.setBounds(360, 170, 160, 26);
outil.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Nessus", "Nmap" }));
getContentPane().add(outil);
outil.setBounds(360, 230, 150, 26);
jLabel6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pfe1/kali-linux.jpg" ))); // NOI18N
getContentPane().add(jLabel6);
jLabel6.setBounds(0, 0, 750, 370);
bindingGroup.bind();
}// </editor-fold>
private void loginActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String ps=new String(this.pass.getPassword());
String lg=this.login.getText().trim();
if (((ps.equals("" ))&&(lg.equals("" ))) || (!lg.equals(ps))) {
JOptionPane.showMessageDialog(null, " Invalid Mot de Pass et Login", "Error", JOptionPane.ERROR_MESSAGE);
} else {
if ( lg.equals("admin" ) && ps.equals("admin" ))
{
int nb =outil.getSelectedIndex();
if (nb==0)
{
}
}
}
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
login.setText("" );
pass.setText("" );
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel6;
private javax.swing.JTextField login;
private javax.swing.JComboBox outil;
private javax.swing.JPasswordField pass;
private org.jdesktop.beansbinding.BindingGroup bindingGroup;
// End of variables declaration
}
je veux s'avoir comment faire appeler une class Nessus dans JApplet form et merci pour votre collaboration
voici le class Nessus
package pfe1;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Nessus {
public static void main(String[] args) {
Nessus obj = new Nessus();
String command = "/etc/init.d/nessusd start";
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();
}
}