/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template
 */
package shells.plugins.java;

import shells.plugins.java.handler.*;
import core.Encoding;
import core.annotation.PluginAnnotation;
import core.imp.Payload;
import core.shell.ShellEntity;
import shells.plugins.java.handler.*;

import javax.swing.*;

/**
 *
 * @author Administrator
 */
@PluginAnnotation(
        payloadName = "JavaDynamicPayload",
        Name = "ZohoPlugin",
        DisplayName = "ZohoPlugin"
)
public class ZohoUI extends javax.swing.JFrame implements core.imp.Plugin {

    private Payload payload;
    private Encoding encoding;
    private ShellEntity shellEntity;
    public ZohoUI() {
        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.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        BypassIPButton = new javax.swing.JButton();
        GenerateSessionButton = new javax.swing.JButton();
        JDBCInfoButton = new javax.swing.JButton();
        OtherCertifictionButton = new javax.swing.JButton();
        DCAuthInfoButton = new javax.swing.JButton();
        IPDetectButton = new javax.swing.JButton();
        ClearLogButton = new javax.swing.JButton();
        RecordPasswordButton = new javax.swing.JButton();
        GetPasswordButton1 = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        scrollPane1 = new java.awt.ScrollPane();
        textArea1 = new java.awt.TextArea();

        jPanel1.setLayout(new BoxLayout(jPanel1,BoxLayout.Y_AXIS));

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

//        jPanel1.setLayout(new java.awt.GridBagLayout());

        BypassIPButton.setText("BypassIP");
        BypassIPButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                BypassIPButtonMouseClicked(evt);
            }
        });

        GenerateSessionButton.setText("GenerateAdminSession");
        GenerateSessionButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                GenerateSessionButtonMouseClicked(evt);
            }
        });

        JDBCInfoButton.setText("GetJDBCInfoButton");
        JDBCInfoButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                JDBCInfoButtonMouseClicked(evt);
            }
        });

        OtherCertifictionButton.setText("GetOtherCertifiction");
        OtherCertifictionButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                OtherCertifictionButtonMouseClicked(evt);
            }
        });

        DCAuthInfoButton.setText("GetDCAuthInfo");
        DCAuthInfoButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                DCAuthInfoButtonMouseClicked(evt);
            }
        });

        IPDetectButton.setText("Detect IP");
        IPDetectButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                IPDetectButtonMouseClicked(evt);
            }
        });

        ClearLogButton.setText("ClearLog");
        ClearLogButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                ClearLogButtonMouseClicked(evt);
            }
        });

        RecordPasswordButton.setText("RecordPassword");
        RecordPasswordButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                RecordPasswordButtonMouseClicked(evt);
            }
        });

        GetPasswordButton1.setText("GetPassword");
        GetPasswordButton1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                GetPasswordButton1MouseClicked(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(48, 48, 48)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(DCAuthInfoButton, javax.swing.GroupLayout.PREFERRED_SIZE, 224, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(93, 93, 93)
                        .addComponent(JDBCInfoButton, javax.swing.GroupLayout.PREFERRED_SIZE, 232, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(99, 99, 99)
                        .addComponent(GenerateSessionButton, javax.swing.GroupLayout.PREFERRED_SIZE, 256, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(77, 77, 77)
                        .addComponent(OtherCertifictionButton, javax.swing.GroupLayout.PREFERRED_SIZE, 270, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(IPDetectButton, javax.swing.GroupLayout.PREFERRED_SIZE, 224, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(BypassIPButton, javax.swing.GroupLayout.PREFERRED_SIZE, 232, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(RecordPasswordButton, javax.swing.GroupLayout.PREFERRED_SIZE, 256, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(39, 39, 39)
                        .addComponent(GetPasswordButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 216, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(38, 38, 38)
                        .addComponent(ClearLogButton, javax.swing.GroupLayout.PREFERRED_SIZE, 216, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(29, 29, 29))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(15, 15, 15)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(DCAuthInfoButton, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(JDBCInfoButton, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(GenerateSessionButton, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(OtherCertifictionButton, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(38, 38, 38)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(IPDetectButton, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(BypassIPButton, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(RecordPasswordButton, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(GetPasswordButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(ClearLogButton, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        jPanel1.add(jPanel2, gridBagConstraints);

        scrollPane1.add(textArea1);

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(scrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(scrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 495, Short.MAX_VALUE)
        );

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.ipadx = 1222;
        gridBagConstraints.ipady = 415;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(12, 6, 0, 0);
        jPanel1.add(jPanel3, gridBagConstraints);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 644, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void DCAuthInfoButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_DCAuthInfoButtonMouseClicked
//        Log.clear(textArea1);
        DCInfoHandler dcInfoHandler = new DCInfoHandler();
        dcInfoHandler.init(this.encoding,this.payload);
        String dcinfo = dcInfoHandler.handler();
        Log.addtitle("All domain control information is as follows:",textArea1);
        Log.adddata(dcinfo, textArea1);
    }

    private void JDBCInfoButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_JDBCInfoButtonMouseClicked
        Log.clear(textArea1);
        DBInfoHandler dbInfoHandler = new DBInfoHandler();
        dbInfoHandler.init(this.encoding,this.payload);
        String jdbc = dbInfoHandler.handler();
        Log.addtitle("The database connection information is as follows:",textArea1);
        Log.adddata(jdbc, textArea1);
    }

    private void GenerateSessionButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_GenerateSessionButtonMouseClicked
        Log.clear(textArea1);
        GenerateSessionHandler generateSessionHandler = new GenerateSessionHandler();
        generateSessionHandler.init(this.encoding,this.payload);
        String sessions = generateSessionHandler.handler();
        Log.addtitle("Sessions :",textArea1);
        Log.adddata(sessions, textArea1);
    }

    private void OtherCertifictionButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_OtherCertifictionButtonMouseClicked
        Log.clear(textArea1);
        ThirdpartyHadnler thirdpartyHadnler = new ThirdpartyHadnler();
        thirdpartyHadnler.init(this.encoding,this.payload);
        String third = thirdpartyHadnler.handler();
        Log.addtitle("Obtain third-party certificates as follows :",textArea1);
        Log.adddata(third, textArea1);
    }

    private void IPDetectButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_IPDetectButtonMouseClicked
//        Log.clear(textArea1);
//        BypassIPHandler bypassIPHandler = new BypassIPHandler();
//        bypassIPHandler.init(this.encoding,this.payload);
//        String bypass = bypassIPHandler.handler();
//        Log.addtitle("Bypass IP :",textArea1);
//        Log.adddata(bypass, textArea1);
    }

    private void BypassIPButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_BypassIPButtonMouseClicked
        Log.clear(textArea1);
        BypassIPHandler bypassIPHandler = new BypassIPHandler();
        bypassIPHandler.init(this.encoding,this.payload);
        String bypass = bypassIPHandler.handler();
        Log.addtitle("Bypass IP :",textArea1);
        Log.adddata(bypass, textArea1);
    }

    private void RecordPasswordButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_RecordPasswordButtonMouseClicked
        Log.clear(textArea1);
        RecordPasswordHadnler recordPasswordHadnler = new RecordPasswordHadnler();
        recordPasswordHadnler.init(this.encoding,this.payload);
        String result = recordPasswordHadnler.handler();
        Log.addtitle("Info :",textArea1);
        Log.adddata(result, textArea1);
    }

    private void ClearLogButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ClearLogButtonMouseClicked
        // TODO add your handling code here:
    }

    private void GetPasswordButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_GetPasswordButton1MouseClicked
        Log.clear(textArea1);
        GetPasswordHadnler getPasswordHadnler = new GetPasswordHadnler();
        getPasswordHadnler.init(this.encoding,this.payload);
        String result = getPasswordHadnler.handler();
        Log.addtitle("Info :",textArea1);
        Log.adddata(result, textArea1);
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* 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/tutorial/uiswing/lookandfeel/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(ZohoUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(ZohoUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(ZohoUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(ZohoUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

//        JFrame  frame = new JFrame();
//        frame.setContentPane(new ZohoUI().jPanel1);
//        frame.setVisible(true);
//        frame.pack();
        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new ZohoUI().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BypassIPButton;
    private javax.swing.JButton ClearLogButton;
    private javax.swing.JButton DCAuthInfoButton;
    private javax.swing.JButton GenerateSessionButton;
    private javax.swing.JButton GetPasswordButton1;
    private javax.swing.JButton IPDetectButton;
    private javax.swing.JButton JDBCInfoButton;
    private javax.swing.JButton OtherCertifictionButton;
    private javax.swing.JButton RecordPasswordButton;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private java.awt.ScrollPane scrollPane1;
    private java.awt.TextArea textArea1;

    @Override
    public void init(ShellEntity shellEntity) {
        this.shellEntity = shellEntity;
        this.encoding = shellEntity.getEncodingModule();
        this.payload = shellEntity.getPayloadModule();
    }

    @Override
    public JPanel getView() {
        return (JPanel) this.getContentPane();
    }
    // End of variables declaration//GEN-END:variables
}
