All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sittinglittleduck.DirBuster.gui.JPanelReport Maven / Gradle / Ivy

Go to download

DirBuster is a multi threaded java application designed to brute force directories and files names on web/application servers. Often is the case now of what looks like a web server in a state of default installation is actually not, and has pages and applications hidden within. DirBuster attempts to find these.

The newest version!
/*
 * JPanelReport.java
 *
 * Copyright 2007 James Fisher
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
 */
package com.sittinglittleduck.DirBuster.gui;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

import javax.swing.JFileChooser;
import javax.swing.JOptionPane;

import com.sittinglittleduck.DirBuster.ReportWriter;

public class JPanelReport extends javax.swing.JPanel
{

    private StartGUI parent;

    /**
     * Creates new form JPanelReport
     */
    public JPanelReport(StartGUI parent)
    {
        this.parent = parent;
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // //GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel2 = new javax.swing.JLabel();
        jTextFieldReportFile = new javax.swing.JTextField();
        jButtonReportBrowse = new javax.swing.JButton();
        jButtonGenerate = new javax.swing.JButton();
        jButtonReportExit = new javax.swing.JButton();
        jButtonReportNew = new javax.swing.JButton();
        jButtonBack = new javax.swing.JButton();

        jLabel2.setText("Please select the location to write the report to");

        jButtonReportBrowse.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/sittinglittleduck/DirBuster/gui/icons/system-search.png"))); // NOI18N
        jButtonReportBrowse.setText("Browse");
        jButtonReportBrowse.setToolTipText("Browse location to save reports to");
        jButtonReportBrowse.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonReportBrowseActionPerformed(evt);
            }
        });

        jButtonGenerate.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/sittinglittleduck/DirBuster/gui/icons/txt.png"))); // NOI18N
        jButtonGenerate.setText("Generate Report");
        jButtonGenerate.setToolTipText("Click to generate reports");
        jButtonGenerate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonGenerateActionPerformed(evt);
            }
        });

        jButtonReportExit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/sittinglittleduck/DirBuster/gui/icons/door_out.png"))); // NOI18N
        jButtonReportExit.setText("Exit");
        jButtonReportExit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonReportExitActionPerformed(evt);
            }
        });

        jButtonReportNew.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/sittinglittleduck/DirBuster/gui/icons/window-new.png"))); // NOI18N
        jButtonReportNew.setText("New Test");
        jButtonReportNew.setMaximumSize(new java.awt.Dimension(79, 25));
        jButtonReportNew.setMinimumSize(new java.awt.Dimension(79, 25));
        jButtonReportNew.setPreferredSize(new java.awt.Dimension(79, 25));
        jButtonReportNew.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonReportNewActionPerformed(evt);
            }
        });

        jButtonBack.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/sittinglittleduck/DirBuster/gui/icons/go-previous.png"))); // NOI18N
        jButtonBack.setText("Back");
        jButtonBack.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonBackActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 390, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                        .add(jTextFieldReportFile, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 450, Short.MAX_VALUE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(jButtonReportBrowse)
                        .add(33, 33, 33))
                    .add(layout.createSequentialGroup()
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jButtonGenerate, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 150, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 252, Short.MAX_VALUE)
                        .add(jButtonBack)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jButtonReportNew, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 98, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(6, 6, 6)))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jButtonReportExit, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 70, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(71, 71, 71)
                .add(jLabel2)
                .add(6, 6, 6)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jTextFieldReportFile, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jButtonReportBrowse))
                .add(49, 49, 49)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jButtonGenerate)
                    .add(jButtonReportExit)
                    .add(jButtonReportNew, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jButtonBack)))
        );
    }// //GEN-END:initComponents
    private void jButtonReportNewActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonReportNewActionPerformed
    {//GEN-HEADEREND:event_jButtonReportNewActionPerformed
        //start a new test

        //clear the results table
        parent.jPanelRunning.resultsTableModel.clearData();
        //show the setup panel
        parent.showSetup();
    }//GEN-LAST:event_jButtonReportNewActionPerformed

    private void jButtonReportExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonReportExitActionPerformed
        System.exit(0);
    }//GEN-LAST:event_jButtonReportExitActionPerformed

    private void jButtonReportBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonReportBrowseActionPerformed
        File dir = new File(System.getProperty("user.dir"));
        JFileChooser fc = new JFileChooser(dir);
        fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        fc.setDialogTitle("Please Select The Localtion To Save The Report To");
        int returnVal = fc.showDialog(fc, "Select Directory");
        if(returnVal == JFileChooser.APPROVE_OPTION)
        {
            File file = fc.getSelectedFile();
            jTextFieldReportFile.setText(file.getAbsolutePath() + "/DirBusterReport-" + parent.manager.getHost() + "-" + parent.manager.getPort() +".txt");
        }
    }//GEN-LAST:event_jButtonReportBrowseActionPerformed

    private void jButtonGenerateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonGenerateActionPerformed

        //try to read from the file before we write to it
        int n = 0;
        try
        {
            //write the report
            FileInputStream filein = new FileInputStream(jTextFieldReportFile.getText());

            //file is already there then inform the user

            n = JOptionPane.showConfirmDialog(
                    this,
                    "Report file already there.",
                    "Over write it?",
                    JOptionPane.YES_NO_OPTION);
        //if the anwser is yes
        }
        catch(FileNotFoundException ex)
        {
        //do nothing as the file is not there
        }


        if(n == 0)
        {
            //catch error when no file name is given

            if(jTextFieldReportFile.getText() == null)
            {
                JOptionPane.showMessageDialog(
                        this,
                        "Please enter the location of where you wish the report to be writen to.",
                        "Error",
                        JOptionPane.ERROR_MESSAGE);
                return;
            }

            if(jTextFieldReportFile.getText().equalsIgnoreCase(""))
            {
                JOptionPane.showMessageDialog(
                        this,
                        "Please enter the location of where you wish the report to be writen to.",
                        "Error",
                        JOptionPane.ERROR_MESSAGE);

                return;
            }

            if((new File(jTextFieldReportFile.getText())).isDirectory())
            {
                JOptionPane.showMessageDialog(
                        this,
                        "The given path is a directory. Please specify both path and file name.",
                        "Error",
                        JOptionPane.ERROR_MESSAGE);
                return;
            }

            ReportWriter report = new ReportWriter(jTextFieldReportFile.getText(), parent);
            report.writeReportGUI(parent.jPanelRunning.resultsTableModel.getList());
            new JDialogViewReport(parent, true, jTextFieldReportFile.getText()).setVisible(true);
        }
        
    }//GEN-LAST:event_jButtonGenerateActionPerformed
    
private void jButtonBackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBackActionPerformed
        parent.showRunning();
}//GEN-LAST:event_jButtonBackActionPerformed
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonBack;
    private javax.swing.JButton jButtonGenerate;
    private javax.swing.JButton jButtonReportBrowse;
    private javax.swing.JButton jButtonReportExit;
    private javax.swing.JButton jButtonReportNew;
    private javax.swing.JLabel jLabel2;
    public javax.swing.JTextField jTextFieldReportFile;
    // End of variables declaration//GEN-END:variables
    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy