Don't display or load events table by default. Also, only reload visible windows on refresh.

git-svn-id: file:///home/svn/framework3/trunk@13436 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
Matt Weeks 2011-07-30 21:51:07 +00:00
parent a5e63c2ca9
commit 630fb999f8
9 changed files with 152 additions and 120 deletions

Binary file not shown.

View File

@ -27,12 +27,13 @@
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="defaultsButton" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="208" max="32767" 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="102" alignment="1" 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"/>
@ -59,8 +60,6 @@
<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"/>
@ -91,10 +90,11 @@
<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"/>
<EmptySpace max="-2" 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"/>
<Component id="defaultsButton" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
@ -198,11 +198,14 @@
<Property name="name" type="java.lang.String" value="jLabel6" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel7">
<Component class="javax.swing.JButton" name="defaultsButton">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="jLabel7.text"/>
<Property name="name" type="java.lang.String" value="jLabel7" noResource="true"/>
<Property name="text" type="java.lang.String" resourceKey="defaultsButton.text"/>
<Property name="name" type="java.lang.String" value="defaultsButton" noResource="true"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="defaultsButtonActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

View File

@ -49,39 +49,10 @@ public class DbConnectDialog extends OptionsDialog {
props = MsfguiApp.getPropertiesNode();
try{
//If we don't have saved creds, look for them
if(!props.containsKey("dbusername")){
Scanner s;
try{
s = new Scanner(new File(System.getenv("BASE")+"config/database.yml"));
} catch (FileNotFoundException fnfox){
s = new Scanner(new File(MsfguiApp.getMsfRoot()+"/../config/database.yml"));
}
String token = s.next();
while(!token.equals("production:"))
token = s.next();
while(s.hasNext()){
if(token.equals("adapter:"))
props.put("dbdriver", s.next());
else if(token.equals("database:"))
props.put("dbdatabase", s.next());
else if(token.equals("username:"))
props.put("dbusername", s.next());
else if(token.equals("password:"))
props.put("dbpassword", s.next().replace("'", ""));
else if(token.equals("host:"))
props.put("dbhost", s.next());
else if(token.equals("port:"))
props.put("dbport", s.next());
token = s.next();
}
}
hostField.setText(props.get("dbhost").toString());
portField.setText(props.get("dbport").toString());
usernameField.setText(props.get("dbusername").toString());
passwordField.setText(props.get("dbpassword").toString());
dbNameField.setText(props.get("dbdatabase").toString());
if(!props.containsKey("dbusername"))
reloadDefaults();
showDefaults();
}catch(NullPointerException nex){
}catch(FileNotFoundException fedex){
}catch(MsfException mex){// No msf root?
mex.printStackTrace();
}
@ -115,7 +86,7 @@ public class DbConnectDialog extends OptionsDialog {
portField = new javax.swing.JTextField();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
defaultsButton = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setName("Form"); // NOI18N
@ -173,8 +144,13 @@ public class DbConnectDialog extends OptionsDialog {
jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
jLabel6.setName("jLabel6"); // NOI18N
jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
jLabel7.setName("jLabel7"); // NOI18N
defaultsButton.setText(resourceMap.getString("defaultsButton.text")); // NOI18N
defaultsButton.setName("defaultsButton"); // NOI18N
defaultsButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
defaultsButtonActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
@ -184,11 +160,12 @@ public class DbConnectDialog extends OptionsDialog {
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(defaultsButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 208, Short.MAX_VALUE)
.addComponent(cancelButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(connectButton))
.addComponent(jLabel7)
.addGroup(layout.createSequentialGroup()
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel6)
.addComponent(jLabel5)
@ -210,8 +187,6 @@ public class DbConnectDialog extends OptionsDialog {
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))
@ -235,10 +210,11 @@ public class DbConnectDialog extends OptionsDialog {
.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)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(connectButton)
.addComponent(cancelButton))
.addComponent(cancelButton)
.addComponent(defaultsButton))
.addContainerGap())
);
@ -253,6 +229,47 @@ public class DbConnectDialog extends OptionsDialog {
props.put("db"+key, val);
}
/** Loads database information from the database.yml file in the default install. */
private void reloadDefaults(){
try{
Scanner s;
try{
s = new Scanner(new File(System.getenv("BASE")+"config/database.yml"));
} catch (FileNotFoundException fnfox){
s = new Scanner(new File(MsfguiApp.getMsfRoot()+"/../config/database.yml"));
}
String token = s.next();
while(!token.equals("production:"))
token = s.next();
while(s.hasNext()){
if(token.equals("adapter:"))
props.put("dbdriver", s.next());
else if(token.equals("database:"))
props.put("dbdatabase", s.next());
else if(token.equals("username:"))
props.put("dbusername", s.next());
else if(token.equals("password:"))
props.put("dbpassword", s.next().replace("'", ""));
else if(token.equals("host:"))
props.put("dbhost", s.next());
else if(token.equals("port:"))
props.put("dbport", s.next());
token = s.next();
}
} catch (FileNotFoundException fnfox){
}
showDefaults();
}
/** Takes the values stored in the proproot and display it */
private void showDefaults() {
hostField.setText(props.get("dbhost").toString());
portField.setText(props.get("dbport").toString());
usernameField.setText(props.get("dbusername").toString());
passwordField.setText(props.get("dbpassword").toString());
dbNameField.setText(props.get("dbdatabase").toString());
}
private void connectButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_connectButtonActionPerformed
try {
success = tryConnect();
@ -281,10 +298,15 @@ public class DbConnectDialog extends OptionsDialog {
setVisible(false);
}//GEN-LAST:event_cancelButtonActionPerformed
private void defaultsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_defaultsButtonActionPerformed
reloadDefaults();
}//GEN-LAST:event_defaultsButtonActionPerformed
// 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.JButton defaultsButton;
private javax.swing.JTextField hostField;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
@ -292,7 +314,6 @@ public class DbConnectDialog extends OptionsDialog {
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;

View File

@ -123,6 +123,18 @@ public class DraggableTabbedPane extends JTabbedPane{
}
}
/**
* Finds the parent tab of the component given in c, and makes it visible.
* @param c The component whose tab is to be made visible
*/
public static boolean isVisible(Component c){
Component subParent = c, par;
for(par = subParent.getParent(); !(par instanceof Window); par = par.getParent())
if(par == null || !par.isVisible())
return false;
return true;
}
/**
* Finds the parent tab of the component given in c, and makes it visible.
* @param c The component whose tab is to be made visible

View File

@ -226,33 +226,6 @@
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JScrollPane" name="eventsPane">
<Properties>
<Property name="name" type="java.lang.String" value="eventsPane" noResource="true"/>
</Properties>
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
<JTabbedPaneConstraints tabName="Events">
<Property name="tabTitle" type="java.lang.String" resourceKey="eventsPane.TabConstraints.tabTitle"/>
</JTabbedPaneConstraints>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTable" name="eventsTable">
<Properties>
<Property name="name" type="java.lang.String" value="eventsTable" noResource="true"/>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new MsfTable(new String [] {&#xa;&#x9;&#x9;&quot;Host&quot;, &quot;Created&quot;, &quot;Updated&quot;, &quot;Name&quot;, &quot;Critical&quot;, &quot;Username&quot;, &quot;Info&quot;&#xa;&#x9;})"/>
</AuxValues>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JScrollPane" name="notesPane">
<Properties>
<Property name="name" type="java.lang.String" value="notesPane" noResource="true"/>
@ -652,6 +625,7 @@
<SubComponents>
<MenuItem class="javax.swing.JMenuItem" name="newConsoleItem">
<Properties>
<Property name="mnemonic" type="int" value="78"/>
<Property name="text" type="java.lang.String" resourceKey="newConsoleItem.text"/>
<Property name="name" type="java.lang.String" value="newConsoleItem" noResource="true"/>
</Properties>
@ -661,18 +635,21 @@
</MenuItem>
<Menu class="javax.swing.JMenu" name="existingConsoleMenu">
<Properties>
<Property name="mnemonic" type="int" value="79"/>
<Property name="text" type="java.lang.String" resourceKey="existingConsoleMenu.text"/>
<Property name="name" type="java.lang.String" value="existingConsoleMenu" noResource="true"/>
</Properties>
</Menu>
<Menu class="javax.swing.JMenu" name="closeConsoleMenu">
<Properties>
<Property name="mnemonic" type="int" value="67"/>
<Property name="text" type="java.lang.String" resourceKey="closeConsoleMenu.text"/>
<Property name="name" type="java.lang.String" value="closeConsoleMenu" noResource="true"/>
</Properties>
</Menu>
<MenuItem class="javax.swing.JMenuItem" name="refreshConsolesItem">
<Properties>
<Property name="mnemonic" type="int" value="82"/>
<Property name="text" type="java.lang.String" resourceKey="refreshConsolesItem.text"/>
<Property name="name" type="java.lang.String" value="refreshConsolesItem" noResource="true"/>
</Properties>
@ -712,6 +689,9 @@
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="refreshItem">
<Properties>
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
<KeyStroke key="F5"/>
</Property>
<Property name="mnemonic" type="int" value="82"/>
<Property name="text" type="java.lang.String" resourceKey="refreshItem.text"/>
<Property name="name" type="java.lang.String" value="refreshItem" noResource="true"/>
@ -892,7 +872,10 @@
<MenuItem class="javax.swing.JMenuItem" name="aboutMenuItem">
<Properties>
<Property name="action" type="javax.swing.Action" editor="org.netbeans.modules.swingapp.ActionEditor">
<action class="msfgui.MsfguiJDesktopView" id="showAboutBox" methodName="showAboutBox"/>
<action class="msfgui.MainFrame" id="showAboutBox" methodName="showAboutBox"/>
</Property>
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
<KeyStroke key="F1"/>
</Property>
<Property name="name" type="java.lang.String" value="aboutMenuItem" noResource="true"/>
</Properties>

View File

@ -42,11 +42,19 @@ public class MainFrame extends FrameView {
private String clickedJob;
public Map[] selectedSessions;
private SearchWindow searchWin;
private javax.swing.JTable eventsTable;
private javax.swing.JScrollPane eventsPane;
public MainFrame(SingleFrameApplication app) {
super(app);
MsfFrame.setLnF();
initComponents();
eventsPane = new javax.swing.JScrollPane();
eventsTable = new MsfTable(new String [] {
"Host", "Created", "Updated", "Name", "Critical", "Username", "Info"
});
eventsTable.setName("eventsTable"); // NOI18N
eventsPane.setViewportView(eventsTable);
sessionsTableModel = null;
sessionWindowMap = new HashMap();
@ -425,10 +433,10 @@ nameloop: for (int i = 0; i < names.length; i++) {
setMessage("Querying database...");
//First try to connect to the database
DbConnectDialog.tryConnect(getFrame(), rpcConn);
reloadDb();
reloadDb(true);
if(MainFrame.this.closeConsoleMenu.getItemCount() == 0 && !tabbedPane.isEnabledAt(3)){
registerConsole( (Map)rpcConn.execute("console.create"), false, "");
reloadDb();
reloadDb(true);
}
setProgress(0.95f);
databaseMenu.setEnabled(true);
@ -480,10 +488,6 @@ nameloop: for (int i = 0; i < names.length; i++) {
vulnsTable = new MsfTable(new String [] {
"Port", "Proto", "Time", "Host", "Name", "Refs"
});
eventsPane = new javax.swing.JScrollPane();
eventsTable = new MsfTable(new String [] {
"Host", "Created", "Updated", "Name", "Critical", "Username", "Info"
});
notesPane = new javax.swing.JScrollPane();
notesTable = new MsfTable(new String [] {
"Time", "Host", "Service", "Type", "Data"
@ -638,13 +642,6 @@ nameloop: for (int i = 0; i < names.length; i++) {
tabbedPane.addTab(resourceMap.getString("vulnsPane.TabConstraints.tabTitle"), vulnsPane); // NOI18N
eventsPane.setName("eventsPane"); // NOI18N
eventsTable.setName("eventsTable"); // NOI18N
eventsPane.setViewportView(eventsTable);
tabbedPane.addTab(resourceMap.getString("eventsPane.TabConstraints.tabTitle"), eventsPane); // NOI18N
notesPane.setName("notesPane"); // NOI18N
notesTable.setName("notesTable"); // NOI18N
@ -945,6 +942,7 @@ nameloop: for (int i = 0; i < names.length; i++) {
consoleMenu.setEnabled(false);
consoleMenu.setName("consoleMenu"); // NOI18N
newConsoleItem.setMnemonic('N');
newConsoleItem.setText(resourceMap.getString("newConsoleItem.text")); // NOI18N
newConsoleItem.setName("newConsoleItem"); // NOI18N
newConsoleItem.addActionListener(new java.awt.event.ActionListener() {
@ -954,14 +952,17 @@ nameloop: for (int i = 0; i < names.length; i++) {
});
consoleMenu.add(newConsoleItem);
existingConsoleMenu.setMnemonic('O');
existingConsoleMenu.setText(resourceMap.getString("existingConsoleMenu.text")); // NOI18N
existingConsoleMenu.setName("existingConsoleMenu"); // NOI18N
consoleMenu.add(existingConsoleMenu);
closeConsoleMenu.setMnemonic('C');
closeConsoleMenu.setText(resourceMap.getString("closeConsoleMenu.text")); // NOI18N
closeConsoleMenu.setName("closeConsoleMenu"); // NOI18N
consoleMenu.add(closeConsoleMenu);
refreshConsolesItem.setMnemonic('R');
refreshConsolesItem.setText(resourceMap.getString("refreshConsolesItem.text")); // NOI18N
refreshConsolesItem.setName("refreshConsolesItem"); // NOI18N
refreshConsolesItem.addActionListener(new java.awt.event.ActionListener() {
@ -998,6 +999,7 @@ nameloop: for (int i = 0; i < names.length; i++) {
});
databaseMenu.add(disconnectItem);
refreshItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F5, 0));
refreshItem.setMnemonic('R');
refreshItem.setText(resourceMap.getString("refreshItem.text")); // NOI18N
refreshItem.setName("refreshItem"); // NOI18N
@ -1172,6 +1174,7 @@ nameloop: for (int i = 0; i < names.length; i++) {
helpMenu.add(onlineHelpMenu);
aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
aboutMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F1, 0));
aboutMenuItem.setName("aboutMenuItem"); // NOI18N
helpMenu.add(aboutMenuItem);
@ -1281,14 +1284,14 @@ nameloop: for (int i = 0; i < names.length; i++) {
if(DbConnectDialog.connect(getFrame(), rpcConn))
new SwingWorker(){
protected Object doInBackground() throws Exception {
reloadDb();
reloadDb(true);
return null;
}
}.execute();
}//GEN-LAST:event_connectItemActionPerformed
/** Refreshes the database tables. */
private void reloadDb() {
private void reloadDb(boolean all) {
try { //First try to reset workspace to chosen workspace
if(MsfguiApp.getPropertiesNode().containsKey("workspace"))
rpcConn.execute("db.set_workspace", MsfguiApp.getPropertiesNode().get("workspace"));
@ -1298,17 +1301,19 @@ nameloop: for (int i = 0; i < names.length; i++) {
}
try { //Now load data out of current workspace
MsfguiApp.workspace = ((Map) rpcConn.execute("db.current_workspace")).get("workspace").toString();
reAdd(eventsTable,(List) ((Map)rpcConn.execute("db.events",MsfguiApp.workspace)).get("events"),
new String[]{"host","created_at","updated_at","name","critical","username","info"});
reAdd(lootsTable,(List) ((Map)rpcConn.execute("db.loots",MsfguiApp.workspace)).get("loots"),
new String[]{"host","service","ltype","ctype","data","created_at","updated_at","name","info"});
if(DraggableTabbedPane.isVisible(eventsTable))
reAdd(eventsTable,(List) ((Map)rpcConn.execute("db.events",MsfguiApp.workspace)).get("events"),
new String[]{"host","created_at","updated_at","name","critical","username","info"});
if(all || DraggableTabbedPane.isVisible(lootsTable))
reAdd(lootsTable,(List) ((Map)rpcConn.execute("db.loots",MsfguiApp.workspace)).get("loots"),
new String[]{"host","service","ltype","ctype","data","created_at","updated_at","name","info"});
reAddQuery(hostsTable,"hosts",new String[]{"created_at","address","address6","mac","name","state","os_name",
"os_flavor","os_sp","os_lang","updated_at","purpose","info"});
reAddQuery(clientsTable,"clients",new String[]{"host","ua_string","ua_name","ua_ver","created_at","updated_at"});
reAddQuery(servicesTable, "services", new String[]{"host","created_at","updated_at","port","proto","state","name","info"});
reAddQuery(vulnsTable,"vulns",new String[]{"port","proto","time","host","name","refs"});
reAddQuery(notesTable,"notes",new String[]{"time", "host", "service", "type", "data"});
reAddQuery(credsTable,"creds",new String[]{"host", "time", "port", "proto", "sname", "type", "user", "pass", "active"});
"os_flavor","os_sp","os_lang","updated_at","purpose","info"}, all);
reAddQuery(clientsTable,"clients",new String[]{"host","ua_string","ua_name","ua_ver","created_at","updated_at"}, all);
reAddQuery(servicesTable, "services", new String[]{"host","created_at","updated_at","port","proto","state","name","info"}, all);
reAddQuery(vulnsTable,"vulns",new String[]{"port","proto","time","host","name","refs"}, all);
reAddQuery(notesTable,"notes",new String[]{"time", "host", "service", "type", "data"}, all);
reAddQuery(credsTable,"creds",new String[]{"host", "time", "port", "proto", "sname", "type", "user", "pass", "active"}, all);
} catch (MsfException mex) {
if(!mex.getMessage().equals("database not loaded"))
mex.printStackTrace();
@ -1317,7 +1322,7 @@ nameloop: for (int i = 0; i < names.length; i++) {
}
private void refreshItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_refreshItemActionPerformed
reloadDb();
reloadDb(false);
}//GEN-LAST:event_refreshItemActionPerformed
private void importItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_importItemActionPerformed
@ -1415,7 +1420,7 @@ nameloop: for (int i = 0; i < names.length; i++) {
private String[] tableShortNames = new String[]{"","",};
private void tableDelCheck(KeyEvent evt, String name, String[] colNames){
if(evt.getKeyCode() == KeyEvent.VK_F5)
reloadDb();
reloadDb(false);
if(evt.getKeyCode() != KeyEvent.VK_DELETE)
return;
JTable tab = (JTable)evt.getSource();
@ -1429,7 +1434,7 @@ nameloop: for (int i = 0; i < names.length; i++) {
MsfguiApp.showMessage(getFrame(), mex);
}
}//delete then readd
reAddQuery(tab,name+"s",colNames);
reAddQuery(tab,name+"s",colNames, true);
}
private void hostsTableKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_hostsTableKeyReleased
tableDelCheck(evt,"host",new String[]{"created_at","address","address6","mac","name","state","os_name",
@ -1449,7 +1454,7 @@ nameloop: for (int i = 0; i < names.length; i++) {
}//GEN-LAST:event_notesTableKeyReleased
private void lootsTableKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_lootsTableKeyReleased
reAddQuery(lootsTable,"loots",new String[]{"host","service","ltype","ctype","data","created_at","updated_at","name","info"});
reAddQuery(lootsTable,"loots",new String[]{"host","service","ltype","ctype","data","created_at","updated_at","name","info"}, true);
}//GEN-LAST:event_lootsTableKeyReleased
private void clientsTableKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_clientsTableKeyReleased
@ -1469,7 +1474,7 @@ nameloop: for (int i = 0; i < names.length; i++) {
MsfguiApp.workspace = selected.toString();
rpcConn.execute("db.set_workspace", MsfguiApp.workspace);
MsfguiApp.getPropertiesNode().put("workspace", MsfguiApp.workspace);
reloadDb();
reloadDb(true);
} catch (MsfException mex) {
MsfguiApp.showMessage(getFrame(), mex);
}
@ -1482,7 +1487,7 @@ nameloop: for (int i = 0; i < names.length; i++) {
rpcConn.execute("db.add_workspace",name);
MsfguiApp.workspace = name;
rpcConn.execute("db.set_workspace", name);
reloadDb();
reloadDb(true);
} catch (MsfException mex) {
MsfguiApp.showMessage(getFrame(), mex);
}
@ -1501,7 +1506,7 @@ nameloop: for (int i = 0; i < names.length; i++) {
rpcConn.execute("db.del_workspace", selected.toString());
if(MsfguiApp.workspace.equals(selected.toString())){
MsfguiApp.workspace = "default";
reloadDb();
reloadDb(true);
}
} catch (MsfException mex) {
MsfguiApp.showMessage(getFrame(), mex);
@ -1537,6 +1542,11 @@ nameloop: for (int i = 0; i < names.length; i++) {
}//GEN-LAST:event_vulnsViewItemActionPerformed
private void eventsViewItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_eventsViewItemActionPerformed
if(eventsPane.getParent() == null)
tabbedPane.addTab("Events", eventsPane);
if(eventsTable.getRowCount() == 0)
reAdd(eventsTable,(List) ((Map)rpcConn.execute("db.events",MsfguiApp.workspace)).get("events"),
new String[]{"host","created_at","updated_at","name","critical","username","info"});
DraggableTabbedPane.show(eventsPane);
}//GEN-LAST:event_eventsViewItemActionPerformed
@ -1884,8 +1894,6 @@ nameloop: for (int i = 0; i < names.length; i++) {
private javax.swing.JMenuItem dbTrackerItem;
private javax.swing.JMenuItem delWorkspaceItem;
private javax.swing.JMenuItem disconnectItem;
private javax.swing.JScrollPane eventsPane;
private javax.swing.JTable eventsTable;
private javax.swing.JMenuItem eventsViewItem;
private javax.swing.JMenu existingConsoleMenu;
private javax.swing.JMenu exploitsMenu;
@ -1952,7 +1960,9 @@ nameloop: for (int i = 0; i < names.length; i++) {
private JDialog aboutBox;
/** Clear a table's contents, reenabling the tab, and replace with contents of data returned from a db call */
private void reAddQuery(JTable table, String call, String[] cols) {
private void reAddQuery(JTable table, String call, String[] cols, boolean force) {
if(!force && !DraggableTabbedPane.isVisible(table))
return; //Don't re-add if not visible
try {
HashMap arg = new HashMap();
arg.put("workspace", MsfguiApp.workspace);

View File

@ -9,12 +9,16 @@ import org.jdesktop.application.Action;
public class MsfguiAboutBox extends javax.swing.JDialog {
public static void show(java.awt.Frame parent, RpcConnection rpcConn){
if(rpcConn != null){
java.util.Map version = (java.util.Map)rpcConn.execute("core.version");
MsfguiApp.getApplication().show(new MsfguiAboutBox(parent, version.get("version").toString(),
version.get("ruby").toString(),
System.getProperty("java.version")+" "+System.getProperty("java.vendor")));
java.util.Map version = new java.util.HashMap();
if(rpcConn != null) {
version = (java.util.Map)rpcConn.execute("core.version");
} else {
version.put("version", "4");
version.put("ruby", "");
}
MsfguiApp.getApplication().show(new MsfguiAboutBox(parent, version.get("version").toString(),
version.get("ruby").toString(),
System.getProperty("java.version")+" "+System.getProperty("java.vendor")));
}
public MsfguiAboutBox(java.awt.Frame parent, String msfVersion, String rubyVersion, String javaVersion) {
super(parent);

View File

@ -11,4 +11,4 @@ hostField.text=
portField.text=
jLabel5.text=Host
jLabel6.text=Port
jLabel7.text=Leave options blank to use default
defaultsButton.text=Load Defaults

View File

@ -70,7 +70,6 @@ hostsPane.TabConstraints.tabTitle=Hosts
clientsPane.TabConstraints.tabTitle=Clients
servicesPane.TabConstraints.tabTitle=Services
vulnsPane.TabConstraints.tabTitle=Vulns
eventsPane.TabConstraints.tabTitle=Events
notesPane.TabConstraints.tabTitle=Notes
lootsPane.TabConstraints.tabTitle=Loots
currWorkspaceItem.text=Select Workspace