Ejemplo n.º 1
0
  public void actionPerformed(ActionEvent evt) {
    String cmd = evt.getActionCommand();

    if (cmd.equals("Open")) {

      this.captor.loadPacketsFromFile();

    } else if (cmd.equals("Save")) {

      this.captor.saveToFile();

    } else if (cmd.equals("NewWin")) {

      JpcapDumper.openNewWindow();
    } else if (cmd.equals("Exit")) {

      saveProperty();
      System.exit(0);

    } else if (cmd.equals("Start")) {

      this.captor.capturePacketsFromDevice();

    } else if (cmd.equals("Stop")) {

      this.captor.stopCapture();
    } else if (cmd.startsWith("CUMSTAT")) {

      int index = Integer.parseInt(cmd.substring(7));
      this.captor.addCumulativeStatFrame(JDStatisticsTakerLoader.getStatisticsTakerAt(index));

    } else if (cmd.startsWith("CONSTAT")) {

      int index = Integer.parseInt(cmd.substring(7));
      this.captor.addContinuousStatFrame(JDStatisticsTakerLoader.getStatisticsTakerAt(index));

    } else if (cmd.equals("Add New Rules")) {
      new RuleAdd("Add new rule");

    } else if (cmd.equals("Show All Rules")) {
      new MysqlRetrieve("All Rules");

    } else if (cmd.equals("Intruder")) {
      new IntruderList("Warning!!!!");
    }
  }
Ejemplo n.º 2
0
  public JDFrame(JDCaptor captor) {
    this.captor = captor;
    this.tablePane = new JDTablePane(captor);
    captor.setJDFrame(this);

    setTitle("Network Intrusion Detection Syetem");

    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);

    JMenu menu = new JMenu("System");
    menuBar.add(menu);
    JMenuItem item = new JMenuItem("New Window");
    item.setActionCommand("NewWin");
    item.addActionListener(this);
    menu.add(item);
    item = new JMenuItem("Exit");
    item.setActionCommand("Exit");
    item.addActionListener(this);
    menu.add(item);

    menu = new JMenu("File");
    menuBar.add(menu);
    this.openMenu = new JMenuItem("Open");

    this.openMenu.setActionCommand("Open");
    this.openMenu.addActionListener(this);
    menu.add(this.openMenu);
    this.saveMenu = new JMenuItem("Save");

    this.saveMenu.setActionCommand("Save");
    this.saveMenu.addActionListener(this);
    this.saveMenu.setEnabled(false);
    menu.add(this.saveMenu);

    // this is for Capture Operations
    menu = new JMenu("Capture");
    menuBar.add(menu);
    this.captureMenu = new JMenuItem("Start");

    this.captureMenu.setActionCommand("Start");
    this.captureMenu.addActionListener(this);
    menu.add(this.captureMenu);
    this.stopMenu = new JMenuItem("Stop");

    this.stopMenu.setActionCommand("Stop");
    this.stopMenu.addActionListener(this);
    this.stopMenu.setEnabled(false);
    menu.add(this.stopMenu);

    // to know the statistics like pie graph and X-Y graph
    this.statMenu = new JMenu("Statistics");
    menuBar.add(this.statMenu);
    menu = new JMenu("Cumulative");
    this.statMenu.add(menu);
    List stakers = JDStatisticsTakerLoader.getStatisticsTakers();
    for (int i = 0; i < stakers.size(); i++) {
      item = new JMenuItem(((JDStatisticsTaker) stakers.get(i)).getName());
      item.setActionCommand("CUMSTAT" + i);
      item.addActionListener(this);
      menu.add(item);
    }
    menu = new JMenu("Continuous");
    this.statMenu.add(menu);
    for (int i = 0; i < stakers.size(); i++) {
      item = new JMenuItem(((JDStatisticsTaker) stakers.get(i)).getName());
      item.setActionCommand("CONSTAT" + i);
      item.addActionListener(this);
      menu.add(item);
    }

    //  this is for all statistics of the system
    menu = new JMenu("View");
    menuBar.add(menu);
    this.tablePane.setTableViewMenu(menu);

    //  this is for the Signature Operations
    menu = new JMenu("Signature Operations");
    menuBar.add(menu);
    ruleAdd = new JMenuItem("Add New Rules");
    menu.add(ruleAdd);
    this.ruleAdd.addActionListener(this);

    ruleShow = new JMenuItem("Show All Rules");
    menu.add(ruleShow);
    this.ruleShow.addActionListener(this);

    //  this is for alet info
    menu = new JMenu("Intruder Info");
    menuBar.add(menu);
    alertMessage = new JMenuItem("Intruder");
    menu.add(alertMessage);
    this.alertMessage.addActionListener(this);

    JToolBar toolbar = new JToolBar();
    toolbar.setFloatable(false);
    this.openButton = new JButton(getImageIcon("/image/open.gif"));
    this.openButton.setActionCommand("Open");
    this.openButton.addActionListener(this);
    toolbar.add(this.openButton);
    this.saveButton = new JButton(getImageIcon("/image/save.gif"));
    this.saveButton.setActionCommand("Save");
    this.saveButton.addActionListener(this);
    this.saveButton.setEnabled(false);
    toolbar.add(this.saveButton);
    toolbar.addSeparator();
    this.captureButton = new JButton(getImageIcon("/image/capture.gif"));
    this.captureButton.setActionCommand("Start");
    this.captureButton.addActionListener(this);
    toolbar.add(this.captureButton);
    this.stopButton = new JButton(getImageIcon("/image/stopcap.gif"));
    this.stopButton.setActionCommand("Stop");
    this.stopButton.addActionListener(this);
    this.stopButton.setEnabled(false);
    toolbar.add(this.stopButton);

    this.statusLabel = new JLabel(" Intrusion Detection System started.");

    getContentPane().setLayout(new BorderLayout());

    getContentPane().add(this.statusLabel, "South");
    getContentPane().add(this.tablePane, "Center");
    // getContentPane().add(toolbar, "North");

    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent evt) {
            JDFrame.this.saveProperty();
            JpcapDumper.closeWindow((JDFrame) evt.getSource());
          }
        });
    loadProperty();
  }