1
mirror of https://github.com/rapid7/metasploit-framework synced 2024-11-05 14:57:30 +01:00

Add support for database connect and disconnect, saving connection details.

git-svn-id: file:///home/svn/framework3/trunk@10176 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
Matt Weeks 2010-08-28 18:09:30 +00:00
parent 1d508a7acd
commit 633f84888e
7 changed files with 506 additions and 10 deletions

Binary file not shown.

View File

@ -0,0 +1,208 @@
<?xml version="1.1" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="2"/>
<Property name="name" type="java.lang.String" value="Form" noResource="true"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="2"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="cancelButton" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="connectButton" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="jLabel7" alignment="0" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jLabel6" min="-2" max="-2" attributes="0"/>
<Component id="jLabel5" min="-2" max="-2" attributes="0"/>
<Component id="jLabel4" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" alignment="1" min="-2" max="-2" attributes="1"/>
<Component id="jLabel3" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="1"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="usernameField" pref="327" max="32767" attributes="1"/>
<Component id="typeSpinner" alignment="0" pref="327" max="32767" attributes="1"/>
<Component id="passwordField" alignment="0" pref="327" max="32767" attributes="0"/>
<Component id="dbNameField" alignment="0" pref="327" max="32767" attributes="0"/>
<Component id="hostField" alignment="0" pref="327" max="32767" attributes="0"/>
<Component id="portField" alignment="0" pref="327" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel7" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="typeSpinner" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="usernameField" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="passwordField" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="dbNameField" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="hostField" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="portField" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel6" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="connectButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cancelButton" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JSpinner" name="typeSpinner">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel type="list">
<ListItem value="postgresql"/>
<ListItem value="mysql"/>
<ListItem value="sqlite3"/>
</SpinnerModel>
</Property>
<Property name="name" type="java.lang.String" value="typeSpinner" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="jLabel1.text"/>
<Property name="name" type="java.lang.String" value="jLabel1" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="jLabel2.text"/>
<Property name="name" type="java.lang.String" value="jLabel2" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel3">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="jLabel3.text"/>
<Property name="name" type="java.lang.String" value="jLabel3" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="usernameField">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="usernameField.text"/>
<Property name="name" type="java.lang.String" value="usernameField" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="passwordField">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="passwordField.text"/>
<Property name="name" type="java.lang.String" value="passwordField" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel4">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="jLabel4.text"/>
<Property name="name" type="java.lang.String" value="jLabel4" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="dbNameField">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="dbNameField.text"/>
<Property name="name" type="java.lang.String" value="dbNameField" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="connectButton">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="connectButton.text"/>
<Property name="name" type="java.lang.String" value="connectButton" noResource="true"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="connectButtonActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="cancelButton">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="cancelButton.text"/>
<Property name="name" type="java.lang.String" value="cancelButton" noResource="true"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelButtonActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JTextField" name="hostField">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="hostField.text"/>
<Property name="name" type="java.lang.String" value="hostField" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="portField">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="portField.text"/>
<Property name="name" type="java.lang.String" value="portField" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel5">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="jLabel5.text"/>
<Property name="name" type="java.lang.String" value="jLabel5" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel6">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="jLabel6.text"/>
<Property name="name" type="java.lang.String" value="jLabel6" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel7">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="jLabel7.text"/>
<Property name="name" type="java.lang.String" value="jLabel7" noResource="true"/>
</Properties>
</Component>
</SubComponents>
</Form>

View File

@ -0,0 +1,250 @@
package msfgui;
import java.awt.Frame;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import org.w3c.dom.Element;
/**
*
* @author scriptjunkie
*/
public class DbConnectDialog extends OptionsDialog {
private RpcConnection rpcConn;
private Frame myParent;
private boolean success;
private Element props;
//Opens dialog to get options
public static boolean connect(Frame parent, RpcConnection rpcConn){
DbConnectDialog cd = new DbConnectDialog(parent, rpcConn, true);
cd.setVisible(true);
return cd.success;
}
/** Creates new form DbConnectDialog */
public DbConnectDialog(Frame parent, RpcConnection rpcConn, boolean modal) {
super(parent, "Database Connection Options", modal);
initComponents();
this.rpcConn = rpcConn;
myParent = parent;
success = false;
props = MsfguiApp.getPropertiesNode();
hostField.setText(props.getAttribute("dbhost"));
portField.setText(props.getAttribute("dbport"));
usernameField.setText(props.getAttribute("dbusername"));
passwordField.setText(props.getAttribute("dbpassword"));
dbNameField.setText(props.getAttribute("dbdatabase"));
String driver = props.getAttribute("dbdriver");
List l = ((javax.swing.SpinnerListModel)typeSpinner.getModel()).getList();
for ( Object o : l )
if(o.equals(driver))
typeSpinner.setValue(driver);
}
/** 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() {
typeSpinner = new javax.swing.JSpinner();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
usernameField = new javax.swing.JTextField();
passwordField = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
dbNameField = new javax.swing.JTextField();
connectButton = new javax.swing.JButton();
cancelButton = new javax.swing.JButton();
hostField = new javax.swing.JTextField();
portField = new javax.swing.JTextField();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setName("Form"); // NOI18N
typeSpinner.setModel(new javax.swing.SpinnerListModel(new String[] {"postgresql", "mysql", "sqlite3"}));
typeSpinner.setName("typeSpinner"); // NOI18N
org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(msfgui.MsfguiApp.class).getContext().getResourceMap(DbConnectDialog.class);
jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
jLabel1.setName("jLabel1"); // NOI18N
jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
jLabel2.setName("jLabel2"); // NOI18N
jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
jLabel3.setName("jLabel3"); // NOI18N
usernameField.setText(resourceMap.getString("usernameField.text")); // NOI18N
usernameField.setName("usernameField"); // NOI18N
passwordField.setText(resourceMap.getString("passwordField.text")); // NOI18N
passwordField.setName("passwordField"); // NOI18N
jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
jLabel4.setName("jLabel4"); // NOI18N
dbNameField.setText(resourceMap.getString("dbNameField.text")); // NOI18N
dbNameField.setName("dbNameField"); // NOI18N
connectButton.setText(resourceMap.getString("connectButton.text")); // NOI18N
connectButton.setName("connectButton"); // NOI18N
connectButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
connectButtonActionPerformed(evt);
}
});
cancelButton.setText(resourceMap.getString("cancelButton.text")); // NOI18N
cancelButton.setName("cancelButton"); // NOI18N
cancelButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancelButtonActionPerformed(evt);
}
});
hostField.setText(resourceMap.getString("hostField.text")); // NOI18N
hostField.setName("hostField"); // NOI18N
portField.setText(resourceMap.getString("portField.text")); // NOI18N
portField.setName("portField"); // NOI18N
jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
jLabel5.setName("jLabel5"); // NOI18N
jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
jLabel6.setName("jLabel6"); // NOI18N
jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
jLabel7.setName("jLabel7"); // NOI18N
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(cancelButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(connectButton))
.addComponent(jLabel7)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel6)
.addComponent(jLabel5)
.addComponent(jLabel4)
.addComponent(jLabel2)
.addComponent(jLabel3)
.addComponent(jLabel1))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(usernameField, javax.swing.GroupLayout.DEFAULT_SIZE, 327, Short.MAX_VALUE)
.addComponent(typeSpinner, javax.swing.GroupLayout.DEFAULT_SIZE, 327, Short.MAX_VALUE)
.addComponent(passwordField, javax.swing.GroupLayout.DEFAULT_SIZE, 327, Short.MAX_VALUE)
.addComponent(dbNameField, javax.swing.GroupLayout.DEFAULT_SIZE, 327, Short.MAX_VALUE)
.addComponent(hostField, javax.swing.GroupLayout.DEFAULT_SIZE, 327, Short.MAX_VALUE)
.addComponent(portField, javax.swing.GroupLayout.DEFAULT_SIZE, 327, Short.MAX_VALUE))))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel7)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(typeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(usernameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(passwordField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(dbNameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(hostField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(portField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel6))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(connectButton)
.addComponent(cancelButton))
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
/** Adds if text is non-empty, and saves in properties node */
private void addNonempty(String key, JTextField text, HashMap opts) {
String val = text.getText();
if (val.length() > 0)
opts.put(key, val);
props.setAttribute("db"+key, val);
}
private void connectButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_connectButtonActionPerformed
HashMap opts = new HashMap();
addNonempty("host",hostField, opts);
addNonempty("port", portField, opts);
addNonempty("username", usernameField, opts);
addNonempty("password", passwordField, opts);
addNonempty("database", dbNameField, opts);
opts.put("driver", typeSpinner.getValue().toString());
props.setAttribute("dbdriver", typeSpinner.getValue().toString());
try{
Map res = (Map)rpcConn.execute("db.connect",new Object[]{opts});
success = "success".equals(res.get("result"));
if(!success)
JOptionPane.showMessageDialog(myParent, res);
}catch(MsfException mex){
JOptionPane.showMessageDialog(myParent, mex);
}
setVisible(false);
}//GEN-LAST:event_connectButtonActionPerformed
private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
setVisible(false);
}//GEN-LAST:event_cancelButtonActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton cancelButton;
private javax.swing.JButton connectButton;
private javax.swing.JTextField dbNameField;
private javax.swing.JTextField hostField;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JTextField passwordField;
private javax.swing.JTextField portField;
private javax.swing.JSpinner typeSpinner;
private javax.swing.JTextField usernameField;
// End of variables declaration//GEN-END:variables
}

View File

@ -550,6 +550,16 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="connectItemActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="disconnectItem">
<Properties>
<Property name="mnemonic" type="int" value="68"/>
<Property name="text" type="java.lang.String" resourceKey="disconnectItem.text"/>
<Property name="name" type="java.lang.String" value="disconnectItem" noResource="true"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="disconnectItemActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="refreshItem">
<Properties>
<Property name="mnemonic" type="int" value="82"/>

View File

@ -436,6 +436,7 @@ public class MainFrame extends FrameView {
closeConsoleMenu = new javax.swing.JMenu();
databaseMenu = new javax.swing.JMenu();
connectItem = new javax.swing.JMenuItem();
disconnectItem = new javax.swing.JMenuItem();
refreshItem = new javax.swing.JMenuItem();
importItem = new javax.swing.JMenuItem();
helpMenu = new javax.swing.JMenu();
@ -774,6 +775,16 @@ public class MainFrame extends FrameView {
});
databaseMenu.add(connectItem);
disconnectItem.setMnemonic('D');
disconnectItem.setText(resourceMap.getString("disconnectItem.text")); // NOI18N
disconnectItem.setName("disconnectItem"); // NOI18N
disconnectItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
disconnectItemActionPerformed(evt);
}
});
databaseMenu.add(disconnectItem);
refreshItem.setMnemonic('R');
refreshItem.setText(resourceMap.getString("refreshItem.text")); // NOI18N
refreshItem.setName("refreshItem"); // NOI18N
@ -832,7 +843,7 @@ public class MainFrame extends FrameView {
.addGroup(statusPanelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(statusMessageLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 696, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 698, Short.MAX_VALUE)
.addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(statusAnimationLabel)
@ -933,15 +944,8 @@ public class MainFrame extends FrameView {
}//GEN-LAST:event_searchItemActionPerformed
private void connectItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_connectItemActionPerformed
String answer = JOptionPane.showInputDialog(getFrame(), "Enter Connection String", "Connection String", JOptionPane.QUESTION_MESSAGE);
if(answer == null)
return;
try{
Map session = (Map)rpcConn.execute("console.create");
registerConsole(session, true, "db_connect "+answer);
}catch(MsfException mex){
JOptionPane.showMessageDialog(getFrame(), mex);
}
if(DbConnectDialog.connect(getFrame(), rpcConn))
reloadDb();
}//GEN-LAST:event_connectItemActionPerformed
/** Refreshes the database tables. */
@ -988,6 +992,14 @@ public class MainFrame extends FrameView {
}
}//GEN-LAST:event_importItemActionPerformed
private void disconnectItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_disconnectItemActionPerformed
try {
rpcConn.execute("db.disconnect");
} catch (MsfException mex) {
JOptionPane.showMessageDialog(getFrame(), mex);
}
}//GEN-LAST:event_disconnectItemActionPerformed
/** Runs command on all current meterpreter sessions in new thread; posting updates for each thread */
private void runOnAllMeterpreters(String cmd, String output, JLabel outputLabel) {
SessionCommand.runOnAllMeterpreters(sessionsTableModel, cmd, output, outputLabel, rpcConn);
@ -1231,6 +1243,7 @@ public class MainFrame extends FrameView {
private javax.swing.JMenuItem connectRpcMenuItem;
private javax.swing.JMenu consoleMenu;
private javax.swing.JMenu databaseMenu;
private javax.swing.JMenuItem disconnectItem;
private javax.swing.JTable eventsTable;
private javax.swing.JMenu existingConsoleMenu;
private javax.swing.JMenu exploitsMenu;

View File

@ -0,0 +1,14 @@
jLabel1.text=Type
jLabel2.text=Database Name
jLabel3.text=Username
usernameField.text=
passwordField.text=
jLabel4.text=Password
dbNameField.text=
connectButton.text=Connect
cancelButton.text=Cancel
hostField.text=
portField.text=
jLabel5.text=Host
jLabel6.text=Port
jLabel7.text=Leave options blank to use default

View File

@ -75,3 +75,4 @@ hostsTable.columnModel.title3=MAC
hostsTable.columnModel.title2=Address6
hostsTable.columnModel.title1=Address
importItem.text=Import
disconnectItem.text=Disconnect