Tabs disabled until loaded from database, auto-load database on connect, and more simplified database calls,

git-svn-id: file:///home/svn/framework3/trunk@10161 4d416f70-5f16-0410-b530-b9f4589650da
unstable
Matt Weeks 2010-08-26 23:49:35 +00:00
parent 4651a0ad33
commit 8f52ae02df
3 changed files with 40 additions and 39 deletions

Binary file not shown.

View File

@ -10,20 +10,20 @@
<Layout> <Layout>
<DimensionLayout dim="0"> <DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="jTabbedPane1" alignment="0" pref="882" max="32767" attributes="0"/> <Component id="tabbedPane" alignment="0" pref="882" max="32767" attributes="0"/>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
<DimensionLayout dim="1"> <DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="jTabbedPane1" alignment="1" pref="532" max="32767" attributes="0"/> <Component id="tabbedPane" alignment="1" pref="532" max="32767" attributes="0"/>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
</Layout> </Layout>
<SubComponents> <SubComponents>
<Container class="javax.swing.JTabbedPane" name="jTabbedPane1"> <Container class="javax.swing.JTabbedPane" name="tabbedPane">
<Properties> <Properties>
<Property name="selectedIndex" type="int" value="1"/> <Property name="selectedIndex" type="int" value="1"/>
<Property name="name" type="java.lang.String" value="jTabbedPane1" noResource="true"/> <Property name="name" type="java.lang.String" value="tabbedPane" noResource="true"/>
</Properties> </Properties>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/> <Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/>
@ -616,7 +616,7 @@
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="statusMessageLabel" min="-2" max="-2" attributes="0"/> <Component id="statusMessageLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="696" max="32767" attributes="0"/> <EmptySpace pref="698" max="32767" attributes="0"/>
<Component id="progressBar" min="-2" max="-2" attributes="0"/> <Component id="progressBar" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="statusAnimationLabel" min="-2" max="-2" attributes="0"/> <Component id="statusAnimationLabel" min="-2" max="-2" attributes="0"/>

View File

@ -4,7 +4,6 @@
package msfgui; package msfgui;
import java.awt.Component; import java.awt.Component;
import java.awt.Graphics;
import java.awt.HeadlessException; import java.awt.HeadlessException;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import javax.swing.JTable; import javax.swing.JTable;
@ -27,7 +26,6 @@ import java.util.HashMap;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Vector;
import javax.swing.Timer; import javax.swing.Timer;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JComponent; import javax.swing.JComponent;
@ -136,6 +134,9 @@ public class MainFrame extends FrameView {
}); });
//Setup icon //Setup icon
this.getFrame().setIconImage( resourceMap.getImageIcon("main.icon").getImage()); this.getFrame().setIconImage( resourceMap.getImageIcon("main.icon").getImage());
//Disable tabs by default
for(int i = 2; i <= 5; i++)
tabbedPane.setEnabledAt(i, false);
} }
private void confirmStop() { private void confirmStop() {
@ -352,10 +353,10 @@ public class MainFrame extends FrameView {
//Exploits and auxiliary get modulepopups; payloads get payloadpopups duh //Exploits and auxiliary get modulepopups; payloads get payloadpopups duh
setMessage("Getting exploits"); setMessage("Getting exploits");
expandList((Object[]) ((Map)rpcConn.execute("module.exploits")).get("modules"), exploitsMenu, moduleFactory, "exploit"); expandList((Object[]) ((Map)rpcConn.execute("module.exploits")).get("modules"), exploitsMenu, moduleFactory, "exploit");
setProgress(0.33f); setProgress(0.3f);
setMessage("Getting auxiliary modules"); setMessage("Getting auxiliary modules");
expandList((Object[]) ((Map)rpcConn.execute("module.auxiliary")).get("modules"), auxiliaryMenu, moduleFactory, "auxiliary"); expandList((Object[]) ((Map)rpcConn.execute("module.auxiliary")).get("modules"), auxiliaryMenu, moduleFactory, "auxiliary");
setProgress(0.66f); setProgress(0.5f);
setMessage("Getting payloads"); setMessage("Getting payloads");
expandList((Object[]) ((Map)rpcConn.execute("module.payloads")).get("modules"), payloadsMenu, new RunMenuFactory(){ expandList((Object[]) ((Map)rpcConn.execute("module.payloads")).get("modules"), payloadsMenu, new RunMenuFactory(){
public ActionListener getActor(final String modName, final String type, final RpcConnection rpcConn) { public ActionListener getActor(final String modName, final String type, final RpcConnection rpcConn) {
@ -366,6 +367,9 @@ public class MainFrame extends FrameView {
}; };
} }
}, "payload"); }, "payload");
setProgress(0.8f);
setMessage("Querying database...");
reloadDb();
setProgress(1.0f); setProgress(1.0f);
} catch (MsfException ex) { } catch (MsfException ex) {
statusAnimationLabel.setText("Error getting module lists. " + ex); statusAnimationLabel.setText("Error getting module lists. " + ex);
@ -393,7 +397,7 @@ public class MainFrame extends FrameView {
private void initComponents() { private void initComponents() {
mainPanel = new javax.swing.JPanel(); mainPanel = new javax.swing.JPanel();
jTabbedPane1 = new javax.swing.JTabbedPane(); tabbedPane = new javax.swing.JTabbedPane();
jScrollPane1 = new javax.swing.JScrollPane(); jScrollPane1 = new javax.swing.JScrollPane();
jobsList = new javax.swing.JList(); jobsList = new javax.swing.JList();
jScrollPane2 = new javax.swing.JScrollPane(); jScrollPane2 = new javax.swing.JScrollPane();
@ -444,7 +448,7 @@ public class MainFrame extends FrameView {
mainPanel.setName("mainPanel"); // NOI18N mainPanel.setName("mainPanel"); // NOI18N
jTabbedPane1.setName("jTabbedPane1"); // NOI18N tabbedPane.setName("tabbedPane"); // NOI18N
jScrollPane1.setName("jScrollPane1"); // NOI18N jScrollPane1.setName("jScrollPane1"); // NOI18N
jScrollPane1.setPreferredSize(new java.awt.Dimension(10, 10)); jScrollPane1.setPreferredSize(new java.awt.Dimension(10, 10));
@ -453,7 +457,7 @@ public class MainFrame extends FrameView {
jScrollPane1.setViewportView(jobsList); jScrollPane1.setViewportView(jobsList);
org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(msfgui.MsfguiApp.class).getContext().getResourceMap(MainFrame.class); org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(msfgui.MsfguiApp.class).getContext().getResourceMap(MainFrame.class);
jTabbedPane1.addTab(resourceMap.getString("jScrollPane1.TabConstraints.tabTitle"), jScrollPane1); // NOI18N tabbedPane.addTab(resourceMap.getString("jScrollPane1.TabConstraints.tabTitle"), jScrollPane1); // NOI18N
jScrollPane2.setName("jScrollPane2"); // NOI18N jScrollPane2.setName("jScrollPane2"); // NOI18N
@ -469,7 +473,7 @@ public class MainFrame extends FrameView {
sessionsTable.setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); sessionsTable.setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
jScrollPane2.setViewportView(sessionsTable); jScrollPane2.setViewportView(sessionsTable);
jTabbedPane1.addTab(resourceMap.getString("jScrollPane2.TabConstraints.tabTitle"), jScrollPane2); // NOI18N tabbedPane.addTab(resourceMap.getString("jScrollPane2.TabConstraints.tabTitle"), jScrollPane2); // NOI18N
jScrollPane3.setName("jScrollPane3"); // NOI18N jScrollPane3.setName("jScrollPane3"); // NOI18N
@ -505,7 +509,7 @@ public class MainFrame extends FrameView {
hostsTable.getColumnModel().getColumn(11).setHeaderValue(resourceMap.getString("hostsTable.columnModel.title11")); // NOI18N hostsTable.getColumnModel().getColumn(11).setHeaderValue(resourceMap.getString("hostsTable.columnModel.title11")); // NOI18N
hostsTable.getColumnModel().getColumn(12).setHeaderValue(resourceMap.getString("hostsTable.columnModel.title12")); // NOI18N hostsTable.getColumnModel().getColumn(12).setHeaderValue(resourceMap.getString("hostsTable.columnModel.title12")); // NOI18N
jTabbedPane1.addTab(resourceMap.getString("jScrollPane3.TabConstraints.tabTitle"), jScrollPane3); // NOI18N tabbedPane.addTab(resourceMap.getString("jScrollPane3.TabConstraints.tabTitle"), jScrollPane3); // NOI18N
jScrollPane4.setName("jScrollPane4"); // NOI18N jScrollPane4.setName("jScrollPane4"); // NOI18N
@ -528,7 +532,7 @@ public class MainFrame extends FrameView {
servicesTable.setName("servicesTable"); // NOI18N servicesTable.setName("servicesTable"); // NOI18N
jScrollPane4.setViewportView(servicesTable); jScrollPane4.setViewportView(servicesTable);
jTabbedPane1.addTab(resourceMap.getString("jScrollPane4.TabConstraints.tabTitle"), jScrollPane4); // NOI18N tabbedPane.addTab(resourceMap.getString("jScrollPane4.TabConstraints.tabTitle"), jScrollPane4); // NOI18N
jScrollPane5.setName("jScrollPane5"); // NOI18N jScrollPane5.setName("jScrollPane5"); // NOI18N
@ -551,7 +555,7 @@ public class MainFrame extends FrameView {
vulnsTable.setName("vulnsTable"); // NOI18N vulnsTable.setName("vulnsTable"); // NOI18N
jScrollPane5.setViewportView(vulnsTable); jScrollPane5.setViewportView(vulnsTable);
jTabbedPane1.addTab(resourceMap.getString("jScrollPane5.TabConstraints.tabTitle"), jScrollPane5); // NOI18N tabbedPane.addTab(resourceMap.getString("jScrollPane5.TabConstraints.tabTitle"), jScrollPane5); // NOI18N
jScrollPane6.setName("jScrollPane6"); // NOI18N jScrollPane6.setName("jScrollPane6"); // NOI18N
@ -574,19 +578,19 @@ public class MainFrame extends FrameView {
eventsTable.setName("eventsTable"); // NOI18N eventsTable.setName("eventsTable"); // NOI18N
jScrollPane6.setViewportView(eventsTable); jScrollPane6.setViewportView(eventsTable);
jTabbedPane1.addTab(resourceMap.getString("jScrollPane6.TabConstraints.tabTitle"), jScrollPane6); // NOI18N tabbedPane.addTab(resourceMap.getString("jScrollPane6.TabConstraints.tabTitle"), jScrollPane6); // NOI18N
jTabbedPane1.setSelectedIndex(1); tabbedPane.setSelectedIndex(1);
javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel); javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
mainPanel.setLayout(mainPanelLayout); mainPanel.setLayout(mainPanelLayout);
mainPanelLayout.setHorizontalGroup( mainPanelLayout.setHorizontalGroup(
mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 882, Short.MAX_VALUE) .addComponent(tabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 882, Short.MAX_VALUE)
); );
mainPanelLayout.setVerticalGroup( mainPanelLayout.setVerticalGroup(
mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTabbedPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 532, Short.MAX_VALUE) .addComponent(tabbedPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 532, Short.MAX_VALUE)
); );
menuBar.setName("menuBar"); // NOI18N menuBar.setName("menuBar"); // NOI18N
@ -942,26 +946,14 @@ public class MainFrame extends FrameView {
/** Refreshes the database tables. */ /** Refreshes the database tables. */
private void reloadDb() { private void reloadDb() {
try { reAddQuery(hostsTable,2,"hosts",new String[]{"created_at","address","address6","mac","name","state","os_name",
Object[] hosts = (Object[]) ((Map)rpcConn.execute("db.hosts",new Object[]{new HashMap()})).get("hosts");
reAdd(hostsTable,hosts,new String[]{"created_at","address","address6","mac","name","state","os_name",
"os_flavor","os_sp","os_lang","updated_at","purpose","info"}); "os_flavor","os_sp","os_lang","updated_at","purpose","info"});
} catch (MsfException mex) { reAddQuery(servicesTable, 3, "services", new String[]{"host","created_at","updated_at","port","proto","state","name","info"});
} reAddQuery(vulnsTable,4,"vulns",new String[]{"port","proto","time","host","name","refs"});
try {
Object[] services = (Object[]) ((Map)rpcConn.execute("db.services",new Object[]{new HashMap()})).get("services");
reAdd(servicesTable, services, new String[]{"host","created_at","updated_at","port","proto","state","name","info"});
} catch (MsfException mex) {
}
try {
Object[] vulns = (Object[]) ((Map)rpcConn.execute("db.vulns",new Object[]{new HashMap()})).get("vulns");
reAdd(vulnsTable,vulns,new String[]{"port","proto","time","host","name","refs"});
} catch (MsfException mex) {
}
try { try {
Object wspace = ((Map) rpcConn.execute("db.current_workspace")).get("workspace"); Object wspace = ((Map) rpcConn.execute("db.current_workspace")).get("workspace");
Object[] events = (Object[]) ((Map)rpcConn.execute("db.events",new Object[]{wspace})).get("events"); Object[] events = (Object[]) ((Map)rpcConn.execute("db.events",new Object[]{wspace})).get("events");
reAdd(eventsTable,events,new String[]{"host","created_at","updated_at","name","critical","username","info"}); reAdd(eventsTable,5,events,new String[]{"host","created_at","updated_at","name","critical","username","info"});
} catch (MsfException mex) { } catch (MsfException mex) {
} }
} }
@ -1253,7 +1245,6 @@ public class MainFrame extends FrameView {
private javax.swing.JScrollPane jScrollPane5; private javax.swing.JScrollPane jScrollPane5;
private javax.swing.JScrollPane jScrollPane6; private javax.swing.JScrollPane jScrollPane6;
private javax.swing.JPopupMenu.Separator jSeparator1; private javax.swing.JPopupMenu.Separator jSeparator1;
private javax.swing.JTabbedPane jTabbedPane1;
private javax.swing.JList jobsList; private javax.swing.JList jobsList;
private javax.swing.JMenuItem killSessionsMenuItem; private javax.swing.JMenuItem killSessionsMenuItem;
private javax.swing.JMenuItem logGenerateMenuItem; private javax.swing.JMenuItem logGenerateMenuItem;
@ -1275,6 +1266,7 @@ public class MainFrame extends FrameView {
private javax.swing.JLabel statusAnimationLabel; private javax.swing.JLabel statusAnimationLabel;
private javax.swing.JLabel statusMessageLabel; private javax.swing.JLabel statusMessageLabel;
private javax.swing.JPanel statusPanel; private javax.swing.JPanel statusPanel;
private javax.swing.JTabbedPane tabbedPane;
private javax.swing.JTable vulnsTable; private javax.swing.JTable vulnsTable;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
private final Timer messageTimer; private final Timer messageTimer;
@ -1306,8 +1298,16 @@ public class MainFrame extends FrameView {
} }
} }
/** Clear a table's contents, and replace with contents of data */ /** Clear a table's contents, reenabling the tab, and replace with contents of data returned from a db call */
private void reAdd(JTable table, Object[] data, String[] cols) { private void reAddQuery(JTable table, int tabIndex, String call, String[] cols) {
try {
Object[] data = (Object[]) ((Map)rpcConn.execute("db."+call,new Object[]{new HashMap()})).get(call);
reAdd(hostsTable,tabIndex, data,cols);
} catch (MsfException mex) {
}
}
/** Clear a table's contents, reenabling the tab, and replace with contents of data */
private void reAdd(JTable table, int tabIndex, Object[] data, String[] cols) {
DefaultTableModel mod = (DefaultTableModel) table.getModel(); DefaultTableModel mod = (DefaultTableModel) table.getModel();
while (mod.getRowCount() > 0) while (mod.getRowCount() > 0)
mod.removeRow(0); mod.removeRow(0);
@ -1318,6 +1318,7 @@ public class MainFrame extends FrameView {
mod.addRow(row); mod.addRow(row);
} }
TableHelper.fitColumnWidths(mod, table); TableHelper.fitColumnWidths(mod, table);
tabbedPane.setEnabledAt(tabIndex, true);
} }
} }