Binary files /tmp/S5OQQjp5SJ/metasploit-gui-1.0/AbsoluteLayout.jar and /tmp/kvQywBdWKJ/metasploit-gui-1.0/AbsoluteLayout.jar differ Binary files /tmp/S5OQQjp5SJ/metasploit-gui-1.0/appframework-1.0.3.jar and /tmp/kvQywBdWKJ/metasploit-gui-1.0/appframework-1.0.3.jar differ diff -Nru metasploit-gui-1.0/build.xml metasploit-gui-1.0/build.xml --- metasploit-gui-1.0/build.xml 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/build.xml 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project msfgui. + + + diff -Nru metasploit-gui-1.0/debian/changelog metasploit-gui-1.0/debian/changelog --- metasploit-gui-1.0/debian/changelog 2015-10-11 09:40:44.000000000 +0000 +++ metasploit-gui-1.0/debian/changelog 2015-11-19 12:06:23.000000000 +0000 @@ -1,4 +1,4 @@ -metasploit-gui (1.0-3panto) trusty; urgency=low +metasploit-gui (1.0-4panto) trusty; urgency=low * Metasploit-gui for panto linux. diff -Nru metasploit-gui-1.0/debian/install metasploit-gui-1.0/debian/install --- metasploit-gui-1.0/debian/install 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/debian/install 2015-11-19 11:45:49.000000000 +0000 @@ -0,0 +1,3 @@ +debian/Metasploit-Gui.desktop /usr/share/applications +debian/msfgui /usr/bin +metasploit-gui.tar.gz /var/cache/metasploit-gui diff -Nru metasploit-gui-1.0/debian/links metasploit-gui-1.0/debian/links --- metasploit-gui-1.0/debian/links 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/debian/links 2015-11-19 11:54:08.000000000 +0000 @@ -0,0 +1,2 @@ +opt/metasploit-gui/msfgui usr/bin/msfgui + Binary files /tmp/S5OQQjp5SJ/metasploit-gui-1.0/debian/metasploit-gui.tar.gz and /tmp/kvQywBdWKJ/metasploit-gui-1.0/debian/metasploit-gui.tar.gz differ diff -Nru metasploit-gui-1.0/debian/msfgui.postinst metasploit-gui-1.0/debian/msfgui.postinst --- metasploit-gui-1.0/debian/msfgui.postinst 2015-10-11 09:39:25.000000000 +0000 +++ metasploit-gui-1.0/debian/msfgui.postinst 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -#!/bin/sh - -set -e - -case "$1" in - configure) - echo "Panto is installing Metasploit gui ..." - mkdir /usr/local/share/Msfgui - tar zxf debian/metasploit-gui.tar.gz -C /usr/local/share/Msfgui - mv debian/Metasploit-Gui.desktop /usr/share/applications - cp debian/msfgui /usr/bin - - ;; - - abort-upgrade|abort-remove|abort-deconfigure) - ;; - - *) - echo "postinst called with unknown argument \`$1'" >&2 - exit 1 - ;; -esac - -#DEBHELPER# - -exit 0 - - - diff -Nru metasploit-gui-1.0/debian/postinst metasploit-gui-1.0/debian/postinst --- metasploit-gui-1.0/debian/postinst 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/debian/postinst 2015-11-19 12:02:35.000000000 +0000 @@ -0,0 +1,41 @@ +#!/bin/sh + +set -e + +case "$1" in + configure) + echo "Extracting Metasploit Gui ..." + [ -d /opt/metasploit-gui ] || mkdir /opt/metasploit-gui + DIRECTORY="/opt/metasploit-gui" + if [ -d "$DIRECTORY" ]; then + rm -rf /opt/metasploit-gui/* + tar -C /opt/metasploit-gui/ -xf /var/cache/metasploit-gui/metasploit-gui.tar.gz + chown -R root:root /opt/metasploit-gui + echo "Removing cache tarball ..." + rm -rf /var/cache/metasploit-gui + echo "Panto is installing Metasploit gui ..." + else + mkdir /opt/metasploit-gui + tar -C /opt/ -xf /var/cache/metasploit-gui/metasploit-gui.tar.gz + chown -R root:root /opt/metasploit-gui + echo "Removing cache tarball ..." + rm -rf /var/cache/metasploit-gui + echo "Panto is installing Metasploit gui ..." + fi + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# + +exit 0 + + + diff -Nru metasploit-gui-1.0/debian/postrm metasploit-gui-1.0/debian/postrm --- metasploit-gui-1.0/debian/postrm 2015-10-11 09:08:48.000000000 +0000 +++ metasploit-gui-1.0/debian/postrm 2015-11-19 12:04:11.000000000 +0000 @@ -12,7 +12,7 @@ remove|failed-upgrade|abort-install|abort-upgrade|disappear) if [ -d "/usr/local/share/Msfgui/" ]; then echo "Panto is Removing the Metasploit Gui ..." - rm -rf "/usr/local/share/Msfgui/" + rm -rf "/opt/metasploit-gui" rm -rf "/usr/bin/msfgui" rm -rf "/usr/share/applications/Metasploit-Gui.desktop" fi diff -Nru metasploit-gui-1.0/debian/preinst metasploit-gui-1.0/debian/preinst --- metasploit-gui-1.0/debian/preinst 2015-10-11 09:09:30.000000000 +0000 +++ metasploit-gui-1.0/debian/preinst 2015-11-19 12:04:29.000000000 +0000 @@ -6,7 +6,7 @@ install|upgrade) if [ -d "/usr/local/share/Msfgui/" ]; then echo "Panto is Removing the Metasploit Gui ..." - rm -rf "/usr/local/share/Msfgui/" + rm -rf "/opt/metasploit-gui" rm -rf "/usr/bin/msfgui" rm -rf "/usr/share/applications/Metasploit-Gui.desktop" fi diff -Nru metasploit-gui-1.0/launch4j.xml metasploit-gui-1.0/launch4j.xml --- metasploit-gui-1.0/launch4j.xml 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/launch4j.xml 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,22 @@ + + true + gui + dist\msfgui.jar + msfgui.exe + + + + normal + http://java.com/download + + false + false + + metasploit.ico + + + 1.5.0 + + preferJre + + \ No newline at end of file diff -Nru metasploit-gui-1.0/manifest.mf metasploit-gui-1.0/manifest.mf --- metasploit-gui-1.0/manifest.mf 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/manifest.mf 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build +SplashScreen-Image: msfgui/resources/splash.png Binary files /tmp/S5OQQjp5SJ/metasploit-gui-1.0/metasploit-gui.tar.gz and /tmp/kvQywBdWKJ/metasploit-gui-1.0/metasploit-gui.tar.gz differ Binary files /tmp/S5OQQjp5SJ/metasploit-gui-1.0/metasploit.ico and /tmp/kvQywBdWKJ/metasploit-gui-1.0/metasploit.ico differ diff -Nru metasploit-gui-1.0/msfgui metasploit-gui-1.0/msfgui --- metasploit-gui-1.0/msfgui 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/msfgui 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,4 @@ +#!/bin/sh +SCRIPT=$(readlink -f $0) +SCRIPTPATH=`dirname $SCRIPT` +java -jar $SCRIPTPATH/dist/msfgui.jar Binary files /tmp/S5OQQjp5SJ/metasploit-gui-1.0/msfgui.exe and /tmp/kvQywBdWKJ/metasploit-gui-1.0/msfgui.exe differ Binary files /tmp/S5OQQjp5SJ/metasploit-gui-1.0/msfgui-installer.exe and /tmp/kvQywBdWKJ/metasploit-gui-1.0/msfgui-installer.exe differ Binary files /tmp/S5OQQjp5SJ/metasploit-gui-1.0/msgpack-0.5.1-devel.jar and /tmp/kvQywBdWKJ/metasploit-gui-1.0/msgpack-0.5.1-devel.jar differ diff -Nru metasploit-gui-1.0/nsisscript.nsi metasploit-gui-1.0/nsisscript.nsi --- metasploit-gui-1.0/nsisscript.nsi 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/nsisscript.nsi 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,129 @@ +# If you change the names "msfgui.exe", "metasploit.ico", or "license.rtf" you should do a search and replace - they +# show up in a few places. +# All the other settings can be tweaked by editing the !defines at the top of this script +!define APPNAME "msfgui" +!define COMPANYNAME "Scriptjunkie Software" +!define DESCRIPTION "The Metasploit GUI" +# These three must be integers +!define VERSIONMAJOR 4 +!define VERSIONMINOR 6 +!define VERSIONBUILD 0 +# These will be displayed by the "Click here for support information" link in "Add/Remove Programs" +# It is possible to use "mailto:" links in here to open the email client +!define HELPURL "http://scriptjunkie.us/msfgui/" # "Support Information" link +!define UPDATEURL "https://github.com/scriptjunkie/msfgui" # "Product Updates" link +!define ABOUTURL "http://scriptjunkie.us/" # "Publisher" link +# This is the size (in kB) of all the files copied into "Program Files" +!define INSTALLSIZE 7233 + +RequestExecutionLevel admin ;Require admin rights on NT6+ (When UAC is turned on) + +InstallDir "$PROGRAMFILES\${APPNAME}" + +# rtf or txt file - remember if it is txt, it must be in the DOS text format (\r\n) +LicenseData "README.md" +# This will be in the installer/uninstaller's title bar +Name "${APPNAME}" +Icon "metasploit.ico" +outFile "msfgui-installer.exe" + +!include LogicLib.nsh + +# Just three pages - license agreement, install location, and installation +Page license +Page directory +Page instfiles + +!macro VerifyUserIsAdmin +UserInfo::GetAccountType +pop $0 +${If} $0 != "admin" ;Require admin rights on NT4+ + messageBox mb_iconstop "Administrator rights required!" + setErrorLevel 740 ;ERROR_ELEVATION_REQUIRED + quit +${EndIf} +!macroend + +function .onInit + setShellVarContext all + !insertmacro VerifyUserIsAdmin +functionEnd + +section "install" + # Files for the install directory - to build the installer, these should be in the same directory as the install script (this file) + setOutPath $INSTDIR + # Files added here should be removed by the uninstaller (see section "uninstall") + file "msfgui.exe" + file /r "dist" + file "metasploit.ico" + file "README.md" + # Add any other files for the install directory (license files, app data, etc) here + + # Uninstaller - See function un.onInit and section "uninstall" for configuration + writeUninstaller "$INSTDIR\uninstall.exe" + + # Start Menu + createDirectory "$SMPROGRAMS\${APPNAME}" + createShortCut "$SMPROGRAMS\${APPNAME}\${APPNAME}.lnk" "$INSTDIR\msfgui.exe" "" "$INSTDIR\metasploit.ico" + + # Registry information for add/remove programs + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "DisplayName" "${APPNAME} - ${DESCRIPTION}" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\"" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "InstallLocation" "$\"$INSTDIR$\"" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "DisplayIcon" "$\"$INSTDIR\metasploit.ico$\"" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "Publisher" "${COMPANYNAME}" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "HelpLink" "${HELPURL}" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "URLUpdateInfo" "${UPDATEURL}" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "URLInfoAbout" "${ABOUTURL}" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "DisplayVersion" "${VERSIONMAJOR}.${VERSIONMINOR}.${VERSIONBUILD}" + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "VersionMajor" ${VERSIONMAJOR} + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "VersionMinor" ${VERSIONMINOR} + # There is no option for modifying or repairing the install + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "NoModify" 1 + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "NoRepair" 1 + # Set the INSTALLSIZE constant (!defined at the top of this script) so Add/Remove Programs can accurately report the size + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "EstimatedSize" ${INSTALLSIZE} +sectionEnd + +# Installed +Function .onInstSuccess + MessageBox MB_YESNO "Start msfgui?" IDNO Nolaunch + SetOutPath $INSTDIR + ExecShell "" '"$INSTDIR\msfgui.exe"' + Nolaunch: +FunctionEnd + +# Uninstaller +function un.onInit + SetShellVarContext all + + #Verify the uninstaller - last chance to back out + MessageBox MB_OKCANCEL "Permanantly remove ${APPNAME}?" IDOK next + Abort + next: + !insertmacro VerifyUserIsAdmin +functionEnd + +section "uninstall" + + # Remove Start Menu launcher + delete "$SMPROGRAMS\${APPNAME}\${APPNAME}.lnk" + # Try to remove the Start Menu folder - this will only happen if it is empty + rmDir "$SMPROGRAMS\${APPNAME}" + + # Remove files + delete $INSTDIR\msfgui.exe + rmDir /r $INSTDIR\dist + delete $INSTDIR\metasploit.ico + delete $INSTDIR\README.md + + # Always delete uninstaller as the last action + delete $INSTDIR\uninstall.exe + + # Try to remove the install directory - this will only happen if it is empty + rmDir $INSTDIR + + # Remove uninstaller information from the registry + DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" +sectionEnd diff -Nru metasploit-gui-1.0/README.md metasploit-gui-1.0/README.md --- metasploit-gui-1.0/README.md 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/README.md 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +msfgui +====== + +The Metasploit GUI + +License +======= + +Copyright (C) 2010-2013 scriptjunkie +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * Neither the name of msfgui nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff -Nru metasploit-gui-1.0/src/msfgui/AutorouteOptionsDialog.form metasploit-gui-1.0/src/msfgui/AutorouteOptionsDialog.form --- metasploit-gui-1.0/src/msfgui/AutorouteOptionsDialog.form 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/AutorouteOptionsDialog.form 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,110 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff -Nru metasploit-gui-1.0/src/msfgui/AutorouteOptionsDialog.java metasploit-gui-1.0/src/msfgui/AutorouteOptionsDialog.java --- metasploit-gui-1.0/src/msfgui/AutorouteOptionsDialog.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/AutorouteOptionsDialog.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,113 @@ +package msfgui; + +/** + * Options dialog to get options for autoroute script + * @author scriptjunkie + */ +public class AutorouteOptionsDialog extends OptionsDialog { + + /** Creates new form AutorouteOptionsDialog */ + public AutorouteOptionsDialog(MainFrame parent, boolean modal) { + super(parent.getFrame(), "Autoroute Options", modal); + 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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + buttonGroup1 = new javax.swing.ButtonGroup(); + addRouteButton = new javax.swing.JRadioButton(); + deleteRouteButton = new javax.swing.JRadioButton(); + subnetLabel = new javax.swing.JLabel(); + ipField = new javax.swing.JTextField(); + okButton = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + + buttonGroup1.add(addRouteButton); + addRouteButton.setSelected(true); + org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(msfgui.MsfguiApp.class).getContext().getResourceMap(AutorouteOptionsDialog.class); + addRouteButton.setText(resourceMap.getString("addRouteButton.text")); // NOI18N + addRouteButton.setName("addRouteButton"); // NOI18N + + buttonGroup1.add(deleteRouteButton); + deleteRouteButton.setText(resourceMap.getString("deleteRouteButton.text")); // NOI18N + deleteRouteButton.setName("deleteRouteButton"); // NOI18N + + subnetLabel.setText(resourceMap.getString("subnetLabel.text")); // NOI18N + subnetLabel.setName("subnetLabel"); // NOI18N + + ipField.setText(resourceMap.getString("ipField.text")); // NOI18N + ipField.setName("ipField"); // NOI18N + + okButton.setText(resourceMap.getString("okButton.text")); // NOI18N + okButton.setName("okButton"); // NOI18N + okButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + okButtonActionPerformed(evt); + } + }); + + 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(layout.createSequentialGroup() + .addComponent(addRouteButton) + .addGap(18, 18, 18) + .addComponent(deleteRouteButton)) + .addGroup(layout.createSequentialGroup() + .addComponent(subnetLabel) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(ipField, javax.swing.GroupLayout.DEFAULT_SIZE, 314, Short.MAX_VALUE)) + .addComponent(okButton, javax.swing.GroupLayout.Alignment.TRAILING)) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(addRouteButton) + .addComponent(deleteRouteButton)) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(subnetLabel) + .addComponent(ipField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(okButton) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + pack(); + }// //GEN-END:initComponents + + private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed + if(addRouteButton.isSelected()) + command = "autoroute -s " + ipField.getText(); + else + command = "autoroute -d -s " + ipField.getText(); + setVisible(false); + dispose(); + }//GEN-LAST:event_okButtonActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JRadioButton addRouteButton; + private javax.swing.ButtonGroup buttonGroup1; + private javax.swing.JRadioButton deleteRouteButton; + private javax.swing.JTextField ipField; + private javax.swing.JButton okButton; + private javax.swing.JLabel subnetLabel; + // End of variables declaration//GEN-END:variables + +} diff -Nru metasploit-gui-1.0/src/msfgui/Base64.java metasploit-gui-1.0/src/msfgui/Base64.java --- metasploit-gui-1.0/src/msfgui/Base64.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/Base64.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,121 @@ +package msfgui; + +import java.io.*; + +/** + * Simple Base64 encoding/decoding. Very loosely based on Apache Base64 class. + * + * @author scriptjunkie + */ +public class Base64 { + private static final char intToBase64[] = { + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', + 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', + 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', + 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', + 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', + 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', '+', '/' + }; + private static final byte base64ToInt[] = { + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, + -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51 + }; + /** Converts a byte array to a bae64-encoded String. */ + public static String encode(byte source[]) { + int offset = 0; + int num = 0; + int numBytes = 0; + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < source.length; i++) { + int b = source[offset++]; + if (b < 0) + b += 256; + num = (num << 8) + b; + if (++numBytes != 3) + continue; + sb.append(intToBase64[num >> 18]); + sb.append(intToBase64[num >> 12 & 0x3f]); + sb.append(intToBase64[num >> 6 & 0x3f]); + sb.append(intToBase64[num & 0x3f]); + num = 0; + numBytes = 0; + } + if (numBytes > 0) { + if (numBytes == 1) { + sb.append(intToBase64[num >> 2]); + sb.append(intToBase64[num << 4 & 0x3f]); + sb.append("=="); + } else { + sb.append(intToBase64[num >> 10]); + sb.append(intToBase64[num >> 4 & 0x3f]); + sb.append(intToBase64[num << 2 & 0x3f]); + sb.append('='); + } + } + return sb.toString(); + } + /** Decodes a Base64-encoded String to a byte array. */ + public static byte[] decode(String source) throws MsfException { + int num=0; + int numBytes=0; + int eofBytes = 0; + ByteArrayOutputStream bout = new ByteArrayOutputStream(); + for (int i = 0; i < source.length(); i++) { + char c = source.charAt(i); + if (Character.isWhitespace(c)) + continue; + if (c == '=') { + eofBytes++; + num = num << 6; + switch (++numBytes) { + case 1: + case 2: + throw new MsfException("Unexpected end of stream character (=)"); + case 3: + break; + case 4: + bout.write((byte) (num >> 16)); + if (eofBytes == 1) + bout.write((byte) (num >> 8)); + break; + case 5: + throw new MsfException("Trailing garbage detected"); + default: + throw new IllegalStateException("Invalid value for numBytes"); + } + continue; + } + if (eofBytes > 0) + throw new MsfException("Base64 characters after end of stream character (=) detected."); + if (c >= 0 && c < Base64.base64ToInt.length) { + int result = Base64.base64ToInt[c]; + if (result >= 0) { + num = (num << 6) + result; + if (++numBytes != 4) + continue; + bout.write((byte) (num >> 16)); + bout.write((byte) (num >> 8 & 0xff)); + bout.write((byte) (num & 0xff)); + num = 0; + numBytes = 0; + continue; + } + } + if (!Character.isWhitespace(c)) + throw new MsfException("Invalid Base64 character: " + (int) c); + } + return bout.toByteArray(); + } +} diff -Nru metasploit-gui-1.0/src/msfgui/DbConnectDialog.form metasploit-gui-1.0/src/msfgui/DbConnectDialog.form --- metasploit-gui-1.0/src/msfgui/DbConnectDialog.form 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/DbConnectDialog.form 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,211 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff -Nru metasploit-gui-1.0/src/msfgui/DbConnectDialog.java metasploit-gui-1.0/src/msfgui/DbConnectDialog.java --- metasploit-gui-1.0/src/msfgui/DbConnectDialog.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/DbConnectDialog.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,328 @@ +package msfgui; + +import java.awt.Frame; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Scanner; +import javax.swing.JTextField; + +/** + * Options dialog to get database connection options. + * @author scriptjunkie + */ +public class DbConnectDialog extends OptionsDialog { + private RpcConnection rpcConn; + private Frame myParent; + private boolean success; + private Map props; + + //Opens dialog to get options + public static boolean connect(Frame parent, RpcConnection rpcConn){ + DbConnectDialog cd = new DbConnectDialog(parent, rpcConn, true); + if(cd.tryConnect()) + return 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(); + try{ + //If we don't have saved creds, look for them + if(!props.containsKey("dbusername")) + reloadDefaults(); + showDefaults(); + }catch(NullPointerException nex){ + }catch(MsfException mex){// No msf root? + mex.printStackTrace(); + } + Object driver = props.get("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") + // //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(); + defaultsButton = new javax.swing.JButton(); + + 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 + + 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); + 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(defaultsButton) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 208, Short.MAX_VALUE) + .addComponent(cancelButton) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(connectButton)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, 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() + .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) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(connectButton) + .addComponent(cancelButton) + .addComponent(defaultsButton)) + .addContainerGap()) + ); + + pack(); + }// //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.put("db"+key, val); + } + + /** Remove quotes */ + private String stripQuotes(String quoted){ + if(quoted.startsWith("\"") && quoted.endsWith("\"") + || quoted.startsWith("\'") && quoted.endsWith("\'")) + return quoted.substring(1, quoted.length() - 1); + return quoted; + } + + /** Loads database information from the database.yml file in the default install. */ + private void reloadDefaults(){ + try{ + Scanner s; + try{ + s = new Scanner(new File(MsfguiApp.getBase()+"/apps/pro/ui/config/database.yml")); + } catch (IOException iox){ + iox.printStackTrace(); + s = new Scanner(new File("/opt/metasploit/apps/pro/ui/config/database.yml")); + } + String token = s.next(); + while(!token.equals("production:")) + token = s.next(); + while(s.hasNext()){ + if(token.equals("adapter:")) + props.put("dbdriver", stripQuotes(s.next())); + else if(token.equals("database:")) + props.put("dbdatabase", stripQuotes(s.next())); + else if(token.equals("username:")) + props.put("dbusername", stripQuotes(s.next())); + else if(token.equals("password:")) + props.put("dbpassword", stripQuotes(s.next())); + else if(token.equals("host:")) + props.put("dbhost", stripQuotes(s.next())); + else if(token.equals("port:")) + props.put("dbport", stripQuotes(s.next())); + token = s.next(); + } + } catch (FileNotFoundException fnfox){ + fnfox.printStackTrace(); + } + 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(); + if (!success) + MsfguiApp.showMessage(myParent, "Failure connecting to database!"); + } catch (MsfException mex) { + MsfguiApp.showMessage(myParent, mex); + } + setVisible(false); + } + /** Sees whether we're connected */ + public static boolean isConnected(RpcConnection rpcConn) throws MsfException{ + Map status = (Map) rpcConn.execute("db.status"); + return status.containsKey("db"); + } + /** Tries to connect to the database with given credentials */ + private boolean tryConnect() throws MsfException{ + if(isConnected(rpcConn)) + return true; // already connected + 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.put("dbdriver", typeSpinner.getValue().toString()); + Map res = (Map) rpcConn.execute("db.connect",opts); + return "success".equals(res.get("result")); + }//GEN-LAST:event_connectButtonActionPerformed + + private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed + 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; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel6; + 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 +} diff -Nru metasploit-gui-1.0/src/msfgui/DraggableTabbedPane.java metasploit-gui-1.0/src/msfgui/DraggableTabbedPane.java --- metasploit-gui-1.0/src/msfgui/DraggableTabbedPane.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/DraggableTabbedPane.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,482 @@ +package msfgui; + +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.HeadlessException; +import java.awt.Point; +import java.awt.Window; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseMotionAdapter; +import java.awt.event.MouseMotionListener; +import java.awt.event.WindowEvent; +import java.awt.event.WindowFocusListener; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JMenuItem; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JSplitPane; +import javax.swing.JTabbedPane; +import javax.swing.JWindow; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; + +/** + * An extension of the JTabbedPane that supports dragging tabs into a new order + * or even into and out of new windows. + * + * @author scriptjunkie + */ +public class DraggableTabbedPane extends JTabbedPane{ + private static Set panes = new HashSet(); + private boolean dragging = false; + private int draggedTabIndex = 0; + private Container paneParent; + private Map focusListeners = new HashMap(); + private static FocusListener lastFocusListener = null; + private static JWindow window; + private final ChangeListener chListener; + static{ + //Set up placeholder window. (Shows when moving tabs) + window = new JWindow(); + JLabel lab = new JLabel("Moving", JLabel.CENTER); + lab.addMouseMotionListener(new MouseMotionListener() { + public void mouseMoved(MouseEvent e) { + window.setVisible(false); + } + public void mouseDragged(MouseEvent e) { + window.setVisible(false); + } + }); + window.getContentPane().add(lab, java.awt.BorderLayout.CENTER); + window.setSize(300, 300); + } + + /** + * Finds the parent tab of the component given in c. + * @param c The component whose tab is to be obtained + */ + public static DraggableTabbedPane getTabPane(Component c){ + Component subParent = c, par; + for(par = subParent.getParent(); !(par instanceof DraggableTabbedPane); par = par.getParent()) + subParent = par; + return (DraggableTabbedPane)par; + } + + /** + * Returns a object composed of nested arrays & strings representing the layout + * of splitpanes and tabs in the given object + * @param component The root component + * @return + */ + public static Object getSplitLayout(Object component){ + if(component instanceof javax.swing.JPanel){ + return getSplitLayout(((javax.swing.JPanel)component).getComponent(0)); + }else if(component instanceof javax.swing.JSplitPane){ + javax.swing.JSplitPane split = (javax.swing.JSplitPane)component; + ArrayList list = new ArrayList(); + list.add(split.getOrientation()); + list.add(getSplitLayout(split.getLeftComponent())); + list.add(getSplitLayout(split.getRightComponent())); + return list; + }else if(component instanceof DraggableTabbedPane){ + ArrayList list = new ArrayList(); + DraggableTabbedPane pane = (DraggableTabbedPane)component; + for(int i = 0; i < pane.getTabCount(); i++) + list.add(pane.getTitleAt(i)); + return list; + } + return null; + } + /** + * Restores a layout of splitpanes and tabs to the given container + * from an object composed of nested arrays & strings representing the layout + * @param component The root component + * @return + */ + public static Component restoreSplitLayout(Object component, Container parent, DraggableTabbedPane root){ + if(!(component instanceof ArrayList)) + return null; + ArrayList list = (ArrayList)component; + //Split pane + if(list.size() == 3 && ((ArrayList)component).get(0) instanceof Integer){ + JSplitPane split = new JSplitPane(); + Component left = restoreSplitLayout(list.get(1), split, root); + if(left == null) // If the only tabs here are not present (meterp, file, etc) + return restoreSplitLayout(list.get(2), parent, root); //return other side + //Get right + Component right = restoreSplitLayout(list.get(2), split, root); + if(right == null){ + //uhoh. now we told left the wrong parent. Fix. + if(left instanceof DraggableTabbedPane) + ((DraggableTabbedPane)left).paneParent = parent; + return left; + } + //Ok! both sides are good. Plug 'em in and we'll go + split.setOrientation((Integer)list.get(0)); + split.setLeftComponent(left); + split.setRightComponent(right); + return split; + } + DraggableTabbedPane pane = new DraggableTabbedPane(parent); + for(Object o : list) + if(root.indexOfTab(o.toString()) != -1) + root.moveTabTo(root.indexOfTab(o.toString()), pane); + if(pane.getTabCount() == 0) + return null; + root.paneParent = null; //we're disconnecting you + return pane; + } + + /** + * Finds the parent tab of the component given in c, and dis/enables it. + * @param c The component whose tab is to be dis/enabled + * @param enabled The new enabled state of the tab + */ + public static void setTabComponentEnabled(Component c, boolean enabled){ + Component subParent = c, par; + for(par = subParent.getParent(); !(par instanceof DraggableTabbedPane) && par != null; par = par.getParent()) + subParent = par; + if(par == null) + throw new MsfException("Error in DraggableTabbedPane.show; no parent is a DraggableTabbedPane!"); + DraggableTabbedPane pane = (DraggableTabbedPane)par; + for(int i = 0; i < pane.getTabCount(); i++) + if(pane.getComponentAt(i).equals(subParent)) + pane.setEnabledAt(i, enabled); + } + + /** + * Adds a listener which will be notified when the given tab receives or loses focus + * + * @param listener + */ + public void setTabFocusListener(int tabIndex, FocusListener listener){ + focusListeners.put(getComponentAt(tabIndex), listener); + } + + /** + * Moves the given tab to the destination DraggableTabbedPane. + * + * @param sourceIndex + * @param destinationPane + */ + public void moveTabTo(int sourceIndex, DraggableTabbedPane destinationPane){ + moveTabTo(sourceIndex, destinationPane, destinationPane.getTabCount()); + } + + /** + * Moves the given tab to the destination DraggableTabbedPane at the destination index + * + * @param sourceIndex + * @param destinationPane + * @param destinationIndex + */ + public void moveTabTo(int sourceIndex, DraggableTabbedPane destinationPane, int destinationIndex){ + //First save tab information + Component comp = getComponentAt(sourceIndex); + String title = getTitleAt(sourceIndex); + boolean enabled = isEnabledAt(sourceIndex); + + //Then move tab and restore information + removeTabAt(sourceIndex); + destinationPane.insertTab(title, null, comp, null, destinationIndex); + destinationPane.setEnabledAt(destinationIndex, enabled); + destinationPane.setSelectedIndex(destinationIndex); + destinationPane.focusListeners.put(comp, focusListeners.get(comp)); + + //If we got rid of the last tab, close this window, unless it's the main window + if(getTabCount() < 1 && MsfguiApp.mainFrame != null //This can be referenced in constructor + && paneParent != MsfguiApp.mainFrame.getFrame().getContentPane()){ + panes.remove(this); + if(paneParent instanceof JPanel) + paneParent = ((JPanel)paneParent).getTopLevelAncestor(); + //If parent is a frame, just close it + if(paneParent instanceof JFrame){ + paneParent.setVisible(false); + ((JFrame)paneParent).dispose(); + //If it's a split pane, replace with other side + }else if(paneParent instanceof JSplitPane){ + JSplitPane split = (JSplitPane)paneParent; + Component replacement; + if (split.getRightComponent() == this) + replacement = split.getLeftComponent(); + else if (((JSplitPane)paneParent).getLeftComponent() == this) + replacement = split.getRightComponent(); + else + throw new MsfException("Not either side of split? This should never happen"); + Container parent = split.getParent(); + parent.remove(split); + parent.add(replacement); + //If the other side is a DraggableTabbedPane, update its parent + for(Container c = parent; c != null; c=c.getParent()){ + if((c instanceof JSplitPane || c instanceof JFrame) + && replacement instanceof DraggableTabbedPane){ + ((DraggableTabbedPane)replacement).paneParent = c; + break; + } + } + ((Window)((javax.swing.JComponent)replacement).getTopLevelAncestor()).pack(); + } + } + } + + /** + * 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 + */ + public static void show(Component c){ + //Find containing tab pane + Component subParent = c, par; + for(par = subParent.getParent(); !(par instanceof DraggableTabbedPane) && par != null; par = par.getParent()) + subParent = par; + if(par == null) + throw new MsfException("Error in DraggableTabbedPane.show; no parent is a DraggableTabbedPane!"); + DraggableTabbedPane pane = (DraggableTabbedPane)par; + //Show this tab + for(int i = 0; i < pane.getTabCount(); i++) + if(pane.getComponentAt(i).equals(subParent)) + pane.setSelectedIndex(i); + lastFocusListener = (FocusListener)pane.focusListeners.get(pane.getSelectedComponent()); + try{ + //Also make containing window show up + for(par = pane.getParent(); !(par instanceof Window); par = par.getParent()) + ; + ((Window)par).setVisible(true); + }catch (NullPointerException nex){ // If it is not associated with a window, make one + pane.moveTabToNewFrame(pane.getSelectedIndex(), 0, 0).setSize(400, 300); + } + } + + /** + * Tells this DraggableTabbedPane to listen for focus events on the parent window. + */ + public void addWindowFocusListener(){ + Window win = (Window)getTopLevelAncestor(); + //Notify on focus changes + win.addWindowFocusListener(new WindowFocusListener(){ + public void windowGainedFocus(WindowEvent e) { + chListener.stateChanged(new ChangeEvent(getSelectedComponent())); + } + public void windowLostFocus(WindowEvent e) { + } + }); + } + + /** + * Constructs a new DraggableTabbedPane with a parent + * @param parent + */ + public DraggableTabbedPane(Container parent) { + paneParent = parent; + //Set up right-click menu + final JPopupMenu tabPopupMenu = new JPopupMenu(); + JMenuItem closeTabItem = new JMenuItem("Close this tab"); + closeTabItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + int indx = getSelectedIndex(); + if(indx != -1){ + JFrame newFrame = moveTabToNewFrame(indx,0,0); + newFrame.setVisible(false); + newFrame.dispose(); + } + } + }); + tabPopupMenu.add(closeTabItem); + JMenuItem newWinItem = new JMenuItem("Move to new window"); + newWinItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + int indx = getSelectedIndex(); + if(indx == -1) + return; + moveTabToNewFrame(indx,0,0); + } + }); + tabPopupMenu.add(newWinItem); + JMenuItem splitVerticalItem = new JMenuItem("Split vertically"); + splitVerticalItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + int indx = getSelectedIndex(); + if(indx == -1) + return; + addSplit(indx,JSplitPane.VERTICAL_SPLIT); + } + }); + tabPopupMenu.add(splitVerticalItem); + JMenuItem splitHorizontalItem = new JMenuItem("Split horizontally"); + splitHorizontalItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + int indx = getSelectedIndex(); + if(indx == -1) + return; + addSplit(indx,JSplitPane.HORIZONTAL_SPLIT); + } + }); + tabPopupMenu.add(splitHorizontalItem); + addMouseListener( new PopupMouseListener() { + public void showPopup(MouseEvent e) { + tabPopupMenu.show(DraggableTabbedPane.this, e.getX(), e.getY() ); + } + }); + //Set up dragging listener + addMouseMotionListener(new MouseMotionAdapter() { + public void mouseDragged(MouseEvent e) { + if (!dragging && ((e.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) != 0)) { + // Gets the tab index based on the mouse position + int tabNumber = getUI().tabForCoordinate(DraggableTabbedPane.this, e.getX(), e.getY()); + if (tabNumber < 0) + return; + draggedTabIndex = tabNumber; + dragging = true; + window.setVisible(true); + } else { + window.setLocation(e.getXOnScreen(), e.getYOnScreen()); + } + super.mouseDragged(e); + } + }); + //Set up tab change focus listener + chListener = new ChangeListener() { + public void stateChanged(ChangeEvent e) { + FocusEvent event = new FocusEvent((Component)e.getSource(), getSelectedIndex()); + FocusListener listener = (FocusListener)focusListeners.get(getSelectedComponent()); + //If focus has been lost, trigger lost focus event + if(lastFocusListener != null && lastFocusListener != listener) + lastFocusListener.focusLost(event); + //If we got focus, trigger gained focus event + if(listener != null && lastFocusListener != listener){ // If we have a new tab + listener.focusGained(event); + lastFocusListener = listener; + } + } + }; + this.addChangeListener(chListener); + + //Set up drop handler + addMouseListener(new MouseAdapter() { + public void mouseReleased(MouseEvent e) { + if (!dragging) + return; + //We are done dragging + dragging = false; + window.setVisible(false); + boolean moved = false; + + //Find out what pane this tab has been dragged to. + for(Object tabo : panes){ + DraggableTabbedPane pane = (DraggableTabbedPane)tabo; + try{ + Point ptabo = pane.getLocationOnScreen(); + int x = e.getXOnScreen() - ptabo.x; + int y = e.getYOnScreen() - ptabo.y; + int tabNumber = pane.getUI().tabForCoordinate(pane, x, y); + + //If it's not on one of the tabs, but it's still in the tab bar, make a new tab + int paneW = pane.getWidth(); + int paneH = pane.getHeight(); + if (tabNumber < 0 && x > 0 && y > 0 && x <= paneW && y <= paneH) + tabNumber = pane.getTabCount() - 1; + + //We found it! + if (tabNumber >= 0) { + moveTabTo(draggedTabIndex, pane, tabNumber); + return; + } + }catch(java.awt.IllegalComponentStateException icse){ + }// This is fired for non-visible windows. Can be safely ignored + } + //Not found. Must create new frame + moveTabToNewFrame(draggedTabIndex,e.getXOnScreen(),e.getYOnScreen()); + } + }); + panes.add(this); + } + + /** + * Splits the current tabbed pane, adding indx to the new split + * @param indx + */ + private void addSplit(int indx, int orientation) { + //Sanity check + if(getTabCount() < 2) + throw new MsfException("Need more than one tab to split view!"); + //Make split pane + JSplitPane split = new javax.swing.JSplitPane(); + split.setOrientation(orientation); + split.setLeftComponent(DraggableTabbedPane.this); + //make new tabbedpane + final DraggableTabbedPane tabs = new DraggableTabbedPane(split); + moveTabTo(indx, tabs, 0); + split.setRightComponent(tabs); + if (paneParent instanceof JFrame) { + Dimension size = paneParent.getSize(); + ((JFrame) paneParent).getContentPane().removeAll(); + ((JFrame) paneParent).getContentPane().setLayout(new java.awt.GridLayout()); + ((JFrame) paneParent).getContentPane().add(split); + ((JFrame) paneParent).pack(); + if((((JFrame)paneParent).getExtendedState() & JFrame.MAXIMIZED_BOTH) == 0) + paneParent.setSize(size); + } else if (paneParent instanceof JSplitPane) { + JSplitPane splitParent = (JSplitPane) paneParent; + if (splitParent.getRightComponent() == null) { + splitParent.setRightComponent(split); + } else if (splitParent.getLeftComponent() == null) { + splitParent.setLeftComponent(split); + } + splitParent.setDividerLocation(0.5); + }else if (paneParent instanceof JPanel){ + paneParent.removeAll(); + paneParent.setLayout(new java.awt.GridLayout()); + paneParent.add(split); + ((JPanel)paneParent).validate(); + } + split.setDividerLocation(0.5); + paneParent = split; + } + + /** + * Creates a new frame, and places the given tab in it + */ + private MsfFrame moveTabToNewFrame(int tabNumber, int x, int y) throws HeadlessException { + final MsfFrame newFrame = new MsfFrame("Msfgui"); + newFrame.setSize(DraggableTabbedPane.this.getSize()); + newFrame.setLocation(x, y); + //Make tabs to go in the frame + final DraggableTabbedPane tabs = new DraggableTabbedPane(newFrame); + moveTabTo(tabNumber, tabs, 0); + newFrame.add(tabs); + newFrame.setVisible(true); + //Clean up on exit + newFrame.addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosing(java.awt.event.WindowEvent evt) { + panes.remove(tabs); + if (panes.size() < 1) + System.exit(0); + } + }); + tabs.addWindowFocusListener(); + return newFrame; + } +} diff -Nru metasploit-gui-1.0/src/msfgui/InteractWindow.form metasploit-gui-1.0/src/msfgui/InteractWindow.form --- metasploit-gui-1.0/src/msfgui/InteractWindow.form 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/InteractWindow.form 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,144 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff -Nru metasploit-gui-1.0/src/msfgui/InteractWindow.java metasploit-gui-1.0/src/msfgui/InteractWindow.java --- metasploit-gui-1.0/src/msfgui/InteractWindow.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/InteractWindow.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,414 @@ +package msfgui; + +import java.awt.Font; +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.ClipboardOwner; +import java.awt.datatransfer.StringSelection; +import java.awt.datatransfer.Transferable; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.locks.ReentrantLock; +import org.jdesktop.swingworker.SwingWorker; + +/** + * Window to interact with shells/meterpreters/consoles. Interacts with tab completion and holds command + * history. Also allows synchronization with other threads or windows interacting with the same console. + * Only polls for output when open. + * @author scriptjunkie + */ +public class InteractWindow extends MsfFrame implements ClipboardOwner { + public final ReentrantLock lock = new ReentrantLock(); + private final Map session; + private final RpcConnection rpcConn; + private final String cmdPrefix; + private String prompt; + private Object sid; + public static final char POLL = 'r'; + public static final char PAUSE = 'p'; + public static final char STOP_POLLING = 's'; + private final StringBuffer timerCommand;//synchronized mutable object as command placeholder for polling thread + private final ArrayList commands; + private int currentCommand = 0; + + /** Create a new console window to run a command */ + public static InteractWindow runCmdWindow(final RpcConnection rpcConn, final Map session, final String autoCommand){ + return new InteractWindow(rpcConn, session, java.util.Arrays.asList(new String[]{autoCommand})); + } + /** Create a new console window to run a module */ + public InteractWindow(final RpcConnection rpcConn, final Map session, final List autoCommands){ + this(rpcConn, session, "console"); + inputField.setEnabled(false); + + //start new thread auto + new SwingWorker() { + protected Object doInBackground() throws Exception { + //for some reason the first command doesn't usually work. Do first command twice. + try { + if(autoCommands.get(0).toString().startsWith("use")) + rpcConn.execute(cmdPrefix + "write", session.get("id"), autoCommands.get(0) + "\n"); + } catch (MsfException ex) { + MsfguiApp.showMessage(null, ex); + } + for(Object cmd : autoCommands) { + try { + Thread.sleep(500);// Two commands a second + } catch (InterruptedException iex) { + } + this.publish(cmd); + } + inputField.setEnabled(true); + return null; + } + protected void process(List l){ + for(Object cmd : l){ + inputField.setText(cmd.toString()); + doInput(); + } + } + }.execute(); + } + + /** Creates a new window for interacting with shells/meterpreters/consoles */ + public InteractWindow(final RpcConnection rpcConn, final Map session, String type) { + super(type+" interaction window"); + initComponents(); + loadSavedSize(); + this.rpcConn = rpcConn; + this.session = session; + sid = session.get("id"); + tabbedPane.setTitleAt(0, type+" "+sid); + commands = new ArrayList(); + commands.add(""); + if(type.equals("console")) //console stuff + cmdPrefix = "console."; + else + cmdPrefix = "session." + type + "_"; + inputField.setFocusTraversalKeysEnabled(false); + //Add tab completion handler + inputField.addKeyListener(new KeyAdapter(){ + public void keyTyped(KeyEvent ke) { + //ignore other keys + if(ke.getKeyChar() != '\t') + return; + Map res = (Map)rpcConn.execute(cmdPrefix+"tabs", sid,inputField.getText()); + List tabs = (List)res.get("tabs"); + //one option: use it + if(tabs.size() == 1){ + inputField.setText(tabs.get(0).toString()+" "); + //more options: display, and use common prefix + } else if (tabs.size() > 1){ + String prefix = tabs.get(0).toString(); + for(Object o : tabs){ + String s = o.toString(); + int len = Math.min(s.length(), prefix.length()); + String newprefix = prefix; + for(int i = 0; i < len && s.charAt(i) == prefix.charAt(i); i++) + newprefix = prefix.substring(0,i+1); + prefix = newprefix; + outputArea.append("\n"+o.toString()); + } + outputArea.append("\n"); + inputField.setText(prefix); + } + } + }); + timerCommand = new StringBuffer(""+PAUSE); + prompt = ">>>"; + + //start new thread polling for input + new SwingWorker() { + protected Object doInBackground() throws Exception { + long time = 100; + while (timerCommand.charAt(0) != STOP_POLLING) { + if (timerCommand.charAt(0)== PAUSE){ + synchronized(timerCommand){ + timerCommand.wait(); + } + continue; + } + if (lock.tryLock() == false) { + this.publish("locked"); + lock.lock(); + this.publish("unlocked"); + } + try { //Get data, append to window, and send notification for prompt + long start = System.currentTimeMillis(); + Map received = (Map) rpcConn.execute(cmdPrefix+"read",sid); + time = System.currentTimeMillis() - start; + byte[] decodedBytes = RpcConnection.getData(received); + if (decodedBytes.length > 0) { + outputArea.append(new String(decodedBytes)); + if(decodedBytes[decodedBytes.length-1] != '\n') + outputArea.append("\n");//cause windows is just like that. + publish("data"); + } + publish(received); + } catch (MsfException ex) { + MsfguiApp.showMessage(null, ex); + if(ex.getMessage().toLowerCase().contains("unknown session") // we're dead. + || !ex.getMessage().contains("timed out")) // on timeout, just retry + timerCommand.setCharAt(0, STOP_POLLING); + } + lock.unlock(); + try { + Thread.sleep(100 + (time * 3));// if it takes a long time to get data, ask for it slower + } catch (InterruptedException iex) { + } + } + return null; + } + protected void process(List l){ + for(Object o : l){ + if(o.equals("locked")){ + submitButton.setEnabled(false); + inputField.setEditable(false); + }else if(o.equals("unlocked")){ + submitButton.setEnabled(true); + inputField.setEditable(true); + }else if(o instanceof Map){ //Update prompt if received + checkPrompt((Map)o); + }else{ //Data printed, scroll to end + outputArea.setCaretPosition(outputArea.getDocument().getLength()); + } + } + } + }.execute(); + + if(type.equals("meterpreter")) + inputField.setText("help"); + outputArea.setFont(new Font("Monospaced", outputArea.getFont().getStyle(), outputArea.getFont().getSize())); + checkPrompt(session); + ((DraggableTabbedPane)tabbedPane).setTabFocusListener(0, new FocusListener() { + public void focusGained(FocusEvent e) { + activate(); + } + public void focusLost(FocusEvent e) { + while(lock.getHoldCount() > 0) + lock.unlock(); + } + }); + } + /** Also sets initial command */ + public InteractWindow(final RpcConnection rpcConn, final Map session, String type, String initVal) { + this(rpcConn,session, type); + inputField.setText(initVal); + } + /** Sets the prompt if provided */ + private void checkPrompt(Map o) { + try{ + Object pobj = o.get("prompt"); + if (pobj == null) + return; + if(o.containsKey("encoding") && o.get("encoding").equals("base64")) + prompt = new String(Base64.decode(pobj.toString())); + else + prompt = pobj.toString(); + StringBuilder sb = new StringBuilder(); + for(int i = 0; i < prompt.length(); i++) + if(!Character.isISOControl(prompt.charAt(i))) + sb.append(prompt.charAt(i)); + prompt=sb.toString(); + promptLabel.setText(prompt); + submitButton.setEnabled(Boolean.FALSE.equals(o.get("busy"))); + }catch (MsfException mex){//bad prompt: do nothing + } + } + + private void doInput() { + try { + if(!submitButton.isEnabled()) + return; + String command = inputField.getText(); + commands.add(command); + rpcConn.execute(cmdPrefix + "write", session.get("id"), command + "\n"); + outputArea.append(prompt + command + "\n"); + outputArea.setCaretPosition(outputArea.getDocument().getLength()); + inputField.setText(""); + currentCommand = 0; + } catch (MsfException ex) { + MsfguiApp.showMessage(null, ex); + } + } + /** 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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + tabbedPane = new DraggableTabbedPane(this); + outputScrollPane = new javax.swing.JScrollPane(); + outputArea = new javax.swing.JTextArea(); + promptLabel = new javax.swing.JLabel(); + inputField = new javax.swing.JTextField(); + submitButton = new javax.swing.JButton(); + + addWindowListener(new java.awt.event.WindowAdapter() { + public void windowOpened(java.awt.event.WindowEvent evt) { + formWindowOpened(evt); + } + public void windowClosing(java.awt.event.WindowEvent evt) { + formWindowClosing(evt); + } + public void windowActivated(java.awt.event.WindowEvent evt) { + formWindowActivated(evt); + } + }); + + tabbedPane.setName("tabbedPane"); // NOI18N + + mainPanel.setName("mainPanel"); // NOI18N + + outputScrollPane.setAutoscrolls(true); + outputScrollPane.setName("outputScrollPane"); // NOI18N + + outputArea.setColumns(20); + outputArea.setEditable(false); + outputArea.setRows(5); + outputArea.setName("outputArea"); // NOI18N + outputScrollPane.setViewportView(outputArea); + + org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(msfgui.MsfguiApp.class).getContext().getResourceMap(InteractWindow.class); + promptLabel.setText(resourceMap.getString("promptLabel.text")); // NOI18N + promptLabel.setName("promptLabel"); // NOI18N + + inputField.setText(resourceMap.getString("inputField.text")); // NOI18N + inputField.setName("inputField"); // NOI18N + inputField.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + inputFieldActionPerformed(evt); + } + }); + inputField.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + inputFieldKeyPressed(evt); + } + }); + + submitButton.setText(resourceMap.getString("submitButton.text")); // NOI18N + submitButton.setName("submitButton"); // NOI18N + submitButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + submitButtonActionPerformed(evt); + } + }); + + javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel); + mainPanel.setLayout(mainPanelLayout); + mainPanelLayout.setHorizontalGroup( + mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(mainPanelLayout.createSequentialGroup() + .addComponent(promptLabel) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(inputField, javax.swing.GroupLayout.DEFAULT_SIZE, 505, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(submitButton) + .addContainerGap()) + .addComponent(outputScrollPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 619, Short.MAX_VALUE) + ); + mainPanelLayout.setVerticalGroup( + mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup() + .addComponent(outputScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 459, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(promptLabel) + .addComponent(inputField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(submitButton)) + .addContainerGap()) + ); + + tabbedPane.addTab(resourceMap.getString("mainPanel.TabConstraints.tabTitle"), mainPanel); // NOI18N + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(tabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 631, Short.MAX_VALUE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(tabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 551, Short.MAX_VALUE) + ); + + pack(); + }// //GEN-END:initComponents + + private void inputFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_inputFieldActionPerformed + doInput(); + }//GEN-LAST:event_inputFieldActionPerformed + + private void submitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_submitButtonActionPerformed + inputFieldActionPerformed(evt); + }//GEN-LAST:event_submitButtonActionPerformed + + private void inputFieldKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_inputFieldKeyPressed + if(evt.getKeyCode() == KeyEvent.VK_UP){ + currentCommand = (currentCommand - 1 + commands.size()) % commands.size(); + inputField.setText(commands.get(currentCommand).toString()); + }else if(evt.getKeyCode() == KeyEvent.VK_DOWN){ + currentCommand = (currentCommand + 1) % commands.size(); + inputField.setText(commands.get(currentCommand).toString()); + }else if (evt.isControlDown()) { + try { + if (evt.getKeyCode() == KeyEvent.VK_C){ + String selText = outputArea.getSelectedText(); + if(selText != null && selText.length() > 0){ + Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(selText), this); + }else{ + rpcConn.execute(cmdPrefix+"session_kill", session.get("id")); + } + }else if (evt.getKeyCode() == KeyEvent.VK_Z){ + rpcConn.execute(cmdPrefix+"session_detach", session.get("id")); + outputArea.append("backgrounding session...\n"); + } + } catch (MsfException ex) { + MsfguiApp.showMessage(null, ex); + } + } + }//GEN-LAST:event_inputFieldKeyPressed + + private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened + inputField.requestFocusInWindow(); + }//GEN-LAST:event_formWindowOpened + + private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing + timerCommand.setCharAt(0, PAUSE); + }//GEN-LAST:event_formWindowClosing + + private void formWindowActivated(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowActivated + activate(); + }//GEN-LAST:event_formWindowActivated + + /** + * Starts the polling process again + */ + public void activate(){ + timerCommand.setCharAt(0, POLL); + synchronized(timerCommand){ + timerCommand.notify(); + } + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JTextField inputField; + public final javax.swing.JPanel mainPanel = new javax.swing.JPanel(); + private javax.swing.JTextArea outputArea; + private javax.swing.JScrollPane outputScrollPane; + private javax.swing.JLabel promptLabel; + private javax.swing.JButton submitButton; + public javax.swing.JTabbedPane tabbedPane; + // End of variables declaration//GEN-END:variables + + /** ok */ + public void lostOwnership(Clipboard clipboard, Transferable contents) { + } +} diff -Nru metasploit-gui-1.0/src/msfgui/JobInfoPopup.form metasploit-gui-1.0/src/msfgui/JobInfoPopup.form --- metasploit-gui-1.0/src/msfgui/JobInfoPopup.form 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/JobInfoPopup.form 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,80 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff -Nru metasploit-gui-1.0/src/msfgui/JobInfoPopup.java metasploit-gui-1.0/src/msfgui/JobInfoPopup.java --- metasploit-gui-1.0/src/msfgui/JobInfoPopup.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/JobInfoPopup.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,100 @@ +package msfgui; + +import java.util.Map; + +/** + * Popup to show info from a job + * @author scriptjunkie + */ +public class JobInfoPopup extends javax.swing.JDialog { + + /** Creates new form JobInfoPopup */ + public JobInfoPopup(java.awt.Frame parent, boolean modal, Object text) { + super(parent, modal); + initComponents(); + Map myMap = (Map)text; + StringBuilder sb = new StringBuilder(); + for(Object oEntry : myMap.entrySet()){ + Map.Entry entry = (Map.Entry)oEntry; + if(entry.getValue() instanceof Map){ + sb.append(entry.getKey()).append("\n"); + for(Object osubEntry : ((Map)entry.getValue()).entrySet()){ + Map.Entry subEntry = (Map.Entry)osubEntry; + sb.append(" ").append(subEntry.getKey()).append(" = ").append(subEntry.getValue()).append("\n"); + } + }else { + sb.append(entry.getKey()).append(" = ").append(entry.getValue()).append("\n"); + } + } + textArea.setText(sb.toString()); + } + + /** 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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + okButton = new javax.swing.JButton(); + jScrollPane1 = new javax.swing.JScrollPane(); + textArea = new javax.swing.JTextArea(); + + setName("Form"); // NOI18N + + org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(msfgui.MsfguiApp.class).getContext().getResourceMap(JobInfoPopup.class); + okButton.setText(resourceMap.getString("okButton.text")); // NOI18N + okButton.setName("okButton"); // NOI18N + okButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + okButtonActionPerformed(evt); + } + }); + + jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + jScrollPane1.setName("jScrollPane1"); // NOI18N + + textArea.setColumns(20); + textArea.setLineWrap(true); + textArea.setRows(5); + textArea.setWrapStyleWord(true); + textArea.setName("textArea"); // NOI18N + jScrollPane1.setViewportView(textArea); + + 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) + .addComponent(okButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 395, Short.MAX_VALUE)) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap() + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 358, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(okButton) + .addContainerGap()) + ); + + pack(); + }// //GEN-END:initComponents + + private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed + setVisible(false); + dispose(); + }//GEN-LAST:event_okButtonActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JButton okButton; + private javax.swing.JTextArea textArea; + // End of variables declaration//GEN-END:variables +} diff -Nru metasploit-gui-1.0/src/msfgui/MainFrame.form metasploit-gui-1.0/src/msfgui/MainFrame.form --- metasploit-gui-1.0/src/msfgui/MainFrame.form 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/MainFrame.form 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,975 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -Nru metasploit-gui-1.0/src/msfgui/MainFrame.java metasploit-gui-1.0/src/msfgui/MainFrame.java --- metasploit-gui-1.0/src/msfgui/MainFrame.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/MainFrame.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,2000 @@ +/* + * MainFrame.java + */ +package msfgui; + +import java.awt.Component; +import java.awt.HeadlessException; +import org.jdesktop.application.*; +import java.awt.event.*; +import java.io.*; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Map; +import java.util.HashMap; +import java.util.TreeMap; +import java.util.ArrayList; +import java.util.List; +import javax.swing.Timer; +import javax.swing.Icon; +import javax.swing.JComponent; +import javax.swing.JDialog; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JMenu; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JPopupMenu; +import org.jdesktop.application.Task; +import org.jdesktop.swingworker.SwingWorker; + +/** The application's main frame. */ +public class MainFrame extends FrameView { + public static final int MENU_SIZE_LIMIT = 25; + + public HashMap sessionWindowMap; + public RpcConnection rpcConn; + private SwingWorker sessionsPollTimer = null; + private SessionsTable sessionsTableModel; + private JPopupMenu jobPopupMenu, shellPopupMenu, meterpreterPopupMenu, sessionPopupMenu; + private String clickedJob; + public Map[] selectedSessions; + private MsfTable[] tables; + private SearchWindow searchWin; + private javax.swing.JTable eventsTable; + private javax.swing.JScrollPane eventsPane; + + public MainFrame(SingleFrameApplication app) { + super(app); + MsfFrame.setLnF(); + initComponents(); + sessionsTableModel = null; + sessionWindowMap = new HashMap(); + + //"Factory reset" menu + factoryReset = new JMenuItem("Factory reset"); + factoryReset.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent ae) { + if(JOptionPane.showConfirmDialog(getFrame(), "This will reset ALL msfgui preferences and history.\n" + + "Are you sure?", "Factory reset", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) + == JOptionPane.YES_OPTION){ + MsfguiApp.getPropertiesNode().clear(); + MsfguiApp.savePreferences(); + JOptionPane.showMessageDialog(getFrame(), "Restart msfgui to see changes.", "Restart required", JOptionPane.INFORMATION_MESSAGE); + } + } + }); + this.helpMenu.add(factoryReset); + + //Set up action for starting RPC + startRpcMenuItem.setAction(getContext().getActionMap(this).get("startRpc")); + startRpcMenuItem.setMnemonic('S'); + org.jdesktop.application.ResourceMap resources = org.jdesktop.application.Application.getInstance( + msfgui.MsfguiApp.class).getContext().getResourceMap(MainFrame.class); + startRpcMenuItem.setText(resources.getString("startRpcMenuItem.text")); + + // status bar initialization - message timeout, idle icon and busy animation, etc + ResourceMap resourceMap = getResourceMap(); + int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout"); + messageTimer = new Timer(messageTimeout, new ActionListener() { + public void actionPerformed(ActionEvent e) { + statusMessageLabel.setText(""); + } + }); + messageTimer.setRepeats(false); + int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate"); + for (int i = 0; i < busyIcons.length; i++) + busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]"); + busyIconTimer = new Timer(busyAnimationRate, new ActionListener() { + public void actionPerformed(ActionEvent e) { + busyIconIndex = (busyIconIndex + 1) % busyIcons.length; + statusAnimationLabel.setIcon(busyIcons[busyIconIndex]); + } + }); + idleIcon = resourceMap.getIcon("StatusBar.idleIcon"); + statusAnimationLabel.setIcon(idleIcon); + progressBar.setVisible(false); + + // connecting action tasks to status bar via TaskMonitor + TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext()); + taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() { + public void propertyChange(java.beans.PropertyChangeEvent evt) { + String propertyName = evt.getPropertyName(); + if ("started".equals(propertyName)) { + if (!busyIconTimer.isRunning()) { + statusAnimationLabel.setIcon(busyIcons[0]); + busyIconIndex = 0; + busyIconTimer.start(); + } + progressBar.setVisible(true); + progressBar.setIndeterminate(true); + } else if ("done".equals(propertyName)) { + busyIconTimer.stop(); + statusAnimationLabel.setIcon(idleIcon); + progressBar.setVisible(false); + progressBar.setValue(0); + } else if ("message".equals(propertyName)) { + String text = (String)(evt.getNewValue()); + statusMessageLabel.setText((text == null) ? "" : text); + messageTimer.restart(); + } else if ("progress".equals(propertyName)) { + int value = (Integer)(evt.getNewValue()); + progressBar.setVisible(true); + progressBar.setIndeterminate(false); + progressBar.setValue(value); + } + } + }); + //Set up GUI, RPC connection, and recent modules + connectRpc(); // Connect to RPC daemon + setupPopupMenus(); + if(rpcConn != null) + handleNewRpcConnection(); + getFrame().addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent we) { + if(!MsfguiApp.shuttingDown && !confirmStop()) + throw new RuntimeException("Closing aborted."); + } + }); + //Events pane + eventsPane = new javax.swing.JScrollPane(); + eventsTable = new MsfTable(rpcConn, new String [] {"Host", "Created", "Updated", "Name", "Critical", "Username", "Info" + }, "events", new String[]{"host","created_at","updated_at","name","critical","username", "info"}); + eventsTable.setName("eventsTable"); // NOI18N + eventsPane.setViewportView(eventsTable);// Create a scrollable text area + tabbedPane.addTab("Events", eventsPane); // NOI18N + //Setup icon + this.getFrame().setIconImage( resourceMap.getImageIcon("main.icon").getImage()); + //Disable tabs by default + for(int i = 2; i < tabbedPane.getTabCount(); i++) + tabbedPane.setEnabledAt(i, false); + Map props = MsfguiApp.getPropertiesNode(); + if(!props.containsKey("tabWindowPreference")) + props.put("tabWindowPreference", "tab"); + if(props.containsKey("tabLayout")){ + Component realigned = DraggableTabbedPane.restoreSplitLayout( + props.get("tabLayout"), mainPanel, (DraggableTabbedPane)tabbedPane); + if(realigned != null){ + mainPanel.removeAll(); + mainPanel.setLayout(new java.awt.GridLayout()); + mainPanel.add(realigned); + } + } + MsfFrame.updateSizes(getFrame()); + this.tables = new MsfTable[]{(MsfTable)eventsTable, (MsfTable)hostsTable, + (MsfTable)clientsTable, (MsfTable)servicesTable, (MsfTable)vulnsTable, + (MsfTable)notesTable, (MsfTable)lootsTable, (MsfTable)credsTable}; + // Setup table autoquery code + ((MsfTable)eventsTable).addAutoAdjuster(eventsPane); + ((MsfTable)hostsTable).addAutoAdjuster(hostsPane); + ((MsfTable)clientsTable).addAutoAdjuster(clientsPane); + ((MsfTable)servicesTable).addAutoAdjuster(servicesPane); + ((MsfTable)vulnsTable).addAutoAdjuster(vulnsPane); + ((MsfTable)notesTable).addAutoAdjuster(notesPane); + ((MsfTable)lootsTable).addAutoAdjuster(lootsPane); + ((MsfTable)credsTable).addAutoAdjuster(credsPane); + } + /** Before exit, check whether the daemon should be stopped or just the session terminated */ + private boolean confirmStop() { + if (rpcConn == null) + return true; + try { + int choice = JOptionPane.showConfirmDialog(getFrame(), "Stop msfrpcd?"); + if(choice != JOptionPane.YES_OPTION && choice != JOptionPane.NO_OPTION) + return false; + MsfguiApp.shuttingDown = true; + if(choice == JOptionPane.YES_OPTION) + rpcConn.execute("core.stop"); + else if(choice == JOptionPane.NO_OPTION && rpcConn.username.length() > 0) + rpcConn.execute("auth.logout"); + } catch (Exception ex) { + } + // TEST TEST + Object m = DraggableTabbedPane.getSplitLayout(getFrame().getContentPane().getComponent(0)); + MsfguiApp.getPropertiesNode().put("tabLayout", m); + return true; + } + /** Adds window and menu items for reopening and closing the console */ + public void registerConsole(Map res, boolean show, String initVal) { + registerConsole(res,show,new InteractWindow(rpcConn, res, "console", initVal)); + } + /** Adds menu items for reopening and closing the console */ + public void registerConsole(Map res, boolean show, final InteractWindow iw) { + if(show){ + DraggableTabbedPane.show(iw.mainPanel); + if(MsfguiApp.getPropertiesNode().get("tabWindowPreference").equals("tab")) + ((DraggableTabbedPane)iw.tabbedPane).moveTabTo(0, DraggableTabbedPane.getTabPane(sessionsPane)); + iw.activate(); + } + final String id = res.get("id").toString(); + final JMenuItem openItem = new JMenuItem(id); + existingConsoleMenu.add(openItem); + openItem.addActionListener(new RpcAction() { + public void action() throws Exception { + DraggableTabbedPane.show(iw.mainPanel); + } + }); + final JMenuItem closeItem = new JMenuItem(id); + this.closeConsoleMenu.add(closeItem); + closeItem.addActionListener(new RpcAction() { + public void action() throws Exception { + iw.setVisible(false); + iw.dispose(); + rpcConn.execute("console.destroy", id); + existingConsoleMenu.remove(openItem); + closeConsoleMenu.remove(closeItem); + } + }); + } + + /** Set up auto session and job refresh */ + private void setupSessionsPollTimer() throws HeadlessException { + sessionsPollTimer = new SwingWorker(){ + @Override + protected List doInBackground() throws Exception { + int delay = 500; + while(true){ + try { + Thread.sleep(delay); + //update sessions + Map slist = (Map) rpcConn.execute("session.list"); + if(statusMessageLabel.getText().contains("timed out")) + publish(""); // If last attempt was a timeout, reset since we're rollin again + ArrayList sessionList = new ArrayList(); + for (Object sid : slist.keySet()) { + Map session = (Map) slist.get(sid); + session.put("id", sid); + MsfguiLog.defaultLog.logSession(session); + sessionList.add(slist.get(sid)); + //Make a window for the console if we need one and don't have it + if((session.get("type").equals("meterpreter") || session.get("type").equals("shell")) + && sessionWindowMap.get(session.get("id")+"console") == null){ + InteractWindow win = new InteractWindow(rpcConn, session, session.get("type").toString()); + if(MsfguiApp.getPropertiesNode().get("tabWindowPreference").equals("tab")){ + ((DraggableTabbedPane)win.tabbedPane).moveTabTo(0, DraggableTabbedPane.getTabPane(sessionsPane)); + win.activate(); + } + sessionWindowMap.put(session.get("id")+"console", win.mainPanel); + sessionWindowMap.put(session.get("id")+"lock", win.lock); + } + } + MsfguiLog.defaultLog.checkSessions(slist);//Alert the logger + if (sessionsTableModel == null) { + sessionsTableModel = new SessionsTable(sessionList); + sessionsTable.setModel(sessionsTableModel); + } else { + publish(sessionList); + } + //Update jobs + Map jlist = (Map) ((Map)rpcConn.execute("job.list")); + if(jlist.containsKey("jobs")) + jlist = (Map)jlist.get("jobs"); + TreeMap orderedJobsList = new TreeMap(); + orderedJobsList.putAll(jlist); + int i = 0; + String[] jobStrings = new String[jlist.size()]; + for (Object jid : orderedJobsList.keySet()) { + jobStrings[i] = jid.toString() + " - " + orderedJobsList.get(jid).toString(); + i++; + } + publish((Object)jobStrings); + } catch (MsfException msfEx) { + if(!MsfguiApp.shuttingDown || !msfEx.getMessage().contains("Connection refused")) + msfEx.printStackTrace(); + publish("Error getting session list "+msfEx); + if(!msfEx.getMessage().contains("timed out")) // on timeout, just retry + return new ArrayList(); + else + publish("Timeout getting session list. Retrying..."); + } catch (InterruptedException iex){ + } + } + } + // Receives data from polling thread and updates sessions and jobs. + @Override + protected void process(List lis){ + for(Object o : lis){ + if(o instanceof List){ + sessionsTableModel.updateSessions((List)o); + TableHelper.fitColumnWidths(sessionsTableModel,sessionsTable); + sessionsTable.updateUI(); + }else if (o instanceof String[]){ + int indx = jobsList.getSelectedIndex(); + jobsList.setListData((String[])o); + jobsList.setSelectedIndex(indx); + }else if (o instanceof String){ + statusMessageLabel.setText(o.toString()); + } + } + } + }; + } + + /** + * Makes a menu tree from a list of modules, and sets action + * listeners from the given factory. + * @param mlist List of modules. + * @param rootMenu Base menu to build tree off of. + * @param factory Factory to generate handlers to do the actions. + */ + private void expandList(List mlist, JMenu rootMenu, RunMenuFactory factory, String type) { + long currentTime = java.util.Calendar.getInstance().getTimeInMillis(); + + //Make sure modDates object is initialized + Map modDates; + Object mdo = MsfguiApp.getPropertiesNode().get("modDates"); + if(mdo == null){ + modDates = new HashMap(); + MsfguiApp.getPropertiesNode().put("modDates", modDates); + }else{ + modDates = (Map)mdo; + } + + //Update status bar + statusAnimationLabel.setText(statusAnimationLabel.getText()+mlist.size() + " "+type+" "); + + //Display sorted list + java.util.Collections.sort(mlist); + for (Object fullName : mlist) { + //add to dates hash + Object time = modDates.get(fullName); + if(time == null) + modDates.put(fullName, currentTime); + boolean recentlyAdded = Long.parseLong(modDates.get(fullName).toString()) >= currentTime - 604800000;//one week + + //Create or find menu for each element of module name + String[] names = fullName.toString().split("/"); + JMenu currentMenu = rootMenu; +nameloop: for (int i = 0; i < names.length; i++) { + boolean found = false; + Component[] comps = currentMenu.getMenuComponents(); + + boolean searchNext = true; + while(searchNext){ //if "More..." listed, search through more list + if(recentlyAdded) + currentMenu.setFont(currentMenu.getFont().deriveFont(currentMenu.getFont().getStyle() | java.awt.Font.BOLD)); + searchNext = false; + Component [] compsCopy = comps; + for (Component menu : compsCopy) { + if (menu.getName().equals(names[i]) && menu instanceof JMenu) { + if (i < names.length - 1) + currentMenu = (JMenu) menu; + continue nameloop; + }else if (menu.getName().equals("More...")){ + searchNext = true; + comps = ((JMenu)menu).getMenuComponents(); + currentMenu = (JMenu) menu; + } + } + } + //Create new menu element + if(comps.length > MENU_SIZE_LIMIT){ //extend if necessary + JMenu extention = new JMenu("More..."); + extention.setName("More..."); + currentMenu.add(extention); + currentMenu = extention; + } + if (i < names.length - 1) { + JMenu men = new JMenu(names[i]); + men.setName(names[i]); + currentMenu.add(men); + currentMenu = (JMenu) men; + } else { + try{ + JMenuItem men = new JMenuItem(names[i]); + if(recentlyAdded) + men.setFont(men.getFont().deriveFont(men.getFont().getStyle() | java.awt.Font.BOLD)); + men.setName(names[i]); + currentMenu.add(men); + ActionListener actor = factory.getActor(fullName.toString(),type,rpcConn); + men.addActionListener(actor); + searchWin.modules.add(new Object[]{type, fullName.toString(),actor}); + }catch(ClassCastException cce){ + System.err.println(names[i]); + cce.printStackTrace(); + } + } + }//end for each subname + }//end for each module + rootMenu.setEnabled(true); + }//end expandList() + + /** Displays info including version */ + @Action + public void showAboutBox() { + MsfguiAboutBox.show(getFrame(), rpcConn); + } + + /** Makes a menu tree with expandList for exploits and auxiliary. Also start jobs/sessions watcher. */ + public void refreshConsoles(){ + existingConsoleMenu.removeAll(); + closeConsoleMenu.removeAll(); + //Setup consoles + try{ + List consoles = (List) ((Map)rpcConn.execute("console.list")).get("consoles"); + for (Object console : consoles) + registerConsole((Map)console,false, ""); + }catch (MsfException mex){ + MsfguiApp.showMessage(getFrame(), mex); + } + } + + /** Makes a menu tree with expandList for exploits and auxiliary. Also start jobs/sessions watcher. */ + public void handleNewRpcConnection() { + setupSessionsPollTimer(); + searchWin = new SearchWindow(rpcConn); + MsfguiApp.addRecentModules(rpcConn, this); + getContext().getActionMap(this).get("moduleTask").actionPerformed(new java.awt.event.ActionEvent(this,1234,"")); + } + + /** helper for getModules - does the work */ + @Action + public Task moduleTask(){ + return new Task(getApplication()){ + @Override + protected Void doInBackground() throws Exception { + setTitle("Connected to running msfrpcd. Getting module lists."); + setProgress(0.0f); + //Get modules lists + try { + // yeah three layer deep nested inner classes sucks but I hate making new files for each one + RunMenuFactory moduleFactory = new RunMenuFactory(){ + public ActionListener getActor(final String modName, final String type, final RpcConnection rpcConn) { + return new ActionListener(){ + public void actionPerformed(ActionEvent e) { + //If we have saved options for this module, use those + Object modOptions = MsfguiApp.getPropertiesNode().get("modOptions"); + if(modOptions != null && ((Map)modOptions).containsKey(type+" "+modName)) + new ModulePopup(rpcConn, ((List)((Map)modOptions).get(type+" "+modName)).toArray(), MainFrame.this).setVisible(true); + else //otherwise go with the default + new ModulePopup(modName,rpcConn,type, MainFrame.this).setVisible(true); + } + }; + } + }; + //Exploits and auxiliary get modulepopups; payloads get payloadpopups duh + setMessage("Getting exploits"); + statusAnimationLabel.setText(""); + expandList((List) ((Map)rpcConn.execute("module.exploits")).get("modules"), exploitsMenu, moduleFactory, "exploit"); + setProgress(0.3f); + setMessage("Getting auxiliary modules"); + expandList((List) ((Map)rpcConn.execute("module.auxiliary")).get("modules"), auxiliaryMenu, moduleFactory, "auxiliary"); + setProgress(0.5f); + setMessage("Getting payloads"); + expandList((List) ((Map)rpcConn.execute("module.payloads")).get("modules"), payloadsMenu, new RunMenuFactory(){ + public ActionListener getActor(final String modName, final String type, final RpcConnection rpcConn) { + return new ActionListener() { + public void actionPerformed(ActionEvent e) { + new PayloadPopup(modName, rpcConn, MainFrame.this).setVisible(true); + } + }; + } + }, "payload"); + setProgress(0.7f); + setMessage("Getting post modules"); + JMenu postModMenu = new JMenu("Modules"); + meterpreterPopupMenu.add(postModMenu,4); + expandList((List) ((Map)rpcConn.execute("module.post")).get("modules"), postModMenu, moduleFactory, "post"); + setProgress(0.85f); + postMenu.setEnabled(true); + + setMessage("Finding open consoles"); + refreshConsoles(); + consoleMenu.setEnabled(true); + + setMessage("Querying database..."); + //First try to connect to the database + reloadDb(true); + setProgress(0.95f); + databaseMenu.setEnabled(true); + pluginsMenu.setEnabled(true); + setProgress(1.0f); + } catch (MsfException ex) { + statusAnimationLabel.setText("Error getting module lists. " + ex); + } + MsfFrame.updateSizes(getFrame()); + return null; + } + + @Override + protected void succeeded(Void blah) { + sessionsPollTimer.execute(); + statusAnimationLabel.setText(statusAnimationLabel.getText()+"modules"); + setMessage(""); + } + }; + } + + /** 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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + mainPanel = new javax.swing.JPanel(); + tabbedPane = new DraggableTabbedPane(getFrame()); + jobsPane = new javax.swing.JScrollPane(); + jobsList = new javax.swing.JList(); + sessionsPane = new javax.swing.JScrollPane(); + sessionsTable = new javax.swing.JTable(); + hostsPane = new javax.swing.JScrollPane(); + hostsTable = new MsfTable(rpcConn, new String [] {"Created", "Address", "Address6", "MAC", "Name", "State", "OS name", "OS flavor", "OS SP", "OS lang", "Updated", "Purpose", "Info"} + , "hosts",new String[]{"created_at", "address", "address6", "mac", "name", "state", "os_name", "os_flavor", "os_sp", "os_lang", "updated_at", "purpose", "info"}); + clientsPane = new javax.swing.JScrollPane(); + clientsTable = new MsfTable(rpcConn, new String [] {"Host", "UA String", "UA Name", "UA Ver", "Created", "Updated"} + , "clients", new String[]{"host", "ua_string", "ua_name", "ua_ver", "created_at", "updated_at"}); + servicesPane = new javax.swing.JScrollPane(); + servicesTable = new MsfTable(rpcConn, new String [] {"Host", "Created", "Updated", "Port", "Proto", "State", "Name", "Info"} + , "services", new String[]{"host", "created_at", "updated_at", "port", "proto", "state", "name", "info"}); + vulnsPane = new javax.swing.JScrollPane(); + vulnsTable = new MsfTable(rpcConn, new String [] {"Port", "Proto", "Time", "Host", "Name", "Refs" + }, "vulns", new String[]{"port", "proto", "time", "host", "name", "refs"}); + notesPane = new javax.swing.JScrollPane(); + notesTable = new MsfTable(rpcConn, new String [] {"Time", "Host", "Service", "Type", "Data" + }, "notes", new String[]{"time", "host", "service", "type", "data"}); + lootsPane = new javax.swing.JScrollPane(); + lootsTable = new MsfTable(rpcConn,new String [] {"Host", "Service", "Ltype", "Ctype", "Data", "Created", "Updated", "Name", "Info" + }, "loots", new String[]{"host", "service", "ltype", "ctype", "data", "created_at", "updated_at", "name", "info"}); + credsPane = new javax.swing.JScrollPane(); + credsTable = new MsfTable(rpcConn, new String [] {"Host", "Updated", "Port", "Proto", "Sname", "Type", "User", "Pass", "Active" + }, "creds", new String[]{"host", "updated_at", "port", "proto", "sname", "type", "user", "pass", "active"}); + menuBar = new javax.swing.JMenuBar(); + javax.swing.JMenu fileMenu = new javax.swing.JMenu(); + connectRpcMenuItem = new javax.swing.JMenuItem(); + startRpcMenuItem = new javax.swing.JMenuItem(); + showDetailsItem = new javax.swing.JMenuItem(); + jSeparator1 = new javax.swing.JPopupMenu.Separator(); + searchItem = new javax.swing.JMenuItem(); + javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem(); + viewMenu = new javax.swing.JMenu(); + viewPrefsItem = new javax.swing.JMenuItem(); + jobViewItem = new javax.swing.JMenuItem(); + sessionsViewItem = new javax.swing.JMenuItem(); + hostsViewItem = new javax.swing.JMenuItem(); + clientsViewItem = new javax.swing.JMenuItem(); + servicesViewItem = new javax.swing.JMenuItem(); + vulnsViewItem = new javax.swing.JMenuItem(); + eventsViewItem = new javax.swing.JMenuItem(); + notesViewItem = new javax.swing.JMenuItem(); + credsViewItem = new javax.swing.JMenuItem(); + lootsViewItem = new javax.swing.JMenuItem(); + exploitsMenu = new javax.swing.JMenu(); + auxiliaryMenu = new javax.swing.JMenu(); + payloadsMenu = new javax.swing.JMenu(); + historyMenu = new javax.swing.JMenu(); + recentMenu = new javax.swing.JMenu(); + clearHistoryItem = new javax.swing.JMenuItem(); + postMenu = new javax.swing.JMenu(); + menuRunAllMeterp = new javax.swing.JMenu(); + crackPasswordsItem = new javax.swing.JMenuItem(); + killSessionsMenuItem = new javax.swing.JMenuItem(); + logGenerateMenuItem = new javax.swing.JMenuItem(); + consoleMenu = new javax.swing.JMenu(); + newConsoleItem = new javax.swing.JMenuItem(); + existingConsoleMenu = new javax.swing.JMenu(); + closeConsoleMenu = new javax.swing.JMenu(); + refreshConsolesItem = new javax.swing.JMenuItem(); + databaseMenu = new javax.swing.JMenu(); + connectItem = new javax.swing.JMenuItem(); + disconnectItem = new javax.swing.JMenuItem(); + refreshItem = new javax.swing.JMenuItem(); + nmapItem = new javax.swing.JMenuItem(); + importItem = new javax.swing.JMenuItem(); + dbExportItem = new javax.swing.JMenuItem(); + currWorkspaceItem = new javax.swing.JMenuItem(); + addWorkspaceItem = new javax.swing.JMenuItem(); + delWorkspaceItem = new javax.swing.JMenuItem(); + pluginsMenu = new javax.swing.JMenu(); + autoAddRouteItem = new javax.swing.JMenuItem(); + soundItem = new javax.swing.JMenuItem(); + dbCredcollectItem = new javax.swing.JMenuItem(); + dbTrackerItem = new javax.swing.JMenuItem(); + socketLoggerItem = new javax.swing.JMenuItem(); + ipsFilterItem = new javax.swing.JMenuItem(); + otherPluginItem = new javax.swing.JMenuItem(); + unloadPluginItem = new javax.swing.JMenuItem(); + helpMenu = new javax.swing.JMenu(); + onlineHelpMenu = new javax.swing.JMenuItem(); + javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem(); + statusPanel = new javax.swing.JPanel(); + statusMessageLabel = new javax.swing.JLabel(); + statusAnimationLabel = new javax.swing.JLabel(); + progressBar = new javax.swing.JProgressBar(); + + mainPanel.setName("mainPanel"); // NOI18N + + tabbedPane.setMinimumSize(new java.awt.Dimension(77, 50)); + tabbedPane.setName("tabbedPane"); // NOI18N + + jobsPane.setName("jobsPane"); // NOI18N + jobsPane.setPreferredSize(new java.awt.Dimension(10, 10)); + + jobsList.setName("jobsList"); // NOI18N + jobsPane.setViewportView(jobsList); + + org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(msfgui.MsfguiApp.class).getContext().getResourceMap(MainFrame.class); + tabbedPane.addTab(resourceMap.getString("jobsPane.TabConstraints.tabTitle"), jobsPane); // NOI18N + + sessionsPane.setName("sessionsPane"); // NOI18N + + sessionsTable.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] { + + }, + new String [] { + + } + )); + sessionsTable.setName("sessionsTable"); // NOI18N + sessionsTable.setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + sessionsTable.setAutoCreateRowSorter(true); + sessionsPane.setViewportView(sessionsTable); + + tabbedPane.addTab(resourceMap.getString("sessionsPane.TabConstraints.tabTitle"), sessionsPane); // NOI18N + + hostsPane.setName("hostsPane"); // NOI18N + + hostsTable.setName("hostsTable"); // NOI18N + hostsTable.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyReleased(java.awt.event.KeyEvent evt) { + hostsTableKeyReleased(evt); + } + }); + hostsPane.setViewportView(hostsTable); + + tabbedPane.addTab(resourceMap.getString("hostsPane.TabConstraints.tabTitle"), hostsPane); // NOI18N + + clientsPane.setName("clientsPane"); // NOI18N + + clientsTable.setName("clientsTable"); // NOI18N + clientsTable.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyReleased(java.awt.event.KeyEvent evt) { + clientsTableKeyReleased(evt); + } + }); + clientsPane.setViewportView(clientsTable); + + tabbedPane.addTab(resourceMap.getString("clientsPane.TabConstraints.tabTitle"), clientsPane); // NOI18N + + servicesPane.setName("servicesPane"); // NOI18N + + servicesTable.setName("servicesTable"); // NOI18N + servicesTable.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyReleased(java.awt.event.KeyEvent evt) { + servicesTableKeyReleased(evt); + } + }); + servicesPane.setViewportView(servicesTable); + + tabbedPane.addTab(resourceMap.getString("servicesPane.TabConstraints.tabTitle"), servicesPane); // NOI18N + + vulnsPane.setName("vulnsPane"); // NOI18N + + vulnsTable.setName("vulnsTable"); // NOI18N + vulnsTable.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyReleased(java.awt.event.KeyEvent evt) { + vulnsTableKeyReleased(evt); + } + }); + vulnsPane.setViewportView(vulnsTable); + + tabbedPane.addTab(resourceMap.getString("vulnsPane.TabConstraints.tabTitle"), vulnsPane); // NOI18N + + notesPane.setName("notesPane"); // NOI18N + + notesTable.setName("notesTable"); // NOI18N + notesTable.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyReleased(java.awt.event.KeyEvent evt) { + notesTableKeyReleased(evt); + } + }); + notesPane.setViewportView(notesTable); + + tabbedPane.addTab(resourceMap.getString("notesPane.TabConstraints.tabTitle"), notesPane); // NOI18N + + lootsPane.setName("lootsPane"); // NOI18N + + lootsTable.setName("lootsTable"); // NOI18N + lootsTable.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyReleased(java.awt.event.KeyEvent evt) { + lootsTableKeyReleased(evt); + } + }); + lootsPane.setViewportView(lootsTable); + + tabbedPane.addTab(resourceMap.getString("lootsPane.TabConstraints.tabTitle"), lootsPane); // NOI18N + + credsPane.setName("credsPane"); // NOI18N + + credsTable.setName("credsTable"); // NOI18N + credsPane.setViewportView(credsTable); + + tabbedPane.addTab(resourceMap.getString("credsPane.TabConstraints.tabTitle"), credsPane); // NOI18N + + javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel); + mainPanel.setLayout(mainPanelLayout); + mainPanelLayout.setHorizontalGroup( + mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(tabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 882, Short.MAX_VALUE) + ); + mainPanelLayout.setVerticalGroup( + mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(tabbedPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 534, Short.MAX_VALUE) + ); + + menuBar.setName("menuBar"); // NOI18N + + fileMenu.setMnemonic('F'); + fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N + fileMenu.setName("fileMenu"); // NOI18N + + connectRpcMenuItem.setMnemonic('C'); + connectRpcMenuItem.setText(resourceMap.getString("connectRpcMenuItem.text")); // NOI18N + connectRpcMenuItem.setName("connectRpcMenuItem"); // NOI18N + connectRpcMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + connectRpcMenuItemActionPerformed(evt); + } + }); + fileMenu.add(connectRpcMenuItem); + + startRpcMenuItem.setMnemonic('S'); + startRpcMenuItem.setText(resourceMap.getString("startRpcMenuItem.text")); // NOI18N + startRpcMenuItem.setName("startRpcMenuItem"); // NOI18N + fileMenu.add(startRpcMenuItem); + + showDetailsItem.setMnemonic('d'); + showDetailsItem.setText(resourceMap.getString("showDetailsItem.text")); // NOI18N + showDetailsItem.setName("showDetailsItem"); // NOI18N + showDetailsItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + showDetailsItemActionPerformed(evt); + } + }); + fileMenu.add(showDetailsItem); + + jSeparator1.setName("jSeparator1"); // NOI18N + fileMenu.add(jSeparator1); + + searchItem.setText(resourceMap.getString("searchItem.text")); // NOI18N + searchItem.setName("searchItem"); // NOI18N + searchItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + searchItemActionPerformed(evt); + } + }); + fileMenu.add(searchItem); + + javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(msfgui.MsfguiApp.class).getContext().getActionMap(MainFrame.class, this); + exitMenuItem.setAction(actionMap.get("quit")); // NOI18N + exitMenuItem.setName("exitMenuItem"); // NOI18N + exitMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + exitMenuItemActionPerformed(evt); + } + }); + fileMenu.add(exitMenuItem); + + menuBar.add(fileMenu); + + viewMenu.setMnemonic('V'); + viewMenu.setText(resourceMap.getString("viewMenu.text")); // NOI18N + viewMenu.setName("viewMenu"); // NOI18N + + viewPrefsItem.setMnemonic('P'); + viewPrefsItem.setText(resourceMap.getString("viewPrefsItem.text")); // NOI18N + viewPrefsItem.setName("viewPrefsItem"); // NOI18N + viewPrefsItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + viewPrefsItemActionPerformed(evt); + } + }); + viewMenu.add(viewPrefsItem); + + jobViewItem.setMnemonic('J'); + jobViewItem.setText(resourceMap.getString("jobViewItem.text")); // NOI18N + jobViewItem.setName("jobViewItem"); // NOI18N + jobViewItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jobViewItemActionPerformed(evt); + } + }); + viewMenu.add(jobViewItem); + + sessionsViewItem.setMnemonic('s'); + sessionsViewItem.setText(resourceMap.getString("sessionsViewItem.text")); // NOI18N + sessionsViewItem.setName("sessionsViewItem"); // NOI18N + sessionsViewItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + sessionsViewItemActionPerformed(evt); + } + }); + viewMenu.add(sessionsViewItem); + + hostsViewItem.setMnemonic('h'); + hostsViewItem.setText(resourceMap.getString("hostsViewItem.text")); // NOI18N + hostsViewItem.setName("hostsViewItem"); // NOI18N + hostsViewItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + hostsViewItemActionPerformed(evt); + } + }); + viewMenu.add(hostsViewItem); + + clientsViewItem.setMnemonic('c'); + clientsViewItem.setText(resourceMap.getString("clientsViewItem.text")); // NOI18N + clientsViewItem.setName("clientsViewItem"); // NOI18N + clientsViewItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + clientsViewItemActionPerformed(evt); + } + }); + viewMenu.add(clientsViewItem); + + servicesViewItem.setMnemonic('r'); + servicesViewItem.setText(resourceMap.getString("servicesViewItem.text")); // NOI18N + servicesViewItem.setName("servicesViewItem"); // NOI18N + servicesViewItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + servicesViewItemActionPerformed(evt); + } + }); + viewMenu.add(servicesViewItem); + + vulnsViewItem.setMnemonic('v'); + vulnsViewItem.setText(resourceMap.getString("vulnsViewItem.text")); // NOI18N + vulnsViewItem.setName("vulnsViewItem"); // NOI18N + vulnsViewItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + vulnsViewItemActionPerformed(evt); + } + }); + viewMenu.add(vulnsViewItem); + + eventsViewItem.setMnemonic('e'); + eventsViewItem.setText(resourceMap.getString("eventsViewItem.text")); // NOI18N + eventsViewItem.setName("eventsViewItem"); // NOI18N + eventsViewItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + eventsViewItemActionPerformed(evt); + } + }); + viewMenu.add(eventsViewItem); + + notesViewItem.setMnemonic('n'); + notesViewItem.setText(resourceMap.getString("notesViewItem.text")); // NOI18N + notesViewItem.setName("notesViewItem"); // NOI18N + notesViewItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + notesViewItemActionPerformed(evt); + } + }); + viewMenu.add(notesViewItem); + + credsViewItem.setMnemonic('C'); + credsViewItem.setText(resourceMap.getString("credsViewItem.text")); // NOI18N + credsViewItem.setName("credsViewItem"); // NOI18N + credsViewItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + credsViewItemActionPerformed(evt); + } + }); + viewMenu.add(credsViewItem); + + lootsViewItem.setMnemonic('l'); + lootsViewItem.setText(resourceMap.getString("lootsViewItem.text")); // NOI18N + lootsViewItem.setName("lootsViewItem"); // NOI18N + lootsViewItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + lootsViewItemActionPerformed(evt); + } + }); + viewMenu.add(lootsViewItem); + + menuBar.add(viewMenu); + + exploitsMenu.setMnemonic('E'); + exploitsMenu.setText(resourceMap.getString("exploitsMenu.text")); // NOI18N + exploitsMenu.setEnabled(false); + exploitsMenu.setName("exploitsMenu"); // NOI18N + menuBar.add(exploitsMenu); + + auxiliaryMenu.setMnemonic('A'); + auxiliaryMenu.setText(resourceMap.getString("auxiliaryMenu.text")); // NOI18N + auxiliaryMenu.setEnabled(false); + auxiliaryMenu.setName("auxiliaryMenu"); // NOI18N + menuBar.add(auxiliaryMenu); + + payloadsMenu.setMnemonic('P'); + payloadsMenu.setText(resourceMap.getString("payloadsMenu.text")); // NOI18N + payloadsMenu.setEnabled(false); + payloadsMenu.setName("payloadsMenu"); // NOI18N + menuBar.add(payloadsMenu); + + historyMenu.setMnemonic('H'); + historyMenu.setText(resourceMap.getString("historyMenu.text")); // NOI18N + historyMenu.setName("historyMenu"); // NOI18N + + recentMenu.setMnemonic('R'); + recentMenu.setText(resourceMap.getString("recentMenu.text")); // NOI18N + recentMenu.setEnabled(false); + recentMenu.setName("recentMenu"); // NOI18N + historyMenu.add(recentMenu); + + clearHistoryItem.setMnemonic('H'); + clearHistoryItem.setText(resourceMap.getString("clearHistoryItem.text")); // NOI18N + clearHistoryItem.setName("clearHistoryItem"); // NOI18N + clearHistoryItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + clearHistoryItemActionPerformed(evt); + } + }); + historyMenu.add(clearHistoryItem); + + menuBar.add(historyMenu); + + postMenu.setMnemonic('t'); + postMenu.setText(resourceMap.getString("postMenu.text")); // NOI18N + postMenu.setEnabled(false); + postMenu.setName("postMenu"); // NOI18N + + menuRunAllMeterp.setMnemonic('R'); + menuRunAllMeterp.setText(resourceMap.getString("menuRunAllMeterp.text")); // NOI18N + menuRunAllMeterp.setName("menuRunAllMeterp"); // NOI18N + postMenu.add(menuRunAllMeterp); + + crackPasswordsItem.setMnemonic('C'); + crackPasswordsItem.setText(resourceMap.getString("crackPasswordsItem.text")); // NOI18N + crackPasswordsItem.setName("crackPasswordsItem"); // NOI18N + crackPasswordsItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + crackPasswordsItemActionPerformed(evt); + } + }); + postMenu.add(crackPasswordsItem); + + killSessionsMenuItem.setMnemonic('K'); + killSessionsMenuItem.setText(resourceMap.getString("killSessionsMenuItem.text")); // NOI18N + killSessionsMenuItem.setName("killSessionsMenuItem"); // NOI18N + killSessionsMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + killSessionsMenuItemActionPerformed(evt); + } + }); + postMenu.add(killSessionsMenuItem); + + logGenerateMenuItem.setMnemonic('G'); + logGenerateMenuItem.setText(resourceMap.getString("logGenerateMenuItem.text")); // NOI18N + logGenerateMenuItem.setName("logGenerateMenuItem"); // NOI18N + logGenerateMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + logGenerateMenuItemActionPerformed(evt); + } + }); + postMenu.add(logGenerateMenuItem); + + menuBar.add(postMenu); + + consoleMenu.setMnemonic('C'); + consoleMenu.setText(resourceMap.getString("consoleMenu.text")); // NOI18N + 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() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + newConsoleItemActionPerformed(evt); + } + }); + 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() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + refreshConsolesItemActionPerformed(evt); + } + }); + consoleMenu.add(refreshConsolesItem); + + menuBar.add(consoleMenu); + + databaseMenu.setMnemonic('D'); + databaseMenu.setText(resourceMap.getString("databaseMenu.text")); // NOI18N + databaseMenu.setEnabled(false); + databaseMenu.setName("databaseMenu"); // NOI18N + + connectItem.setMnemonic('C'); + connectItem.setText(resourceMap.getString("connectItem.text")); // NOI18N + connectItem.setName("connectItem"); // NOI18N + connectItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + connectItemActionPerformed(evt); + } + }); + 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.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 + refreshItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + refreshItemActionPerformed(evt); + } + }); + databaseMenu.add(refreshItem); + + nmapItem.setMnemonic('N'); + nmapItem.setText(resourceMap.getString("nmapItem.text")); // NOI18N + nmapItem.setName("nmapItem"); // NOI18N + nmapItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + nmapItemActionPerformed(evt); + } + }); + databaseMenu.add(nmapItem); + + importItem.setMnemonic('I'); + importItem.setText(resourceMap.getString("importItem.text")); // NOI18N + importItem.setName("importItem"); // NOI18N + importItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + importItemActionPerformed(evt); + } + }); + databaseMenu.add(importItem); + + dbExportItem.setMnemonic('E'); + dbExportItem.setText(resourceMap.getString("dbExportItem.text")); // NOI18N + dbExportItem.setName("dbExportItem"); // NOI18N + dbExportItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + dbExportItemActionPerformed(evt); + } + }); + databaseMenu.add(dbExportItem); + + currWorkspaceItem.setMnemonic('W'); + currWorkspaceItem.setText(resourceMap.getString("currWorkspaceItem.text")); // NOI18N + currWorkspaceItem.setName("currWorkspaceItem"); // NOI18N + currWorkspaceItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + currWorkspaceItemActionPerformed(evt); + } + }); + databaseMenu.add(currWorkspaceItem); + + addWorkspaceItem.setMnemonic('A'); + addWorkspaceItem.setText(resourceMap.getString("addWorkspaceItem.text")); // NOI18N + addWorkspaceItem.setName("addWorkspaceItem"); // NOI18N + addWorkspaceItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + addWorkspaceItemActionPerformed(evt); + } + }); + databaseMenu.add(addWorkspaceItem); + + delWorkspaceItem.setMnemonic('l'); + delWorkspaceItem.setText(resourceMap.getString("delWorkspaceItem.text")); // NOI18N + delWorkspaceItem.setName("delWorkspaceItem"); // NOI18N + delWorkspaceItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + delWorkspaceItemActionPerformed(evt); + } + }); + databaseMenu.add(delWorkspaceItem); + + menuBar.add(databaseMenu); + + pluginsMenu.setMnemonic('l'); + pluginsMenu.setText(resourceMap.getString("pluginsMenu.text")); // NOI18N + pluginsMenu.setEnabled(false); + pluginsMenu.setName("pluginsMenu"); // NOI18N + + autoAddRouteItem.setMnemonic('A'); + autoAddRouteItem.setText(resourceMap.getString("autoAddRouteItem.text")); // NOI18N + autoAddRouteItem.setName("autoAddRouteItem"); // NOI18N + autoAddRouteItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + autoAddRouteItemActionPerformed(evt); + } + }); + pluginsMenu.add(autoAddRouteItem); + + soundItem.setMnemonic('S'); + soundItem.setText(resourceMap.getString("soundItem.text")); // NOI18N + soundItem.setName("soundItem"); // NOI18N + soundItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + soundItemActionPerformed(evt); + } + }); + pluginsMenu.add(soundItem); + + dbCredcollectItem.setMnemonic('c'); + dbCredcollectItem.setText(resourceMap.getString("dbCredcollectItem.text")); // NOI18N + dbCredcollectItem.setName("dbCredcollectItem"); // NOI18N + dbCredcollectItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + dbCredcollectItemActionPerformed(evt); + } + }); + pluginsMenu.add(dbCredcollectItem); + + dbTrackerItem.setMnemonic('t'); + dbTrackerItem.setText(resourceMap.getString("dbTrackerItem.text")); // NOI18N + dbTrackerItem.setName("dbTrackerItem"); // NOI18N + dbTrackerItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + dbTrackerItemActionPerformed(evt); + } + }); + pluginsMenu.add(dbTrackerItem); + + socketLoggerItem.setMnemonic('k'); + socketLoggerItem.setText(resourceMap.getString("socketLoggerItem.text")); // NOI18N + socketLoggerItem.setName("socketLoggerItem"); // NOI18N + socketLoggerItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + socketLoggerItemActionPerformed(evt); + } + }); + pluginsMenu.add(socketLoggerItem); + + ipsFilterItem.setMnemonic('I'); + ipsFilterItem.setText(resourceMap.getString("ipsFilterItem.text")); // NOI18N + ipsFilterItem.setName("ipsFilterItem"); // NOI18N + ipsFilterItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + ipsFilterItemActionPerformed(evt); + } + }); + pluginsMenu.add(ipsFilterItem); + + otherPluginItem.setMnemonic('O'); + otherPluginItem.setText(resourceMap.getString("otherPluginItem.text")); // NOI18N + otherPluginItem.setName("otherPluginItem"); // NOI18N + otherPluginItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + otherPluginItemActionPerformed(evt); + } + }); + pluginsMenu.add(otherPluginItem); + + unloadPluginItem.setMnemonic('U'); + unloadPluginItem.setText(resourceMap.getString("unloadPluginItem.text")); // NOI18N + unloadPluginItem.setName("unloadPluginItem"); // NOI18N + unloadPluginItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + unloadPluginItemActionPerformed(evt); + } + }); + pluginsMenu.add(unloadPluginItem); + + menuBar.add(pluginsMenu); + + helpMenu.setMnemonic('H'); + helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N + helpMenu.setName("helpMenu"); // NOI18N + + onlineHelpMenu.setMnemonic('O'); + onlineHelpMenu.setText(resourceMap.getString("onlineHelpMenu.text")); // NOI18N + onlineHelpMenu.setName("onlineHelpMenu"); // NOI18N + onlineHelpMenu.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + onlineHelpMenuActionPerformed(evt); + } + }); + helpMenu.add(onlineHelpMenu); + + aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N + aboutMenuItem.setName("aboutMenuItem"); // NOI18N + helpMenu.add(aboutMenuItem); + + menuBar.add(helpMenu); + + statusPanel.setName("statusPanel"); // NOI18N + + statusMessageLabel.setName("statusMessageLabel"); // NOI18N + + statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N + + progressBar.setName("progressBar"); // NOI18N + + javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel); + statusPanel.setLayout(statusPanelLayout); + statusPanelLayout.setHorizontalGroup( + statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(statusPanelLayout.createSequentialGroup() + .addContainerGap() + .addComponent(statusMessageLabel) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 696, 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) + .addContainerGap()) + ); + statusPanelLayout.setVerticalGroup( + statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, statusPanelLayout.createSequentialGroup() + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(statusMessageLabel) + .addComponent(statusAnimationLabel) + .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(12, 12, 12)) + ); + + setComponent(mainPanel); + setMenuBar(menuBar); + setStatusBar(statusPanel); + }// //GEN-END:initComponents + + private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitMenuItemActionPerformed + if(confirmStop()) + System.exit(0); + }//GEN-LAST:event_exitMenuItemActionPerformed + + private void connectRpcMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_connectRpcMenuItemActionPerformed + connectRpc(); + if(rpcConn != null) + handleNewRpcConnection(); + }//GEN-LAST:event_connectRpcMenuItemActionPerformed + + private void clearHistoryItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clearHistoryItemActionPerformed + MsfguiApp.clearHistory(recentMenu); + }//GEN-LAST:event_clearHistoryItemActionPerformed + + private void onlineHelpMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_onlineHelpMenuActionPerformed + try{ + java.awt.Desktop.getDesktop().browse(new URI("http://www.metasploit.com/framework/support")); + } catch (IOException ex){ + MsfguiApp.showMessage(this.getFrame(), "Can't open browser. See http://www.metasploit.com/framework/support"); + } catch ( URISyntaxException usx){ + MsfguiApp.showMessage(this.getFrame(), "Can't find the URL. This really should never happen. Report this bug."); + } + }//GEN-LAST:event_onlineHelpMenuActionPerformed + + private void logGenerateMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_logGenerateMenuItemActionPerformed + try{ + java.awt.Desktop.getDesktop().browse(new URI("file://"+MsfguiApp.cleanBackslashes(MsfguiLog.defaultLog.save()))); + }catch (Exception iox){ + MsfguiApp.fileChooser.setCurrentDirectory(new File(MsfguiApp.getTempFolder())); + MsfguiApp.fileChooser.setSelectedFile(new File("msfguilog.html")); + try{ + if(MsfguiApp.fileChooser.showSaveDialog(this.getFrame()) == JFileChooser.APPROVE_OPTION) + java.awt.Desktop.getDesktop().browse(new URI("file://"+MsfguiLog.defaultLog.save( + MsfguiApp.cleanBackslashes(MsfguiApp.fileChooser.getSelectedFile().getAbsolutePath())))); + }catch (Exception ex){ + MsfguiApp.showMessage(getFrame(), "Problem "+ex); + } + } + }//GEN-LAST:event_logGenerateMenuItemActionPerformed + + private void killSessionsMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_killSessionsMenuItemActionPerformed + for( Object sesObj : sessionsTableModel.sessions ){ + try{ + rpcConn.execute("session.stop", ((Map)sesObj).get("id")); + } catch (MsfException xre) { + statusMessageLabel.setText("Error killing session "+((Map)sesObj).get("id")); + } + } + }//GEN-LAST:event_killSessionsMenuItemActionPerformed + + private void newConsoleItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newConsoleItemActionPerformed + try{ + Map res = (Map)rpcConn.execute("console.create"); + registerConsole(res, true, ""); + }catch(MsfException mex){ + MsfguiApp.showMessage(getFrame(), mex); + } +}//GEN-LAST:event_newConsoleItemActionPerformed + + private void searchItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchItemActionPerformed + searchWin.setVisible(true); + }//GEN-LAST:event_searchItemActionPerformed + + private void connectItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_connectItemActionPerformed + if(DbConnectDialog.connect(getFrame(), rpcConn)) + new SwingWorker(){ + protected Object doInBackground() throws Exception { + reloadDb(true); + return null; + } + }.execute(); + }//GEN-LAST:event_connectItemActionPerformed + + /** Refreshes the database tables. */ + private void reloadDb(boolean all) { + try { //First try to reset workspace to chosen workspace + if(!DbConnectDialog.isConnected(rpcConn)) + return; + if(MsfguiApp.getPropertiesNode().containsKey("workspace")) + rpcConn.execute("db.set_workspace", MsfguiApp.getPropertiesNode().get("workspace")); + } catch (MsfException mex) { + if(!mex.getMessage().equals("database not loaded")) + mex.printStackTrace(); + } + try { //Now load data out of current workspace + MsfguiApp.workspace = ((Map) rpcConn.execute("db.current_workspace")).get("workspace").toString(); + for(MsfTable table : tables){ + table.rpcConn = rpcConn; + table.reAddQuery(all, 0); + } + } catch (MsfException mex) { + if(!mex.getMessage().equalsIgnoreCase("database not loaded")) + mex.printStackTrace(); + else + return; + } + MsfFrame.updateSizes(getFrame()); + } + + private void refreshItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_refreshItemActionPerformed + reloadDb(false); + }//GEN-LAST:event_refreshItemActionPerformed + + private void importItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_importItemActionPerformed + try { + Object filetype = JOptionPane.showInputDialog(getFrame(), "Select file type. Autodetect recommended.", + "Type selection", JOptionPane.PLAIN_MESSAGE,null, new Object[]{"Autodetect","Msfe XML", + "Nexpose simpleXML","Nexpose rawXML", "Nmap XML", "Nessuse NBE","Nessus XML", "Nessus XML v2", + "Qualsys XML", "IP list", "Amap log", "Amap mlog"}, onlineHelpMenu); + String type; + if(filetype == null) + return; + else if(filetype.equals("Autodetect")) + type = "data"; + else + type = filetype.toString().toLowerCase().replaceAll(" ", "_"); + HashMap argHash = new HashMap(); + if (MsfguiApp.fileChooser.showOpenDialog(getFrame()) == javax.swing.JFileChooser.CANCEL_OPTION) + return; + int fsize = (int)MsfguiApp.fileChooser.getSelectedFile().length(); + FileInputStream fin = new FileInputStream(MsfguiApp.fileChooser.getSelectedFile()); + byte[] data = new byte[fsize]; + fin.read(data); + argHash.put("data", data); + rpcConn.execute("db.import_"+type,argHash); + } catch (MsfException mex) { + MsfguiApp.showMessage(getFrame(), mex); + } catch (IOException iex) { + MsfguiApp.showMessage(getFrame(), iex); + } + }//GEN-LAST:event_importItemActionPerformed + + private void disconnectItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_disconnectItemActionPerformed + try { + rpcConn.execute("db.disconnect"); + } catch (MsfException mex) { + MsfguiApp.showMessage(getFrame(), mex); + } + }//GEN-LAST:event_disconnectItemActionPerformed + + private void loadPlugin(String plugin){ + try { + rpcConn.execute("plugin.load",plugin, new HashMap()); + MsfguiApp.showMessage(getFrame(), "Plugin "+plugin+" loaded."); + } catch (MsfException mex) { + MsfguiApp.showMessage(getFrame(), mex); + } + } + private void otherPluginItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_otherPluginItemActionPerformed + String plugin = JOptionPane.showInputDialog(getFrame(),"Enter the name of a plugin","Plugin loader",JOptionPane.QUESTION_MESSAGE); + if(plugin != null && plugin.length() > 0) + loadPlugin(plugin); + }//GEN-LAST:event_otherPluginItemActionPerformed + + private void ipsFilterItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ipsFilterItemActionPerformed + loadPlugin("ips_filter"); + }//GEN-LAST:event_ipsFilterItemActionPerformed + + private void socketLoggerItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_socketLoggerItemActionPerformed + loadPlugin("socket_logger"); + }//GEN-LAST:event_socketLoggerItemActionPerformed + + private void dbTrackerItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dbTrackerItemActionPerformed + loadPlugin("db_tracker"); + }//GEN-LAST:event_dbTrackerItemActionPerformed + + private void soundItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_soundItemActionPerformed + loadPlugin("sounds"); + }//GEN-LAST:event_soundItemActionPerformed + + private void autoAddRouteItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_autoAddRouteItemActionPerformed + loadPlugin("auto_add_route"); + }//GEN-LAST:event_autoAddRouteItemActionPerformed + + private void dbCredcollectItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dbCredcollectItemActionPerformed + loadPlugin("db_credcollect"); + }//GEN-LAST:event_dbCredcollectItemActionPerformed + + private void unloadPluginItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_unloadPluginItemActionPerformed + try { + Object[] plugins = ((List)((Map)rpcConn.execute("plugin.loaded")).get("plugins")).toArray(); + Object plugin = JOptionPane.showInputDialog(getFrame(), "Choose a plugin to unload", "Unload plugin", + JOptionPane.PLAIN_MESSAGE, null, plugins, plugins[0]); + if(plugin == null) + return; + rpcConn.execute("plugin.unload",plugin); + } catch (MsfException mex) { + MsfguiApp.showMessage(getFrame(), mex); + } + }//GEN-LAST:event_unloadPluginItemActionPerformed + + private void showDetailsItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showDetailsItemActionPerformed + JOptionPane.showMessageDialog(getFrame(), rpcConn.toString(), "Connection Details", JOptionPane.INFORMATION_MESSAGE); + }//GEN-LAST:event_showDetailsItemActionPerformed + + private String[] tableShortNames = new String[]{"","",}; + private void tableDelCheck(KeyEvent evt, String name, String[] colNames){ + if(evt.getKeyCode() == KeyEvent.VK_F5) + reloadDb(false); + if(evt.getKeyCode() != KeyEvent.VK_DELETE) + return; + MsfTable tab = (MsfTable)evt.getSource(); + for(int row : tab.getSelectedRows()){ + try { + HashMap map = new HashMap(); + for(int i = 0; i < colNames.length; i++) + map.put(colNames[i], tab.getValueAt(row,i)); + rpcConn.execute("db.del_"+name,map); + } catch (MsfException mex) { + MsfguiApp.showMessage(getFrame(), mex); + } + }//delete then readd + tab.reAddQuery(true, 0); + } + 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", + "os_flavor","os_sp","os_lang","updated_at","purpose","info"}); + }//GEN-LAST:event_hostsTableKeyReleased + + private void servicesTableKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_servicesTableKeyReleased + tableDelCheck(evt,"service",new String[]{"host","created_at","updated_at","port","proto","state","name","info"}); + }//GEN-LAST:event_servicesTableKeyReleased + + private void vulnsTableKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_vulnsTableKeyReleased + tableDelCheck(evt,"vuln",new String[]{"port","proto","time","host","name","refs"}); + }//GEN-LAST:event_vulnsTableKeyReleased + + private void notesTableKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_notesTableKeyReleased + tableDelCheck(evt,"note",new String[]{"time", "host", "service", "type", "data"}); + }//GEN-LAST:event_notesTableKeyReleased + + private void lootsTableKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_lootsTableKeyReleased + ((MsfTable)lootsTable).reAddQuery(true, 0); + }//GEN-LAST:event_lootsTableKeyReleased + + private void clientsTableKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_clientsTableKeyReleased + tableDelCheck(evt,"client",new String[]{"host","ua_string","ua_name","ua_ver","created_at","updated_at"}); + }//GEN-LAST:event_clientsTableKeyReleased + + private void currWorkspaceItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_currWorkspaceItemActionPerformed + try { + Object[] vals = ((List)((Map)rpcConn.execute("db.workspaces")).get("workspaces")).toArray(); + Object[] names = new Object[vals.length]; + for(int i = 0; i < vals.length; i++) + names[i] = ((Map)vals[i]).get("name"); + Object selected = JOptionPane.showInputDialog(getFrame(),"Select a workspace","Workspace selection", + JOptionPane.QUESTION_MESSAGE,null, names, MsfguiApp.workspace); + if(selected == null) + return; + MsfguiApp.workspace = selected.toString(); + rpcConn.execute("db.set_workspace", MsfguiApp.workspace); + MsfguiApp.getPropertiesNode().put("workspace", MsfguiApp.workspace); + reloadDb(true); + } catch (MsfException mex) { + MsfguiApp.showMessage(getFrame(), mex); + } + }//GEN-LAST:event_currWorkspaceItemActionPerformed + + private void addWorkspaceItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addWorkspaceItemActionPerformed + try { + String name = JOptionPane.showInputDialog(getFrame(), "Enter a name for the new workspace"); + if(name != null) + rpcConn.execute("db.add_workspace",name); + MsfguiApp.workspace = name; + rpcConn.execute("db.set_workspace", name); + reloadDb(true); + } catch (MsfException mex) { + MsfguiApp.showMessage(getFrame(), mex); + } + }//GEN-LAST:event_addWorkspaceItemActionPerformed + + private void delWorkspaceItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_delWorkspaceItemActionPerformed + try { + Object[] vals = ((List)((Map)rpcConn.execute("db.workspaces")).get("workspaces")).toArray(); + Object[] names = new Object[vals.length]; + for(int i = 0; i < vals.length; i++) + names[i] = ((Map)vals[i]).get("name"); + Object selected = JOptionPane.showInputDialog(getFrame(),"Select a workspace to delete","Workspace selection", + JOptionPane.QUESTION_MESSAGE,null, names, MsfguiApp.workspace); + if(selected == null) + return; + rpcConn.execute("db.del_workspace", selected.toString()); + if(MsfguiApp.workspace.equals(selected.toString())){ + MsfguiApp.workspace = "default"; + reloadDb(true); + } + } catch (MsfException mex) { + MsfguiApp.showMessage(getFrame(), mex); + } + }//GEN-LAST:event_delWorkspaceItemActionPerformed + + private void refreshConsolesItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_refreshConsolesItemActionPerformed + refreshConsoles(); + }//GEN-LAST:event_refreshConsolesItemActionPerformed + + private void jobViewItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jobViewItemActionPerformed + DraggableTabbedPane.show(jobsPane); + }//GEN-LAST:event_jobViewItemActionPerformed + + private void sessionsViewItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sessionsViewItemActionPerformed + DraggableTabbedPane.show(sessionsPane); + }//GEN-LAST:event_sessionsViewItemActionPerformed + + private void hostsViewItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_hostsViewItemActionPerformed + DraggableTabbedPane.show(hostsPane); + }//GEN-LAST:event_hostsViewItemActionPerformed + + private void clientsViewItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clientsViewItemActionPerformed + DraggableTabbedPane.show(clientsPane); + }//GEN-LAST:event_clientsViewItemActionPerformed + + private void servicesViewItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_servicesViewItemActionPerformed + DraggableTabbedPane.show(servicesPane); + }//GEN-LAST:event_servicesViewItemActionPerformed + + private void vulnsViewItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_vulnsViewItemActionPerformed + DraggableTabbedPane.show(vulnsPane); + }//GEN-LAST:event_vulnsViewItemActionPerformed + + private void eventsViewItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_eventsViewItemActionPerformed + DraggableTabbedPane.show(eventsPane); + }//GEN-LAST:event_eventsViewItemActionPerformed + + private void notesViewItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_notesViewItemActionPerformed + DraggableTabbedPane.show(notesPane); + }//GEN-LAST:event_notesViewItemActionPerformed + + private void credsViewItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_credsViewItemActionPerformed + DraggableTabbedPane.show(credsPane); + }//GEN-LAST:event_credsViewItemActionPerformed + + private void lootsViewItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lootsViewItemActionPerformed + DraggableTabbedPane.show(lootsPane); + }//GEN-LAST:event_lootsViewItemActionPerformed + + private void nmapItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nmapItemActionPerformed + //Get db_nmap options + String opts = JOptionPane.showInputDialog(getFrame(),"Enter arguments to nmap", + "db_nmap options",JOptionPane.QUESTION_MESSAGE); + if(opts == null) + return; + //Start console + Map res = (Map) rpcConn.execute("console.create"); + registerConsole(res, true, InteractWindow.runCmdWindow(rpcConn, res, "db_nmap "+opts)); + }//GEN-LAST:event_nmapItemActionPerformed + + private void viewPrefsItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewPrefsItemActionPerformed + new PreferencesFrame().setVisible(true); + }//GEN-LAST:event_viewPrefsItemActionPerformed + + private void dbExportItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dbExportItemActionPerformed + try { + Object filetype = JOptionPane.showInputDialog(getFrame(), "Select file type. ", + "Type selection", JOptionPane.PLAIN_MESSAGE,null, new Object[]{"XML","pwdump"}, "XML"); + if(filetype == null) + return; + String type = filetype.toString().toLowerCase(); + HashMap argHash = new HashMap(); + if (MsfguiApp.fileChooser.showSaveDialog(getFrame()) == javax.swing.JFileChooser.CANCEL_OPTION) + return; + Map res = (Map) rpcConn.execute("console.create"); + registerConsole(res, true, InteractWindow.runCmdWindow(rpcConn, res, + "db_export -f "+type+" "+MsfguiApp.escapeBackslashes( + MsfguiApp.fileChooser.getSelectedFile().getCanonicalPath()))); + } catch (MsfException mex) { + MsfguiApp.showMessage(getFrame(), mex); + } catch (IOException iex) { + MsfguiApp.showMessage(getFrame(), iex); + } + }//GEN-LAST:event_dbExportItemActionPerformed + + private void crackPasswordsItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_crackPasswordsItemActionPerformed + MsfguiApp.runModule("auxiliary", "analyze/jtr_crack_fast", new HashMap(), rpcConn, this, true); + }//GEN-LAST:event_crackPasswordsItemActionPerformed + + /** 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); + } + + /** Displays a dialog to connect to msfrpcd. */ + private void connectRpc() { + //make new rpcConnection + rpcConn = OpenConnectionDialog.getConnection(this); + } + + /** Attempts to start msfrpcd and connect to it.*/ + @Action + public Task startRpc() { + return RpcConnection.startRpcConn(this); + } + public void showInteractWindow() { + for(Map session : selectedSessions) + DraggableTabbedPane.show((Component)sessionWindowMap.get(session.get("id")+"console")); + } + /* Master function to setup popup menus for jobs and sessions + * First handles jobs, then shell sessions, then meterpreter sessions, + * and finally other sessions (like VNC). + */ + private void setupPopupMenus() throws HeadlessException { + //JOB POPUP MENUS + jobPopupMenu = new JPopupMenu(); + addSessionItem("Info",jobPopupMenu,new RpcAction() { + public void action() throws Exception { + Object obj = rpcConn.execute("job.info", clickedJob); + if(obj instanceof Map && ((Map)obj).containsKey("info")) + obj = ((Map)obj).get("info"); + (new JobInfoPopup(null, true, obj)).setVisible(true); + } + }); + addSessionItem("Stop",jobPopupMenu,new RpcAction() { + public void action() throws Exception { + if(!"success".equals(((Map)rpcConn.execute("job.stop", clickedJob)).get("result"))) + MsfguiApp.showMessage(null, "stop failed."); + } + }); + jobsList.addMouseListener( new PopupMouseListener() { + public void mouseReleased(MouseEvent e){ + super.mouseReleased(e); + int indx = jobsList.locationToIndex(e.getPoint()); + if (indx == -1) + return; + jobsList.setSelectedIndex(indx); + clickedJob = jobsList.getSelectedValue().toString().split(" ")[0]; + if(e.getClickCount() > 1){ + Object obj = rpcConn.execute("job.info", clickedJob); + if(obj instanceof Map && ((Map)obj).containsKey("info")) + obj = ((Map)obj).get("info"); + (new JobInfoPopup(null, true, obj)).setVisible(true); + } + } + public void showPopup(MouseEvent e) { + jobPopupMenu.show(jobsList, e.getX(), e.getY() ); + } + }); + //SESSION POPUP MENUS + sessionsTable.addMouseListener(new PopupMouseListener() { + public void doubleClicked(MouseEvent e){ + getSelected(); + showInteractWindow();//show interaction window on double-click + } + private void getSelected() { + int[] selrows = sessionsTable.getSelectedRows(); + selectedSessions = new HashMap[selrows.length]; + for (int i = 0; i < selrows.length; i++) + selectedSessions[i] = (Map) sessionsTableModel.getSessionList().get(selrows[i]); + } + public void showPopup(MouseEvent e) { + getSelected(); + if(selectedSessions.length == 0) //must have a row selected + return; + Map session = selectedSessions[0]; + if (session.get("type").equals("shell")) + shellPopupMenu.show(e.getComponent(), e.getX(), e.getY()); + else if (session.get("type").equals("meterpreter")) + meterpreterPopupMenu.show(e.getComponent(), e.getX(),e.getY()); + else + sessionPopupMenu.show(e.getComponent(), e.getX(),e.getY()); + } + }); + + //Setup shell popup menu + shellPopupMenu = new JPopupMenu(); + addSessionItem("Interact",shellPopupMenu,null); + addSessionItem("Upgrade",shellPopupMenu,new RpcAction(this) { + String[] vals = null; + public void prepare() throws Exception { + vals = JOptionPane.showInputDialog(getFrame(), "Select host/port for connect back.", + MsfguiApp.getLocalIp()+":4444").split(":"); + if(vals == null) + throw new MsfException("cancelled"); + } + public void action(Map session) throws Exception { + rpcConn.execute("session.shell_upgrade", session.get("id"), vals[0], vals[1]); + } + }); + addSessionKillItem(shellPopupMenu); + + //Setup meterpreter menu + meterpreterPopupMenu = new JPopupMenu(); + addSessionItem("Access Filesystem",meterpreterPopupMenu,new RpcAction(this) { + public void action(Map session) throws Exception { + MeterpFileBrowser.showBrowser(rpcConn, session, sessionWindowMap); + } + }); + addSessionItem("Processes",meterpreterPopupMenu,new RpcAction(this) { + public void action(Map session) throws Exception { + ProcessList.showList(rpcConn,session,sessionWindowMap); + } + }); + addSessionItem("Shell",meterpreterPopupMenu,new RpcAction(this) { + public void action(Map session) throws Exception { + rpcConn.execute("session.meterpreter_write", session.get("id"),"shell\n"); + } + }); + addSessionItem("Console",meterpreterPopupMenu,null); + addScript("Get hashes",meterpreterPopupMenu, + "multi_console_command -cl \"use priv\",\"getsystem\",\"run post/windows/gather/hashdump\""); + addSessionItem("Route through this session",meterpreterPopupMenu,new AutorouteOptionsDialog(this, true)); + addScript("Schedule command",meterpreterPopupMenu,new ScheduleTaskOptionsDialog(getFrame())); + addSessionItem("Unlock screen",meterpreterPopupMenu,"screen_unlock"); + addScript("Upload + execute",meterpreterPopupMenu,new UploadexecOptionsDialog(getFrame())); + addSessionItem("Ping/DNS sweep",meterpreterPopupMenu,new NetenumOptionsDialog(getFrame())); + addSessionItem("ARP sweep",meterpreterPopupMenu,new Object(){ + public String toString(){ + String target = JOptionPane.showInputDialog(getFrame(), + "Enter Target list as address or CIDR","Enter Target", JOptionPane.QUESTION_MESSAGE); + if(target == null) + throw new RuntimeException("cancelled"); + return "arp_scanner.rb -r "+ target; + } + }); + addScript("Run shell commands",meterpreterPopupMenu,new MulticommandOptionsDialog(getFrame())); + addSessionItem("VirtualBox sysenter DoS",meterpreterPopupMenu,"virtualbox_sysenter_dos"); + + JMenu monitorMenu = new JMenu("Monitor"); + meterpreterPopupMenu.add(monitorMenu); + addScript("Start keylogger",monitorMenu,"post/windows/capture/keylog_recorder"); + addScript("Start packet recorder",monitorMenu,"packetrecorder"); + addScript("Screenshot",monitorMenu,"multi_console_command -cl \"screenshot\""); + addSessionItem("View webcam",monitorMenu,new RpcAction(this) { + public void action(Map session) throws Exception { + WebcamFrame.showWebcam(rpcConn,session,sessionWindowMap); + } + }); + addScript("Record Microphone",monitorMenu,new Object(){ + public String toString(){ + return "sound_recorder.rb "+JOptionPane.showInputDialog(getFrame(), "Number of 30 second intervals to record","20"); + } + }); + + JMenu escalateMenu = new JMenu("Privilege escalation"); + meterpreterPopupMenu.add(escalateMenu); + addScript("Bypass UAC", escalateMenu, "post/windows/escalate/bypassuac"); + addScript("Getsystem via windows API or KiTrap0D exploit",escalateMenu, + "multi_console_command -cl \"use priv\",\"getsystem\""); + addSessionItem("Find and exploit weak service permissions",escalateMenu, + "service_permissions_escalate"); + addSessionItem("MS10-092 task scheduler",escalateMenu,"post/windows/escalate/schelevator"); + addSessionItem("HP PML Driver permissions",escalateMenu,"pml_driver_config"); + addSessionItem("Panda Antivirus permissions",escalateMenu,"panda_2007_pavsrv51"); + addSessionItem("SRT WebDrive permissions",escalateMenu,"srt_webdrive_priv"); + addSessionItem("Brute force user/pass",escalateMenu,new WinbfOptionsDialog(getFrame())); + + JMenu accessMenu = new JMenu("Maintaining access"); + meterpreterPopupMenu.add(accessMenu); + addScript("Install metsvc (listening agent)", accessMenu,"metsvc.rb"); + addScript("Run persistence (connect back agent)",accessMenu,new PersistenceOptionsDialog(getFrame())); + addSessionItem("Open VNC",accessMenu,"vnc.rb -i"); + addScript("Setup RDP",accessMenu,new Object(){ + public String toString(){ + return "getgui.rb "+UserPassDialog.getUserPassOpts(getFrame()); + } + }); + addScript("Setup telnet",accessMenu,new Object(){ + public String toString(){ + return "gettelnet.rb "+UserPassDialog.getUserPassOpts(getFrame()); + } + }); + addSessionItem("Add admin user",accessMenu,new Object(){ + public String toString(){ + String[] userPass = UserPassDialog.showUserPassDialog(getFrame()); + return "multicommand -cl \"net user "+userPass[0]+" "+userPass[1]+" /ADD\"" + + ",\"net localgroup Administrators "+userPass[0]+" /ADD\""; + } + }); + addScript("Kill AV",accessMenu,"killav"); + addScript("Duplicate",accessMenu,"duplicate"); + + JMenu infoPopupMenu = new JMenu("System Information"); + meterpreterPopupMenu.add(infoPopupMenu); + addSessionItem("Check if in VM",infoPopupMenu,"post/windows/gather/checkvm"); + addSessionItem("VMWare configurations",infoPopupMenu,"enum_vmware"); + addSessionItem("Past and current logged on users", infoPopupMenu, "post/windows/gather/enum_logged_on_users"); + addSessionItem("Domain admins",infoPopupMenu,"domain_list_gen"); + addSessionItem("Recent documents",infoPopupMenu,"dumplinks -e"); + addSessionItem("Recent programs (by prefetch)",infoPopupMenu,"prefetchtool -p -i"); + addSessionItem("Installed programs",infoPopupMenu,"post/windows/gather/enum_applications"); + addSessionItem("Countermeasures",infoPopupMenu, + "multi_console_command -cl \"run getcountermeasure -h\",\"run getcountermeasure\""); + addSessionItem("Environment variables",infoPopupMenu,"post/multi/gather/env"); + addSessionItem("Powershell Environment",infoPopupMenu,"post/windows/gather/enum_powershell_env"); + addSessionItem("SNMP",infoPopupMenu,"post/windows/gather/enum_snmp"); + addSessionItem("Subnets",infoPopupMenu,"get_local_subnets"); + addSessionItem("Firefox credentials and profile info", infoPopupMenu, "enum_firefox"); + addSessionItem("Google Chrome info", infoPopupMenu, "enum_chrome"); + addSessionItem("Pidgin credentials",infoPopupMenu, + "multi_console_command -cl \"run get_pidgin_creds -h\",\"run get_pidgin_creds\""); + addSessionItem("Filezilla credentials",infoPopupMenu,"get_filezilla_creds"); + addSessionItem("VNC credentials",infoPopupMenu,"getvncpw"); + addSessionItem("Putty credentials",infoPopupMenu,"enum_putty"); + addSessionItem("Shares",infoPopupMenu,"post/windows/gather/enum_shares"); + addSessionItem("winenum: env vars, interfaces, routing, users, processes, tokens...",infoPopupMenu,"winenum"); + addSessionItem("Remote winenum: most of the above run against a different system",infoPopupMenu, + new RemoteWinenumOptionsDialog(getFrame())); + + addSessionItem("Other",meterpreterPopupMenu,new RpcAction(this) { + String command = null; + public void prepare() throws Exception { + command = JOptionPane.showInputDialog(getFrame(), + "Enter a command","Run command on selected meterpreter sessions", JOptionPane.QUESTION_MESSAGE); + if(command == null) + throw new MsfException("cancelled"); + } + public void action(Map session) throws Exception { + rpcConn.execute("session.meterpreter_run_single", session.get("id"),command); + } + }); + addSessionKillItem(meterpreterPopupMenu); + + //Setup generic menu (for vnc or whatever other sessions) + sessionPopupMenu = new JPopupMenu(); + addSessionKillItem(sessionPopupMenu); + } + /** Adds a named session menu item to a given popup menu */ + private void addSessionItem(String name, JComponent menu,ActionListener action) { + if(action == null) + action = new RpcAction(null,this); + JMenuItem tempItem = new JMenuItem(name); + menu.add(tempItem); + tempItem.addActionListener(action); + } + /** Adds a named session menu item to a given popup menu */ + private void addSessionItem(String name, JComponent menu, Object action){ + addSessionItem(name, menu, new RpcAction(action,this)); + } + /** Adds a named session menu item to both a given popup menu and the run on all menu */ + private void addScript(final String name, JComponent menu, final Object action){ + addSessionItem(name,menu,action); + JMenuItem menuItem = new JMenuItem(name); + menuItem.setName(name); + menuItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent evt) { + if(action instanceof OptionsDialog) + runOnAllMeterpreters("run "+((OptionsDialog)action).getCommand(),name,statusMessageLabel); + else + runOnAllMeterpreters("run " + action.toString(), name, statusMessageLabel); + } + }); + menuRunAllMeterp.add(menuItem); + } + /** Adds a kill session menu item to a given popup menu */ + private void addSessionKillItem(JComponent popupMenu) throws HeadlessException { + addSessionItem("Kill session",popupMenu,new RpcAction(this) { + public void action(Map session) throws Exception { + rpcConn.execute("session.stop", session.get("id")); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JMenuItem addWorkspaceItem; + private javax.swing.JMenuItem autoAddRouteItem; + private javax.swing.JMenu auxiliaryMenu; + private javax.swing.JMenuItem clearHistoryItem; + private javax.swing.JScrollPane clientsPane; + private javax.swing.JTable clientsTable; + private javax.swing.JMenuItem clientsViewItem; + private javax.swing.JMenu closeConsoleMenu; + private javax.swing.JMenuItem connectItem; + private javax.swing.JMenuItem connectRpcMenuItem; + private javax.swing.JMenu consoleMenu; + private javax.swing.JMenuItem crackPasswordsItem; + private javax.swing.JScrollPane credsPane; + private javax.swing.JTable credsTable; + private javax.swing.JMenuItem credsViewItem; + private javax.swing.JMenuItem currWorkspaceItem; + private javax.swing.JMenu databaseMenu; + private javax.swing.JMenuItem dbCredcollectItem; + private javax.swing.JMenuItem dbExportItem; + private javax.swing.JMenuItem dbTrackerItem; + private javax.swing.JMenuItem delWorkspaceItem; + private javax.swing.JMenuItem disconnectItem; + private javax.swing.JMenuItem eventsViewItem; + private javax.swing.JMenu existingConsoleMenu; + private javax.swing.JMenu exploitsMenu; + private javax.swing.JMenu helpMenu; + private javax.swing.JMenu historyMenu; + private javax.swing.JScrollPane hostsPane; + private javax.swing.JTable hostsTable; + private javax.swing.JMenuItem hostsViewItem; + private javax.swing.JMenuItem importItem; + private javax.swing.JMenuItem ipsFilterItem; + private javax.swing.JPopupMenu.Separator jSeparator1; + private javax.swing.JMenuItem jobViewItem; + private javax.swing.JList jobsList; + private javax.swing.JScrollPane jobsPane; + private javax.swing.JMenuItem killSessionsMenuItem; + private javax.swing.JMenuItem logGenerateMenuItem; + private javax.swing.JScrollPane lootsPane; + private javax.swing.JTable lootsTable; + private javax.swing.JMenuItem lootsViewItem; + private javax.swing.JPanel mainPanel; + private javax.swing.JMenuBar menuBar; + private javax.swing.JMenu menuRunAllMeterp; + private javax.swing.JMenuItem newConsoleItem; + private javax.swing.JMenuItem nmapItem; + private javax.swing.JScrollPane notesPane; + private javax.swing.JTable notesTable; + private javax.swing.JMenuItem notesViewItem; + private javax.swing.JMenuItem onlineHelpMenu; + private javax.swing.JMenuItem otherPluginItem; + private javax.swing.JMenu payloadsMenu; + private javax.swing.JMenu pluginsMenu; + private javax.swing.JMenu postMenu; + private javax.swing.JProgressBar progressBar; + public javax.swing.JMenu recentMenu; + private javax.swing.JMenuItem refreshConsolesItem; + private javax.swing.JMenuItem refreshItem; + private javax.swing.JMenuItem searchItem; + private javax.swing.JScrollPane servicesPane; + private javax.swing.JTable servicesTable; + private javax.swing.JMenuItem servicesViewItem; + private javax.swing.JScrollPane sessionsPane; + private javax.swing.JTable sessionsTable; + private javax.swing.JMenuItem sessionsViewItem; + private javax.swing.JMenuItem showDetailsItem; + private javax.swing.JMenuItem socketLoggerItem; + private javax.swing.JMenuItem soundItem; + private javax.swing.JMenuItem startRpcMenuItem; + public javax.swing.JLabel statusAnimationLabel; + javax.swing.JLabel statusMessageLabel; + private javax.swing.JPanel statusPanel; + public javax.swing.JTabbedPane tabbedPane; + private javax.swing.JMenuItem unloadPluginItem; + private javax.swing.JMenu viewMenu; + private javax.swing.JMenuItem viewPrefsItem; + private javax.swing.JScrollPane vulnsPane; + private javax.swing.JTable vulnsTable; + private javax.swing.JMenuItem vulnsViewItem; + // End of variables declaration//GEN-END:variables + private final Timer messageTimer; + private final Timer busyIconTimer; + private final Icon idleIcon; + private final Icon[] busyIcons = new Icon[15]; + private int busyIconIndex = 0; + private JDialog aboutBox; + private JMenuItem factoryReset; +} diff -Nru metasploit-gui-1.0/src/msfgui/MeterpFileBrowser.form metasploit-gui-1.0/src/msfgui/MeterpFileBrowser.form --- metasploit-gui-1.0/src/msfgui/MeterpFileBrowser.form 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/MeterpFileBrowser.form 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,235 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+ + diff -Nru metasploit-gui-1.0/src/msfgui/MeterpFileBrowser.java metasploit-gui-1.0/src/msfgui/MeterpFileBrowser.java --- metasploit-gui-1.0/src/msfgui/MeterpFileBrowser.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/MeterpFileBrowser.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,554 @@ +package msfgui; + +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.io.File; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Vector; +import java.util.concurrent.locks.ReentrantLock; +import javax.swing.JOptionPane; +import javax.swing.Icon; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JMenuItem; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JTable; +import javax.swing.Timer; +import javax.swing.filechooser.FileSystemView; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableModel; + +/** + * Provides a file browser for meterpreter sessions. Synchronizes with other windows. + * @author scriptjunkie + */ +public class MeterpFileBrowser extends MsfFrame { + protected Map session, sessionPopupMap; + protected final RpcConnection rpcConn; + protected ReentrantLock lock; + protected Map files; + protected List fileVector; + protected Timer readTimer = null; + protected final Icon folderIcon, fileIcon; + protected JFileChooser fchooser; + protected JPopupMenu popupMenu; + protected final DefaultTableModel model; + protected JPanel interactPane; + + /** Shows file interaction window for a session, creating one if necessary */ + static void showBrowser(RpcConnection rpcConn, Map session, Map sessionWindowMap) { + Object browserWindow = sessionWindowMap.get(session.get("id")+"fileBrowser"); + if(browserWindow == null){ + browserWindow = new MeterpFileBrowser(rpcConn,session,sessionWindowMap).mainPanel; + sessionWindowMap.put(session.get("id")+"fileBrowser",browserWindow); + } + DraggableTabbedPane.show((Component)browserWindow); + } + + /** Creates a new window for interacting with filesystem */ + public MeterpFileBrowser(final RpcConnection rpcConn, final Map session, Map sessionPopupMap) { + super("Meterpreter remote file browsing"); + this.rpcConn = rpcConn; + this.session = session; + this.interactPane = ((JPanel)sessionPopupMap.get(session.get("id")+"console")); + this.lock = (ReentrantLock) sessionPopupMap.get(session.get("id")+"lock"); + files = new HashMap(); + fileVector = new Vector(100); + initComponents(); + loadSavedSize(); + model = new DefaultTableModel(){ + public boolean isCellEditable(int row, int col){ + return false; + } + public Class getColumnClass(int columnIndex) { + try{ + return getValueAt(0, columnIndex).getClass(); + }catch(ArrayIndexOutOfBoundsException aioobex){ + }catch(NullPointerException aioobex){ + } + return java.lang.String.class; + } + }; + tabbedPane.setTitleAt(0, "Session "+session.get("id")+" file browser"); + mainTable.setModel(model); + mainTable.setShowHorizontalLines(false); + mainTable.setShowVerticalLines(false); + fchooser = new JFileChooser(); + + final FileSystemView view = FileSystemView.getFileSystemView(); + folderIcon = view.getSystemIcon(view.getDefaultDirectory()); + File tempFile = null; + Icon tempIcon; + try{ + tempFile = File.createTempFile("temp", ".txt"); + tempIcon = view.getSystemIcon(tempFile); + tempFile.delete(); + } catch (IOException iox){ + tempIcon = null; + MsfguiApp.showMessage(null, "Cannot create temp file. Weird."); + } + fileIcon = tempIcon; + tempFile.delete(); + mainTable.setDefaultRenderer(Object.class,new DefaultTableCellRenderer(){ + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col){ + // Get the renderer component from parent class + JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col); + if(!mainTable.getColumnName(col).equals("Name")){ + label.setIcon(null); + return label; + } + if(files.get(value) != null && files.get(value).equals("dir")){ + label.setIcon(folderIcon); + return label; + } + try{ + File tempFile = File.createTempFile("temp",value.toString()); + label.setIcon(view.getSystemIcon(tempFile)); + tempFile.delete(); + } catch (IOException iox){ + label.setIcon(fileIcon); + } + return label; + } + }); + mainTable.setAutoCreateRowSorter(true); + fchooser.setMultiSelectionEnabled(false); + popupMenu = new JPopupMenu(); + JMenuItem men = new JMenuItem("Delete"); + men.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent e) { + delete(); + } + }); + popupMenu.add(men); + men = new JMenuItem("Download"); + men.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent e) { + download(); + } + }); + popupMenu.add(men); + setupPopupMenu( rpcConn, session); + //See if we need to move our tab + Map props = MsfguiApp.getPropertiesNode(); + if(!props.get("tabWindowPreference").equals("window")){ + ((DraggableTabbedPane)tabbedPane).moveTabTo(0, DraggableTabbedPane.getTabPane(interactPane)); + DraggableTabbedPane.show(mainPanel); + } + // Some exploits open in C:\Windows\system32. Too many files in there! Try to move to C:\ which should be more manageable + executeCommand("cd \"C:\\\\\""); + getFiles(); + } + + /** Calls meterpreter_write with the session ID and cmd. */ + private void executeCommand(String cmd){ + try{ + rpcConn.execute("session.meterpreter_run_single", session.get("id"), cmd); + } catch (Exception ex) { + MsfguiApp.showMessage(this, ex); + } + } + /** Handles click events, like popup menu and double-click navigation */ + private void setupPopupMenu(final RpcConnection rpcConn, final Map session) { + mainTable.addMouseListener(new PopupMouseListener() { + public void doubleClicked(MouseEvent e) { + //show interaction window on double-click + int indx = mainTable.getSelectedRow(); + if (indx == -1) + return; + String clickedFile = mainTable.getValueAt(indx, 0).toString(); + if (files.get(clickedFile).equals("dir")) { + executeCommand("cd " + MsfguiApp.escapeBackslashes(clickedFile)); + getFiles(); + } else { + download(); + } + } + + public void showPopup(MouseEvent e) { + int indx = mainTable.getSelectedRow(); + if (indx == -1) + return; + popupMenu.show(mainTable, e.getX(), e.getY()); + } + }); + } + + /** Deletes selected file */ + protected void delete() { + int[] indxs = mainTable.getSelectedRows(); + for(int indx : indxs){ + String clickedFile = mainTable.getValueAt(indx, 0).toString(); + if (files.get(clickedFile).equals("dir")) + executeCommand("rmdir " + MsfguiApp.escapeBackslashes(clickedFile)); + else + executeCommand("rm " + MsfguiApp.escapeBackslashes(clickedFile)); + } + getFiles(); + } + + /** Retrieves list of files. */ + private void getFiles() { + //Set up locking so the console doesn't eat our output + lock.lock(); + + while(model.getRowCount() > 0) + model.removeRow(0); + executeCommand("ls"); + if(readTimer != null && readTimer.isRunning()) + return; + readTimer = new Timer(300, new ActionListener() { + public void actionPerformed(ActionEvent e) { + try { + Map received = (Map) rpcConn.execute("session.meterpreter_read", session.get("id")); + byte[] decodedBytes = RpcConnection.getData(received); + if (decodedBytes.length == 0) + return; + String[] lines = new String(decodedBytes).split("\n"); + String headerRow = null; + String headerNames = null; + for(String line : lines){ + line = line.trim(); + if(line.startsWith("Listing")){ + addressField.setText(line.substring(line.indexOf(' ')+1)); + }else if(line.startsWith("Mode")){ + headerNames = line; + }else if(line.startsWith("-")){ + headerRow = line; + model.setColumnIdentifiers(TableHelper.fill(headerNames,line)); + while(model.getRowCount() > 0) + model.removeRow(0); + } + if(line.length() == 0 || line.charAt(0) < '0' || line.charAt(0) > '9') + continue; + String filename = line.substring(getEndOfWhitespaceBlock(line, 6)); + fileVector.add(filename); + int indx = getEndOfWhitespaceBlock(line, 2); + files.put(filename,line.substring(indx,indx+3)); + model.addRow(TableHelper.fill(line,headerRow)); + } + stop(); + TableHelper.fitColumnWidths(model, mainTable); + int nameColumn = -1; + for(int i = 0; i < mainTable.getColumnCount(); i++) + if(mainTable.getColumnName(i).equals("Name")) + nameColumn = i; + if(nameColumn != -1) + mainTable.moveColumn(nameColumn, 0); + } catch (Exception ex) { + ex.printStackTrace(); + if(ex.getMessage().toLowerCase().contains("unknown session")) + stop(); + MsfguiApp.showMessage(null, ex); + } + } + + /** Stops read timer, and releases lock */ + private void stop(){ + readTimer.stop(); + lock.unlock(); + } + + /** Helps parsing responses. */ + private int getEndOfWhitespaceBlock(String line, int num) { + int whiteSpaces = 0; + int indx = 0; + while (whiteSpaces < num) { + if (Character.isWhitespace(line.charAt(indx)) && !Character.isWhitespace(line.charAt(indx + 1))) + whiteSpaces++; + indx++; + } + return indx; + } + }); + readTimer.start(); + } + + /** 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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + tabbedPane = new DraggableTabbedPane(this); + mainPanel = new javax.swing.JPanel(); + upButton = new javax.swing.JButton(); + pwdLabel = new javax.swing.JLabel(); + addressField = new javax.swing.JTextField(); + goButton = new javax.swing.JButton(); + jScrollPane1 = new javax.swing.JScrollPane(); + mainTable = new javax.swing.JTable(); + refreshButton = new javax.swing.JButton(); + downloadButton = new javax.swing.JButton(); + deleteButton = new javax.swing.JButton(); + uploadButton = new javax.swing.JButton(); + dirButton = new javax.swing.JButton(); + recSearchDownloadButton = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + + tabbedPane.setName("tabbedPane"); // NOI18N + + mainPanel.setName("mainPanel"); // NOI18N + + org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(msfgui.MsfguiApp.class).getContext().getResourceMap(MeterpFileBrowser.class); + upButton.setText(resourceMap.getString("upButton.text")); // NOI18N + upButton.setName("upButton"); // NOI18N + upButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + upButtonActionPerformed(evt); + } + }); + + pwdLabel.setText(resourceMap.getString("pwdLabel.text")); // NOI18N + pwdLabel.setName("pwdLabel"); // NOI18N + + addressField.setText(resourceMap.getString("addressField.text")); // NOI18N + addressField.setName("addressField"); // NOI18N + addressField.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + addressFieldActionPerformed(evt); + } + }); + + goButton.setText(resourceMap.getString("goButton.text")); // NOI18N + goButton.setName("goButton"); // NOI18N + goButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + goButtonActionPerformed(evt); + } + }); + + jScrollPane1.setName("jScrollPane1"); // NOI18N + + mainTable.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] { + + }, + new String [] { + "Title 1", "Title 2", "Title 3", "Title 4" + } + )); + mainTable.setName("mainTable"); // NOI18N + jScrollPane1.setViewportView(mainTable); + + refreshButton.setText(resourceMap.getString("refreshButton.text")); // NOI18N + refreshButton.setName("refreshButton"); // NOI18N + refreshButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + refreshButtonActionPerformed(evt); + } + }); + + downloadButton.setText(resourceMap.getString("downloadButton.text")); // NOI18N + downloadButton.setName("downloadButton"); // NOI18N + downloadButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + downloadButtonActionPerformed(evt); + } + }); + + deleteButton.setText(resourceMap.getString("deleteButton.text")); // NOI18N + deleteButton.setName("deleteButton"); // NOI18N + deleteButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + deleteButtonActionPerformed(evt); + } + }); + + uploadButton.setText(resourceMap.getString("uploadButton.text")); // NOI18N + uploadButton.setName("uploadButton"); // NOI18N + uploadButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + uploadButtonActionPerformed(evt); + } + }); + + dirButton.setText(resourceMap.getString("dirButton.text")); // NOI18N + dirButton.setName("dirButton"); // NOI18N + dirButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + dirButtonActionPerformed(evt); + } + }); + + recSearchDownloadButton.setText(resourceMap.getString("recSearchDownloadButton.text")); // NOI18N + recSearchDownloadButton.setName("recSearchDownloadButton"); // NOI18N + recSearchDownloadButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + recSearchDownloadButtonActionPerformed(evt); + } + }); + + javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel); + mainPanel.setLayout(mainPanelLayout); + mainPanelLayout.setHorizontalGroup( + mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup() + .addContainerGap() + .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 889, Short.MAX_VALUE) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, mainPanelLayout.createSequentialGroup() + .addComponent(upButton) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(pwdLabel) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(addressField, javax.swing.GroupLayout.DEFAULT_SIZE, 725, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(goButton)) + .addGroup(mainPanelLayout.createSequentialGroup() + .addComponent(refreshButton) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 254, Short.MAX_VALUE) + .addComponent(recSearchDownloadButton) + .addGap(18, 18, 18) + .addComponent(dirButton) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(uploadButton) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(deleteButton) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(downloadButton))) + .addContainerGap()) + ); + mainPanelLayout.setVerticalGroup( + mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(mainPanelLayout.createSequentialGroup() + .addContainerGap() + .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(upButton) + .addComponent(pwdLabel) + .addComponent(addressField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(goButton)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 427, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(refreshButton) + .addComponent(downloadButton) + .addComponent(deleteButton) + .addComponent(uploadButton) + .addComponent(dirButton) + .addComponent(recSearchDownloadButton)) + .addContainerGap()) + ); + + tabbedPane.addTab("tab1", mainPanel); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(tabbedPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 925, Short.MAX_VALUE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(tabbedPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 567, Short.MAX_VALUE) + ); + + pack(); + }// //GEN-END:initComponents + + private void downloadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_downloadButtonActionPerformed + download(); + }//GEN-LAST:event_downloadButtonActionPerformed + + private void uploadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_uploadButtonActionPerformed + fchooser.setDialogTitle("Select file to upload"); + fchooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + if(fchooser.showOpenDialog(this) != JFileChooser.APPROVE_OPTION) + return; + executeCommand("lcd "+MsfguiApp.escapeBackslashes(fchooser.getSelectedFile().getParent())); + executeCommand("upload " + MsfguiApp.escapeBackslashes(fchooser.getSelectedFile().getName())); + getFiles(); + }//GEN-LAST:event_uploadButtonActionPerformed + + private void deleteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteButtonActionPerformed + delete(); + }//GEN-LAST:event_deleteButtonActionPerformed + + private void dirButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dirButtonActionPerformed + String newDir = JOptionPane.showInputDialog(this,"New directory name","Choose Directory Name",JOptionPane.QUESTION_MESSAGE); + if(newDir == null) + return; + executeCommand("mkdir " + MsfguiApp.escapeBackslashes(newDir)); + getFiles(); + }//GEN-LAST:event_dirButtonActionPerformed + + private void refreshButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_refreshButtonActionPerformed + getFiles(); + }//GEN-LAST:event_refreshButtonActionPerformed + + private void upButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_upButtonActionPerformed + executeCommand("cd .."); + getFiles(); + }//GEN-LAST:event_upButtonActionPerformed + + private void recSearchDownloadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_recSearchDownloadButtonActionPerformed + try{ + String currentDir = addressField.getText(); + rpcConn.execute("session.meterpreter_script", session.get("id"), + new SearchDwldOptionsDialog(this, currentDir).getCommand()); + setVisible(false); + dispose(); + + DraggableTabbedPane.show(interactPane); + }catch (NullPointerException nex){//cancelled + }catch (Exception ex){ + MsfguiApp.showMessage(null, ex); + } + }//GEN-LAST:event_recSearchDownloadButtonActionPerformed + + //Applies given directory change + private void applyDirectoryChange(){ + if(addressField.getText().equals("/")) + executeCommand("cd /../"); //Weird annonying bug. "cd /" doesn't work + else + executeCommand("cd " + MsfguiApp.escapeBackslashes(addressField.getText())); + getFiles(); + } + private void goButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_goButtonActionPerformed + applyDirectoryChange(); + }//GEN-LAST:event_goButtonActionPerformed + + private void addressFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addressFieldActionPerformed + applyDirectoryChange(); + }//GEN-LAST:event_addressFieldActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JTextField addressField; + private javax.swing.JButton deleteButton; + private javax.swing.JButton dirButton; + private javax.swing.JButton downloadButton; + private javax.swing.JButton goButton; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JPanel mainPanel; + private javax.swing.JTable mainTable; + private javax.swing.JLabel pwdLabel; + private javax.swing.JButton recSearchDownloadButton; + private javax.swing.JButton refreshButton; + private javax.swing.JTabbedPane tabbedPane; + private javax.swing.JButton upButton; + private javax.swing.JButton uploadButton; + // End of variables declaration//GEN-END:variables + + //Downloads selected files, and folders recursively if desired. + private void download() { + fchooser.setDialogTitle("Select destination folder"); + fchooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + if(fchooser.showSaveDialog(this) != JFileChooser.APPROVE_OPTION) + return; + executeCommand("lcd " + MsfguiApp.escapeBackslashes(fchooser.getSelectedFile().toString())); + for(int indx : mainTable.getSelectedRows()) + executeCommand("download " + MsfguiApp.escapeBackslashes(mainTable.getValueAt(indx, 0).toString())); + } +} diff -Nru metasploit-gui-1.0/src/msfgui/ModuleInfoWindow.java metasploit-gui-1.0/src/msfgui/ModuleInfoWindow.java --- metasploit-gui-1.0/src/msfgui/ModuleInfoWindow.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/ModuleInfoWindow.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,261 @@ +package msfgui; + +import java.awt.Component; +import java.awt.HeadlessException; +import java.text.NumberFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JFormattedTextField; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +/** + * Provides methods of extracting information about a module and displaying it, + * especially options + * + * @author scriptjunkie + */ +public abstract class ModuleInfoWindow extends MsfFrame { + protected String moduleType; + protected String fullName; + protected RpcConnection rpcConn; + protected JLabel authorsLabel; + protected JLabel titleLabel; + protected JLabel licenseLabel; + protected JLabel versionLabel; + protected MainFrame parentFrame; + protected ArrayList requiredOpts; // I love how these options aren't optional + protected ArrayList optionalOpts; + protected ArrayList advancedOpts; + protected Map options; //this holds the complete options returned from RPC + private JComponent descriptionBox = null; + + public ModuleInfoWindow(){ + authorsLabel = new javax.swing.JLabel(); + licenseLabel = new javax.swing.JLabel(); + versionLabel = new javax.swing.JLabel(); + titleLabel = new javax.swing.JLabel(); + } + /** + * Queries metasploit for information about this module, displaying it in the + * basic labels that it knows about. + * @param rpcConn + * @param fullName + * @return + */ + protected Map showBasicInfo(final RpcConnection rpcConn, final String fullName){ + Map info = (Map) rpcConn.execute("module.info", moduleType, fullName); + //Basic info + setTitle(info.get("name") + " " + fullName); + try{ + titleLabel.setText("

"+info.get("name")+ "

Rank: "+Rank.toString(info.get("rank"))+""); + } + catch(Exception ex){ + System.out.println(info); + } + Object references = info.get("references"); + StringBuilder referenceString = new StringBuilder(); + if(references != null){ + List refList = (List)references; + if(refList.size() > 0) + referenceString.append("
References:
"); + for(Object refo : refList){ + List ref = (List)refo; + referenceString.append(ref.get(0)).append(": ").append(ref.get(1)).append("
"); + } + referenceString.append("
"); + } + //Attempt to call setText on descriptionBox. This convolutedness is necessary since JLabels and + //JEditorPanes do not have a common ancestor that we can call setText on. + try{ + descriptionBox = (JComponent)getClass().getField("descriptionBox").get(this); + descriptionBox.getClass().getMethod("setText", String.class).invoke(descriptionBox, + "Description "+info.get("description").toString().replaceAll("\\s+", " ")+referenceString+""); + }catch(Exception ex){ + javax.swing.JOptionPane.showMessageDialog(this, ex); + } + if(info.get("license") instanceof String){ + licenseLabel.setText("License: "+ info.get("license")+""); + }else{ + List license = (List) info.get("license"); + StringBuilder licenseString = new StringBuilder(); + for(Object lic : license) + licenseString.append(lic).append(" "); + licenseLabel.setText("License: "+ licenseString+""); + } + versionLabel.setText("Version: "+ info.get("version")+""); + //Authors + List authors = (List) info.get("authors"); + StringBuilder authorLine = new StringBuilder(); + if (authors.size() > 0) + authorLine.append(authors.get(0).toString()); + for (int i = 1; i < authors.size(); i++) + authorLine.append(", ").append(authors.get(i)); + authorsLabel.setText("Authors: "+ authorLine.toString()+""); + updateSizes(this); + return info; + } + + /** Displays exploit and payload options. */ + protected void showOptions(JPanel mainPanel, String payload) { + for(Object o : requiredOpts) + mainPanel.remove((Component)o); + requiredOpts.clear(); + for(Object o : optionalOpts) + mainPanel.remove((Component)o); + optionalOpts.clear(); + for(Object o : advancedOpts) + mainPanel.remove((Component)o); + advancedOpts.clear(); + try{ + //get options + options = (Map) rpcConn.execute("module.options", moduleType, fullName); + // payload options + if(moduleType.equals("exploit")){ + options.putAll((Map) rpcConn.execute("module.options", "payload", payload)); + Map encodingOpt = new HashMap(); + encodingOpt.put("desc", "Preferred encoding or encodings for the payload."); + encodingOpt.put("required", Boolean.FALSE); + encodingOpt.put("advanced", Boolean.TRUE); + encodingOpt.put("evasion", Boolean.TRUE); + options.put("Encoder", encodingOpt); + } + //Display each option + for (Object optionName : options.keySet()) { + Map option = (Map)options.get(optionName); //{desc=blah, evasion=fals, advanced=false, required=true, type=port, default=blah} + javax.swing.JLabel tempText = new javax.swing.JLabel(); + tempText.setText(""+optionName.toString()+" " + option.get("desc") + ""); + tempText.setBorder(null); + //Width calculation; some of these descriptions are pretty long + //so we need to limit to the size of elements already on the page + //like licenseLabel unless it doesn't exist, then guess based on parent + int mywidth = licenseLabel.getWidth(); + java.awt.Dimension tempsize = tempText.getPreferredSize(); + if(mywidth == 0) + mywidth = mainPanel.getParent().getWidth() * 2 / 3; + //if we are going to squish it, give it room to wrap vertically + if(mywidth < tempsize.width) + tempText.setPreferredSize(new java.awt.Dimension(mywidth,tempsize.height + *(1+tempsize.width/mywidth))); + tempText.setVerticalAlignment(javax.swing.JLabel.BOTTOM); + mainPanel.add(tempText);//mainPanel.add(containerPane); + tempText.setFont(authorsLabel.getFont()); + JComponent optionField; + Object type = option.get("type"); + + //Add different types of input elements for the different types of options + if ("bool".equals(type)){ //bool options get checkboxes + optionField = new JCheckBox("",Boolean.TRUE.equals(option.get("default"))); + } else if ("enum".equals(type)){ //enum options get combo boxes + JComboBox optionCombo = new JComboBox(); + List enums = (List)option.get("enums"); + for(Object opt : enums) + optionCombo.addItem(opt); + optionCombo.setSelectedItem(option.get("default")); + optionField = optionCombo; + } else { + JTextField optionTextField; + if("port".equals(type) || "integer".equals(type)){ + NumberFormat nf = NumberFormat.getIntegerInstance(); + nf.setGroupingUsed(false); + optionTextField = new JFormattedTextField(nf); + } else {// "address" "string" + optionTextField = new JTextField(); + } + if (option.get("default") != null) { + optionTextField.setText(option.get("default").toString()); + } else if (optionName.equals("LHOST")){ //try to find local ip + optionTextField.setText(MsfguiApp.getLocalIp()); + } else if (optionName.equals("WORKSPACE")){ + optionTextField.setText(MsfguiApp.workspace); + } else if (optionName.equals("SESSION") && moduleType.equals("post") + && parentFrame.selectedSessions != null + && parentFrame.selectedSessions.length > 0){ + optionTextField.setText(parentFrame.selectedSessions[0].get("id").toString()); + } + optionField = optionTextField; + } + optionField.setName("field" + optionName); + mainPanel.add(optionField); + if (option.get("advanced").equals(Boolean.FALSE) && option.get("evasion").equals(Boolean.FALSE)){ + if(option.get("required").equals(Boolean.TRUE)){ + requiredOpts.add(tempText); + requiredOpts.add(optionField); + }else { + optionalOpts.add(tempText); + optionalOpts.add(optionField); + } + }else{ + advancedOpts.add(tempText); + advancedOpts.add(optionField); + } + } + } catch (MsfException ex) { + MsfguiApp.showMessage(rootPane, ex); + } + updateSizes(this); + } + + /** + * Iterates through the main panel, finding and extracting options. + * + * @param mainPanel + * @return a map of options the user has selected + */ + protected HashMap getOptions(JPanel mainPanel) { + //Put options into request + HashMap hash = new HashMap(); + //Get all options by looping over all components, and checking name + for (Component comp : mainPanel.getComponents()) { + if (!(comp instanceof JTextField) && !(comp instanceof JCheckBox)) + continue; + JComponent optionField = (JComponent) comp; + String optName = optionField.getName().substring("field".length()); + if(!options.containsKey(optName)) + continue; + Object optVal; + if (comp instanceof JCheckBox) + optVal = ((JCheckBox) comp).isSelected(); + else if (comp instanceof JComboBox) + optVal = ((JComboBox) comp).getSelectedItem(); + else + optVal = ((JTextField) comp).getText(); + Object defaultVal = ((Map) options.get(optName)).get("default"); + //only need non-default vals + if (defaultVal == null && optVal.toString().length() > 0 + && (!optName.equals("WORKSPACE") || !optVal.equals("default")) + && (!optVal.equals(Boolean.FALSE)) + || (defaultVal != null && !optVal.toString().equals(defaultVal.toString()))) { + hash.put(optName, optVal.toString()); //msfrpcd likes strings. Give them strings. + } + } + return hash; + } + + /** + * Takes options the user has provided and runs the module + * @param console + * @param hash + * @throws MsfException + * @throws HeadlessException + */ + protected void run(Map hash, boolean console) throws MsfException, HeadlessException { + run(moduleType, fullName, hash, console); + } + /** + * Takes options the user has provided and runs the specified module + * @param console + * @param hash + * @throws MsfException + * @throws HeadlessException + */ + protected void run(String moduleType, String fullName, Map hash, boolean console) throws MsfException, HeadlessException { + MsfguiApp.runModule(moduleType,fullName,hash,rpcConn,parentFrame,console); + } +} diff -Nru metasploit-gui-1.0/src/msfgui/ModulePopup.form metasploit-gui-1.0/src/msfgui/ModulePopup.form --- metasploit-gui-1.0/src/msfgui/ModulePopup.form 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/ModulePopup.form 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,219 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff -Nru metasploit-gui-1.0/src/msfgui/ModulePopup.java metasploit-gui-1.0/src/msfgui/ModulePopup.java --- metasploit-gui-1.0/src/msfgui/ModulePopup.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/ModulePopup.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,524 @@ +package msfgui; + +import java.awt.Component; +import java.awt.HeadlessException; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.swing.GroupLayout; +import javax.swing.GroupLayout.ParallelGroup; +import javax.swing.GroupLayout.SequentialGroup; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JMenu; +import javax.swing.JRadioButton; +import javax.swing.JTextField; +import javax.swing.event.TreeSelectionEvent; +import javax.swing.event.TreeSelectionListener; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.TreePath; +import javax.swing.tree.TreeSelectionModel; + +/** + * Displays a window showing options for a module, and support for running the module. + * @author scriptjunkie + */ +public class ModulePopup extends ModuleInfoWindow implements TreeSelectionListener{ + private JMenu recentMenu; + private String payload; + private String target; + + /** Creates new ModulePopup from recent run */ + public ModulePopup(RpcConnection rpcConn, Object[] args, MainFrame parentFrame) { + this(args[1].toString(), rpcConn, args[0].toString(), parentFrame); + Map opts = (Map)args[2]; + if(args[0].toString().equals("exploit")){ + //Set target + if(opts.get("TARGET") != null) + target = opts.get("TARGET").toString(); + else if (opts.containsKey("TARGET") && ((Map)opts.get("TARGET")).containsKey("default")) + target = ((Map)opts.get("TARGET")).get("default").toString(); + else + target = "0"; + for (Component comp : mainPanel.getComponents()){ + if(comp.getName().equals("targetButton"+target)){ + ((JRadioButton)comp).setSelected(true); + break; + } + } + //Set payload + showPayloads(rpcConn, fullName, target, opts.get("PAYLOAD").toString()); + } + //Set options + for(Component comp : mainPanel.getComponents()){ + Object optionVal = null; + if(comp.getName() != null && comp.getName().startsWith("field")) + optionVal = opts.get(comp.getName().substring("field".length())); + if(optionVal == null) + continue; + if(comp instanceof JCheckBox) + ((JCheckBox)comp).setSelected(Boolean.TRUE.equals(optionVal)); + else if(comp instanceof JComboBox) + ((JComboBox)comp).setSelectedItem(optionVal); + else if(comp instanceof JTextField) + ((JTextField)comp).setText(optionVal.toString()); + } + } + /** Creates new ModulePopup */ + public ModulePopup(String fullName, RpcConnection rpcConn, String moduleType, MainFrame parentFrame) { + this.parentFrame = parentFrame; + this.recentMenu = parentFrame.recentMenu; + initComponents(); + loadSavedSize(); + exploitButton.setText("Run "+moduleType); + exploitButton1.setText("Run "+moduleType); + exploitButton.setEnabled(false); + exploitButton1.setEnabled(false); + consoleRunButton.setEnabled(false); + consoleRunButton1.setEnabled(false); + this.moduleType = moduleType; + requiredOpts = new ArrayList(); + optionalOpts = new ArrayList(); + advancedOpts = new ArrayList(); + this.fullName = fullName; + setTitle(fullName); + payload = ""; + this.rpcConn = rpcConn; + showModuleInfo(rpcConn, fullName); + if(moduleType.equals("exploit")){ + payloadTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); + //Listen for when the selection changes. + payloadTree.addTreeSelectionListener(this); + payloadTree.setToggleClickCount(1); + } else { + mainPanel.remove(payloadScrollPane); + mainPanel.remove(targetsLabel); + } + descriptionBox.setFont(authorsLabel.getFont()); + descriptionBox.setBackground(authorsLabel.getBackground()); + mainScrollPane.getVerticalScrollBar().setUnitIncrement(40); + } + + /** Sets selected payload to the official payload */ + public void valueChanged(TreeSelectionEvent e) { + DefaultMutableTreeNode node = (DefaultMutableTreeNode)payloadTree.getLastSelectedPathComponent(); + if (node == null || !node.isLeaf()) + return; + payload = node.getUserObject().toString(); + while(node.getParent() != node.getRoot()){ + node = (DefaultMutableTreeNode)node.getParent(); + payload = node.getUserObject() + "/" + payload; + } + showOptions(); + } + + /** Displays targetsMap on frame */ + private void showModuleInfo(final RpcConnection rpcConn, final String fullName) throws HeadlessException { + try { //Get info + Map info = showBasicInfo(rpcConn, fullName); + if(moduleType.equals("exploit")){ + //Targets + Map targetsMap = (Map) info.get("targets"); + if(targetsMap == null){ + MsfguiApp.showMessage(this, "No Targets. ??"); + }else{ + String defaultTarget=""; + if(info.get("default_target") != null) + defaultTarget = info.get("default_target").toString(); + for (Object targetName : targetsMap.keySet()) { + JRadioButton radio = new JRadioButton(); + buttonGroup.add(radio); + radio.setText(targetsMap.get(targetName).toString()); // NOI18N + radio.setName("targetButton" + targetName); // NOI18N + radio.setActionCommand(targetName.toString()); + radio.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent e) { + target = buttonGroup.getSelection().getActionCommand(); + showPayloads(rpcConn,fullName,target); + } + }); + mainPanel.add(radio); + if (targetName.equals(defaultTarget)) { + radio.setSelected(true); + showPayloads(rpcConn,fullName,targetName.toString()); + } + } + } + } else { //AUXILIARY + showOptions(); + } + } catch (MsfException ex) { + MsfguiApp.showMessage(rootPane, ex); + } + reGroup(); + updateSizes(mainPanel); + } + + /** Creates payload menu. */ + private void showPayloads(RpcConnection rpcConn, String modName, String target) throws HeadlessException { + showPayloads(rpcConn, modName, target, null); + } + /** Creates payload menu. */ + private void showPayloads(RpcConnection rpcConn, String modName, String target, String defaultPayload) throws HeadlessException { + try { //Get info + List mlist = (List)((Map)rpcConn.execute("module.target_compatible_payloads", + modName,target)).get("payloads"); + //Ok. it worked. now replace the payload list + + DefaultTreeModel payloadModel = (DefaultTreeModel)payloadTree.getModel(); + DefaultMutableTreeNode top = (DefaultMutableTreeNode)(payloadModel.getRoot()); + int count = top.getChildCount(); + for(int i = count - 1; i >=0; i--){ + payloadModel.removeNodeFromParent((DefaultMutableTreeNode)top.getChildAt(i)); + } + top.removeAllChildren(); + + DefaultMutableTreeNode defaultPayloadNode = null; + for (Object payloadFullName : mlist) { + String[] names = payloadFullName.toString().split("/"); + DefaultMutableTreeNode currentNode = top; + for (int i = 0; i < names.length; i++) { + boolean found = false; + for(int j = 0; j < currentNode.getChildCount(); j++){ + DefaultMutableTreeNode node = (DefaultMutableTreeNode)currentNode.getChildAt(j); + if(node.getUserObject().toString().equals(names[i])){ + if (i < names.length - 1) + currentNode = node; + found = true; + break; + } + } + if (found) + continue; + DefaultMutableTreeNode nod = new DefaultMutableTreeNode(names[i]); + payloadModel.insertNodeInto(nod, currentNode, 0); + if (i < names.length - 1) { + payloadTree.scrollPathToVisible(new TreePath(nod.getPath())); + currentNode = nod; + } + if(payloadFullName.equals(defaultPayload)) + defaultPayloadNode=nod; + }//end for each subname + }//end for each module + if(defaultPayloadNode != null){ + payloadTree.scrollPathToVisible(new TreePath(defaultPayloadNode.getPath())); + payloadTree.setSelectionPath(new TreePath(defaultPayloadNode.getPath())); + } + payloadTree.setRootVisible(false); + payloadTree.revalidate(); + } catch (MsfException ex) { + MsfguiApp.showMessage(rootPane, ex); + } + } + + /** Displays exploit and payload options. */ + private void showOptions() { + exploitButton.setEnabled(true); + exploitButton1.setEnabled(true); + consoleRunButton.setEnabled(true); + consoleRunButton1.setEnabled(true); + showOptions(mainPanel, payload); + reGroup(); + } + + /** Runs the exploit with given options and payload. Closes window if successful. */ + private void runModule(boolean console) { + try{// Get options + HashMap hash = getOptions(mainPanel); + + //Add exploit only options + if(moduleType.equals("exploit")){ + if(payload.length() <= 0){ + MsfguiApp.showMessage(rootPane, "You must select a payload"); + return; + } + hash.put("PAYLOAD",payload.toString()); + target = buttonGroup.getSelection().getActionCommand(); + hash.put("TARGET",target); + } + //Actually run the module + run(hash, console); + + //close out + this.setVisible(false); + this.dispose(); + } catch (MsfException ex) { + MsfguiApp.showMessage(rootPane, ex); + } + } + + /** Reformats the view based on visible options and targetsMap. */ + private void reGroup(){ + GroupLayout mainPanelLayout = (GroupLayout)mainPanel.getLayout(); + ParallelGroup horizGroup = mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(titleLabel) + .addComponent(descriptionPane, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE) + .addComponent(authorsLabel) + .addComponent(licenseLabel) + .addComponent(versionLabel); + //Exploit only stuff + if(moduleType.equals("exploit")){ + horizGroup.addComponent(targetsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(payloadScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE); + } + horizGroup.addComponent(requiredLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(optionalLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE); + Enumeration targets = buttonGroup.getElements(); + while(targets.hasMoreElements()) + horizGroup = horizGroup.addComponent((JRadioButton)targets.nextElement()); + for(Object obj : requiredOpts) + horizGroup = horizGroup.addComponent((Component) obj, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE); + for(Object obj : optionalOpts) + horizGroup = horizGroup.addComponent((Component) obj, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE); + for(Object obj : advancedOpts) + horizGroup = horizGroup.addComponent((Component) obj, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE); + + horizGroup = horizGroup.addGroup(mainPanelLayout.createSequentialGroup() + .addComponent(exploitButton) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(consoleRunButton)) + .addGroup(mainPanelLayout.createSequentialGroup() + .addComponent(exploitButton1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(consoleRunButton1)); + mainPanelLayout.setHorizontalGroup(mainPanelLayout.createSequentialGroup().addContainerGap() + .addGroup(horizGroup).addContainerGap()); + + SequentialGroup vGroup = mainPanelLayout.createSequentialGroup() + .addContainerGap() + .addComponent(titleLabel) + .addComponent(descriptionPane, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(authorsLabel) + .addComponent(licenseLabel) + .addComponent(versionLabel) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED); + //Exploit only stuff + if(moduleType.equals("exploit")){ + vGroup.addComponent(targetsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED); + targets = buttonGroup.getElements(); + while(targets.hasMoreElements()){ + vGroup.addComponent((JRadioButton)targets.nextElement()) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED); + } + vGroup = vGroup.addComponent(payloadScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 296, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED); + } + addObjectsToVgroup(vGroup, requiredLabel, requiredOpts); + vGroup.addGroup(mainPanelLayout.createParallelGroup() + .addComponent(exploitButton1) + .addComponent(consoleRunButton)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED); + addObjectsToVgroup(vGroup, optionalLabel, optionalOpts); + addObjectsToVgroup(vGroup, advancedLabel, advancedOpts); + vGroup = vGroup.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(mainPanelLayout.createParallelGroup() + .addComponent(exploitButton) + .addComponent(consoleRunButton1)) + .addContainerGap(); + mainPanelLayout.setVerticalGroup(vGroup); + } + + //helper for grouping + private void addObjectsToVgroup(SequentialGroup vGroup, Component label, ArrayList opts) { + vGroup = vGroup.addComponent(label, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE); + for (Object obj : opts) + vGroup.addComponent((Component) obj, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE); + } + + /** 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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + buttonGroup = new javax.swing.ButtonGroup(); + mainScrollPane = new javax.swing.JScrollPane(); + mainPanel = new javax.swing.JPanel(); + targetsLabel = new javax.swing.JLabel(); + payloadScrollPane = new javax.swing.JScrollPane(); + payloadTree = new javax.swing.JTree(); + exploitButton = new javax.swing.JButton(); + requiredLabel = new javax.swing.JLabel(); + optionalLabel = new javax.swing.JLabel(); + descriptionPane = new javax.swing.JScrollPane(); + descriptionBox = new javax.swing.JEditorPane(); + advancedLabel = new javax.swing.JLabel(); + exploitButton1 = new javax.swing.JButton(); + consoleRunButton = new javax.swing.JButton(); + consoleRunButton1 = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + + mainScrollPane.setName("mainScrollPane"); // NOI18N + + mainPanel.setName("mainPanel"); // NOI18N + + org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(msfgui.MsfguiApp.class).getContext().getResourceMap(ModulePopup.class); + targetsLabel.setText(resourceMap.getString("targetsLabel.text")); // NOI18N + targetsLabel.setName("targetsLabel"); // NOI18N + + payloadScrollPane.setName("payloadScrollPane"); // NOI18N + + javax.swing.tree.DefaultMutableTreeNode treeNode1 = new javax.swing.tree.DefaultMutableTreeNode("Payloads"); + payloadTree.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1)); + payloadTree.setName("payloadTree"); // NOI18N + payloadScrollPane.setViewportView(payloadTree); + + exploitButton.setText(resourceMap.getString("exploitButton.text")); // NOI18N + exploitButton.setName("exploitButton"); // NOI18N + exploitButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + exploitButtonActionPerformed(evt); + } + }); + + requiredLabel.setText(resourceMap.getString("requiredLabel.text")); // NOI18N + requiredLabel.setName("requiredLabel"); // NOI18N + + optionalLabel.setText(resourceMap.getString("optionalLabel.text")); // NOI18N + optionalLabel.setName("optionalLabel"); // NOI18N + + descriptionPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + descriptionPane.setName("descriptionPane"); // NOI18N + + descriptionBox.setContentType("text/html"); // NOI18N + descriptionBox.setEditable(false); + descriptionBox.setName("descriptionBox"); // NOI18N + descriptionPane.setViewportView(descriptionBox); + + advancedLabel.setText(resourceMap.getString("advancedLabel.text")); // NOI18N + advancedLabel.setName("advancedLabel"); // NOI18N + + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("msfgui/resources/ModulePopup"); // NOI18N + exploitButton1.setText(bundle.getString("exploitButton.text")); // NOI18N + exploitButton1.setName("exploitButton1"); // NOI18N + exploitButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + exploitButton1ActionPerformed(evt); + } + }); + + consoleRunButton.setText(resourceMap.getString("consoleRunButton.text")); // NOI18N + consoleRunButton.setName("consoleRunButton"); // NOI18N + consoleRunButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + consoleRunButtonActionPerformed(evt); + } + }); + + consoleRunButton1.setText(resourceMap.getString("consoleRunButton1.text")); // NOI18N + consoleRunButton1.setName("consoleRunButton1"); // NOI18N + consoleRunButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + consoleRunButton1ActionPerformed(evt); + } + }); + + javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel); + mainPanel.setLayout(mainPanelLayout); + mainPanelLayout.setHorizontalGroup( + mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(mainPanelLayout.createSequentialGroup() + .addContainerGap() + .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(descriptionPane, javax.swing.GroupLayout.DEFAULT_SIZE, 621, Short.MAX_VALUE) + .addComponent(targetsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 431, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(payloadScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 621, Short.MAX_VALUE) + .addComponent(requiredLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(optionalLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(advancedLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(mainPanelLayout.createSequentialGroup() + .addComponent(exploitButton) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(consoleRunButton)) + .addGroup(mainPanelLayout.createSequentialGroup() + .addComponent(exploitButton1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(consoleRunButton1))) + .addContainerGap()) + ); + mainPanelLayout.setVerticalGroup( + mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(mainPanelLayout.createSequentialGroup() + .addGap(36, 36, 36) + .addComponent(descriptionPane, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(78, 78, 78) + .addComponent(targetsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(payloadScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 296, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(requiredLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(optionalLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(advancedLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(exploitButton) + .addComponent(consoleRunButton)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(exploitButton1) + .addComponent(consoleRunButton1)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + mainScrollPane.setViewportView(mainPanel); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(mainScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 663, Short.MAX_VALUE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(mainScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 609, Short.MAX_VALUE) + ); + + pack(); + }// //GEN-END:initComponents + + private void exploitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exploitButtonActionPerformed + runModule(false); + }//GEN-LAST:event_exploitButtonActionPerformed + + private void exploitButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exploitButton1ActionPerformed + runModule(false); + }//GEN-LAST:event_exploitButton1ActionPerformed + + private void consoleRunButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_consoleRunButtonActionPerformed + runModule(true); + }//GEN-LAST:event_consoleRunButtonActionPerformed + + private void consoleRunButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_consoleRunButton1ActionPerformed + runModule(true); + }//GEN-LAST:event_consoleRunButton1ActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel advancedLabel; + private javax.swing.ButtonGroup buttonGroup; + private javax.swing.JButton consoleRunButton; + private javax.swing.JButton consoleRunButton1; + public javax.swing.JEditorPane descriptionBox; + private javax.swing.JScrollPane descriptionPane; + private javax.swing.JButton exploitButton; + private javax.swing.JButton exploitButton1; + private javax.swing.JPanel mainPanel; + private javax.swing.JScrollPane mainScrollPane; + private javax.swing.JLabel optionalLabel; + private javax.swing.JScrollPane payloadScrollPane; + private javax.swing.JTree payloadTree; + private javax.swing.JLabel requiredLabel; + private javax.swing.JLabel targetsLabel; + // End of variables declaration//GEN-END:variables +} diff -Nru metasploit-gui-1.0/src/msfgui/MsfException.java metasploit-gui-1.0/src/msfgui/MsfException.java --- metasploit-gui-1.0/src/msfgui/MsfException.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/MsfException.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +package msfgui; + +/** + * General exception for Metasploit + * @author scriptjunkie + */ +class MsfException extends RuntimeException{ + + public MsfException(Throwable cause) { + super(cause); + } + + public MsfException(String message, Throwable cause) { + super(message, cause); + } + + public MsfException() { + } + + public MsfException(String string) { + super(string); + } + +} diff -Nru metasploit-gui-1.0/src/msfgui/MsfFrame.java metasploit-gui-1.0/src/msfgui/MsfFrame.java --- metasploit-gui-1.0/src/msfgui/MsfFrame.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/MsfFrame.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,157 @@ +package msfgui; + +import java.awt.Color; +import java.awt.Component; +import java.awt.HeadlessException; +import java.util.Map; +import javax.swing.JComponent; +import javax.swing.UIManager; +import javax.swing.UIManager.LookAndFeelInfo; +import javax.swing.plaf.ColorUIResource; +import javax.swing.plaf.metal.DefaultMetalTheme; +import javax.swing.plaf.metal.MetalLookAndFeel; + +/** + * Basic frame; shows default icon and saves dimensions on resize. + * Also handles UI functions across windows + * + * @author scriptjunkie + */ +public class MsfFrame extends javax.swing.JFrame{ + private static Map props = null; + private String frameClass = null; + + /** Sets look and feel to preset or default */ + public static void setLnF(){ + props = MsfguiApp.getPropertiesNode(); + if(Boolean.TRUE.equals(props.get("overrideColors")) && props.containsKey("backgroundColor")){ + final Color bgcol = new Color((Integer)props.get("backgroundColor")); + final Color fgcol = new Color((Integer)props.get("foregroundColor")); + UIManager.put("nimbusBase", bgcol); + UIManager.put("nimbusBlueGrey", bgcol); + UIManager.put("control", bgcol); + UIManager.put("nimbusLightBackground", bgcol); + UIManager.put("nimbusSelectedText", bgcol); + UIManager.put("textHighlightText", bgcol); + UIManager.put("textForeground", fgcol); + UIManager.put("menuText", fgcol); + UIManager.put("infoText", fgcol); + UIManager.put("controlText", fgcol); + UIManager.put("text", fgcol); + MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme() { + public String getName() {return "msfgui custom";} + private final ColorUIResource foreground = new ColorUIResource(fgcol); + private final ColorUIResource background = new ColorUIResource(bgcol); + protected ColorUIResource getPrimary1() {return foreground;} + protected ColorUIResource getPrimary2() {return foreground;} + protected ColorUIResource getPrimary3() {return foreground;} + protected ColorUIResource getSecondary1() {return foreground;} + protected ColorUIResource getSecondary2() {return background;} + protected ColorUIResource getSecondary3() {return background;} + public ColorUIResource getMenuSelectedForeground() {return background;} + public ColorUIResource getMenuSelectedBackground() {return foreground;} + protected ColorUIResource getBlack() {return foreground;} + protected ColorUIResource getWhite() {return background;} + }); + } + + String classname=""+MsfguiApp.getPropertiesNode().get("LnF"); + try { + boolean system = !"Metal".equals(props.get("LnF")); + try{ + UIManager.setLookAndFeel(classname); + props.put("LnF", classname); + }catch(Exception ulafex){ + String newLnF = UIManager.getSystemLookAndFeelClassName(); + //Prefer nimbus + for(LookAndFeelInfo lookAndFeel : UIManager.getInstalledLookAndFeels()) + if(lookAndFeel.getClassName().equals("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel")) + newLnF = "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"; + UIManager.setLookAndFeel(newLnF); + props.put("LnF", newLnF); + } + } catch (Exception e) { + MsfguiApp.showMessage(null, e); + e.printStackTrace(); + } + } + + /** + * Applies any UI changes to all frames. + */ + public static void updateUIs(){ + setLnF(); + for(java.awt.Frame fram : java.awt.Frame.getFrames()){ + updateSizes(fram); + javax.swing.SwingUtilities.updateComponentTreeUI(fram); + fram.pack(); + } + } + + /** + * Recursively iterates through a container, updating the size + * + * @param c Container or component to be resized + */ + public static void updateSizes(java.awt.Component com) { + //Make sure props is initialized + if(props == null) + props = MsfguiApp.getPropertiesNode(); + + //Reset size + if(com instanceof JComponent && props.containsKey("jComponentSizeVariant")) + ((JComponent)com).putClientProperty("JComponent.sizeVariant", props.get("jComponentSizeVariant")); + java.awt.Font fnt = com.getFont(); + if(fnt != null && props.containsKey("defaultTextSize")) + com.setFont(fnt.deriveFont(new Float(props.get("defaultTextSize").toString()).floatValue())); + if(Boolean.TRUE.equals(props.get("overrideColors"))){ + if(props.containsKey("backgroundColor")) + com.setBackground(new Color((Integer)props.get("backgroundColor"))); + if(props.containsKey("foregroundColor")) + com.setForeground(new Color((Integer)props.get("foregroundColor"))); + } + + //Loop through containers + if(com instanceof javax.swing.JMenu) + for(Component cc : ((javax.swing.JMenu)com).getMenuComponents()) + updateSizes(cc); + else if(com instanceof java.awt.Container) + for(Component cc : ((java.awt.Container)com).getComponents()) + updateSizes(cc); + } + + public MsfFrame(String title) throws HeadlessException { + super(title); + org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance( + msfgui.MsfguiApp.class).getContext().getResourceMap(ModulePopup.class); + this.setIconImage(resourceMap.getImageIcon("main.icon").getImage()); + } + + /** + * Checks to see if this frame has saved height and width, and reloads it. + */ + public void loadSavedSize(){ + props = MsfguiApp.getPropertiesNode(); + updateSizes(this); + //Do inital setup if needed + if(frameClass == null){ + frameClass = getClass().getName(); + + //And update saved height/width data on resize + addComponentListener(new java.awt.event.ComponentAdapter() { + public void componentResized(java.awt.event.ComponentEvent e) { + props.put(frameClass +"Width", getWidth()); + props.put(frameClass +"Height", getHeight()); + } + }); + } + //Reset the size + if(props.containsKey(frameClass+"Width") && props.containsKey(frameClass+"Height")) + setSize((Integer)props.get(frameClass+"Width"), + (Integer)props.get(frameClass+"Height")); + } + + public MsfFrame() throws HeadlessException { + this(""); + } +} diff -Nru metasploit-gui-1.0/src/msfgui/MsfguiAboutBox.form metasploit-gui-1.0/src/msfgui/MsfguiAboutBox.form --- metasploit-gui-1.0/src/msfgui/MsfguiAboutBox.form 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/MsfguiAboutBox.form 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,231 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -Nru metasploit-gui-1.0/src/msfgui/MsfguiAboutBox.java metasploit-gui-1.0/src/msfgui/MsfguiAboutBox.java --- metasploit-gui-1.0/src/msfgui/MsfguiAboutBox.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/MsfguiAboutBox.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,177 @@ +package msfgui; + +import org.jdesktop.application.Action; + +/** + * Provides an about box for msfgui. + * @author scriptjunkie + */ +public class MsfguiAboutBox extends javax.swing.JDialog { + + public static void show(java.awt.Frame parent, RpcConnection rpcConn){ + 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); + initComponents(); + getRootPane().setDefaultButton(closeButton); + appVersionLabel.setText(msfVersion); + appJavaVersionLabel.setText(javaVersion); + appRubyVersionLabel.setText(rubyVersion); + org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(msfgui.MsfguiApp.class).getContext().getResourceMap(ModulePopup.class); + this.setIconImage(resourceMap.getImageIcon("main.icon").getImage()); + } + + @Action public void closeAboutBox() { + dispose(); + } + + /** 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() { + + closeButton = new javax.swing.JButton(); + javax.swing.JLabel appTitleLabel = new javax.swing.JLabel(); + javax.swing.JLabel versionLabel = new javax.swing.JLabel(); + appVersionLabel = new javax.swing.JLabel(); + javax.swing.JLabel homepageLabel = new javax.swing.JLabel(); + javax.swing.JLabel appHomepageLabel = new javax.swing.JLabel(); + javax.swing.JLabel appDescLabel = new javax.swing.JLabel(); + javax.swing.JLabel imageLabel = new javax.swing.JLabel(); + javax.swing.JLabel rubyVersionLabel = new javax.swing.JLabel(); + javax.swing.JLabel javaVersionLabel = new javax.swing.JLabel(); + appRubyVersionLabel = new javax.swing.JLabel(); + appJavaVersionLabel = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(msfgui.MsfguiApp.class).getContext().getResourceMap(MsfguiAboutBox.class); + setTitle(resourceMap.getString("title")); // NOI18N + setModal(true); + setResizable(false); + + javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(msfgui.MsfguiApp.class).getContext().getActionMap(MsfguiAboutBox.class, this); + closeButton.setAction(actionMap.get("closeAboutBox")); // NOI18N + closeButton.setName("closeButton"); // NOI18N + + appTitleLabel.setFont(appTitleLabel.getFont().deriveFont(appTitleLabel.getFont().getStyle() | java.awt.Font.BOLD, appTitleLabel.getFont().getSize()+8)); + appTitleLabel.setText(resourceMap.getString("Application.title")); // NOI18N + appTitleLabel.setName("appTitleLabel"); // NOI18N + + versionLabel.setFont(versionLabel.getFont().deriveFont(versionLabel.getFont().getStyle() | java.awt.Font.BOLD)); + versionLabel.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + versionLabel.setText(resourceMap.getString("versionLabel.text")); // NOI18N + versionLabel.setName("versionLabel"); // NOI18N + + appVersionLabel.setText(resourceMap.getString("Application.version")); // NOI18N + appVersionLabel.setName("appVersionLabel"); // NOI18N + + homepageLabel.setFont(homepageLabel.getFont().deriveFont(homepageLabel.getFont().getStyle() | java.awt.Font.BOLD)); + homepageLabel.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + homepageLabel.setText(resourceMap.getString("homepageLabel.text")); // NOI18N + homepageLabel.setName("homepageLabel"); // NOI18N + + appHomepageLabel.setText(resourceMap.getString("Application.homepage")); // NOI18N + appHomepageLabel.setName("appHomepageLabel"); // NOI18N + + appDescLabel.setText(resourceMap.getString("appDescLabel.text")); // NOI18N + appDescLabel.setName("appDescLabel"); // NOI18N + + imageLabel.setIcon(resourceMap.getIcon("imageLabel.icon")); // NOI18N + imageLabel.setName("imageLabel"); // NOI18N + + rubyVersionLabel.setFont(rubyVersionLabel.getFont().deriveFont(rubyVersionLabel.getFont().getStyle() | java.awt.Font.BOLD)); + rubyVersionLabel.setText(resourceMap.getString("rubyVersionLabel.text")); // NOI18N + rubyVersionLabel.setName("rubyVersionLabel"); // NOI18N + + javaVersionLabel.setFont(javaVersionLabel.getFont().deriveFont(javaVersionLabel.getFont().getStyle() | java.awt.Font.BOLD)); + javaVersionLabel.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + javaVersionLabel.setText(resourceMap.getString("javaVersionLabel.text")); // NOI18N + javaVersionLabel.setName("javaVersionLabel"); // NOI18N + + appRubyVersionLabel.setText(resourceMap.getString("appRubyVersionLabel.text")); // NOI18N + appRubyVersionLabel.setName("appRubyVersionLabel"); // NOI18N + + appJavaVersionLabel.setText(resourceMap.getString("appJavaVersionLabel.text")); // NOI18N + appJavaVersionLabel.setName("appJavaVersionLabel"); // 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() + .addComponent(imageLabel) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(appTitleLabel, javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(appDescLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 466, Short.MAX_VALUE) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addComponent(homepageLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(javaVersionLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(versionLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(rubyVersionLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(appVersionLabel) + .addComponent(appRubyVersionLabel) + .addComponent(appJavaVersionLabel)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 353, Short.MAX_VALUE)) + .addComponent(appHomepageLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 361, Short.MAX_VALUE))) + .addComponent(closeButton)) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(imageLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 305, Short.MAX_VALUE) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(appTitleLabel) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(appDescLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(versionLabel) + .addComponent(appVersionLabel)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(rubyVersionLabel) + .addComponent(appRubyVersionLabel)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(javaVersionLabel) + .addComponent(appJavaVersionLabel)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(homepageLabel) + .addComponent(appHomepageLabel)) + .addGap(104, 104, 104) + .addComponent(closeButton) + .addContainerGap()) + ); + + pack(); + }// //GEN-END:initComponents + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel appJavaVersionLabel; + private javax.swing.JLabel appRubyVersionLabel; + private javax.swing.JLabel appVersionLabel; + private javax.swing.JButton closeButton; + // End of variables declaration//GEN-END:variables + +} diff -Nru metasploit-gui-1.0/src/msfgui/MsfguiApp.java metasploit-gui-1.0/src/msfgui/MsfguiApp.java --- metasploit-gui-1.0/src/msfgui/MsfguiApp.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/MsfguiApp.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,390 @@ +package msfgui; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.net.DatagramSocket; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.regex.Pattern; +import javax.swing.JFileChooser; +import javax.swing.JMenu; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; +import org.jdesktop.application.Application; +import org.jdesktop.application.SingleFrameApplication; +import org.w3c.dom.Document; + +/** + * The main class of the application. Handles global settings and system functions. + * @author scriptjunkie + */ +public class MsfguiApp extends SingleFrameApplication { + public static final int NUM_REMEMBERED_MODULES = 20; + private static final Map propRoot; + public static JFileChooser fileChooser; + protected static Pattern backslash = Pattern.compile("\\\\"); + public static String workspace = "default"; + public static final String confFilename = System.getProperty("user.home")+File.separatorChar+".msf4"+File.separatorChar+"msfgui"; + public static MainFrame mainFrame; + public static boolean shuttingDown = false; + + static{ //get saved properties file + Map props; + try{ + props = (Map)XmlRpc.parseVal(DocumentBuilderFactory.newInstance().newDocumentBuilder() + .parse(new FileInputStream(confFilename)).getDocumentElement()); + } catch (Exception ex) { //if anything goes wrong, make new (IOException, SAXException, ParserConfigurationException, NullPointerException + props = new HashMap();//ensure existence + } + propRoot = props; + RpcConnection.disableDb = Boolean.TRUE.equals(propRoot.get("disableDb")); //restore this, since it can't be checked on connect + if(propRoot.get("recentList") == null) + propRoot.put("recentList", new LinkedList()); + Runtime.getRuntime().addShutdownHook(new Thread(){ + @Override + public void run() { + savePreferences(); + try{ + MsfguiLog.defaultLog.save(); + }catch(IOException iox){//nothing you can do + } + } + }); + fileChooser = new JFileChooser(); + } + public static void showMessage(java.awt.Component parent, Object message){ + String msg = message.toString(); + if(!shuttingDown && !msg.toLowerCase().contains("unknown session")) + JOptionPane.showMessageDialog(parent, message); + } + + /** + * Saves the properties node as an XML file specified by confFilename + */ + public static void savePreferences(){ + try { + Document docElement = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); + docElement.appendChild(XmlRpc.objectToNode(docElement, propRoot)); + TransformerFactory.newInstance().newTransformer().transform(new DOMSource(docElement), new StreamResult(new FileOutputStream(confFilename))); + } catch (Exception ex) { + //fail + try { + //Problem saving conf file; we are probably closing here, so we shouldn't try to pop up a message box + FileWriter fout = new FileWriter(confFilename + "ERROR.log", true); + fout.write(java.util.Calendar.getInstance().getTime().toString()); + fout.write(" Error saving properties. Check " + confFilename + " file permissions.\n"); + fout.write(ex.toString() + "\n"); + fout.close(); + } catch (Exception exc) { + //epic fail + } + } + } + + /** + * Finds or asks the user for the base path of Metasploit on Windows. + */ + static String getBase() throws IOException { + if (propRoot.containsKey("BASE") && (new File(propRoot.get("BASE") + "\\apps\\pro")).isDirectory()) + return propRoot.get("BASE").toString(); + if (new File("C:\\metasploit\\apps\\pro\\").isDirectory()){ + propRoot.put("BASE", "C:\\metasploit\\"); + }else if (new File("/opt/metasploit/apps/pro/").isDirectory()){ + propRoot.put("BASE", "/opt/metasploit/"); + }else{ + if(JOptionPane.showConfirmDialog(null, + "Cannot find metasploit install directory (usually C:\\metasploit \n" + + "on Windows or /opt/metasploit on Linux). If you have not installed \n" + + "an updated version of metasploit, go to http://metasploit.com/download\n" + + " to get an updated copy. Otherwise, click yes to choose a different \n" + + "install directory.") == JOptionPane.YES_OPTION){ + fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + fileChooser.showOpenDialog(null); + fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + //Now verify + if((new File(fileChooser.getSelectedFile().getCanonicalPath()+"/apps/pro")).isDirectory()){ + MsfguiApp.getPropertiesNode().put("BASE", fileChooser.getSelectedFile().getCanonicalPath()); + } else { + if(JOptionPane.showConfirmDialog(null, "Folder might not be valid. Use anyway?") == JOptionPane.YES_OPTION){ + MsfguiApp.getPropertiesNode().put("BASE", fileChooser.getSelectedFile().getCanonicalPath()); + } + } + }else{ + return ""; + } + } + return propRoot.get("BASE").toString(); + } + + /** + * At startup create and show the main frame of the application. + */ + @Override protected void startup() { + MsfguiLog.initDefaultLog(); + mainFrame = new MainFrame(this); + show(mainFrame); + } + + /** + * This method is to initialize the specified window by injecting resources. + * Windows shown in our application come fully initialized from the GUI + * builder, so this additional configuration is not needed. + */ + @Override protected void configureWindow(java.awt.Window root) { + } + + /** + * A convenient static getter for the application instance. + * @return the instance of MsfguiApp + */ + public static MsfguiApp getApplication() { + return Application.getInstance(MsfguiApp.class); + } + + /** + * Main method launching the application. + */ + public static void main(String[] args) { + launch(MsfguiApp.class, args); + } + + /** Application helper to launch msfrpcd or msfencode, etc. */ + public static Process startMsfProc(List command) throws MsfException{ + return startMsfProc((String[])command.toArray(new String[command.size()])); + } + /** Application helper to launch msfrpcd or msfencode, etc. */ + public static Process startMsfProc(String[] args) throws MsfException { + String msfCommand = args[0]; + Process proc; + String[] winArgs = null; + try { + args[0] = msfCommand; + proc = Runtime.getRuntime().exec(args); + } catch (Exception ex1) { + try { + proc = Runtime.getRuntime().exec(args); + } catch (IOException ex2) { + try { //Try on Windows + winArgs = new String[args.length + 3]; + System.arraycopy(args, 0, winArgs, 3, args.length); + winArgs[0] = "cmd"; + winArgs[1] = "/c"; + winArgs[2] = "ruby.exe"; + winArgs[3] = msfCommand; + ProcessBuilder p = new ProcessBuilder(); + String path = "PATH"; //Gotta figure out how it's capitalized + for(Object o : p.environment().keySet()) + if(o.toString().toLowerCase().equals("path")) + path = o.toString(); + p.environment().put("BASE", getBase() + "\\"); + p.environment().put(path, getBase() + "\\ruby\\bin"+ + File.pathSeparator + getBase() + "\\java\\bin"+ + File.pathSeparator + getBase() + "\\tools"+ + File.pathSeparator + getBase() + "\\nmap" + + File.pathSeparator + p.environment().get(path)); + p.environment().put("MSF_DATABASE_CONFIG", getBase() + "\\config\\database.yml"); + p.environment().put("MSFCONSOLE_OPTS", "-e production -y \"" + getBase() + "\\apps\\pro\\ui\\config\\database.yml\""); + p.environment().put("BUNDLE_GEMFILE", getBase() + "\\apps\\pro\\ui\\Gemfile"); + p.directory(new File(getBase()+"\\apps\\pro\\msf3")); + p.command(winArgs); + proc = p.start(); + } catch (IOException ex4){ + throw new MsfException("Executable not found for "+msfCommand); + } + } + } + return proc; + } + + /** + * Runs the specified module from options provided, sending results to main frame + * @param console + * @param hash + * @throws MsfException + * @throws HeadlessException + */ + public static void runModule(String moduleType, String fullName, Map hash, RpcConnection rpcConn, + MainFrame parentFrame, boolean console) throws MsfException, java.awt.HeadlessException { + //Execute and get results + if (console) { // Create a list of commands to run in the console + Map res = (Map) rpcConn.execute("console.create"); + java.util.ArrayList autoCommands = new java.util.ArrayList(); + autoCommands.add("use " + moduleType + "/" + fullName); + //Add target if it is set and not zero if there is no default or non-default if there is a default + if(moduleType.equals("exploit") && hash.containsKey("TARGET")){ + Map info = (Map) rpcConn.execute("module.info", moduleType, fullName); + if(info.containsKey("default_target") && !hash.get("TARGET").toString().equals(info.get("default_target").toString()) + || !info.containsKey("default_target") && !hash.get("TARGET").toString().equals("0")) + autoCommands.add("set TARGET " + hash.get("TARGET")); + } + if (hash.containsKey("PAYLOAD")) + autoCommands.add("set PAYLOAD " + hash.get("PAYLOAD")); + //Convert the rest of the options to set commands + for (Object entObj : hash.entrySet()) { + Map.Entry ent = (Map.Entry) entObj; + if (!(ent.getKey().toString().equals("TARGET")) && !(ent.getKey().toString().equals("PAYLOAD"))) + autoCommands.add("set " + ent.getKey() + " " + MsfguiApp.escapeBackslashes(ent.getValue().toString())); + } + autoCommands.add("exploit"); + InteractWindow iw = new InteractWindow(rpcConn, res, autoCommands); + parentFrame.registerConsole(res, true, iw); + MsfguiLog.defaultLog.logMethodCall("module.execute", new Object[]{moduleType, fullName, hash}); + } else { // Non-console; just fire away + Map info = (Map) rpcConn.execute("module.execute",moduleType, fullName,hash); + if (!info.containsKey("job_id") && !info.get("result").equals("success")) + MsfguiApp.showMessage(parentFrame.getFrame(), info); + } + MsfguiApp.addRecentModule(java.util.Arrays.asList(new Object[]{moduleType, fullName, hash}), rpcConn, parentFrame); + } + + /** Get root node of xml saved options file */ + public static Map getPropertiesNode(){ + return propRoot; + } + /** + * Finds the path to this jar file + * @return The path of this jar file as a String + */ + public static String getMyPath() throws MsfException{ + try{ + return MsfguiApp.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath(); + }catch(java.net.URISyntaxException urisex){ + urisex.printStackTrace(); + } + return null; + } + + /** Adds a module run to the recent modules list */ + public static void addRecentModule(final List args, final RpcConnection rpcConn, final MainFrame mf) { + addRecentModule(args, rpcConn, mf, true); + } + public static void addRecentModule(final List args, final RpcConnection rpcConn, final MainFrame mf, boolean ignoreDups) { + final JMenu recentMenu = mf.recentMenu; + List recentList = (List)propRoot.get("recentList"); + if(recentList.contains(args)){ + if(ignoreDups) + return; + }else{ + recentList.add(args); + } + Map hash = (Map)args.get(2); + StringBuilder name = new StringBuilder(args.get(0) + " " + args.get(1)); + //Save these options + if(!propRoot.containsKey("modOptions")) //first ensure option map exists + propRoot.put("modOptions", new HashMap()); + ((Map)propRoot.get("modOptions")).put(name.toString(), args); + + //Generate display name + for(Object ento : hash.entrySet()){ + Entry ent = (Entry)ento; + String propName = ent.getKey().toString(); + if(propName.endsWith("HOST") || propName.endsWith("PORT") || propName.equals("PAYLOAD")) + name.append(" ").append(propName).append("-").append(ent.getValue()); + } + //Make menu item + final JMenuItem item = new JMenuItem(name.toString()); + item.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + new ModulePopup(rpcConn, args.toArray(), mf).setVisible(true); + recentMenu.remove(item); + recentMenu.add(item); + List recentList = (List)propRoot.get("recentList"); + for(int i = 0; i < recentList.size(); i++){ + if(recentList.get(i).equals(args)){ + recentList.add(recentList.remove(i)); + break; + } + } + } + }); + MsfFrame.updateSizes(item); + recentMenu.add(item); + recentMenu.setEnabled(true); + if(recentMenu.getItemCount() > NUM_REMEMBERED_MODULES) + recentMenu.remove(0); + if(recentList.size() > NUM_REMEMBERED_MODULES) + recentList.remove(0); + } + public static void addRecentModules(final RpcConnection rpcConn, final MainFrame mf) { + List recentList = (List)propRoot.get("recentList"); + for(Object item : recentList) + addRecentModule((List)item, rpcConn, mf, false); + } + + /** Clear history of run modules */ + public static void clearHistory(JMenu recentMenu){ + ((List)propRoot.get("recentList")).clear(); + recentMenu.removeAll(); + recentMenu.setEnabled(false); + } + + /** Gets a temp file from system */ + public static String getTempFilename(String prefix, String suffix) { + try{ + final File temp = File.createTempFile(prefix, suffix); + String path = temp.getAbsolutePath(); + temp.delete(); + return path; + }catch(IOException ex){ + MsfguiApp.showMessage(null, "Cannot create temp file. This is a bad and unexpected error. What is wrong with your system?!"); + return null; + } + } + + /** Gets a temp folder from system */ + public static String getTempFolder() { + try{ + final File temp = File.createTempFile("abcde", ".bcde"); + String path = temp.getParentFile().getAbsolutePath(); + temp.delete(); + return path; + }catch(IOException ex){ + MsfguiApp.showMessage(null, "Cannot create temp file. This is a bad and unexpected error. What is wrong with your system?!"); + return null; + } + } + + /** Returns the likely local IP address for talking to the world */ + public static String getLocalIp(){ + try{ + DatagramSocket socket = new DatagramSocket(); + socket.connect(InetAddress.getByName("1.2.3.4"),1234); + String answer = socket.getLocalAddress().getHostAddress(); + socket.close(); + return answer; + } catch(IOException ioe){ + try{ + return InetAddress.getLocalHost().getHostAddress(); + }catch (UnknownHostException uhe){ + return "127.0.0.1"; + } + } + } + + public static String cleanBackslashes(String input){ + return backslash.matcher(input).replaceAll("/"); + } + public static String escapeBackslashes(String input){ + StringBuilder output = new StringBuilder(); + for(char c : input.toCharArray()){ + if(c == '\\' || c == ' ' || c == '\'' || c == '"') + output.append('\\'); + output.append(c); + } + return output.toString(); + } +} diff -Nru metasploit-gui-1.0/src/msfgui/MsfguiLog.java metasploit-gui-1.0/src/msfgui/MsfguiLog.java --- metasploit-gui-1.0/src/msfgui/MsfguiLog.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/MsfguiLog.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,250 @@ +package msfgui; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.text.DateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +/** + * This class keeps a record of activities taken, sessions run, and + * credentials collected + * @author scriptjunkie + */ +public class MsfguiLog { + final protected Map sessions; // maps session ids to sessions + final protected ArrayList activityLog; // list of strings denoting major activities + final protected DateFormat formatter; + public static MsfguiLog defaultLog; + + /** Sets up default log */ + public static void initDefaultLog(){ + defaultLog = new MsfguiLog(); + } + + /** Creates a new log to be written to a file */ + public MsfguiLog() { + sessions = new HashMap(); + activityLog = new ArrayList(); + formatter = DateFormat.getDateTimeInstance(); + activityLog.add(now()+" msfgui started."); + } + /** Ensure that a session is recorded in the sessions map */ + public void logSession(Map session){ + if(sessions.get(session.get("id")) != null) + return; + sessions.put(session.get("id"), session); + activityLog.add(now() + " Session "+session.get("id")+" to "+session.get("tunnel_peer")+" opened."); + } + /** See if any non-console sessions have been closed. */ + public void checkSessions(Map sessionsActive){ + for(Object o : sessions.keySet()){ + Map session = (Map)sessions.get(o); + //mark as inactive if we haven't already done so, and it is inactive + if(session.get("inactive") == null && sessionsActive.get(o) == null){ + session.put("inactive", o); + activityLog.add(now() + " Session "+o+" closed."); + } + } + } + /** Logs method calls, such as module runs, console commands, and plugin actions */ + public void logMethodCall(String methodName, Object[] params) { + try { + if (methodName.startsWith("session.")) { + if (methodName.endsWith("_write")) + logConsole(params[0], params[1].toString(), true); + else if (methodName.endsWith("_run_single")) + logConsole(params[0], params[1].toString(), true); + else if (methodName.endsWith("_script")) + logConsole(params[0], "run " + params[1].toString(), true); + else if (methodName.endsWith("_upgrade")) + activityLog.add(now() + " Session " + params[0] + " upgrade initiated."); + } else if (methodName.equals("module.execute")) { + activityLog.add(now() + " " + params[0] + " " + params[1] + " executed with options " + params[2]); + } else if (methodName.equals("console.write")) { + logConsole("Console " + params[0], params[1].toString(), true); + } else if (methodName.equals("console.destroy")) { + activityLog.add(now() + " Console " + params[0] + " destroyed."); + } else if (methodName.equals("plugin.load")) { + activityLog.add(now() + " Plugin " + params[0] + " loading."); + } else if (methodName.equals("plugin.unload")) { + activityLog.add(now() + " Plugin " + params[0] + " unloaded."); + } else if (methodName.equals("db.connect")) { + activityLog.add(now() + " Database connection started with options " + params[0]); + } + } catch (MsfException mex) { + } + } + + /** Logs received data */ + public void logMethodReturn(String methodName, Object[] params, Object result) { + try { + //new consoles are added to the active session list + if (methodName.equals("console.create")) { + activityLog.add(now() + " Console " + ((Map) result).get("id") + " created."); + sessions.put("Console " + ((Map) result).get("id"), result); + ((Map)result).put("inactive", "console"); // mark consoles as inactive to avoid session checking + } else if (methodName.equals("console.list")) { + List consoles = ((List)((Map)result).get("consoles")); + for (Object console : consoles){ + activityLog.add(now() + " Console " + ((Map) console).get("id") + " discovered."); + sessions.put("Console " + ((Map) console).get("id"), result); + ((Map)console).put("inactive", "console"); + } + //New data on existing sessions + } else if (methodName.equals("console.read")) { + logConsole("Console " + params[0], new String(RpcConnection.getData((Map)result)), false); + } else if (methodName.startsWith("session.") && methodName.endsWith("_read")) { + logConsole(params[0], new String(RpcConnection.getData((Map)result)), false); + } + } catch (MsfException mex) { + } + } + /** Record console communication */ + public void logConsole(Object sessionId, String message, boolean sending){ + Map session = (Map)sessions.get(sessionId); + if(session == null || message.length() == 0) + return; + //if it is multiline, add a line break before + if((message.indexOf('\n') - message.length()) % message.length() != -1) + message = "\n"+message; + ArrayList consoleLog = (ArrayList)session.get("console"); + if(consoleLog == null){ + consoleLog = new ArrayList(30); + session.put("console",consoleLog); + } + message = htmlEntities(message); // Fix dangerous characters XSS-wise + if(sending) + consoleLog.add(now() + " >>>" + message); + else + consoleLog.add(now() + " " + message); + } + /** Saves the file and returns where */ + public String save() throws IOException{ //example: /tmp/msfguilog_Jun-9-2010.html + String destination = MsfguiApp.getTempFolder()+File.separator+"msfguilog_" + +(DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM).format( + new Date()).replaceAll("[, :]+","-"))+".html"; + save(destination); + return destination; + } + public String htmlEntities(String input){ + return input.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">") + .replaceAll("\"", """); + } + /** Saves the file and returns where */ + public String save(String filename) throws IOException{ + activityLog.add(now()+" msfgui log created."); + FileWriter fout = new FileWriter(filename); + + //Style header + fout.write("\n\n

msfgui

"); + + //Host summary + //Add headers + fout.write("

Hosts

"); + Set sessionsEntrySet = sessions.entrySet(); + HashMap hosts = new HashMap(); + //Map hosts to sessions by IP + for(Object e : sessionsEntrySet){ + Map session = (Map)((Entry) e).getValue(); + if(session.containsKey("tunnel_peer")){ //actual session; not console + String host = session.get("tunnel_peer").toString().split(":")[0]; + Set hostSet = (Set)hosts.get(host); + if(hostSet == null){ + hostSet = new HashSet(); + hosts.put(host, hostSet); + } + hostSet.add(session); + } + } + if(hosts.isEmpty()){ + fout.write("

None. Go exploit something next time.

"); + }else{ + fout.write("\n"); + ArrayList headers = new ArrayList(); + headers.add("type"); + headers.add("via_exploit"); + headers.add("via_payload"); + headers.add("tunnel_peer"); + headers.add("tunnel_local"); + headers.add("desc"); + fout.write(""); + fout.write("\n"); + + for(Object e : hosts.entrySet()){ + String key = ((Entry)e).getKey().toString(); + fout.write("\n"); + Set hostSessions = (Set)(((Entry)e).getValue()); + for(Object o : hostSessions){ + Map session = (Map)o; + for(Object var : headers) + fout.write(""); + fout.write("\n"); + } + fout.write(""); + } + fout.write("
hosttypevia exploitvia payloadtunnel peertunnel localdesc
"+key+""+session.get(var)+"
\n\n"); + }//end hosts + + //Activity log + fout.write("

Activities

\n"); + for(Object o : activityLog) + fout.write("\n"); + fout.write("
"+htmlEntities(o.toString())+"
\n\n"); + + //Complete console logs + fout.write("

Session logs

\n"); + for(Object e : sessionsEntrySet){ + Entry ent = (Entry) e; + Object log = ((Map)(ent.getValue())).get("console"); + if(log == null) + continue; + Map session = (Map)ent.getValue(); + fout.write("

Session "+ent.getKey()+"

"); + if(session.containsKey("tunnel_peer")) + fout.write("To " + session.get("tunnel_peer")); + fout.write("\n"); + for(Object logEntry : (ArrayList)log){ + String entryString = logEntry.toString(); + + //If has a newline, and it's not at the end, it's multiline - put in
 tags
+				if((entryString.indexOf('\n') - entryString.length()) % entryString.length() != -1)
+					entryString = "
"+entryString+"
"; + if(entryString.contains(">>>")) + fout.write("
\n"); + else + fout.write("\n"); + } + fout.write("
"+entryString+"
"+entryString+"
"); + } + fout.write("\n"); + fout.flush(); + fout.close(); + return filename; + } + + /** Gets localized date and now properly formatted */ + private String now() { + return formatter.format(new Date()); + } +} diff -Nru metasploit-gui-1.0/src/msfgui/MsfTable.java metasploit-gui-1.0/src/msfgui/MsfTable.java --- metasploit-gui-1.0/src/msfgui/MsfTable.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/MsfTable.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,130 @@ +package msfgui; + +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.AdjustmentEvent; +import java.awt.event.AdjustmentListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.swing.JOptionPane; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.ScrollPaneConstants; +import javax.swing.table.DefaultTableModel; + +/** + * Table customization defaults to non-editable, autosorted table with some preferences + * from the MsfGuiApp properties set. + * Also has a more sane column class getter and default renderer. + * + * @author scriptjunkie + */ +public class MsfTable extends javax.swing.JTable { + private final String[] dbNames; + private final String dbTable; + public RpcConnection rpcConn; + /** + * Default constructor just takes column names + * @param colnames The names of the columns in the table + */ + public MsfTable(final RpcConnection rpcConn, String[] colnames, String dbTable, String[] dbNames){ + this.dbNames = dbNames; + this.dbTable = dbTable; + this.rpcConn = rpcConn; + setModel(new javax.swing.table.DefaultTableModel(new Object [][] {}, colnames) { + public Class getColumnClass(int columnIndex) { + try{ + return getValueAt(0, columnIndex).getClass(); + }catch(ArrayIndexOutOfBoundsException aioobex){ + }catch(NullPointerException aioobex){ + } + return java.lang.String.class; + } + public boolean isCellEditable(int i,int j) { + return false; + } + }); + setAutoCreateRowSorter(true); //sorting is cool! + + //Render options + boolean showLines = Boolean.TRUE.equals(MsfguiApp.getPropertiesNode().get("tableShowLines")); + setShowHorizontalLines(showLines); + setShowVerticalLines(showLines); + setDefaultRenderer(java.util.Date.class, new javax.swing.table.DefaultTableCellRenderer()); + if(!"off".equals(MsfguiApp.getPropertiesNode().get("tableResize"))) // + setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF); + + //On double-click show a window with cell contents + addMouseListener(new MouseAdapter(){ + public void mouseClicked(MouseEvent e){ + if (e.getClickCount() != 2) + return; + JTextArea jack = new JTextArea(getValueAt( + rowAtPoint(e.getPoint()), + columnAtPoint(e.getPoint())).toString()); + jack.setLineWrap(true); + JScrollPane scroll = new JScrollPane(jack); + scroll.setPreferredSize(new Dimension(400, 300)); + scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + JOptionPane.showMessageDialog(MsfTable.this, scroll,"Cell info",JOptionPane.INFORMATION_MESSAGE); + } + } ); + } + /** Automatically query more info on new data */ + public void addAutoAdjuster(final JScrollPane pane){ + //Add autoadjuster to get more DB info + pane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener(){ + public void adjustmentValueChanged(AdjustmentEvent evt) { + java.awt.Adjustable adj = evt.getAdjustable(); + if(evt.getValueIsAdjusting() || adj.getValue() + adj.getVisibleAmount() != adj.getMaximum()) + return; + Component source = ((Component)evt.getSource()); + while(!(source instanceof JScrollPane)) + source = source.getParent(); + int rowCount = getRowCount(); + if(rowCount == 0 || (getRowCount() % 100) != 0) + return; + reAddQuery(false, rowCount); + } + }); + } + + /** Clear a table's contents, reenabling the tab, and replace with contents of data returned from a db call */ + public void reAddQuery(boolean force, int offset) { + if(!force && !DraggableTabbedPane.isVisible(this)) + return; //Don't re-add if not visible + try { + HashMap arg = new HashMap(10); + arg.put("workspace", MsfguiApp.workspace); + arg.put("offset", offset); + List data = (List) ((Map)rpcConn.execute("db."+dbTable, arg)).get(dbTable); + if(data == null) + return; + DefaultTableModel mod = (DefaultTableModel) getModel(); + while (mod.getRowCount() > offset) + mod.removeRow(mod.getRowCount() - 1); + for (Object dataObj : data) { + Object[] row = new Object[dbNames.length]; + for (int i = 0; i < dbNames.length; i++){ + row[i] = ((Map) dataObj).get(dbNames[i]); + try{ + if(dbNames[i].endsWith("_at") || dbNames[i].equals("time")) + row[i] = new java.util.Date(Long.parseLong(row[i].toString()) * 1000); + }catch(NumberFormatException nfex){ + //don't do anything + } + } + mod.addRow(row); + } + TableHelper.fitColumnWidths(mod, this); + DraggableTabbedPane.setTabComponentEnabled(this, true); + } catch (MsfException mex) { + mex.printStackTrace(); + if(mex.getMessage().equals("database not loaded")) + throw mex; + } + } +} diff -Nru metasploit-gui-1.0/src/msfgui/MsgRpc.java metasploit-gui-1.0/src/msfgui/MsgRpc.java --- metasploit-gui-1.0/src/msfgui/MsgRpc.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/MsgRpc.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,136 @@ +package msfgui; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.MalformedURLException; +import java.net.URLConnection; +import java.net.URL; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSession; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; +import org.msgpack.MessagePack; +import org.msgpack.MessagePackObject; +import org.msgpack.Packer; +import org.msgpack.object.*; + +/** + * Implements an RPC backend using the MessagePack interface + * @author scriptjunkie + */ +public class MsgRpc extends RpcConnection { + private URL u; + private URLConnection huc; // new for each call + protected int timeout = 5000; + + /** + * Creates a new URL to use as the basis of a connection. + */ + protected void connect() throws MalformedURLException{ + if(ssl){ // Install the all-trusting trust manager & HostnameVerifier + try { + SSLContext sc = SSLContext.getInstance("SSL"); + sc.init(null, new TrustManager[]{ + new X509TrustManager() { + public java.security.cert.X509Certificate[] getAcceptedIssuers() { + return null; + } + public void checkClientTrusted( + java.security.cert.X509Certificate[] certs, String authType) { + } + public void checkServerTrusted( + java.security.cert.X509Certificate[] certs, String authType) { + } + } + }, new java.security.SecureRandom()); + HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); + HttpsURLConnection.setDefaultHostnameVerifier( new HostnameVerifier(){ + public boolean verify(String string,SSLSession ssls) { + return true; + } + }); + } catch (Exception e) { + } + u = new URL("https",host,port,"/api/1.0"); + }else{ + u = new URL("http",host,port,"/api/1.0"); + } + } + + /** + * Decodes a response recursively from MessagePackObject to a normal Java object + * @param src MessagePack response + * @return decoded object + */ + private static Object unMsg(Object src){ + Object out = src; + if(src instanceof ArrayType){ + List l = ((ArrayType)src).asList(); + List outList = new ArrayList(l.size()); + out = outList; + for(Object o : l) + outList.add(unMsg(o)); + }else if(src instanceof BooleanType){ + out = ((BooleanType)src).asBoolean(); + }else if(src instanceof FloatType){ + out = ((FloatType)src).asFloat(); + }else if(src instanceof IntegerType){ + out = ((IntegerType)src).asInt(); + }else if(src instanceof MapType){ + Set ents = ((MapType)src).asMap().entrySet(); + out = new HashMap(); + for (Object ento : ents){ + Map.Entry ent = (Map.Entry)ento; + Object key = unMsg(ent.getKey()); + Object val = ent.getValue(); + // Hack - keep bytes of generated or encoded payload + if(ents.size() == 1 && val instanceof RawType && + (key.equals("payload") || key.equals("encoded"))) + val = ((RawType)val).asByteArray(); + else + val = unMsg(val); + ((Map)out).put(key, val); + } + if(((Map)out).containsKey("error") && ((Map)out).containsKey("error_class")){ + System.out.println(((Map)out).get("error_backtrace")); + throw new MsfException(((Map)out).get("error_message").toString()); + } + }else if(src instanceof NilType){ + out = null; + }else if(src instanceof RawType){ + out = ((RawType)src).asString(); + } + return out; + } + + /** Creates an XMLRPC call from the given method name and parameters and sends it */ + protected void writeCall(String methodName, Object[] args) throws Exception{ + huc = u.openConnection(); + huc.setDoOutput(true); + huc.setDoInput(true); + huc.setUseCaches(false); + huc.setRequestProperty("Content-Type", "binary/message-pack"); + huc.setReadTimeout(timeout); + OutputStream os = huc.getOutputStream(); + Packer pk = new Packer(os); + + pk.packArray(args.length+1); + pk.pack(methodName); + for(Object o : args) + pk.pack(o); + os.close(); + } + + /** Receives an RPC response and converts to an object */ + protected Object readResp() throws Exception{ + InputStream is = huc.getInputStream(); + MessagePackObject mpo = MessagePack.unpack(is); + return unMsg(mpo); + } +} diff -Nru metasploit-gui-1.0/src/msfgui/MulticommandOptionsDialog.form metasploit-gui-1.0/src/msfgui/MulticommandOptionsDialog.form --- metasploit-gui-1.0/src/msfgui/MulticommandOptionsDialog.form 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/MulticommandOptionsDialog.form 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,150 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff -Nru metasploit-gui-1.0/src/msfgui/MulticommandOptionsDialog.java metasploit-gui-1.0/src/msfgui/MulticommandOptionsDialog.java --- metasploit-gui-1.0/src/msfgui/MulticommandOptionsDialog.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/MulticommandOptionsDialog.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,184 @@ +package msfgui; + +import javax.swing.JFileChooser; + +/** + * Options dialog for the multicommand script + * @author scriptjunkie + */ +public class MulticommandOptionsDialog extends OptionsDialog { + /** Creates new form UploadexecOptionsDialog */ + public MulticommandOptionsDialog(java.awt.Frame parent) { + super(parent, "Multicommand Options", true); + 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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + okButton = new javax.swing.JButton(); + chooseButton = new javax.swing.JButton(); + outputFileField = new javax.swing.JTextField(); + commandFileField = new javax.swing.JTextField(); + commandFileButton = new javax.swing.JButton(); + jScrollPane1 = new javax.swing.JScrollPane(); + commandsArea = new javax.swing.JTextArea(); + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + + setName("Form"); // NOI18N + addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosing(java.awt.event.WindowEvent evt) { + closeDialog(evt); + } + }); + + org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(msfgui.MsfguiApp.class).getContext().getResourceMap(MulticommandOptionsDialog.class); + okButton.setText(resourceMap.getString("okButton.text")); // NOI18N + okButton.setName("okButton"); // NOI18N + okButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + okButtonActionPerformed(evt); + } + }); + + chooseButton.setText(resourceMap.getString("chooseButton.text")); // NOI18N + chooseButton.setName("chooseButton"); // NOI18N + chooseButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + chooseButtonActionPerformed(evt); + } + }); + + outputFileField.setText(resourceMap.getString("outputFileField.text")); // NOI18N + outputFileField.setName("outputFileField"); // NOI18N + + commandFileField.setText(resourceMap.getString("commandFileField.text")); // NOI18N + commandFileField.setName("commandFileField"); // NOI18N + + commandFileButton.setText(resourceMap.getString("commandFileButton.text")); // NOI18N + commandFileButton.setName("commandFileButton"); // NOI18N + commandFileButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + commandFileButtonActionPerformed(evt); + } + }); + + jScrollPane1.setName("jScrollPane1"); // NOI18N + + commandsArea.setColumns(20); + commandsArea.setRows(5); + commandsArea.setName("commandsArea"); // NOI18N + jScrollPane1.setViewportView(commandsArea); + + jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N + jLabel1.setName("jLabel1"); // NOI18N + + jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N + jLabel2.setName("jLabel2"); // NOI18N + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(chooseButton) + .addComponent(commandFileButton) + .addComponent(jLabel1) + .addComponent(jLabel2)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE) + .addComponent(okButton, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(commandFileField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE) + .addComponent(outputFileField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE)) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(outputFileField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(chooseButton)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(commandFileField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(commandFileButton)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 247, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(okButton)) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel2))) + .addContainerGap()) + ); + + pack(); + }// //GEN-END:initComponents + + private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed + StringBuilder cmd = new StringBuilder("multicommand "); + if(outputFileField.getText().length() > 0) + cmd.append(" -f ").append(MsfguiApp.escapeBackslashes(outputFileField.getText())); + String commandList = commandsArea.getText(); + if(commandFileField.getText().length() > 0){ + cmd.append(" -rc ").append(MsfguiApp.escapeBackslashes(commandFileField.getText())); + }else if(commandList.length() > 0){ + String [] cmds = commandList.split("\n"); + cmd.append(" -cl "); + for(int i = 0; i < cmds.length; i++){ + cmd.append(MsfguiApp.escapeBackslashes(cmds[i].trim())); + if (i < cmds.length - 1) + cmd.append(','); + } + } + command = cmd.toString(); + doClose(); + }//GEN-LAST:event_okButtonActionPerformed + + /** Closes the dialog */ + private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog + doClose(); + }//GEN-LAST:event_closeDialog + + private void chooseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chooseButtonActionPerformed + if(MsfguiApp.fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) + outputFileField.setText(MsfguiApp.fileChooser.getSelectedFile().getPath()); + }//GEN-LAST:event_chooseButtonActionPerformed + + private void commandFileButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_commandFileButtonActionPerformed + if(MsfguiApp.fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) + commandFileField.setText(MsfguiApp.fileChooser.getSelectedFile().getPath()); + }//GEN-LAST:event_commandFileButtonActionPerformed + + private void doClose() { + setVisible(false); + dispose(); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton chooseButton; + private javax.swing.JButton commandFileButton; + private javax.swing.JTextField commandFileField; + private javax.swing.JTextArea commandsArea; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JButton okButton; + private javax.swing.JTextField outputFileField; + // End of variables declaration//GEN-END:variables + +} diff -Nru metasploit-gui-1.0/src/msfgui/NetenumOptionsDialog.form metasploit-gui-1.0/src/msfgui/NetenumOptionsDialog.form --- metasploit-gui-1.0/src/msfgui/NetenumOptionsDialog.form 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/NetenumOptionsDialog.form 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,173 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff -Nru metasploit-gui-1.0/src/msfgui/NetenumOptionsDialog.java metasploit-gui-1.0/src/msfgui/NetenumOptionsDialog.java --- metasploit-gui-1.0/src/msfgui/NetenumOptionsDialog.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/NetenumOptionsDialog.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,192 @@ +package msfgui; + +import javax.swing.JFileChooser; + +/** + * Options dialog for the netenum script + * @author scriptjunkie + */ +public class NetenumOptionsDialog extends OptionsDialog { + /** Creates new form NetenumOptionsDialog */ + public NetenumOptionsDialog(java.awt.Frame parent) { + super(parent, "Netenum options", true); + 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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + okButton = new javax.swing.JButton(); + jLabel1 = new javax.swing.JLabel(); + addressField = new javax.swing.JTextField(); + pingBox = new javax.swing.JCheckBox(); + reverseDnsBox = new javax.swing.JCheckBox(); + forwardBox = new javax.swing.JCheckBox(); + mxNsBox = new javax.swing.JCheckBox(); + serviceBox = new javax.swing.JCheckBox(); + jLabel2 = new javax.swing.JLabel(); + domainField = new javax.swing.JTextField(); + fileField = new javax.swing.JTextField(); + chooseButton = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + + org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(msfgui.MsfguiApp.class).getContext().getResourceMap(NetenumOptionsDialog.class); + okButton.setText(resourceMap.getString("okButton.text")); // NOI18N + okButton.setName("okButton"); // NOI18N + okButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + okButtonActionPerformed(evt); + } + }); + + jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N + jLabel1.setName("jLabel1"); // NOI18N + + addressField.setText(resourceMap.getString("addressField.text")); // NOI18N + addressField.setName("addressField"); // NOI18N + + pingBox.setText(resourceMap.getString("pingBox.text")); // NOI18N + pingBox.setName("pingBox"); // NOI18N + + reverseDnsBox.setText(resourceMap.getString("reverseDnsBox.text")); // NOI18N + reverseDnsBox.setName("reverseDnsBox"); // NOI18N + + forwardBox.setText(resourceMap.getString("forwardBox.text")); // NOI18N + forwardBox.setName("forwardBox"); // NOI18N + + mxNsBox.setText(resourceMap.getString("mxNsBox.text")); // NOI18N + mxNsBox.setName("mxNsBox"); // NOI18N + + serviceBox.setText(resourceMap.getString("serviceBox.text")); // NOI18N + serviceBox.setName("serviceBox"); // NOI18N + + jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N + jLabel2.setName("jLabel2"); // NOI18N + + domainField.setText(resourceMap.getString("domainField.text")); // NOI18N + domainField.setName("domainField"); // NOI18N + + fileField.setText(resourceMap.getString("fileField.text")); // NOI18N + fileField.setName("fileField"); // NOI18N + + chooseButton.setText(resourceMap.getString("chooseButton.text")); // NOI18N + chooseButton.setName("chooseButton"); // NOI18N + chooseButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + chooseButtonActionPerformed(evt); + } + }); + + 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) + .addComponent(forwardBox) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(addressField, javax.swing.GroupLayout.DEFAULT_SIZE, 196, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(pingBox) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(reverseDnsBox)) + .addComponent(mxNsBox) + .addComponent(serviceBox) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(domainField, javax.swing.GroupLayout.DEFAULT_SIZE, 292, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(chooseButton) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(fileField, javax.swing.GroupLayout.DEFAULT_SIZE, 198, Short.MAX_VALUE)) + .addComponent(okButton, javax.swing.GroupLayout.Alignment.TRAILING)) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1) + .addComponent(addressField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(reverseDnsBox) + .addComponent(pingBox)) + .addGap(18, 18, 18) + .addComponent(mxNsBox) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(serviceBox) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2) + .addComponent(domainField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addComponent(forwardBox) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(fileField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(chooseButton)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(okButton) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + pack(); + }// //GEN-END:initComponents + + private void chooseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chooseButtonActionPerformed + if(MsfguiApp.fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) + fileField.setText(MsfguiApp.fileChooser.getSelectedFile().getPath()); + }//GEN-LAST:event_chooseButtonActionPerformed + + private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed + StringBuilder cmd = new StringBuilder("netenum "); + if(addressField.getText().length() > 0) + cmd.append(" -r ").append(addressField.getText()); + if(pingBox.isSelected()) + cmd.append(" -ps"); + if(reverseDnsBox.isSelected()) + cmd.append(" -rl"); + if(forwardBox.isSelected()) + cmd.append(" -fl"); + if(fileField.getText().length() > 0) + cmd.append(" -hl ").append(MsfguiApp.escapeBackslashes(fileField.getText())); + if(domainField.getText().length() > 0) + cmd.append(" -d ").append(domainField.getText()); + if(mxNsBox.isSelected()) + cmd.append(" -st"); + if(serviceBox.isSelected()) + cmd.append(" -sr"); + command = cmd.toString(); + setVisible(false); + dispose(); + }//GEN-LAST:event_okButtonActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JTextField addressField; + private javax.swing.JButton chooseButton; + private javax.swing.JTextField domainField; + private javax.swing.JTextField fileField; + private javax.swing.JCheckBox forwardBox; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JCheckBox mxNsBox; + private javax.swing.JButton okButton; + private javax.swing.JCheckBox pingBox; + private javax.swing.JCheckBox reverseDnsBox; + private javax.swing.JCheckBox serviceBox; + // End of variables declaration//GEN-END:variables + +} diff -Nru metasploit-gui-1.0/src/msfgui/OpenConnectionDialog.form metasploit-gui-1.0/src/msfgui/OpenConnectionDialog.form --- metasploit-gui-1.0/src/msfgui/OpenConnectionDialog.form 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/OpenConnectionDialog.form 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,258 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -Nru metasploit-gui-1.0/src/msfgui/OpenConnectionDialog.java metasploit-gui-1.0/src/msfgui/OpenConnectionDialog.java --- metasploit-gui-1.0/src/msfgui/OpenConnectionDialog.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/OpenConnectionDialog.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,457 @@ +package msfgui; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.security.NoSuchAlgorithmException; +import java.util.Map; +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; +import javax.swing.JTextField; + +/** + * Options dialog for opening a connection the rpc daemon + * @author scriptjunkie + */ +public class OpenConnectionDialog extends javax.swing.JDialog { + private MainFrame mainframe; + private RpcConnection rpcConn; + private int timeout = 4; + private javax.swing.Timer countdown; + + /** Creates new form UserPassDialog */ + public OpenConnectionDialog(boolean modal, MainFrame mainframe) { + super(mainframe.getFrame(), modal); + this.mainframe = mainframe; + initComponents(); + setTitle("msfgui"); + org.jdesktop.application.ResourceMap resourceMap + = org.jdesktop.application.Application.getInstance(msfgui.MsfguiApp.class) + .getContext().getResourceMap(ModulePopup.class); + this.setIconImage(resourceMap.getImageIcon("main.icon").getImage()); + + startNewButton.requestFocusInWindow(); + startNewButton.addFocusListener(new FocusListener(){ + public void focusGained(FocusEvent fe) { + } + public void focusLost(FocusEvent fe) { + timeout = 0; + startNewButton.setText("Start new msfrpcd"); + } + }); + countdown = new javax.swing.Timer(1000,new ActionListener(){ + public void actionPerformed(ActionEvent ae) { + if(timeout == 0){ + countdown.stop(); + return; + } + timeout = timeout - 1; + startNewButton.setText("Start new msfrpcd ("+timeout+")"); + if(timeout == 0) + startNewButtonActionPerformed(ae); + } + }); + countdown.start(); + startNewButton.setText("Start new msfrpcd ("+timeout+")"); + Map root = MsfguiApp.getPropertiesNode(); + fillDefault(root.get("username"),usernameField); + fillDefault(root.get("host"),hostField); + if(root.containsKey("port") && !root.get("port").toString().equals("3790")) //don't interfere with default Metasploit + fillDefault(root.get("port"),portField); + sslBox.setSelected(Boolean.TRUE.equals(root.get("ssl"))); + disableDbButton.setSelected(Boolean.TRUE.equals(root.get("disableDb"))); + } + + private boolean checkCrypto(boolean ssl) throws MsfException { + try { + if (ssl) + javax.crypto.KeyGenerator.getInstance("SunTlsRsaPremasterSecret"); + } catch (NoSuchAlgorithmException nsax) { + int res = JOptionPane.showConfirmDialog(this, "Error: this version of Java may not support the necessary " + + "\ncryptographic capabilities to connect to msfrpcd over SSL. Try running \n" + + (System.getProperty("os.name").toLowerCase().contains("windows") ? "" : "java -jar ") + + MsfguiApp.getMyPath() + " \n" + + "as your system version of Java may work.\n\nContinue anyway?"); + if(res != JOptionPane.YES_OPTION) + throw new MsfException("SSLcheck", nsax); + } + return ssl; + } + + /** Sets the text of the given component if val is defined */ + private void fillDefault(Object val, JTextField field) { + if (val!= null) + field.setText(val.toString()); + } + + /** Gets a connection for a main window from saved credentials or via the open + * connection dialog. + * @param mainframe the parent frame + * @return the new connection + */ + public static RpcConnection getConnection(MainFrame mainframe) { + if(mainframe.rpcConn != null){ + MsfguiApp.showMessage(mainframe.getFrame(), "You are already connected!\n" + + "Exit before making a new connection."); + throw new RuntimeException("Already connected"); + } + //try saved connection credentials + try{ + Map info = MsfguiApp.getPropertiesNode(); + String username = info.get("username").toString(); + String password = info.get("password").toString(); + String host = info.get("host").toString(); + int port = Integer.parseInt(info.get("port").toString()); + boolean ssl = Boolean.parseBoolean(info.get("ssl").toString()); + RpcConnection rpc = RpcConnection.getConn(username, password.toCharArray(), host, port, ssl); + if(JOptionPane.showConfirmDialog(null, "Connect to last remembered rpcd?") == JOptionPane.YES_OPTION) + return rpc; + rpc.execute("auth.logout"); + } catch (MsfException mex) { + if(mex.getMessage().toLowerCase().contains("authentication error")) + mainframe.statusAnimationLabel.setText("Error authenticating; msfrpcd is running " + +"but you did not enter the right credentials."); + else if (mex.getMessage().toLowerCase().contains("connection reset")) + mainframe.statusAnimationLabel.setText("Connection reset; is the SSL option correct?" + + " Is msfrpcd running on the right port?"); + else if (mex.getMessage().toLowerCase().contains("timed out")) + mainframe.statusAnimationLabel.setText("Timeout; is the SSL option correct?" + + " Is msfrpcd running on the right port?"); + } catch (NullPointerException nex) {//generated when attributes dont exist. + } catch (Exception ex) { //for weird msg exceptions + } + //Try service token on default 3790 + BufferedReader fin = null; + try{//Init base path if necessary + if(System.getProperty("os.name").toLowerCase().contains("windows")) + MsfguiApp.getBase(); + //Get path to servicekey + String serviceKeyPath = "/opt/metasploit/apps/pro/engine/tmp/servicekey.txt"; + if(System.getProperty("os.name").toLowerCase().contains("windows")) + serviceKeyPath = MsfguiApp.getPropertiesNode().get("BASE") + "\\apps\\pro\\engine\\tmp\\servicekey.txt"; + //open servicekey and try connecting + System.out.println(serviceKeyPath); + fin = new BufferedReader(new FileReader(serviceKeyPath)); + RpcConnection rpc = RpcConnection.getConn("", fin.readLine().toCharArray(), "localhost", 3790, true); + //if it worked, give user the option to connect + if(JOptionPane.showConfirmDialog(null, "Connect to local rpcd?") == JOptionPane.YES_OPTION) + return rpc; + }catch(IOException iox){//file not found/unreadable/ + if(JOptionPane.showConfirmDialog(null, + "Cannot open service key. If metasploit is installed\n" + + "as a service, try running msfgui as root. Do you want\n" + + "to connect to a different service or start a new one?\n") != JOptionPane.YES_OPTION) + System.exit(0); + }catch(MsfException mx){//local rpc not running - ignore + } + //Darn. open the gui anyway + OpenConnectionDialog diag = new OpenConnectionDialog(true, mainframe); + diag.setVisible(true); + return diag.rpcConn; + } + + /** 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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + buttonGroup1 = new javax.swing.ButtonGroup(); + titleLabel = new javax.swing.JLabel(); + usernameLabel = new javax.swing.JLabel(); + passwordLabel = new javax.swing.JLabel(); + hostLabel = new javax.swing.JLabel(); + portLabel = new javax.swing.JLabel(); + usernameField = new javax.swing.JTextField(); + passwordField = new javax.swing.JPasswordField(); + hostField = new javax.swing.JTextField(); + portField = new javax.swing.JTextField(); + connectButton = new javax.swing.JButton(); + cancelButton = new javax.swing.JButton(); + startNewButton = new javax.swing.JButton(); + pathButton = new javax.swing.JButton(); + sslBox = new javax.swing.JCheckBox(); + sslLabel = new javax.swing.JLabel(); + disableDbLabel = new javax.swing.JLabel(); + disableDbButton = new javax.swing.JCheckBox(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(msfgui.MsfguiApp.class).getContext().getResourceMap(OpenConnectionDialog.class); + setTitle(resourceMap.getString("Form.title")); // NOI18N + + titleLabel.setText(resourceMap.getString("titleLabel.text")); // NOI18N + titleLabel.setName("titleLabel"); // NOI18N + + usernameLabel.setText(resourceMap.getString("usernameLabel.text")); // NOI18N + usernameLabel.setName("usernameLabel"); // NOI18N + + passwordLabel.setText(resourceMap.getString("passwordLabel.text")); // NOI18N + passwordLabel.setName("passwordLabel"); // NOI18N + + hostLabel.setText(resourceMap.getString("hostLabel.text")); // NOI18N + hostLabel.setName("hostLabel"); // NOI18N + + portLabel.setText(resourceMap.getString("portLabel.text")); // NOI18N + portLabel.setName("portLabel"); // NOI18N + + usernameField.setText(resourceMap.getString("usernameField.text")); // NOI18N + usernameField.setName("usernameField"); // NOI18N + usernameField.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + usernameFieldActionPerformed(evt); + } + }); + + passwordField.setText(resourceMap.getString("passwordField.text")); // NOI18N + passwordField.setName("passwordField"); // NOI18N + passwordField.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + passwordFieldActionPerformed(evt); + } + }); + + hostField.setText(resourceMap.getString("hostField.text")); // NOI18N + hostField.setName("hostField"); // NOI18N + hostField.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + hostFieldActionPerformed(evt); + } + }); + + portField.setText(resourceMap.getString("portField.text")); // NOI18N + portField.setName("portField"); // NOI18N + portField.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + portFieldActionPerformed(evt); + } + }); + + connectButton.setFont(connectButton.getFont()); + 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.setFont(cancelButton.getFont()); + 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); + } + }); + + startNewButton.setFont(startNewButton.getFont().deriveFont(startNewButton.getFont().getStyle() | java.awt.Font.BOLD)); + startNewButton.setText(resourceMap.getString("startNewButton.text")); // NOI18N + startNewButton.setName("startNewButton"); // NOI18N + startNewButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + startNewButtonActionPerformed(evt); + } + }); + + pathButton.setText(resourceMap.getString("pathButton.text")); // NOI18N + pathButton.setName("pathButton"); // NOI18N + pathButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + pathButtonActionPerformed(evt); + } + }); + + sslBox.setText(resourceMap.getString("sslBox.text")); // NOI18N + sslBox.setName("sslBox"); // NOI18N + + sslLabel.setText(resourceMap.getString("sslLabel.text")); // NOI18N + sslLabel.setName("sslLabel"); // NOI18N + + disableDbLabel.setText(resourceMap.getString("disableDbLabel.text")); // NOI18N + disableDbLabel.setName("disableDbLabel"); // NOI18N + + disableDbButton.setText(resourceMap.getString("disableDbButton.text")); // NOI18N + disableDbButton.setName("disableDbButton"); // 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) + .addComponent(titleLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createSequentialGroup() + .addGap(6, 6, 6) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(sslLabel) + .addComponent(hostLabel) + .addComponent(passwordLabel) + .addComponent(portLabel) + .addComponent(disableDbLabel) + .addComponent(usernameLabel)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(disableDbButton) + .addComponent(usernameField, javax.swing.GroupLayout.DEFAULT_SIZE, 433, Short.MAX_VALUE) + .addComponent(hostField, javax.swing.GroupLayout.DEFAULT_SIZE, 433, Short.MAX_VALUE) + .addComponent(passwordField, javax.swing.GroupLayout.DEFAULT_SIZE, 433, Short.MAX_VALUE) + .addComponent(portField, javax.swing.GroupLayout.DEFAULT_SIZE, 433, Short.MAX_VALUE) + .addComponent(sslBox))) + .addGroup(layout.createSequentialGroup() + .addComponent(startNewButton) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(pathButton) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 132, Short.MAX_VALUE) + .addComponent(cancelButton) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(connectButton))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(titleLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .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(usernameLabel)) + .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(passwordLabel)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(hostLabel) + .addComponent(hostField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .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(portLabel)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addComponent(sslBox, javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE) + .addComponent(sslLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(disableDbLabel) + .addComponent(disableDbButton, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(connectButton, javax.swing.GroupLayout.DEFAULT_SIZE, 37, Short.MAX_VALUE) + .addComponent(cancelButton, javax.swing.GroupLayout.DEFAULT_SIZE, 37, Short.MAX_VALUE) + .addComponent(startNewButton, javax.swing.GroupLayout.DEFAULT_SIZE, 37, Short.MAX_VALUE) + .addComponent(pathButton, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + + pack(); + }// //GEN-END:initComponents + + private void connectButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_connectButtonActionPerformed + String username = usernameField.getText(); + char[] password = passwordField.getPassword(); + String host = hostField.getText(); + int port = Integer.parseInt(portField.getText()); + boolean ssl = checkCrypto(sslBox.isSelected()); + try { + rpcConn = RpcConnection.getConn(username, password, host, port, ssl); + } catch (MsfException mex) { + rpcConn = null; + } + setVisible(false); + }//GEN-LAST:event_connectButtonActionPerformed + + private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed + rpcConn = null; + setVisible(false); + }//GEN-LAST:event_cancelButtonActionPerformed + + private void usernameFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_usernameFieldActionPerformed + connectButtonActionPerformed(evt); + }//GEN-LAST:event_usernameFieldActionPerformed + + private void passwordFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_passwordFieldActionPerformed + connectButtonActionPerformed(evt); + }//GEN-LAST:event_passwordFieldActionPerformed + + private void hostFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_hostFieldActionPerformed + connectButtonActionPerformed(evt); + }//GEN-LAST:event_hostFieldActionPerformed + + private void portFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_portFieldActionPerformed + connectButtonActionPerformed(evt); + }//GEN-LAST:event_portFieldActionPerformed + + private void startNewButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_startNewButtonActionPerformed + //Setup defaults + RpcConnection.defaultUser = usernameField.getText().trim(); + if(RpcConnection.defaultUser.length() == 0) //make sure we don't try to use a blank username + RpcConnection.defaultUser = "msf"; + if(passwordField.getPassword().length > 0) + RpcConnection.defaultPass = new String(passwordField.getPassword()); + if(hostField.getText().length() > 0) + RpcConnection.defaultHost = hostField.getText(); + RpcConnection.defaultPort = Integer.parseInt(portField.getText()); + RpcConnection.defaultSsl = checkCrypto(sslBox.isSelected()); + RpcConnection.disableDb = disableDbButton.isSelected(); + //do the action. There's probably a "right" way to do Oh well. + mainframe.getContext().getActionMap(mainframe).get("startRpc").actionPerformed(new java.awt.event.ActionEvent(startNewButton,1234,"")); + setVisible(false); + }//GEN-LAST:event_startNewButtonActionPerformed + + private void pathButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pathButtonActionPerformed + File dir =new File("/opt/metasploit3/msf3/"); + if(dir.isDirectory()){ + MsfguiApp.fileChooser.setCurrentDirectory(dir); + }else{ + dir = new File("C:\\metasploit"); + if(dir.isDirectory()) + MsfguiApp.fileChooser.setCurrentDirectory(dir); + } + if(MsfguiApp.getPropertiesNode().get("commandPrefix") != null) + dir =new File(MsfguiApp.getPropertiesNode().get("commandPrefix").toString()); + if(dir.isDirectory()) + MsfguiApp.fileChooser.setCurrentDirectory(dir); + MsfguiApp.fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + int result = MsfguiApp.fileChooser.showOpenDialog(this); + MsfguiApp.fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + if (result != JFileChooser.APPROVE_OPTION) + return; + if(!(new File(MsfguiApp.fileChooser.getSelectedFile().getPath()+"/apps/pro")).isDirectory()){ + MsfguiApp.showMessage(this, "Uh oh! That's not a valid metasploit folder.\n" + + "The right metasploit folder should have an apps subfolder."); + } + MsfguiApp.getPropertiesNode().put("BASE", + MsfguiApp.fileChooser.getSelectedFile().getPath()); + }//GEN-LAST:event_pathButtonActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.ButtonGroup buttonGroup1; + private javax.swing.JButton cancelButton; + private javax.swing.JButton connectButton; + private javax.swing.JCheckBox disableDbButton; + private javax.swing.JLabel disableDbLabel; + private javax.swing.JTextField hostField; + private javax.swing.JLabel hostLabel; + private javax.swing.JPasswordField passwordField; + private javax.swing.JLabel passwordLabel; + private javax.swing.JButton pathButton; + private javax.swing.JTextField portField; + private javax.swing.JLabel portLabel; + private javax.swing.JCheckBox sslBox; + private javax.swing.JLabel sslLabel; + private javax.swing.JButton startNewButton; + private javax.swing.JLabel titleLabel; + private javax.swing.JTextField usernameField; + private javax.swing.JLabel usernameLabel; + // End of variables declaration//GEN-END:variables +} diff -Nru metasploit-gui-1.0/src/msfgui/OptionsDialog.form metasploit-gui-1.0/src/msfgui/OptionsDialog.form --- metasploit-gui-1.0/src/msfgui/OptionsDialog.form 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/OptionsDialog.form 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,26 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + +
diff -Nru metasploit-gui-1.0/src/msfgui/OptionsDialog.java metasploit-gui-1.0/src/msfgui/OptionsDialog.java --- metasploit-gui-1.0/src/msfgui/OptionsDialog.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/OptionsDialog.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,42 @@ +package msfgui; + +/** + * Basic options dialog for msfgui; includes icon + * @author scriptjunkie + */ +public class OptionsDialog extends javax.swing.JDialog { + + protected String command; + + //Opens dialog to get options + public String getCommand(){ + setVisible(true); + return command; + } + + /** Creates new form OptionsDialog */ + public OptionsDialog(java.awt.Frame parent, String title, boolean modal) { + super(parent, title, modal); + command = null; + org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance( + msfgui.MsfguiApp.class).getContext().getResourceMap(ModulePopup.class); + this.setIconImage(resourceMap.getImageIcon("main.icon").getImage()); + } + + /** 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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + getContentPane().setLayout(null); + }// //GEN-END:initComponents + + // Variables declaration - do not modify//GEN-BEGIN:variables + // End of variables declaration//GEN-END:variables + +} diff -Nru metasploit-gui-1.0/src/msfgui/PayloadPopup.form metasploit-gui-1.0/src/msfgui/PayloadPopup.form --- metasploit-gui-1.0/src/msfgui/PayloadPopup.form 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/PayloadPopup.form 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,427 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff -Nru metasploit-gui-1.0/src/msfgui/PayloadPopup.java metasploit-gui-1.0/src/msfgui/PayloadPopup.java --- metasploit-gui-1.0/src/msfgui/PayloadPopup.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/PayloadPopup.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,683 @@ +package msfgui; + +import java.awt.Component; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.ArrayList; +import java.util.List; +import javax.swing.DefaultComboBoxModel; +import javax.swing.GroupLayout; +import javax.swing.GroupLayout.ParallelGroup; +import javax.swing.GroupLayout.SequentialGroup; +import javax.swing.JFileChooser; +import javax.swing.LayoutStyle; + +/** + * Popup for generating payloads and starting handlers. + * @author scriptjunkie + */ +public class PayloadPopup extends ModuleInfoWindow { + + /** Creates new form PayloadPopup */ + public PayloadPopup(String fullName, RpcConnection rpcConn, MainFrame frame) { + moduleType = "payload"; + parentFrame = frame; + initComponents(); + outputPathField.setText(MsfguiApp.getTempFolder()+File.separator+"msf.exe"); + this.rpcConn = rpcConn; + requiredOpts = new ArrayList(); + optionalOpts = requiredOpts; + advancedOpts = requiredOpts; + this.fullName = fullName; + showOptions(fullName); + loadSavedSize(); + + //get encoders + try{ + Object[] encoders = ((List)((Map) rpcConn.execute("module.encoders")).get("modules")).toArray(); + int defaultEncoder = 0; + for(int i = 0; i < encoders.length; i++) + if(encoders[i].toString().equals("generic/none")) + defaultEncoder = i; + encoderCombo.setModel(new DefaultComboBoxModel(encoders)); + encoderCombo.setSelectedIndex(defaultEncoder); + }catch(MsfException xre){ + } + //get formats + try{ + Object[] formats = ((List)rpcConn.execute("module.encode_formats")).toArray(); + int defaultFormat = 0; + for(int i = 0; i < formats.length; i++) + if(formats[i].toString().equals("exe")) + defaultFormat = i; + outputCombo.setModel(new DefaultComboBoxModel(formats)); + outputCombo.setSelectedIndex(defaultFormat); + }catch(MsfException xre){ + xre.printStackTrace(); + } + mainScrollPane.getVerticalScrollBar().setUnitIncrement(40); + } + + private void doRun(boolean console) { + Map hash = getOptions(mainPanel); + hash.put("PAYLOAD", fullName); + hash.put("TARGET", "0"); + run("exploit", "multi/handler", hash, console); + } + + /** Resets group layout displaying appropriate elements */ + private void resetLayout(){ + boolean saving = saveButton.isSelected(); + outputScrollPane.setVisible(!saving); + archField.setVisible(saving); + archLabel.setVisible(saving); + choosePathButton.setVisible(saving); + encoderCombo.setVisible(saving); + encoderLabel.setVisible(saving); + outputCombo.setVisible(saving); + outputLabel.setVisible(saving); + outputPathField.setVisible(saving); + outputPathLabel.setVisible(saving); + templateButton.setVisible(saving); + templateField.setVisible(saving); + templateLabel.setVisible(saving); + templateWorkingCheck.setVisible(saving); + timesField.setVisible(saving); + timesLabel.setVisible(saving); + badcharsField.setVisible(saving); + badcharsLabel.setVisible(saving); + addCodeButton.setVisible(saving); + addCodeLabel.setVisible(saving); + addCodeField.setVisible(saving); + + GroupLayout mainPanelLayout = (GroupLayout)mainPanel.getLayout(); + //HORIZONTAL GROUPING + ParallelGroup labelGroup = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING); + //make label group + for(int i = 0; i < optionalOpts.size(); i+= 2) + labelGroup = labelGroup.addComponent((Component)optionalOpts.get(i), GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE); + //make text box group + ParallelGroup textBoxGroup = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING); + for(int i = 1; i < optionalOpts.size(); i+= 2) + textBoxGroup = textBoxGroup.addComponent((Component)optionalOpts.get(i)); + //put it together + mainPanelLayout.setHorizontalGroup( + mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addGroup(mainPanelLayout.createSequentialGroup() + .addContainerGap() + .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(titleLabel) + .addComponent(descriptionBox) + .addComponent(authorsLabel) + .addComponent(licenseLabel) + .addComponent(versionLabel) + .addGroup(mainPanelLayout.createSequentialGroup() + .addGroup(labelGroup) + .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(textBoxGroup) + .addContainerGap()) + .addGroup(mainPanelLayout.createSequentialGroup() + .addComponent(generateButton) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(displayButton) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(saveButton) + .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(handleButton) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(handleConsoleButton)) + .addGroup(GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup() + .addComponent(outputScrollPane, GroupLayout.DEFAULT_SIZE, 40, Short.MAX_VALUE) + .addContainerGap()) + .addGroup(mainPanelLayout.createSequentialGroup() + .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.TRAILING) + .addComponent(encoderLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE) + .addComponent(outputLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE) + .addComponent(archLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE) + .addComponent(badcharsLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE) + .addComponent(timesLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE) + .addComponent(outputPathLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE) + .addComponent(templateLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE) + .addComponent(addCodeLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(encoderCombo, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(outputCombo, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(archField, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(badcharsField, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup() + .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(templateField, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(outputPathField, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(addCodeField, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.TRAILING) + .addComponent(templateButton) + .addComponent(choosePathButton) + .addComponent(addCodeButton))) + .addComponent(timesField, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(templateWorkingCheck))) + .addContainerGap())); + + //VERTICAL GROUPING + SequentialGroup groupie = mainPanelLayout.createSequentialGroup(). + addComponent(titleLabel). + addPreferredGap(LayoutStyle.ComponentPlacement.RELATED). + addComponent(descriptionBox). + addPreferredGap(LayoutStyle.ComponentPlacement.RELATED). + addComponent(authorsLabel). + addPreferredGap(LayoutStyle.ComponentPlacement.RELATED). + addComponent(licenseLabel). + addPreferredGap(LayoutStyle.ComponentPlacement.RELATED). + addComponent(versionLabel); + for(int i = 0; i < optionalOpts.size(); i+=2){ + groupie = groupie.addGroup(mainPanelLayout.createParallelGroup( + GroupLayout.Alignment.BASELINE) + .addComponent((Component)optionalOpts.get(i)) //LABEL + .addComponent((Component)optionalOpts.get(i+1), //TEXT BOX + GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED); + } + groupie = groupie + .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(generateButton) + .addComponent(displayButton) + .addComponent(saveButton) + .addComponent(handleButton) + .addComponent(handleConsoleButton)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(outputScrollPane, GroupLayout.DEFAULT_SIZE, 30, Short.MAX_VALUE); + if(saving) + groupie = groupie.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(outputPathLabel) + .addComponent(outputPathField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addComponent(choosePathButton)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(encoderLabel) + .addComponent(encoderCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(outputLabel) + .addComponent(outputCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(timesLabel) + .addComponent(timesField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(badcharsLabel) + .addComponent(badcharsField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(archLabel) + .addComponent(archField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(templateLabel) + .addComponent(templateField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addComponent(templateButton) + .addComponent(templateWorkingCheck)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(addCodeLabel) + .addComponent(addCodeField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addComponent(addCodeButton)); + groupie = groupie.addContainerGap(); + mainPanelLayout.setVerticalGroup(mainPanelLayout.createParallelGroup( + GroupLayout.Alignment.LEADING).addGroup(groupie)); + } + /** Displays payload info and options. */ + private void showOptions(String fullName) { + Map info = showBasicInfo(rpcConn, fullName); + showOptions(mainPanel, null); + resetLayout(); + } + + /** 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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + buttonGroup1 = new javax.swing.ButtonGroup(); + mainScrollPane = new javax.swing.JScrollPane(); + mainPanel = new javax.swing.JPanel(); + timesField = new javax.swing.JTextField(); + encoderCombo = new javax.swing.JComboBox(); + outputCombo = new javax.swing.JComboBox(); + templateButton = new javax.swing.JButton(); + templateWorkingCheck = new javax.swing.JCheckBox(); + archLabel = new javax.swing.JLabel(); + outputLabel = new javax.swing.JLabel(); + timesLabel = new javax.swing.JLabel(); + archField = new javax.swing.JTextField(); + descriptionBox = new javax.swing.JLabel(); + encoderLabel = new javax.swing.JLabel(); + generateButton = new javax.swing.JButton(); + outputScrollPane = new javax.swing.JScrollPane(); + outputPane = new javax.swing.JTextArea(); + displayButton = new javax.swing.JRadioButton(); + saveButton = new javax.swing.JRadioButton(); + outputPathLabel = new javax.swing.JLabel(); + outputPathField = new javax.swing.JTextField(); + choosePathButton = new javax.swing.JButton(); + templateLabel = new javax.swing.JLabel(); + templateField = new javax.swing.JTextField(); + handleButton = new javax.swing.JButton(); + handleConsoleButton = new javax.swing.JButton(); + addCodeLabel = new javax.swing.JLabel(); + addCodeField = new javax.swing.JTextField(); + addCodeButton = new javax.swing.JButton(); + badcharsLabel = new javax.swing.JLabel(); + badcharsField = new javax.swing.JTextField(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setName("Form"); // NOI18N + + mainScrollPane.setName("mainScrollPane"); // NOI18N + + mainPanel.setName("mainPanel"); // NOI18N + + org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(msfgui.MsfguiApp.class).getContext().getResourceMap(PayloadPopup.class); + timesField.setText(resourceMap.getString("timesField.text")); // NOI18N + timesField.setName("timesField"); // NOI18N + + encoderCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); + encoderCombo.setName("encoderCombo"); // NOI18N + + outputCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "c", "elf", "exe", "jar", "java", "js_le", "js_be", "perl", "raw", "ruby", "vba", "vbs", "loop-vbs", "asp", "war", "macho" })); + outputCombo.setName("outputCombo"); // NOI18N + + templateButton.setText(resourceMap.getString("templateButton.text")); // NOI18N + templateButton.setName("templateButton"); // NOI18N + templateButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + templateButtonActionPerformed(evt); + } + }); + + templateWorkingCheck.setText(resourceMap.getString("templateWorkingCheck.text")); // NOI18N + templateWorkingCheck.setName("templateWorkingCheck"); // NOI18N + + archLabel.setText(resourceMap.getString("archLabel.text")); // NOI18N + archLabel.setName("archLabel"); // NOI18N + + outputLabel.setText(resourceMap.getString("outputLabel.text")); // NOI18N + outputLabel.setName("outputLabel"); // NOI18N + + timesLabel.setText(resourceMap.getString("timesLabel.text")); // NOI18N + timesLabel.setName("timesLabel"); // NOI18N + + archField.setText(resourceMap.getString("archField.text")); // NOI18N + archField.setName("archField"); // NOI18N + + descriptionBox.setText(resourceMap.getString("descriptionBox.text")); // NOI18N + descriptionBox.setName("descriptionBox"); // NOI18N + + encoderLabel.setText(resourceMap.getString("encoderLabel.text")); // NOI18N + encoderLabel.setName("encoderLabel"); // NOI18N + + generateButton.setText(resourceMap.getString("generateButton.text")); // NOI18N + generateButton.setName("generateButton"); // NOI18N + generateButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + generateButtonActionPerformed(evt); + } + }); + + outputScrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + outputScrollPane.setName("outputScrollPane"); // NOI18N + + outputPane.setColumns(20); + outputPane.setEditable(false); + outputPane.setLineWrap(true); + outputPane.setName("outputPane"); // NOI18N + outputScrollPane.setViewportView(outputPane); + + buttonGroup1.add(displayButton); + displayButton.setSelected(true); + displayButton.setText(resourceMap.getString("displayButton.text")); // NOI18N + displayButton.setName("displayButton"); // NOI18N + displayButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + displayButtonActionPerformed(evt); + } + }); + + buttonGroup1.add(saveButton); + saveButton.setText(resourceMap.getString("saveButton.text")); // NOI18N + saveButton.setName("saveButton"); // NOI18N + saveButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + saveButtonActionPerformed(evt); + } + }); + + outputPathLabel.setText(resourceMap.getString("outputPathLabel.text")); // NOI18N + outputPathLabel.setName("outputPathLabel"); // NOI18N + + outputPathField.setText(resourceMap.getString("outputPathField.text")); // NOI18N + outputPathField.setName("outputPathField"); // NOI18N + + choosePathButton.setText(resourceMap.getString("choosePathButton.text")); // NOI18N + choosePathButton.setName("choosePathButton"); // NOI18N + choosePathButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + choosePathButtonActionPerformed(evt); + } + }); + + templateLabel.setText(resourceMap.getString("templateLabel.text")); // NOI18N + templateLabel.setName("templateLabel"); // NOI18N + + templateField.setName("templateField"); // NOI18N + + handleButton.setText(resourceMap.getString("handleButton.text")); // NOI18N + handleButton.setName("handleButton"); // NOI18N + handleButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + handleButtonActionPerformed(evt); + } + }); + + handleConsoleButton.setText(resourceMap.getString("handleConsoleButton.text")); // NOI18N + handleConsoleButton.setName("handleConsoleButton"); // NOI18N + handleConsoleButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + handleConsoleButtonActionPerformed(evt); + } + }); + + addCodeLabel.setText(resourceMap.getString("addCodeLabel.text")); // NOI18N + addCodeLabel.setName("addCodeLabel"); // NOI18N + + addCodeField.setText(resourceMap.getString("addCodeField.text")); // NOI18N + addCodeField.setName("addCodeField"); // NOI18N + + addCodeButton.setText(resourceMap.getString("addCodeButton.text")); // NOI18N + addCodeButton.setName("addCodeButton"); // NOI18N + addCodeButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + addCodeButtonActionPerformed(evt); + } + }); + + badcharsLabel.setText(resourceMap.getString("badcharsLabel.text")); // NOI18N + badcharsLabel.setName("badcharsLabel"); // NOI18N + + badcharsField.setName("badcharsField"); // NOI18N + + javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel); + mainPanel.setLayout(mainPanelLayout); + mainPanelLayout.setHorizontalGroup( + mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(mainPanelLayout.createSequentialGroup() + .addContainerGap() + .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(mainPanelLayout.createSequentialGroup() + .addComponent(descriptionBox) + .addGap(1394, 1394, 1394)) + .addGroup(mainPanelLayout.createSequentialGroup() + .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(outputPathLabel) + .addComponent(encoderLabel) + .addComponent(outputLabel) + .addComponent(timesLabel) + .addComponent(addCodeLabel) + .addComponent(badcharsLabel) + .addComponent(archLabel) + .addComponent(templateLabel)) + .addGap(18, 18, 18) + .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(mainPanelLayout.createSequentialGroup() + .addComponent(outputPathField, javax.swing.GroupLayout.DEFAULT_SIZE, 453, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(choosePathButton, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(archField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 550, Short.MAX_VALUE) + .addComponent(badcharsField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 550, Short.MAX_VALUE) + .addComponent(timesField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 550, Short.MAX_VALUE) + .addComponent(outputCombo, javax.swing.GroupLayout.Alignment.LEADING, 0, 550, Short.MAX_VALUE) + .addComponent(encoderCombo, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 540, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, mainPanelLayout.createSequentialGroup() + .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(addCodeField) + .addComponent(templateField, javax.swing.GroupLayout.DEFAULT_SIZE, 447, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(addCodeButton, javax.swing.GroupLayout.DEFAULT_SIZE, 97, Short.MAX_VALUE) + .addComponent(templateButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 97, Short.MAX_VALUE)))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(templateWorkingCheck) + .addGap(115, 115, 115)))) + .addGroup(mainPanelLayout.createSequentialGroup() + .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(mainPanelLayout.createSequentialGroup() + .addComponent(generateButton) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(displayButton) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(saveButton) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(handleButton) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(handleConsoleButton) + .addGap(121, 121, 121)) + .addComponent(outputScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 691, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(795, 795, 795)) + ); + mainPanelLayout.setVerticalGroup( + mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup() + .addGap(119, 119, 119) + .addComponent(descriptionBox) + .addGap(18, 18, 18) + .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(generateButton) + .addComponent(displayButton) + .addComponent(saveButton) + .addComponent(handleButton) + .addComponent(handleConsoleButton)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(outputScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 12, Short.MAX_VALUE) + .addGap(6, 6, 6) + .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(outputPathField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(outputPathLabel) + .addComponent(choosePathButton)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(encoderCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(encoderLabel)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(outputCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(outputLabel)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(timesField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(timesLabel)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(badcharsField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(badcharsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(archField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(archLabel)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(templateField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(templateLabel) + .addComponent(templateButton) + .addComponent(templateWorkingCheck)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(addCodeField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(addCodeLabel) + .addComponent(addCodeButton)) + .addContainerGap()) + ); + + mainScrollPane.setViewportView(mainPanel); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(mainScrollPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 795, Short.MAX_VALUE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(mainScrollPane) + ); + + pack(); + }// //GEN-END:initComponents + + private void generateButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_generateButtonActionPerformed + try { + HashMap hash = getOptions(mainPanel); + if(outputCombo.getSelectedItem().toString().equals("jar")) + hash.put("Format", "jar"); + hash.put("Encoder", "generic/none"); + Map data = (Map) rpcConn.execute("module.execute", "payload", fullName,hash); + //Basic info + byte[] buffer = (byte[])data.get("payload"); + + if(saveButton.isSelected()){ //Encode and output + hash.put("format", outputCombo.getSelectedItem().toString()); + if(timesField.getText().length() > 0) + hash.put("ecount", timesField.getText()); + if(badcharsField.getText().length() > 0){ + StringBuilder badbinary = new StringBuilder(); + for(String s : badcharsField.getText().split("\\\\x")) + if(s.length() > 0) + badbinary.append((char)Integer.parseInt(s, 16)); + hash.put("badchars", badbinary.toString()); + } + if(archField.getText().length() > 0) + hash.put("arch", archField.getText()); + if(addCodeField.getText().length() > 0) + hash.put("addshellcode", addCodeField.getText()); + if(templateField.getText().length() > 0){ + hash.put("altexe", templateField.getText()); + if(templateWorkingCheck.isSelected()) + hash.put("inject", true); + } + if(!outputCombo.getSelectedItem().toString().equals("jar")){ //jars don't get encoded + Map encoded = (Map) rpcConn.execute("module.encode", buffer, + encoderCombo.getSelectedItem().toString(),hash); + buffer = (byte[])encoded.get("encoded"); + } + FileOutputStream fout = new FileOutputStream(outputPathField.getText()); + fout.write(buffer); + fout.close(); + return; + } + + outputPane.setText("Payload "+fullName+" "+hash+" "+buffer.length+" bytes."); + boolean isPlain = true; + StringBuilder plain = new StringBuilder(""); + for(int i = 0; i < buffer.length; i++){ + if (!Character.isISOControl(buffer[i]))// or check isLetterOrDigit isWhitespace or " , . (){}-_+=<>.,?/'"; etc. + plain.append((char)buffer[i]); + else + isPlain = false; + } + if(isPlain) + outputPane.append("\n\nplain text\n"+plain); + StringBuilder rubyHex = new StringBuilder("\""); + for(int i = 0; i < buffer.length; i += 10){ + for(int j = 0; j < 10 && i + j < buffer.length; j++){ + rubyHex.append("\\x"); + rubyHex.append(Integer.toString((buffer[i+j] & 0xF0)/16,16)); + rubyHex.append(Integer.toString(buffer[i+j] & 0x0F,16)); + } + rubyHex.append("\""); + if(i + 10 < buffer.length) + rubyHex.append("+\n\""); + } + outputPane.append("\n\nruby\n"+rubyHex); + } catch (MsfException ex) { + MsfguiApp.showMessage(this, ex); + } catch (IOException ex) { + MsfguiApp.showMessage(this, ex); + } + }//GEN-LAST:event_generateButtonActionPerformed + + private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveButtonActionPerformed + resetLayout(); + }//GEN-LAST:event_saveButtonActionPerformed + + private void displayButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_displayButtonActionPerformed + resetLayout(); + }//GEN-LAST:event_displayButtonActionPerformed + + private void choosePathButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_choosePathButtonActionPerformed + if(MsfguiApp.fileChooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) + outputPathField.setText(MsfguiApp.fileChooser.getSelectedFile().getAbsolutePath()); + }//GEN-LAST:event_choosePathButtonActionPerformed + + private void templateButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_templateButtonActionPerformed + if(MsfguiApp.fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) + templateField.setText(MsfguiApp.fileChooser.getSelectedFile().getAbsolutePath()); + }//GEN-LAST:event_templateButtonActionPerformed + + private void handleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_handleButtonActionPerformed + doRun(false); + }//GEN-LAST:event_handleButtonActionPerformed + + private void handleConsoleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_handleConsoleButtonActionPerformed + doRun(true); + }//GEN-LAST:event_handleConsoleButtonActionPerformed + + private void addCodeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addCodeButtonActionPerformed + if(MsfguiApp.fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) + addCodeField.setText(MsfguiApp.fileChooser.getSelectedFile().getAbsolutePath()); + }//GEN-LAST:event_addCodeButtonActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton addCodeButton; + private javax.swing.JTextField addCodeField; + private javax.swing.JLabel addCodeLabel; + private javax.swing.JTextField archField; + private javax.swing.JLabel archLabel; + private javax.swing.JTextField badcharsField; + private javax.swing.JLabel badcharsLabel; + private javax.swing.ButtonGroup buttonGroup1; + private javax.swing.JButton choosePathButton; + public javax.swing.JLabel descriptionBox; + private javax.swing.JRadioButton displayButton; + private javax.swing.JComboBox encoderCombo; + private javax.swing.JLabel encoderLabel; + private javax.swing.JButton generateButton; + private javax.swing.JButton handleButton; + private javax.swing.JButton handleConsoleButton; + private javax.swing.JPanel mainPanel; + private javax.swing.JScrollPane mainScrollPane; + private javax.swing.JComboBox outputCombo; + private javax.swing.JLabel outputLabel; + private javax.swing.JTextArea outputPane; + private javax.swing.JTextField outputPathField; + private javax.swing.JLabel outputPathLabel; + private javax.swing.JScrollPane outputScrollPane; + private javax.swing.JRadioButton saveButton; + private javax.swing.JButton templateButton; + private javax.swing.JTextField templateField; + private javax.swing.JLabel templateLabel; + private javax.swing.JCheckBox templateWorkingCheck; + private javax.swing.JTextField timesField; + private javax.swing.JLabel timesLabel; + // End of variables declaration//GEN-END:variables + +} diff -Nru metasploit-gui-1.0/src/msfgui/PersistenceOptionsDialog.form metasploit-gui-1.0/src/msfgui/PersistenceOptionsDialog.form --- metasploit-gui-1.0/src/msfgui/PersistenceOptionsDialog.form 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/PersistenceOptionsDialog.form 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,208 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff -Nru metasploit-gui-1.0/src/msfgui/PersistenceOptionsDialog.java metasploit-gui-1.0/src/msfgui/PersistenceOptionsDialog.java --- metasploit-gui-1.0/src/msfgui/PersistenceOptionsDialog.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/PersistenceOptionsDialog.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,225 @@ +package msfgui; + +/** + * Options dialog for persistence + * @author scriptjunkie + */ +public class PersistenceOptionsDialog extends OptionsDialog { + + /** Creates new form PersistenceOptionsDialog */ + public PersistenceOptionsDialog(java.awt.Frame parent) { + super(parent,"Enter options for persistence", true); + initComponents(); + ipField.setText(MsfguiApp.getLocalIp()); + } + + /** 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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + ipLabel = new javax.swing.JLabel(); + portLabel = new javax.swing.JLabel(); + ipField = new javax.swing.JTextField(); + portField = new javax.swing.JTextField(); + okButton = new javax.swing.JButton(); + jLabel1 = new javax.swing.JLabel(); + cancelButton = new javax.swing.JButton(); + serviceRestartBox = new javax.swing.JCheckBox(); + handlerBox = new javax.swing.JCheckBox(); + intervalField = new javax.swing.JTextField(); + intervalLabel = new javax.swing.JLabel(); + loginRestartBox = new javax.swing.JCheckBox(); + anyLoginRestartBox = new javax.swing.JCheckBox(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + + ipLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(msfgui.MsfguiApp.class).getContext().getResourceMap(PersistenceOptionsDialog.class); + ipLabel.setText(resourceMap.getString("ipLabel.text")); // NOI18N + ipLabel.setName("ipLabel"); // NOI18N + + portLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + portLabel.setText(resourceMap.getString("portLabel.text")); // NOI18N + portLabel.setName("portLabel"); // NOI18N + + ipField.setName("ipField"); // NOI18N + ipField.setPreferredSize(new java.awt.Dimension(50, 27)); + + portField.setText(resourceMap.getString("portField.text")); // NOI18N + portField.setName("portField"); // NOI18N + portField.setPreferredSize(new java.awt.Dimension(50, 27)); + + okButton.setText(resourceMap.getString("okButton.text")); // NOI18N + okButton.setName("okButton"); // NOI18N + okButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + okButtonActionPerformed(evt); + } + }); + + jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N + jLabel1.setName("jLabel1"); // NOI18N + + 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); + } + }); + + serviceRestartBox.setSelected(true); + serviceRestartBox.setText(resourceMap.getString("serviceRestartBox.text")); // NOI18N + serviceRestartBox.setName("serviceRestartBox"); // NOI18N + + handlerBox.setText(resourceMap.getString("handlerBox.text")); // NOI18N + handlerBox.setName("handlerBox"); // NOI18N + + intervalField.setText(resourceMap.getString("intervalField.text")); // NOI18N + intervalField.setName("intervalField"); // NOI18N + + intervalLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + intervalLabel.setText(resourceMap.getString("intervalLabel.text")); // NOI18N + intervalLabel.setName("intervalLabel"); // NOI18N + + loginRestartBox.setText(resourceMap.getString("loginRestartBox.text")); // NOI18N + loginRestartBox.setName("loginRestartBox"); // NOI18N + loginRestartBox.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + loginRestartBoxActionPerformed(evt); + } + }); + + anyLoginRestartBox.setText(resourceMap.getString("anyLoginRestartBox.text")); // NOI18N + anyLoginRestartBox.setName("anyLoginRestartBox"); // NOI18N + anyLoginRestartBox.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + anyLoginRestartBoxActionPerformed(evt); + } + }); + + 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(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(44, 44, 44)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(intervalLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(ipLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(portLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(portField, javax.swing.GroupLayout.DEFAULT_SIZE, 424, Short.MAX_VALUE) + .addComponent(ipField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 424, Short.MAX_VALUE) + .addComponent(intervalField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 424, Short.MAX_VALUE)) + .addContainerGap()) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addComponent(handlerBox, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(serviceRestartBox, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(loginRestartBox) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(anyLoginRestartBox) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addComponent(cancelButton) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(okButton) + .addContainerGap()))) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(serviceRestartBox) + .addComponent(loginRestartBox) + .addComponent(anyLoginRestartBox)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(handlerBox) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(ipLabel) + .addComponent(ipField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .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(portLabel)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(intervalField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(intervalLabel)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(okButton) + .addComponent(cancelButton)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + pack(); + }// //GEN-END:initComponents + + private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed + StringBuilder cmd = new StringBuilder("persistence "); + if(handlerBox.isSelected()) + cmd.append(" -A "); + if(serviceRestartBox.isSelected()) + cmd.append(" -S "); + if(anyLoginRestartBox.isSelected()) + cmd.append(" -X "); + if(loginRestartBox.isSelected()) + cmd.append(" -U "); + cmd.append(" -i ").append(Integer.parseInt(intervalField.getText())); + cmd.append(" -p ").append(Integer.parseInt(portField.getText())); + cmd.append(" -r ").append(ipField.getText()); + command = cmd.toString(); + this.setVisible(false); + }//GEN-LAST:event_okButtonActionPerformed + + private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed + command = null; + this.setVisible(false); + }//GEN-LAST:event_cancelButtonActionPerformed + + private void loginRestartBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loginRestartBoxActionPerformed + if(loginRestartBox.isSelected()) + anyLoginRestartBox.setSelected(false); + }//GEN-LAST:event_loginRestartBoxActionPerformed + + private void anyLoginRestartBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_anyLoginRestartBoxActionPerformed + if(anyLoginRestartBox.isSelected()) + loginRestartBox.setSelected(false); + }//GEN-LAST:event_anyLoginRestartBoxActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JCheckBox anyLoginRestartBox; + private javax.swing.JButton cancelButton; + private javax.swing.JCheckBox handlerBox; + private javax.swing.JTextField intervalField; + private javax.swing.JLabel intervalLabel; + private javax.swing.JTextField ipField; + private javax.swing.JLabel ipLabel; + private javax.swing.JLabel jLabel1; + private javax.swing.JCheckBox loginRestartBox; + private javax.swing.JButton okButton; + private javax.swing.JTextField portField; + private javax.swing.JLabel portLabel; + private javax.swing.JCheckBox serviceRestartBox; + // End of variables declaration//GEN-END:variables + +} diff -Nru metasploit-gui-1.0/src/msfgui/PopupMouseListener.java metasploit-gui-1.0/src/msfgui/PopupMouseListener.java --- metasploit-gui-1.0/src/msfgui/PopupMouseListener.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/PopupMouseListener.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +package msfgui; + +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/** + * Convenient handler for showing popup windows from mouse clicks + * @author scriptjunkie + */ +public abstract class PopupMouseListener extends MouseAdapter{ + public void mousePressed(MouseEvent e) { + if (e.isPopupTrigger()) + showPopup(e); + } + public void mouseReleased(MouseEvent e) { + if (e.isPopupTrigger()) + showPopup(e); + } + public void mouseClicked(MouseEvent e){ //show interaction window on double-click + try{ + if(e.getClickCount() == 2) + doubleClicked(e); + }catch(MsfException xre){ + MsfguiApp.showMessage(null, "action failed " + xre); + } + } + public void doubleClicked (MouseEvent e) throws MsfException{//empty by default + }; + public abstract void showPopup(MouseEvent e); +} diff -Nru metasploit-gui-1.0/src/msfgui/PreferencesFrame.form metasploit-gui-1.0/src/msfgui/PreferencesFrame.form --- metasploit-gui-1.0/src/msfgui/PreferencesFrame.form 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/PreferencesFrame.form 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,231 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff -Nru metasploit-gui-1.0/src/msfgui/PreferencesFrame.java metasploit-gui-1.0/src/msfgui/PreferencesFrame.java --- metasploit-gui-1.0/src/msfgui/PreferencesFrame.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/PreferencesFrame.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,309 @@ +package msfgui; + +import java.awt.Color; +import java.util.Map; +import javax.swing.JColorChooser; +import javax.swing.UIManager; +import javax.swing.UIManager.LookAndFeelInfo; + +/** + * Preferences form to see/save preferences. + * + * @author scriptjunkie + */ +public class PreferencesFrame extends MsfFrame { + private final Map prefs; + private String[] lookNFeels; + + /** Creates new form viewPrefs */ + public PreferencesFrame() { + LookAndFeelInfo[] infoArray = UIManager.getInstalledLookAndFeels(); + lookNFeels = new String[infoArray.length]; + for(int i = 0; i < infoArray.length; i++) + lookNFeels[i] = infoArray[i].getClassName(); + initComponents(); + updateSizes(this); + prefs = MsfguiApp.getPropertiesNode(); + setLnFBox.setSelectedItem(prefs.get("LnF")); + tabWindowBox.setSelected(!"window".equals(prefs.get("tabWindowPreference"))); + tableLineBox.setSelected(Boolean.TRUE.equals(prefs.get("tableShowLines"))); + tableExpandBox.setSelected(!"off".equals(prefs.get("tableResize"))); + if(Boolean.TRUE.equals(prefs.get("overrideColors"))) + colorThemeBox.setSelected(true); + if(prefs.containsKey("defaultTextSize")) + fontSizeSlider.setValue(new Integer(prefs.get("defaultTextSize").toString())); + } + + /** 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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + tabWindowBox = new javax.swing.JCheckBox(); + tableLineBox = new javax.swing.JCheckBox(); + tableExpandBox = new javax.swing.JCheckBox(); + headerLabel = new javax.swing.JLabel(); + okButton = new javax.swing.JButton(); + cancelButton = new javax.swing.JButton(); + restartLabel = new javax.swing.JLabel(); + setLnFBox = new javax.swing.JComboBox(); + lnFLabel = new javax.swing.JLabel(); + fontSizeSlider = new javax.swing.JSlider(); + textSizeLabel = new javax.swing.JLabel(); + colorThemeBox = new javax.swing.JCheckBox(); + foregroundButton = new javax.swing.JButton(); + background = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setName("Form"); // NOI18N + + org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(msfgui.MsfguiApp.class).getContext().getResourceMap(PreferencesFrame.class); + tabWindowBox.setText(resourceMap.getString("tabWindowBox.text")); // NOI18N + tabWindowBox.setName("tabWindowBox"); // NOI18N + + tableLineBox.setText(resourceMap.getString("tableLineBox.text")); // NOI18N + tableLineBox.setName("tableLineBox"); // NOI18N + + tableExpandBox.setText(resourceMap.getString("tableExpandBox.text")); // NOI18N + tableExpandBox.setName("tableExpandBox"); // NOI18N + + headerLabel.setText(resourceMap.getString("headerLabel.text")); // NOI18N + headerLabel.setName("headerLabel"); // NOI18N + + okButton.setText(resourceMap.getString("okButton.text")); // NOI18N + okButton.setName("okButton"); // NOI18N + okButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + okButtonActionPerformed(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); + } + }); + + restartLabel.setText(resourceMap.getString("restartLabel.text")); // NOI18N + restartLabel.setName("restartLabel"); // NOI18N + + setLnFBox.setModel(new javax.swing.DefaultComboBoxModel(lookNFeels)); + setLnFBox.setName("setLnFBox"); // NOI18N + setLnFBox.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + setLnFBoxActionPerformed(evt); + } + }); + + lnFLabel.setText(resourceMap.getString("lnFLabel.text")); // NOI18N + lnFLabel.setName("lnFLabel"); // NOI18N + + fontSizeSlider.setMaximum(20); + fontSizeSlider.setMinimum(4); + fontSizeSlider.setPaintLabels(true); + fontSizeSlider.setPaintTicks(true); + fontSizeSlider.setSnapToTicks(true); + fontSizeSlider.setValue(10); + fontSizeSlider.setName("fontSizeSlider"); // NOI18N + fontSizeSlider.addChangeListener(new javax.swing.event.ChangeListener() { + public void stateChanged(javax.swing.event.ChangeEvent evt) { + fontSizeSliderStateChanged(evt); + } + }); + + textSizeLabel.setText(resourceMap.getString("textSizeLabel.text")); // NOI18N + textSizeLabel.setName("textSizeLabel"); // NOI18N + + colorThemeBox.setText(resourceMap.getString("colorThemeBox.text")); // NOI18N + colorThemeBox.setName("colorThemeBox"); // NOI18N + + foregroundButton.setText(resourceMap.getString("foregroundButton.text")); // NOI18N + foregroundButton.setName("foregroundButton"); // NOI18N + foregroundButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + foregroundButtonActionPerformed(evt); + } + }); + + background.setText(resourceMap.getString("background.text")); // NOI18N + background.setName("background"); // NOI18N + background.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + backgroundActionPerformed(evt); + } + }); + + 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(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(headerLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addComponent(setLnFBox, 0, 704, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(lnFLabel))) + .addContainerGap()) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(tableLineBox) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 638, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addComponent(tableExpandBox) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 476, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addComponent(restartLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 696, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(cancelButton) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(okButton))) + .addGap(18, 18, 18)) + .addGroup(layout.createSequentialGroup() + .addComponent(tabWindowBox) + .addContainerGap(635, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(fontSizeSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(textSizeLabel) + .addContainerGap(486, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(colorThemeBox) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(foregroundButton) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(background) + .addContainerGap(445, Short.MAX_VALUE)))) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(headerLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(setLnFBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(lnFLabel)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(colorThemeBox) + .addComponent(foregroundButton) + .addComponent(background)) + .addGap(47, 47, 47) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(textSizeLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(fontSizeSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(tabWindowBox) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(tableLineBox) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(tableExpandBox) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(restartLabel) + .addComponent(cancelButton) + .addComponent(okButton)) + .addContainerGap()) + ); + + pack(); + }// //GEN-END:initComponents + + private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed + try{ + UIManager.setLookAndFeel(prefs.get("LnF").toString()); + }catch(Exception ex){ + } + setVisible(false); + dispose(); + }//GEN-LAST:event_cancelButtonActionPerformed + + private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed + prefs.put("LnF", setLnFBox.getSelectedItem().toString()); + prefs.put("tabWindowPreference", tabWindowBox.isSelected() ? "tab" : "window"); + prefs.put("tableShowLines", tableLineBox.isSelected()); + prefs.put("tableResize", tableExpandBox.isSelected() ? "on" : "off"); + prefs.put("overrideColors", colorThemeBox.isSelected()); + prefs.put("defaultTextSize", new Integer(fontSizeSlider.getValue()).toString()); + if(fontSizeSlider.getValue() >= 12) + prefs.put("jComponentSizeVariant", "large"); + else if(fontSizeSlider.getValue() >= 10) + prefs.put("jComponentSizeVariant", "regular"); + else if(fontSizeSlider.getValue() >= 8) + prefs.put("jComponentSizeVariant", "small"); + else + prefs.put("jComponentSizeVariant", "mini"); + setVisible(false); + dispose(); + updateUIs(); + }//GEN-LAST:event_okButtonActionPerformed + + /** + * Recursively iterates through a container, updating the size to this local font slider size + * @param c Container to be resized + */ + public void updateSize(java.awt.Container c) { + for(java.awt.Component com : c.getComponents()) { + com.setFont(com.getFont().deriveFont((float)fontSizeSlider.getValue())); + if (com instanceof java.awt.Container) + updateSize((java.awt.Container) com); + } + } + private void fontSizeSliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_fontSizeSliderStateChanged + updateSize(this); + }//GEN-LAST:event_fontSizeSliderStateChanged + + private void setLnFBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_setLnFBoxActionPerformed + try{ + UIManager.setLookAndFeel(setLnFBox.getSelectedItem().toString()); + javax.swing.SwingUtilities.updateComponentTreeUI(this); + pack(); + }catch(Exception ex){ + } + }//GEN-LAST:event_setLnFBoxActionPerformed + + private void foregroundButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_foregroundButtonActionPerformed + Color fgcol = JColorChooser.showDialog(this, null, lnFLabel.getForeground()); + prefs.put("foregroundColor",fgcol.getRGB()); + colorThemeBox.setSelected(true); + prefs.put("overrideColors",true); + updateSizes(this); + }//GEN-LAST:event_foregroundButtonActionPerformed + + private void backgroundActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backgroundActionPerformed + Color bgcol = JColorChooser.showDialog(this, null, lnFLabel.getForeground()); + prefs.put("backgroundColor",bgcol.getRGB()); + colorThemeBox.setSelected(true); + prefs.put("overrideColors",true); + updateSizes(this); + }//GEN-LAST:event_backgroundActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton background; + private javax.swing.JButton cancelButton; + private javax.swing.JCheckBox colorThemeBox; + private javax.swing.JSlider fontSizeSlider; + private javax.swing.JButton foregroundButton; + private javax.swing.JLabel headerLabel; + private javax.swing.JLabel lnFLabel; + private javax.swing.JButton okButton; + private javax.swing.JLabel restartLabel; + private javax.swing.JComboBox setLnFBox; + private javax.swing.JCheckBox tabWindowBox; + private javax.swing.JCheckBox tableExpandBox; + private javax.swing.JCheckBox tableLineBox; + private javax.swing.JLabel textSizeLabel; + // End of variables declaration//GEN-END:variables + +} diff -Nru metasploit-gui-1.0/src/msfgui/ProcessList.form metasploit-gui-1.0/src/msfgui/ProcessList.form --- metasploit-gui-1.0/src/msfgui/ProcessList.form 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/ProcessList.form 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,151 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+
diff -Nru metasploit-gui-1.0/src/msfgui/ProcessList.java metasploit-gui-1.0/src/msfgui/ProcessList.java --- metasploit-gui-1.0/src/msfgui/ProcessList.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/ProcessList.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,260 @@ +package msfgui; + +import java.awt.Component; +import java.awt.HeadlessException; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.util.Map; +import java.util.concurrent.locks.ReentrantLock; +import javax.swing.Timer; +import javax.swing.table.DefaultTableModel; + +/** + * Window displaying a process list for meterpreter sessions. + * @author scriptjunkie + */ +public class ProcessList extends MsfFrame { + protected final Map session; + protected final RpcConnection rpcConn; + protected ReentrantLock lock; + protected final DefaultTableModel model; + protected Timer readTimer = null; + + /** Shows process list window for a session, creating one if necessary */ + static void showList(RpcConnection rpcConn, Map session, Map sessionWindowMap) { + Object processListWindow = sessionWindowMap.get(session.get("id")+"procList"); + if(processListWindow == null){ + processListWindow = new ProcessList(rpcConn,session,sessionWindowMap).mainPanel; + sessionWindowMap.put(session.get("id")+"procList",processListWindow); + } + DraggableTabbedPane.show((Component)processListWindow); + } + + /** Creates new form ProcessList */ + public ProcessList(final RpcConnection rpcConn, final Map session, Map sessionPopupMap) { + super("Meterpreter remote process list"); + initComponents(); + tabbedPane.setTitleAt(0, "Session "+session.get("id")+" process list"); + loadSavedSize(); + model = new DefaultTableModel(){ + public boolean isCellEditable(int row, int col){ + return false; + } + public Class getColumnClass(int columnIndex) { + try{ + return getValueAt(0, columnIndex).getClass(); + }catch(ArrayIndexOutOfBoundsException aioobex){ + return java.lang.String.class; + } + } + }; + processTable.setModel(model); + processTable.setShowHorizontalLines(false); + processTable.setShowVerticalLines(false); + processTable.setAutoCreateRowSorter(true); + this.rpcConn = rpcConn; + this.session = session; + this.lock = (ReentrantLock)sessionPopupMap.get(session.get("id")+"lock"); + //See if we need to move our tab + Map props = MsfguiApp.getPropertiesNode(); + if(!props.get("tabWindowPreference").equals("window")){ + ((DraggableTabbedPane)tabbedPane).moveTabTo(0, DraggableTabbedPane.getTabPane( + (Component)sessionPopupMap.get(session.get("id")+"console"))); + DraggableTabbedPane.show(mainPanel); + } + listProcs(); + } + + /** Lists the processes that are running */ + protected void listProcs() throws HeadlessException { + lock.lock(); + if (runCommand("ps")) + return; + readTimer = new Timer(300, new ActionListener() { + public void actionPerformed(ActionEvent e) { + try { + Map received = (Map) rpcConn.execute("session.meterpreter_read", session.get("id")); + byte[] decodedBytes = RpcConnection.getData(received); + if (decodedBytes.length == 0) + return; //no data + String[] lines = new String(decodedBytes).split("\n"); + String headerRow = null; + for (String line : lines) { + line = line.trim(); + if(line.startsWith("PID")){ + headerRow = line; + model.setColumnIdentifiers(line.split("\\s+")); + while(model.getRowCount() > 0) + model.removeRow(0); + } + if (line.length() < 2 || line.charAt(1) < '0' || line.charAt(1) > '9') + continue; + model.addRow(TableHelper.fill(line,headerRow)); + } + readTimer.stop(); + TableHelper.fitColumnWidths(model, processTable); + } catch(NullPointerException nex){ //junk data from previous command? Ignore. + } catch (Exception ex) { + ex.printStackTrace(); + if (ex.getMessage().contains("unknown session")) + readTimer.stop(); + MsfguiApp.showMessage(null, ex.getMessage()); + } + lock.unlock(); + } + }); + readTimer.start(); + } + + //Runs command, returning whether error was found + private boolean runCommand(String cmd) throws HeadlessException { + try { + rpcConn.execute("session.meterpreter_run_single", session.get("id"),cmd); + } catch (Exception ex) { + MsfguiApp.showMessage(this, ex); + if (ex.getMessage().toLowerCase().contains("unknown session")) + return true; + } + return false; + } + + /** 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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + tabbedPane = new DraggableTabbedPane(this); + mainPanel = new javax.swing.JPanel(); + jScrollPane1 = new javax.swing.JScrollPane(); + processTable = new javax.swing.JTable(); + refreshButton = new javax.swing.JButton(); + migrateButton = new javax.swing.JButton(); + killButton = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + + tabbedPane.setName("tabbedPane"); // NOI18N + + mainPanel.setName("mainPanel"); // NOI18N + + jScrollPane1.setName("jScrollPane1"); // NOI18N + + processTable.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] { + + }, + new String [] { + "Name", "PID", "User", "Session", "Path" + } + ) { + Class[] types = new Class [] { + java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class + }; + + public Class getColumnClass(int columnIndex) { + return types [columnIndex]; + } + }); + processTable.setName("processTable"); // NOI18N + jScrollPane1.setViewportView(processTable); + + org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(msfgui.MsfguiApp.class).getContext().getResourceMap(ProcessList.class); + refreshButton.setText(resourceMap.getString("refreshButton.text")); // NOI18N + refreshButton.setName("refreshButton"); // NOI18N + refreshButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + refreshButtonActionPerformed(evt); + } + }); + + migrateButton.setText(resourceMap.getString("migrateButton.text")); // NOI18N + migrateButton.setName("migrateButton"); // NOI18N + migrateButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + migrateButtonActionPerformed(evt); + } + }); + + killButton.setText(resourceMap.getString("killButton.text")); // NOI18N + killButton.setName("killButton"); // NOI18N + killButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + killButtonActionPerformed(evt); + } + }); + + javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel); + mainPanel.setLayout(mainPanelLayout); + mainPanelLayout.setHorizontalGroup( + mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(mainPanelLayout.createSequentialGroup() + .addContainerGap() + .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 586, Short.MAX_VALUE) + .addGroup(mainPanelLayout.createSequentialGroup() + .addComponent(refreshButton) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 416, Short.MAX_VALUE) + .addComponent(killButton) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(migrateButton))) + .addContainerGap()) + ); + mainPanelLayout.setVerticalGroup( + mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup() + .addContainerGap() + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 352, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(refreshButton) + .addComponent(migrateButton) + .addComponent(killButton)) + .addContainerGap()) + ); + + tabbedPane.addTab("tab1", mainPanel); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(tabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(tabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 456, Short.MAX_VALUE) + ); + + pack(); + }// //GEN-END:initComponents + + private void migrateButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_migrateButtonActionPerformed + runCommand("migrate "+processTable.getModel().getValueAt(processTable.getSelectedRow(),0)); + listProcs(); + }//GEN-LAST:event_migrateButtonActionPerformed + + private void killButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_killButtonActionPerformed + runCommand("kill "+processTable.getModel().getValueAt(processTable.getSelectedRow(),0)); + listProcs(); + }//GEN-LAST:event_killButtonActionPerformed + + private void refreshButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_refreshButtonActionPerformed + listProcs(); + }//GEN-LAST:event_refreshButtonActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JButton killButton; + private javax.swing.JPanel mainPanel; + private javax.swing.JButton migrateButton; + private javax.swing.JTable processTable; + private javax.swing.JButton refreshButton; + private javax.swing.JTabbedPane tabbedPane; + // End of variables declaration//GEN-END:variables +} diff -Nru metasploit-gui-1.0/src/msfgui/Rank.java metasploit-gui-1.0/src/msfgui/Rank.java --- metasploit-gui-1.0/src/msfgui/Rank.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/Rank.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,62 @@ +package msfgui; + +/** + * + * Represents a module rank. Immutable, like an integer. + * @author scriptjunkie + */ +public final class Rank { + //ManualRanking = 0 + //LowRanking = 100 + //AverageRanking = 200 + //NormalRanking = 300 + //GoodRanking = 400 + //GreatRanking = 500 + //ExcellentRanking = 600 + private final int rank; + + //Creates from object, hopefully string or integer + public Rank(Object rank){ + this(rank instanceof Integer ? + ((Integer)rank).intValue() + : Integer.parseInt(rank.toString())); + } + + //Only accept valid ranks + public Rank(int rank){ + if(rank % 100 != 0 || rank < 0 || rank > 600) + throw new RuntimeException("Invalid rank assigned in constructor."); + this.rank = rank; + } + + //Give back internal int; makes comparison easier + public int toInt(){ + return rank; + } + + //Return easy String representation + public String toString(){ + switch(rank){ + case 0: + return "Manual"; + case 100: + return "Low"; + case 200: + return "Average"; + case 300: + return "Normal"; + case 400: + return "Good"; + case 500: + return "Great"; + case 600: + return "Excellent"; + } + throw new RuntimeException("Invalid internal rank state."); + } + + //Static method to simplify getting rank string from int + public static String toString(Object rank){ + return new Rank(rank).toString(); + } +} diff -Nru metasploit-gui-1.0/src/msfgui/RemoteWinenumOptionsDialog.form metasploit-gui-1.0/src/msfgui/RemoteWinenumOptionsDialog.form --- metasploit-gui-1.0/src/msfgui/RemoteWinenumOptionsDialog.form 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/RemoteWinenumOptionsDialog.form 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,132 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff -Nru metasploit-gui-1.0/src/msfgui/RemoteWinenumOptionsDialog.java metasploit-gui-1.0/src/msfgui/RemoteWinenumOptionsDialog.java --- metasploit-gui-1.0/src/msfgui/RemoteWinenumOptionsDialog.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/RemoteWinenumOptionsDialog.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,137 @@ +package msfgui; + +/** + * Options dialog for remote winenum script + * @author scriptjunkie + */ +public class RemoteWinenumOptionsDialog extends OptionsDialog { + + /** Creates new OptionsDialog */ + public RemoteWinenumOptionsDialog(java.awt.Frame parent) { + super(parent, "Remote winenum options", true); + 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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + okButton = new javax.swing.JButton(); + jLabel1 = new javax.swing.JLabel(); + addressField = new javax.swing.JTextField(); + jLabel2 = new javax.swing.JLabel(); + userField = new javax.swing.JTextField(); + passField = new javax.swing.JTextField(); + jLabel3 = new javax.swing.JLabel(); + jLabel4 = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + + org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(msfgui.MsfguiApp.class).getContext().getResourceMap(RemoteWinenumOptionsDialog.class); + okButton.setText(resourceMap.getString("okButton.text")); // NOI18N + okButton.setName("okButton"); // NOI18N + okButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + okButtonActionPerformed(evt); + } + }); + + jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N + jLabel1.setName("jLabel1"); // NOI18N + + addressField.setText(resourceMap.getString("addressField.text")); // NOI18N + addressField.setName("addressField"); // NOI18N + + jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N + jLabel2.setName("jLabel2"); // NOI18N + + userField.setText(resourceMap.getString("userField.text")); // NOI18N + userField.setName("userField"); // NOI18N + + passField.setText(resourceMap.getString("passField.text")); // NOI18N + passField.setName("passField"); // NOI18N + + jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N + jLabel3.setName("jLabel3"); // NOI18N + + jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N + jLabel4.setName("jLabel4"); // 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(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(addressField, javax.swing.GroupLayout.DEFAULT_SIZE, 340, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGap(13, 13, 13) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(passField, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 361, Short.MAX_VALUE) + .addComponent(userField, javax.swing.GroupLayout.DEFAULT_SIZE, 361, Short.MAX_VALUE))) + .addComponent(okButton, javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel3)) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1) + .addComponent(addressField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addComponent(jLabel3) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(userField, 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.LEADING) + .addComponent(passField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel4)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(okButton) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + pack(); + }// //GEN-END:initComponents + + private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed + StringBuilder cmd = new StringBuilder("remotewinenum "); + if(addressField.getText().length() > 0) + cmd.append(" -t "+addressField.getText()); + if(userField.getText().length() > 0) + cmd.append(" -u \""+userField.getText()+"\""); + if(passField.getText().length() > 0) + cmd.append(" -p \""+passField.getText()+"\""); + command = cmd.toString(); + setVisible(false); + dispose(); + }//GEN-LAST:event_okButtonActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JTextField addressField; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JButton okButton; + private javax.swing.JTextField passField; + private javax.swing.JTextField userField; + // End of variables declaration//GEN-END:variables + +} diff -Nru metasploit-gui-1.0/src/msfgui/resources/AutorouteOptionsDialog.properties metasploit-gui-1.0/src/msfgui/resources/AutorouteOptionsDialog.properties --- metasploit-gui-1.0/src/msfgui/resources/AutorouteOptionsDialog.properties 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/resources/AutorouteOptionsDialog.properties 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,5 @@ +deleteRouteButton.text=Delete Route +addRouteButton.text=Add route +okButton.text=Ok +ipField.text=192.168.1.0/24 +subnetLabel.text=Subnet: Binary files /tmp/S5OQQjp5SJ/metasploit-gui-1.0/src/msfgui/resources/busyicons/busy-icon0.png and /tmp/kvQywBdWKJ/metasploit-gui-1.0/src/msfgui/resources/busyicons/busy-icon0.png differ Binary files /tmp/S5OQQjp5SJ/metasploit-gui-1.0/src/msfgui/resources/busyicons/busy-icon10.png and /tmp/kvQywBdWKJ/metasploit-gui-1.0/src/msfgui/resources/busyicons/busy-icon10.png differ Binary files /tmp/S5OQQjp5SJ/metasploit-gui-1.0/src/msfgui/resources/busyicons/busy-icon11.png and /tmp/kvQywBdWKJ/metasploit-gui-1.0/src/msfgui/resources/busyicons/busy-icon11.png differ Binary files /tmp/S5OQQjp5SJ/metasploit-gui-1.0/src/msfgui/resources/busyicons/busy-icon12.png and /tmp/kvQywBdWKJ/metasploit-gui-1.0/src/msfgui/resources/busyicons/busy-icon12.png differ Binary files /tmp/S5OQQjp5SJ/metasploit-gui-1.0/src/msfgui/resources/busyicons/busy-icon13.png and /tmp/kvQywBdWKJ/metasploit-gui-1.0/src/msfgui/resources/busyicons/busy-icon13.png differ Binary files /tmp/S5OQQjp5SJ/metasploit-gui-1.0/src/msfgui/resources/busyicons/busy-icon14.png and /tmp/kvQywBdWKJ/metasploit-gui-1.0/src/msfgui/resources/busyicons/busy-icon14.png differ Binary files /tmp/S5OQQjp5SJ/metasploit-gui-1.0/src/msfgui/resources/busyicons/busy-icon1.png and /tmp/kvQywBdWKJ/metasploit-gui-1.0/src/msfgui/resources/busyicons/busy-icon1.png differ Binary files /tmp/S5OQQjp5SJ/metasploit-gui-1.0/src/msfgui/resources/busyicons/busy-icon2.png and /tmp/kvQywBdWKJ/metasploit-gui-1.0/src/msfgui/resources/busyicons/busy-icon2.png differ Binary files /tmp/S5OQQjp5SJ/metasploit-gui-1.0/src/msfgui/resources/busyicons/busy-icon3.png and /tmp/kvQywBdWKJ/metasploit-gui-1.0/src/msfgui/resources/busyicons/busy-icon3.png differ Binary files /tmp/S5OQQjp5SJ/metasploit-gui-1.0/src/msfgui/resources/busyicons/busy-icon4.png and /tmp/kvQywBdWKJ/metasploit-gui-1.0/src/msfgui/resources/busyicons/busy-icon4.png differ Binary files /tmp/S5OQQjp5SJ/metasploit-gui-1.0/src/msfgui/resources/busyicons/busy-icon5.png and /tmp/kvQywBdWKJ/metasploit-gui-1.0/src/msfgui/resources/busyicons/busy-icon5.png differ Binary files /tmp/S5OQQjp5SJ/metasploit-gui-1.0/src/msfgui/resources/busyicons/busy-icon6.png and /tmp/kvQywBdWKJ/metasploit-gui-1.0/src/msfgui/resources/busyicons/busy-icon6.png differ Binary files /tmp/S5OQQjp5SJ/metasploit-gui-1.0/src/msfgui/resources/busyicons/busy-icon7.png and /tmp/kvQywBdWKJ/metasploit-gui-1.0/src/msfgui/resources/busyicons/busy-icon7.png differ Binary files /tmp/S5OQQjp5SJ/metasploit-gui-1.0/src/msfgui/resources/busyicons/busy-icon8.png and /tmp/kvQywBdWKJ/metasploit-gui-1.0/src/msfgui/resources/busyicons/busy-icon8.png differ Binary files /tmp/S5OQQjp5SJ/metasploit-gui-1.0/src/msfgui/resources/busyicons/busy-icon9.png and /tmp/kvQywBdWKJ/metasploit-gui-1.0/src/msfgui/resources/busyicons/busy-icon9.png differ Binary files /tmp/S5OQQjp5SJ/metasploit-gui-1.0/src/msfgui/resources/busyicons/idle-icon.png and /tmp/kvQywBdWKJ/metasploit-gui-1.0/src/msfgui/resources/busyicons/idle-icon.png differ diff -Nru metasploit-gui-1.0/src/msfgui/resources/DbConnectDialog.properties metasploit-gui-1.0/src/msfgui/resources/DbConnectDialog.properties --- metasploit-gui-1.0/src/msfgui/resources/DbConnectDialog.properties 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/resources/DbConnectDialog.properties 2014-05-20 19:41:40.000000000 +0000 @@ -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 +defaultsButton.text=Load Defaults diff -Nru metasploit-gui-1.0/src/msfgui/resources/EditorWindow.properties metasploit-gui-1.0/src/msfgui/resources/EditorWindow.properties --- metasploit-gui-1.0/src/msfgui/resources/EditorWindow.properties 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/resources/EditorWindow.properties 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,3 @@ + +saveButton.text=Save +jLabel1.text=Unique hashes collected from all meterpreter sessions diff -Nru metasploit-gui-1.0/src/msfgui/resources/InteractWindow.properties metasploit-gui-1.0/src/msfgui/resources/InteractWindow.properties --- metasploit-gui-1.0/src/msfgui/resources/InteractWindow.properties 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/resources/InteractWindow.properties 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,6 @@ + +inputField.text= +submitButton.text=Submit +main.icon=metasploit.png +promptLabel.text=>>> +mainPanel.TabConstraints.tabTitle=Console 1 diff -Nru metasploit-gui-1.0/src/msfgui/resources/JobInfoPopup.properties metasploit-gui-1.0/src/msfgui/resources/JobInfoPopup.properties --- metasploit-gui-1.0/src/msfgui/resources/JobInfoPopup.properties 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/resources/JobInfoPopup.properties 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1 @@ +okButton.text=OK diff -Nru metasploit-gui-1.0/src/msfgui/resources/MainFrame.properties metasploit-gui-1.0/src/msfgui/resources/MainFrame.properties --- metasploit-gui-1.0/src/msfgui/resources/MainFrame.properties 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/resources/MainFrame.properties 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,94 @@ +# Resources for the MsfguiJDesktopView class + +# top-level menus + +fileMenu.text = File + +# @Action resources + +showAboutBox.Action.text = &About... +showAboutBox.Action.shortDescription = Show the application's information dialog + +# status bar resources + +StatusBar.messageTimeout = 5000 +StatusBar.busyAnimationRate = 30 +StatusBar.idleIcon = busyicons/idle-icon.png +StatusBar.busyIcons[0] = busyicons/busy-icon0.png +StatusBar.busyIcons[1] = busyicons/busy-icon1.png +StatusBar.busyIcons[2] = busyicons/busy-icon2.png +StatusBar.busyIcons[3] = busyicons/busy-icon3.png +StatusBar.busyIcons[4] = busyicons/busy-icon4.png +StatusBar.busyIcons[5] = busyicons/busy-icon5.png +StatusBar.busyIcons[6] = busyicons/busy-icon6.png +StatusBar.busyIcons[7] = busyicons/busy-icon7.png +StatusBar.busyIcons[8] = busyicons/busy-icon8.png +StatusBar.busyIcons[9] = busyicons/busy-icon9.png +StatusBar.busyIcons[10] = busyicons/busy-icon10.png +StatusBar.busyIcons[11] = busyicons/busy-icon11.png +StatusBar.busyIcons[12] = busyicons/busy-icon12.png +StatusBar.busyIcons[13] = busyicons/busy-icon13.png +StatusBar.busyIcons[14] = busyicons/busy-icon14.png +exploitsMenu.text=Exploits +auxiliaryMenu.text=Auxiliary +startRpcMenuItem.text=Start new msfrpcd +connectRpcMenuItem.text=Connect to msfrpcd +payloadsMenu.text=Payloads +main.icon=metasploit.png +recentMenu.text=Recent +clearHistoryItem.text=Clear History +helpMenu.text=Help +onlineHelpMenu.text=Online +postMenu.text=Post-Exploit +menuRunAllMeterp.text=Run on all meterpreter sessions... +logGenerateMenuItem.text=Generate HTML Log Report +historyMenu.text=History +killSessionsMenuItem.text=Kill all sessions +databaseMenu.text=Database +connectItem.text=Connect +refreshItem.text=Refresh +searchItem.text=Search +closeConsoleMenu.text=Close Existing +existingConsoleMenu.text=Open Existing +newConsoleItem.text=New +consoleMenu.text=Console +importItem.text=Import +disconnectItem.text=Disconnect +pluginsMenu.text=Plugins +dbTrackerItem.text=DB tracker +autoAddRouteItem.text=Auto add route +soundItem.text=Sound +ipsFilterItem.text=IPS filter +socketLoggerItem.text=Socket logger +otherPluginItem.text=Other +dbCredcollectItem.text=DB credcollect +unloadPluginItem.text=Unload plugin +showDetailsItem.text=Show connection details +jobsPane.TabConstraints.tabTitle=Jobs +sessionsPane.TabConstraints.tabTitle=Sessions +hostsPane.TabConstraints.tabTitle=Hosts +clientsPane.TabConstraints.tabTitle=Clients +servicesPane.TabConstraints.tabTitle=Services +vulnsPane.TabConstraints.tabTitle=Vulns +notesPane.TabConstraints.tabTitle=Notes +lootsPane.TabConstraints.tabTitle=Loots +currWorkspaceItem.text=Select Workspace +addWorkspaceItem.text=Add Workspace +delWorkspaceItem.text=Delete Workspace +refreshConsolesItem.text=Refresh Existing +credsPane.TabConstraints.tabTitle=Creds +viewMenu.text=View +jobViewItem.text=Jobs +lootsViewItem.text=Loots +sessionsViewItem.text=Sessions +credsViewItem.text=Creds +notesViewItem.text=Notes +eventsViewItem.text=Events +vulnsViewItem.text=Vulns +servicesViewItem.text=Services +clientsViewItem.text=Clients +hostsViewItem.text=Hosts +nmapItem.text=Nmap +viewPrefsItem.text=Preferences... +dbExportItem.text=Export +crackPasswordsItem.text=Crack Passwords Binary files /tmp/S5OQQjp5SJ/metasploit-gui-1.0/src/msfgui/resources/metasploit.png and /tmp/kvQywBdWKJ/metasploit-gui-1.0/src/msfgui/resources/metasploit.png differ diff -Nru metasploit-gui-1.0/src/msfgui/resources/MeterpFileBrowser.properties metasploit-gui-1.0/src/msfgui/resources/MeterpFileBrowser.properties --- metasploit-gui-1.0/src/msfgui/resources/MeterpFileBrowser.properties 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/resources/MeterpFileBrowser.properties 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +uploadButton.text=Upload +downloadButton.text=Download +deleteButton.text=Delete +dirButton.text=Make Directory +refreshButton.text=Refresh +pwdLabel.text=Listing +upButton.text=Go up +recSearchDownloadButton.text=Recursive search/download +goButton.text=Go +addressField.text= diff -Nru metasploit-gui-1.0/src/msfgui/resources/ModulePopup.properties metasploit-gui-1.0/src/msfgui/resources/ModulePopup.properties --- metasploit-gui-1.0/src/msfgui/resources/ModulePopup.properties 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/resources/ModulePopup.properties 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +targetsLabel.text=

Targets

+exploitButton.text=Run Exploit +requiredLabel.text=

Required

+optionalLabel.text=

Optional

+main.icon=metasploit.png +advancedLabel.text=

Advanced

+exploitButton1.text=Run Exploit +consoleRunButton1.text=Run in Console +consoleRunButton.text=Run in Console diff -Nru metasploit-gui-1.0/src/msfgui/resources/MsfguiAboutBox.properties metasploit-gui-1.0/src/msfgui/resources/MsfguiAboutBox.properties --- metasploit-gui-1.0/src/msfgui/resources/MsfguiAboutBox.properties 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/resources/MsfguiAboutBox.properties 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +title = About: ${Application.title} + +closeAboutBox.Action.text = &Close + +appDescLabel.text=A Java GUI to the Metasploit Framework created by scriptjunkie. + +versionLabel.text=Version\: + +homepageLabel.text=Homepage\: + +#NOI18N +imageLabel.icon=splash.png +targetsLabel.text=

Targets

+main.icon=metasploit.png +rubyVersionLabel.text=Ruby Version: +javaVersionLabel.text=Java Version: +appJavaVersionLabel.text=3 +appRubyVersionLabel.text=3 diff -Nru metasploit-gui-1.0/src/msfgui/resources/MsfguiApp.properties metasploit-gui-1.0/src/msfgui/resources/MsfguiApp.properties --- metasploit-gui-1.0/src/msfgui/resources/MsfguiApp.properties 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/resources/MsfguiApp.properties 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +# Application global resources + +Application.name = msfguiJDesktop +Application.title = msfgui +Application.version = 3 +Application.homepage = http\://www.metasploit.com/ +Application.description = A Java GUI to the Metasploit Framework. +Application.vendorId = Metasploit +Application.id = ${Application.name} +Application.lookAndFeel = system diff -Nru metasploit-gui-1.0/src/msfgui/resources/MulticommandOptionsDialog.properties metasploit-gui-1.0/src/msfgui/resources/MulticommandOptionsDialog.properties --- metasploit-gui-1.0/src/msfgui/resources/MulticommandOptionsDialog.properties 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/resources/MulticommandOptionsDialog.properties 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,7 @@ +okButton.text=Go +chooseButton.text=Choose output file +commandFileButton.text=Choose command file +commandFileField.text= +outputFileField.text= +jLabel1.text=Commands - one per line +jLabel2.text=Leave blank to use file diff -Nru metasploit-gui-1.0/src/msfgui/resources/NetenumOptionsDialog.properties metasploit-gui-1.0/src/msfgui/resources/NetenumOptionsDialog.properties --- metasploit-gui-1.0/src/msfgui/resources/NetenumOptionsDialog.properties 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/resources/NetenumOptionsDialog.properties 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,13 @@ + +okButton.text=Ok +jLabel1.text=Target address (may be CIDR) +addressField.text=192.168.1.1/24 +pingBox.text=Ping sweep +reverseDnsBox.text=DNS reverse lookup +forwardBox.text=Forward lookup host list and domain +mxNsBox.text=Perform MX and NS lookups for domain +jLabel2.text=Domian name +domainField.text= +chooseButton.text=Choose file with host list +fileField.text= +serviceBox.text=Perform service record lookups for domain diff -Nru metasploit-gui-1.0/src/msfgui/resources/OpenConnectionDialog.properties metasploit-gui-1.0/src/msfgui/resources/OpenConnectionDialog.properties --- metasploit-gui-1.0/src/msfgui/resources/OpenConnectionDialog.properties 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/resources/OpenConnectionDialog.properties 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +passwordField.text= +usernameField.text=msf +hostField.text=127.0.0.1 +portField.text=55553 +connectButton.text=Connect +usernameLabel.text=Username +titleLabel.text=

Connect to msfrpcd

+passwordLabel.text=Password +hostLabel.text=Host +portLabel.text=Port +cancelButton.text=Cancel +Form.title=msfgui - connection +main.icon=metasploit.png +startNewButton.text=Start new msfrpcd +pathButton.text=Change path +sslBox.text= +sslLabel.text=SSL +disableDbButton.text= +disableDbLabel.text=Disable DB diff -Nru metasploit-gui-1.0/src/msfgui/resources/PayloadPopup.properties metasploit-gui-1.0/src/msfgui/resources/PayloadPopup.properties --- metasploit-gui-1.0/src/msfgui/resources/PayloadPopup.properties 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/resources/PayloadPopup.properties 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +main.icon=metasploit.png +jScrollPane2.TabConstraints.tabTitle=payload +jLabel6.text=Platform +timesField.text= +archField.text= +templateButton.text=Choose... +encoderLabel.text=Encoder +outputLabel.text=Output Format +timesLabel.text=Number of times to encode +archLabel.text=Architecture +templateWorkingCheck.text=Keep template working? +generateButton.text=Generate +displayButton.text=display +saveButton.text=encode/save +outputPathField.text=/tmp/msfoutput.exe +choosePathButton.text=Choose... +outputPathLabel.text=Output Path +templateLabel.text=(win32 only) exe template +handleButton.text=Start handler +handleConsoleButton.text=Start handler in console +descriptionBox.text=Description +addCodeLabel.text=(win32 only) add shellcode +addCodeButton.text=Choose... +addCodeField.text= +badcharsLabel.text=Badchars (\\xff\\x00) diff -Nru metasploit-gui-1.0/src/msfgui/resources/PersistenceOptionsDialog.properties metasploit-gui-1.0/src/msfgui/resources/PersistenceOptionsDialog.properties --- metasploit-gui-1.0/src/msfgui/resources/PersistenceOptionsDialog.properties 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/resources/PersistenceOptionsDialog.properties 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +jLabel1.text=

Options

+okButton.text=OK +cancelButton.text=Cancel +ipField.text=metasploit +jCheckBox2.text=Start on boot? +portField.text=4444 +portLabel.text=Port for connect-back +ipLabel.text=IP for connect-back +handlerBox.text=Start handler now +intervalField.text=10 +intervalLabel.text=Interval for connect-back +loginRestartBox.text=Restart on current user login +anyLoginRestartBox.text=Restart on any login +serviceRestartBox.text=Restart on boot as service diff -Nru metasploit-gui-1.0/src/msfgui/resources/PreferencesFrame.properties metasploit-gui-1.0/src/msfgui/resources/PreferencesFrame.properties --- metasploit-gui-1.0/src/msfgui/resources/PreferencesFrame.properties 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/resources/PreferencesFrame.properties 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,12 @@ +tabWindowBox.text=Prefer tabs to windows +tableLineBox.text=Prefer lines in tables +tableExpandBox.text=Expand tables to fit data instead of window +okButton.text=OK +cancelButton.text=Cancel +headerLabel.text=

View Preferences

+restartLabel.text=Note: may need to restart msfgui to apply changes +foregroundButton.text=Foreground +textSizeLabel.text=Default text size +colorThemeBox.text=Override color theme +lnFLabel.text=Look and Feel +background.text=Background diff -Nru metasploit-gui-1.0/src/msfgui/resources/ProcessList.properties metasploit-gui-1.0/src/msfgui/resources/ProcessList.properties --- metasploit-gui-1.0/src/msfgui/resources/ProcessList.properties 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/resources/ProcessList.properties 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,3 @@ +migrateButton.text=Migrate +killButton.text=Kill +refreshButton.text=Refresh diff -Nru metasploit-gui-1.0/src/msfgui/resources/ProcessWindow.properties metasploit-gui-1.0/src/msfgui/resources/ProcessWindow.properties --- metasploit-gui-1.0/src/msfgui/resources/ProcessWindow.properties 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/resources/ProcessWindow.properties 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,2 @@ + +outputField.text=Output (Running) diff -Nru metasploit-gui-1.0/src/msfgui/resources/RemoteWinenumOptionsDialog.properties metasploit-gui-1.0/src/msfgui/resources/RemoteWinenumOptionsDialog.properties --- metasploit-gui-1.0/src/msfgui/resources/RemoteWinenumOptionsDialog.properties 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/resources/RemoteWinenumOptionsDialog.properties 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,9 @@ + +okButton.text=Ok +jLabel1.text=Target address +addressField.text=192.168.1.2 +jLabel2.text=Username +jLabel3.text=Credentials: (leave blank to use current process's creds) +jLabel4.text=Password +passField.text= +userField.text= diff -Nru metasploit-gui-1.0/src/msfgui/resources/ScheduleTaskOptionsDialog.properties metasploit-gui-1.0/src/msfgui/resources/ScheduleTaskOptionsDialog.properties --- metasploit-gui-1.0/src/msfgui/resources/ScheduleTaskOptionsDialog.properties 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/resources/ScheduleTaskOptionsDialog.properties 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +jLabel1.text=Schedule a task +dailyButton.text=Every - days +startupButton.text=Startup +loginButton.text=Login +hourlyButton.text=Every - hours +minuteButton.text=Every - minutes +immediateButton.text=Immediately - once +uploadField.text= +goButton.text=Go +jLabel2.text=Command +commandField.text= +jLabel3.text=Options for uploaded EXE +uploadedArgs.text= +uploadButton.text=Upload EXE +jLabel4.text=Remote system +remoteSystemField.text= +remoteScheduleBox.text=Remote schedule? EXE must already be on target system +jLabel5.text=How many? +howManyField.text=1 +jLabel6.text=Password +usernameField.text= +passwordField.text= +jLabel7.text=Username (leave empty to use current account) +jLabel8.text=leave blank if not uploading diff -Nru metasploit-gui-1.0/src/msfgui/resources/SearchDwldOptionsDialog.properties metasploit-gui-1.0/src/msfgui/resources/SearchDwldOptionsDialog.properties --- metasploit-gui-1.0/src/msfgui/resources/SearchDwldOptionsDialog.properties 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/resources/SearchDwldOptionsDialog.properties 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +okButton.text=Go +jLabel1.text=Directory (or blank for all drives): +dirField.text= +jLabel2.text=Filter: +outputDirField.text= +recursiveBox.text=Recursive +searchPatternField.text=*.doc|*.odt|*.png|pass* +outDirButton.text=Output Directory diff -Nru metasploit-gui-1.0/src/msfgui/resources/SearchWindow.properties metasploit-gui-1.0/src/msfgui/resources/SearchWindow.properties --- metasploit-gui-1.0/src/msfgui/resources/SearchWindow.properties 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/resources/SearchWindow.properties 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +jLabel1.text=Search for modules +jLabel2.text=All by name: +exploitsRadioButton.text=Exploits +auxiliaryRadioButton.text=Auxiliary +payloadsRadioButton.text=Payloads +jLabel3.text=Individual by details: (Note, loading all details takes a long time!) +jLabel4.text=By: +referenceRadioButton.text=Reference (CVE, BID, OSVDB, etc) +descriptionRadioButton.text=Description +searchButton.text=Search +searchField.text= +exploitsRadioButton.actionCommand=exploit +auxiliaryRadioButton.actionCommand=auxiliary +payloadsRadioButton.actionCommand=payload +descriptionRadioButton.actionCommand=description +referenceRadioButton.actionCommand=reference +launchButton.text=Launch diff -Nru metasploit-gui-1.0/src/msfgui/resources/ShellWindow.properties metasploit-gui-1.0/src/msfgui/resources/ShellWindow.properties --- metasploit-gui-1.0/src/msfgui/resources/ShellWindow.properties 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/resources/ShellWindow.properties 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,4 @@ + +inputField.text= +submitButton.text=Submit +main.icon=metasploit.png Binary files /tmp/S5OQQjp5SJ/metasploit-gui-1.0/src/msfgui/resources/splash.png and /tmp/kvQywBdWKJ/metasploit-gui-1.0/src/msfgui/resources/splash.png differ diff -Nru metasploit-gui-1.0/src/msfgui/resources/UploadexecOptionsDialog.properties metasploit-gui-1.0/src/msfgui/resources/UploadexecOptionsDialog.properties --- metasploit-gui-1.0/src/msfgui/resources/UploadexecOptionsDialog.properties 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/resources/UploadexecOptionsDialog.properties 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +okButton.text=Go +fileField.text= +chooseButton.text=Choose exe/script +jLabel1.text=Options to pass +optionsField.text= +pathField.text= +jLabel2.text=Path (blank = %TEMP%) +removeBox.text=Remove after running? +verboseBox.text=Show output? +jLabel3.text=Only works if exe finishes right away diff -Nru metasploit-gui-1.0/src/msfgui/resources/UserPassDialog.properties metasploit-gui-1.0/src/msfgui/resources/UserPassDialog.properties --- metasploit-gui-1.0/src/msfgui/resources/UserPassDialog.properties 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/resources/UserPassDialog.properties 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,7 @@ +passwordField.text=rocks +usernameField.text=metasploit +usernameLabel.text=Username: +passwordLabel.text=Password: +jLabel1.text=

Enter credentials

Note: special characters and quotes don't always work. +dontButton.text=Dont add user +okButton.text=OK diff -Nru metasploit-gui-1.0/src/msfgui/resources/WebcamFrame.properties metasploit-gui-1.0/src/msfgui/resources/WebcamFrame.properties --- metasploit-gui-1.0/src/msfgui/resources/WebcamFrame.properties 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/resources/WebcamFrame.properties 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,7 @@ + +startButton.text=Start +stopButton.text=Stop +delayField.text=1000 +delayLabel.text=Delay (MS) +imageLabel.text= +frameButton.text=Save Frame diff -Nru metasploit-gui-1.0/src/msfgui/resources/WinbfOptionsDialog.properties metasploit-gui-1.0/src/msfgui/resources/WinbfOptionsDialog.properties --- metasploit-gui-1.0/src/msfgui/resources/WinbfOptionsDialog.properties 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/resources/WinbfOptionsDialog.properties 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +okButton.text=Go +jLabel2.text=Login name to brute force +jLabel3.text=Target IP +targetField.text= +passwordButton.text=Choose Password List +userButton.text=Choose Username List +userField.text= +passwordField.text= +loginField.text= +checkPolicyBox.text=Check local lockout policy diff -Nru metasploit-gui-1.0/src/msfgui/RpcAction.java metasploit-gui-1.0/src/msfgui/RpcAction.java --- metasploit-gui-1.0/src/msfgui/RpcAction.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/RpcAction.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,62 @@ +package msfgui; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Map; + +/** + * Provides an ActionListener for running a meterpreter script on each selected session. Each time + * the action is executed, the command is retrieved from the toString() method of commandGenerator + * and executed on each session. + * @author scriptjunkie + */ +public class RpcAction implements ActionListener { + protected Object commandGenerator = null; + protected String command = null; + protected MainFrame parent = null; + public RpcAction(){ + } + public RpcAction( MainFrame parent){ + this.parent = parent; + } + public RpcAction(Object commandGenerator, MainFrame parent){ + this.commandGenerator = commandGenerator; + this.parent = parent; + } + public void actionPerformed(ActionEvent e){ + try{ + prepare(); + if(parent == null) + action(); + else + for(Map session : parent.selectedSessions) + action(session); + }catch(Exception ex){ + if(!ex.getMessage().equals("cancelled")){ + MsfguiApp.showMessage(null, "Error in RPC call: "+ex); + ex.printStackTrace(); + } + } + } + /** prepare() is provided to prepare state of action handler + * such as preparing a command that will be run on all selected sessions. */ + public void prepare() throws Exception{ + if(commandGenerator != null){ + if(commandGenerator instanceof OptionsDialog) + command = ((OptionsDialog)commandGenerator).getCommand(); + else + command = commandGenerator.toString(); + } + } + /** action() with no args provided as an exception-handling action listener. */ + public void action() throws Exception{ + if (parent == null) + throw new MsfException("Error: no parent. If using default constructor, must override action()."); + } + /** Default action executes session.meterpreter_script and shows console window. */ + public void action(Map session) throws Exception{ + if(commandGenerator != null) + parent.rpcConn.execute("session.meterpreter_script", session.get("id"), command); + parent.showInteractWindow(); + } +} diff -Nru metasploit-gui-1.0/src/msfgui/RpcConnection.java metasploit-gui-1.0/src/msfgui/RpcConnection.java --- metasploit-gui-1.0/src/msfgui/RpcConnection.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/RpcConnection.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,341 @@ +package msfgui; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.Socket; +import java.net.SocketException; +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.util.HashMap; +import java.util.Map; +import java.util.Random; +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; +import org.jdesktop.application.Task; + +/** + * RpcConnection handles connection details to a msfrpcd and automatically sends + * activity to be logged. It also caches some method calls to more quickly + * retrieve results later. + * + * Connection implementation is left to child classes, which must implemtent + * writeCall() and readResp() and may implement connect. + * + * @author scriptjunkie + */ +public abstract class RpcConnection { + protected String rpcToken; + protected Map callCache = new HashMap(); + public static String defaultUser = "msf",defaultPass = null, defaultHost = "127.0.0.1"; + public static int defaultPort = 55553; + public static boolean defaultSsl = false; + public static boolean disableDb = false; + protected Socket connection; + protected OutputStream sout; //socket output/input + protected InputStream sin; + protected final Object lockObject = new Object();//to synchronize one request at a time + protected String username, password, host; + protected int port; + protected boolean ssl; + + protected abstract void writeCall(String methname, Object[] params) throws Exception; + protected abstract Object readResp() throws Exception; + + /** + * Creates an RPC connection of the appropriate type and connection details + * @param type RPC type + * @param username + * @param password + * @param host IP address or hostname of RPC server + * @param port Port RPC server is operating on + * @param ssl Whether SSL is to be used + * @return A new RPC connection + * @throws MsfException + */ + public static RpcConnection getConn(String username, char[] password, String host, int port, boolean ssl) throws MsfException{ + RpcConnection conn = new MsgRpc(); + conn.setup(username, password, host, port, ssl); + return conn; + } + + /** + * Gets the unencoded data returned from a something.read call + * @param ret The return from the read call + * @return the + */ + public static byte[] getData(Map received){ + if(received.containsKey("encoding") && received.get("encoding").equals("base64")) + return Base64.decode(received.get("data").toString()); + else + return received.get("data").toString().getBytes(); + } + + /** Setup sets up a connection and authenticates. */ + public void setup(String username, char[] password, String host, int port, boolean ssl) throws MsfException { + boolean haveRpcd=false; + this.username = username; + this.password = new String(password); + this.host = host; + this.port = port; + this.ssl = ssl; + String message = ""; + try { + connect(); + if(username == null || username.equals("")){ + rpcToken = this.password; + execute("core.version"); //throws error if unsuccessful + haveRpcd = true; + }else{ + Map results = (Map)exec("auth.login",new Object[]{username, this.password}); + rpcToken=results.get("token").toString(); + haveRpcd=results.get("result").equals("success"); + } + } catch (MsfException xre) { + message = xre.getLocalizedMessage(); + } catch (IOException io){ + message = io.getLocalizedMessage(); + } catch (NullPointerException nex){ + } catch (NoSuchAlgorithmException nsax){ + } catch (KeyManagementException kmx){ + } + if(!haveRpcd) + throw new MsfException("Error connecting. "+message); + Map root = MsfguiApp.getPropertiesNode(); + root.put("username", username); + root.put("password", this.password); + root.put("host", host); + root.put("port", port); + root.put("ssl", ssl); + root.put("disableDb", disableDb); + MsfguiApp.savePreferences(); + } + + /** + * Disconnects this connection + * + * @throws SocketException + * @throws IOException + */ + protected void disconnect() throws SocketException, IOException{ + if(connection != null) + connection.close(); + } + + /** + * Disconnects then reconnects. + * + * @throws SocketException + * @throws KeyManagementException + * @throws IOException + * @throws NoSuchAlgorithmException + */ + protected void reconnect() throws SocketException, KeyManagementException, IOException, NoSuchAlgorithmException { + disconnect(); + connect(); + } + + /** + * Default connect method connects the TCP stream, setting up SSL if necessary. + * + * @throws SocketException + * @throws KeyManagementException + * @throws IOException + * @throws NoSuchAlgorithmException + */ + protected void connect() throws SocketException, KeyManagementException, IOException, NoSuchAlgorithmException { + if (ssl) { + TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() { + public java.security.cert.X509Certificate[] getAcceptedIssuers() { + return null; + } + public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) { + } + public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) { + } + }}; + // Let us create the factory where we can set some parameters for the connection + SSLContext sc = SSLContext.getInstance("SSL"); + sc.init(null, trustAllCerts, new java.security.SecureRandom()); + connection = sc.getSocketFactory().createSocket(host, port); + } else { + connection = new Socket(host, port); + } + connection.setSoTimeout(10000); //Ten second timeout + sout = connection.getOutputStream(); + sin = connection.getInputStream(); + } + + public String toString(){ + return "RPC connection " + + "\nusername: "+username + + "\npassword: " + password + + "\nhost: " + host + + "\nport: " + Integer.toString(port) + + "\nssl: " + ssl; + } + /** Destructor cleans up. */ + protected void finalize() throws Throwable{ + super.finalize(); + connection.close(); + } + + /** Adds token, runs command, and notifies logger on call and return */ + public Object execute(String methodName, Object... params) throws MsfException{ + MsfguiLog.defaultLog.logMethodCall(methodName, params); + Object[] paramsNew = new Object[params.length+1]; + paramsNew[0] = rpcToken; + System.arraycopy(params, 0, paramsNew, 1, params.length); + Object result = cacheExecute(methodName, paramsNew); + MsfguiLog.defaultLog.logMethodReturn(methodName, params, result); + return result; + } + + /** Caches certain calls and checks cache for re-executing them. + * If not cached or not cacheable, calls exec. */ + private Object cacheExecute(String methodName, Object[] params) throws MsfException{ + if(methodName.equals("module.info") || methodName.equals("module.options") + || methodName.equals("module.compatible_payloads") || methodName.equals("module.post")){ + StringBuilder keysb = new StringBuilder(methodName); + for(int i = 1; i < params.length; i++) + keysb.append(params[i].toString()); + String key = keysb.toString(); + Object result = callCache.get(key); + if(result == null){ + result = exec(methodName, params); + callCache.put(key, result); + } + if(result instanceof Map){ + HashMap clone = new HashMap(); + clone.putAll((Map)result); + return clone; + } + return result; + } + return exec(methodName, params); + } + + /** Method that handles synchronization and error handling for calls */ + private Object exec (String methname, Object[] params) throws MsfException{ + synchronized(lockObject){ //Only one method call at a time! + try{ + writeCall(methname, params); + return readResp(); + }catch(Exception ex){ //any weirdness gets wrapped in a MsfException + try{ + if(ex instanceof java.net.SocketTimeoutException) + reconnect(); //reconnect on socket timeout + }catch (Exception ex2){ + ex = ex2; + } + if(! (ex instanceof MsfException)){ + if(! MsfguiApp.shuttingDown || !ex.getLocalizedMessage().toLowerCase().contains("broken pipe")){ + if(!(ex instanceof java.net.ConnectException)) + ex.printStackTrace(); + throw new MsfException("Error in call: "+ex.getLocalizedMessage(), ex); + } + } + throw (MsfException)ex; + } + } + } + + /** Attempts to start msfrpcd and connect to it.*/ + public static Task startRpcConn(final MainFrame mainFrame){ + if(mainFrame.rpcConn != null){ + MsfguiApp.showMessage(mainFrame.getFrame(), "You are already connected!\n" + + "Exit before making a new connection."); + throw new RuntimeException("Already connected"); + } + return new Task(mainFrame.getApplication()){ + private RpcConnection myRpcConn; + @Override + protected RpcConnection doInBackground() throws Exception { + setTitle("Starting new msfrpcd"); + setMessage("Setting up and saving parameters."); + if(defaultPass == null){ + StringBuilder password = new StringBuilder(); + Random secrand = new SecureRandom(); + for (int i = 0; i < 10; i++) + password.append((char) ('a'+secrand.nextInt(26))); + defaultPass = password.toString(); + } + + // Don't fork cause we'll check if it dies + String rpcType = "Basic"; + java.util.List args = new java.util.ArrayList(java.util.Arrays.asList(new String[]{ + "msfrpcd","-f","-P",defaultPass,"-U",defaultUser,"-a","0.0.0.0", + "-p",Integer.toString(defaultPort)})); + if(!defaultSsl) + args.add("-S"); + if(disableDb) + args.add("-n"); + setMessage("Starting msfrpcd."); + Process proc = null; + try { + proc = MsfguiApp.startMsfProc(args); + } catch (MsfException ex) { + setMessage("msfrpcd not found."); + setProgress(1f); + throw new MsfException("Could not find or start msfrpcd"); //darn + } + + //Connect to started daemon + setMessage("Started msfrpcd. Connecting to new msfrpcd..."); + boolean connected = false; + int timeoutTries = 0; + for (int tries = 0; tries < 10000; tries++) { //it usually takes a minute to get started + + try{ //unfortunately this is the only direct way to check if process has terminated + int exitval = proc.exitValue(); + setMessage("msfrpcd died with exit value "+exitval); + throw new MsfException("msfrpcd died"); + } catch (IllegalThreadStateException itsy){ + } //Nope. We're good. + + try { + myRpcConn = RpcConnection.getConn(defaultUser, defaultPass.toCharArray(), "127.0.0.1", defaultPort, defaultSsl); + connected = true; + break; + } catch (MsfException mex) { + if(mex.getMessage().toLowerCase().contains("authentication error")){ + mex.printStackTrace(); + setMessage("Cannot connect to started msfrpcd."); + proc.destroy(); + throw mex; + }else if(mex.getMessage().toLowerCase().contains("connection reset")){ + mex.printStackTrace(); + setMessage("Connection reset."); + proc.destroy(); + throw mex; + }else if(mex.getMessage().toLowerCase().contains("timed out")){ + mex.printStackTrace(); + setMessage("Timeout."); + timeoutTries++; + if(timeoutTries > 5){ //this can happen legitimately + proc.destroy(); + throw mex; + } + } + } + try { + Thread.sleep(200); //Wait for msfrpcd to be ready + } catch (InterruptedException iex) { + } + }//end try to connect loop + if(!connected){ + setMessage("Cannot connect to started msfrpcd."); + throw new MsfException("Cannot connect to started msfrpcd."); + } + return myRpcConn; + } + @Override + protected void succeeded(RpcConnection myRpcConn) { + mainFrame.rpcConn = myRpcConn; + mainFrame.handleNewRpcConnection(); + } + }; + } +} diff -Nru metasploit-gui-1.0/src/msfgui/RunMenuFactory.java metasploit-gui-1.0/src/msfgui/RunMenuFactory.java --- metasploit-gui-1.0/src/msfgui/RunMenuFactory.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/RunMenuFactory.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,12 @@ +package msfgui; + +import java.awt.event.ActionListener; + +/** + * + * @author scriptjunkie + */ +public interface RunMenuFactory { + + public ActionListener getActor(String modName, String type, RpcConnection rpcConn); +} diff -Nru metasploit-gui-1.0/src/msfgui/ScheduleTaskOptionsDialog.form metasploit-gui-1.0/src/msfgui/ScheduleTaskOptionsDialog.form --- metasploit-gui-1.0/src/msfgui/ScheduleTaskOptionsDialog.form 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/ScheduleTaskOptionsDialog.form 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,319 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff -Nru metasploit-gui-1.0/src/msfgui/ScheduleTaskOptionsDialog.java metasploit-gui-1.0/src/msfgui/ScheduleTaskOptionsDialog.java --- metasploit-gui-1.0/src/msfgui/ScheduleTaskOptionsDialog.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/ScheduleTaskOptionsDialog.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,308 @@ +package msfgui; + +import javax.swing.JFileChooser; +import javax.swing.JFrame; + +/** + * Options dialog for schedule task script + * @author scriptjunkie + */ +public class ScheduleTaskOptionsDialog extends OptionsDialog { + + /** Creates new form ScheduleTaskOptionsDialog */ + public ScheduleTaskOptionsDialog(JFrame owner) { + super(owner,"Schedule Task Options",true); + 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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + whenGroup = new javax.swing.ButtonGroup(); + jLabel1 = new javax.swing.JLabel(); + startupButton = new javax.swing.JRadioButton(); + loginButton = new javax.swing.JRadioButton(); + dailyButton = new javax.swing.JRadioButton(); + hourlyButton = new javax.swing.JRadioButton(); + minuteButton = new javax.swing.JRadioButton(); + immediateButton = new javax.swing.JRadioButton(); + uploadField = new javax.swing.JTextField(); + uploadButton = new javax.swing.JButton(); + goButton = new javax.swing.JButton(); + jLabel2 = new javax.swing.JLabel(); + commandField = new javax.swing.JTextField(); + jLabel3 = new javax.swing.JLabel(); + uploadedArgs = new javax.swing.JTextField(); + remoteScheduleBox = new javax.swing.JCheckBox(); + remoteSystemField = new javax.swing.JTextField(); + jLabel4 = new javax.swing.JLabel(); + howManyField = new javax.swing.JTextField(); + jLabel5 = new javax.swing.JLabel(); + passwordField = new javax.swing.JTextField(); + jLabel6 = new javax.swing.JLabel(); + usernameField = new javax.swing.JTextField(); + jLabel7 = new javax.swing.JLabel(); + jLabel8 = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + + org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(msfgui.MsfguiApp.class).getContext().getResourceMap(ScheduleTaskOptionsDialog.class); + jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N + jLabel1.setName("jLabel1"); // NOI18N + + whenGroup.add(startupButton); + startupButton.setSelected(true); + startupButton.setText(resourceMap.getString("startupButton.text")); // NOI18N + startupButton.setName("startupButton"); // NOI18N + + whenGroup.add(loginButton); + loginButton.setText(resourceMap.getString("loginButton.text")); // NOI18N + loginButton.setName("loginButton"); // NOI18N + + whenGroup.add(dailyButton); + dailyButton.setText(resourceMap.getString("dailyButton.text")); // NOI18N + dailyButton.setName("dailyButton"); // NOI18N + + whenGroup.add(hourlyButton); + hourlyButton.setText(resourceMap.getString("hourlyButton.text")); // NOI18N + hourlyButton.setName("hourlyButton"); // NOI18N + + whenGroup.add(minuteButton); + minuteButton.setText(resourceMap.getString("minuteButton.text")); // NOI18N + minuteButton.setName("minuteButton"); // NOI18N + + whenGroup.add(immediateButton); + immediateButton.setText(resourceMap.getString("immediateButton.text")); // NOI18N + immediateButton.setName("immediateButton"); // NOI18N + + uploadField.setText(resourceMap.getString("uploadField.text")); // NOI18N + uploadField.setName("uploadField"); // NOI18N + + uploadButton.setText(resourceMap.getString("uploadButton.text")); // NOI18N + uploadButton.setName("uploadButton"); // NOI18N + uploadButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + uploadButtonActionPerformed(evt); + } + }); + + goButton.setText(resourceMap.getString("goButton.text")); // NOI18N + goButton.setName("goButton"); // NOI18N + goButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + goButtonActionPerformed(evt); + } + }); + + jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N + jLabel2.setName("jLabel2"); // NOI18N + + commandField.setText(resourceMap.getString("commandField.text")); // NOI18N + commandField.setName("commandField"); // NOI18N + + jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N + jLabel3.setName("jLabel3"); // NOI18N + + uploadedArgs.setText(resourceMap.getString("uploadedArgs.text")); // NOI18N + uploadedArgs.setName("uploadedArgs"); // NOI18N + + remoteScheduleBox.setText(resourceMap.getString("remoteScheduleBox.text")); // NOI18N + remoteScheduleBox.setName("remoteScheduleBox"); // NOI18N + + remoteSystemField.setText(resourceMap.getString("remoteSystemField.text")); // NOI18N + remoteSystemField.setName("remoteSystemField"); // NOI18N + + jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N + jLabel4.setName("jLabel4"); // NOI18N + + howManyField.setText(resourceMap.getString("howManyField.text")); // NOI18N + howManyField.setName("howManyField"); // NOI18N + + jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N + jLabel5.setName("jLabel5"); // NOI18N + + passwordField.setText(resourceMap.getString("passwordField.text")); // NOI18N + passwordField.setName("passwordField"); // NOI18N + + jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N + jLabel6.setName("jLabel6"); // NOI18N + + usernameField.setText(resourceMap.getString("usernameField.text")); // NOI18N + usernameField.setName("usernameField"); // NOI18N + + jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N + jLabel7.setName("jLabel7"); // NOI18N + + jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N + jLabel8.setName("jLabel8"); // 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) + .addComponent(jLabel1) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addComponent(startupButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(loginButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(dailyButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(hourlyButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(minuteButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(immediateButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(remoteScheduleBox, javax.swing.GroupLayout.DEFAULT_SIZE, 513, Short.MAX_VALUE) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel4) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(remoteSystemField, javax.swing.GroupLayout.DEFAULT_SIZE, 420, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel3) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(uploadedArgs, javax.swing.GroupLayout.DEFAULT_SIZE, 363, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(uploadButton) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel8) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(uploadField, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel5) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(howManyField, javax.swing.GroupLayout.DEFAULT_SIZE, 442, Short.MAX_VALUE)))) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel7) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(usernameField, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jLabel6) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(passwordField, javax.swing.GroupLayout.DEFAULT_SIZE, 159, Short.MAX_VALUE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addComponent(jLabel2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(commandField, javax.swing.GroupLayout.DEFAULT_SIZE, 553, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(goButton))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(startupButton) + .addComponent(uploadField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(uploadButton) + .addComponent(jLabel8)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(loginButton) + .addComponent(jLabel3) + .addComponent(uploadedArgs, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(dailyButton) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(hourlyButton) + .addComponent(howManyField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel5)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(minuteButton) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(immediateButton) + .addGroup(layout.createSequentialGroup() + .addComponent(remoteScheduleBox) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(remoteSystemField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel4)))) + .addGap(18, 18, 18) + .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(usernameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel7) + .addComponent(jLabel6)) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(goButton) + .addComponent(commandField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel2)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + pack(); + }// //GEN-END:initComponents + + private void uploadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_uploadButtonActionPerformed + if(MsfguiApp.fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) + uploadField.setText(MsfguiApp.fileChooser.getSelectedFile().getPath()); + }//GEN-LAST:event_uploadButtonActionPerformed + + private void goButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_goButtonActionPerformed + StringBuilder cmd = new StringBuilder("scheduleme "); + if(loginButton.isSelected()) + cmd.append(" -l"); + else if(immediateButton.isSelected()) + cmd.append(" -i"); + else if(startupButton.isSelected()) + cmd.append(" -s"); + else if(dailyButton.isSelected()) + cmd.append(" -d ").append(howManyField.getText()); + else if(hourlyButton.isSelected()) + cmd.append(" -hr ").append(howManyField.getText()); + else if(minuteButton.isSelected()) + cmd.append(" -m ").append(howManyField.getText()); + if(remoteScheduleBox.isSelected()) + cmd.append(" -r -t ").append(remoteSystemField.getText()); + if(usernameField.getText().length() > 0) + cmd.append(" -u ").append(usernameField.getText()).append(" -p ").append(passwordField.getText()); + if(uploadField.getText().length() > 0) + cmd.append(" -e ").append(MsfguiApp.escapeBackslashes(uploadField.getText())).append(" -o ") + .append(MsfguiApp.escapeBackslashes(uploadedArgs.getText())); + cmd.append(" -c ").append(MsfguiApp.escapeBackslashes(commandField.getText())); + command = cmd.toString(); + setVisible(false); + }//GEN-LAST:event_goButtonActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JTextField commandField; + private javax.swing.JRadioButton dailyButton; + private javax.swing.JButton goButton; + private javax.swing.JRadioButton hourlyButton; + private javax.swing.JTextField howManyField; + private javax.swing.JRadioButton immediateButton; + 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.JLabel jLabel8; + private javax.swing.JRadioButton loginButton; + private javax.swing.JRadioButton minuteButton; + private javax.swing.JTextField passwordField; + private javax.swing.JCheckBox remoteScheduleBox; + private javax.swing.JTextField remoteSystemField; + private javax.swing.JRadioButton startupButton; + private javax.swing.JButton uploadButton; + private javax.swing.JTextField uploadField; + private javax.swing.JTextField uploadedArgs; + private javax.swing.JTextField usernameField; + private javax.swing.ButtonGroup whenGroup; + // End of variables declaration//GEN-END:variables + +} diff -Nru metasploit-gui-1.0/src/msfgui/SearchDwldOptionsDialog.form metasploit-gui-1.0/src/msfgui/SearchDwldOptionsDialog.form --- metasploit-gui-1.0/src/msfgui/SearchDwldOptionsDialog.form 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/SearchDwldOptionsDialog.form 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,138 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff -Nru metasploit-gui-1.0/src/msfgui/SearchDwldOptionsDialog.java metasploit-gui-1.0/src/msfgui/SearchDwldOptionsDialog.java --- metasploit-gui-1.0/src/msfgui/SearchDwldOptionsDialog.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/SearchDwldOptionsDialog.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,173 @@ +package msfgui; + +import javax.swing.JFileChooser; + +/** + * Options dialog for file collector script + * @author scriptjunkie + */ +public class SearchDwldOptionsDialog extends OptionsDialog { + + /** Creates new form SearchDwldOptionsDialog */ + public SearchDwldOptionsDialog(java.awt.Frame parent, String currentDir) { + super(parent, "Search/Download Options", true); + initComponents(); + dirField.setText(currentDir); + } + + /** 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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + buttonGroup1 = new javax.swing.ButtonGroup(); + okButton = new javax.swing.JButton(); + jLabel1 = new javax.swing.JLabel(); + dirField = new javax.swing.JTextField(); + jLabel2 = new javax.swing.JLabel(); + searchPatternField = new javax.swing.JTextField(); + outputDirField = new javax.swing.JTextField(); + outDirButton = new javax.swing.JButton(); + recursiveBox = new javax.swing.JCheckBox(); + + addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosing(java.awt.event.WindowEvent evt) { + closeDialog(evt); + } + }); + + org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(msfgui.MsfguiApp.class).getContext().getResourceMap(SearchDwldOptionsDialog.class); + okButton.setText(resourceMap.getString("okButton.text")); // NOI18N + okButton.setName("okButton"); // NOI18N + okButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + okButtonActionPerformed(evt); + } + }); + + jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N + jLabel1.setName("jLabel1"); // NOI18N + + dirField.setText(resourceMap.getString("dirField.text")); // NOI18N + dirField.setName("dirField"); // NOI18N + + jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N + jLabel2.setName("jLabel2"); // NOI18N + + searchPatternField.setText(resourceMap.getString("searchPatternField.text")); // NOI18N + searchPatternField.setName("searchPatternField"); // NOI18N + + outputDirField.setText(resourceMap.getString("outputDirField.text")); // NOI18N + outputDirField.setName("outputDirField"); // NOI18N + + outDirButton.setText(resourceMap.getString("outDirButton.text")); // NOI18N + outDirButton.setName("outDirButton"); // NOI18N + outDirButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + outDirButtonActionPerformed(evt); + } + }); + + recursiveBox.setSelected(true); + recursiveBox.setText(resourceMap.getString("recursiveBox.text")); // NOI18N + recursiveBox.setName("recursiveBox"); // 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(layout.createSequentialGroup() + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(dirField, javax.swing.GroupLayout.DEFAULT_SIZE, 322, Short.MAX_VALUE)) + .addComponent(okButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addComponent(jLabel2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(searchPatternField, javax.swing.GroupLayout.DEFAULT_SIZE, 404, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(recursiveBox)) + .addGroup(layout.createSequentialGroup() + .addComponent(outDirButton) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(outputDirField, javax.swing.GroupLayout.DEFAULT_SIZE, 418, Short.MAX_VALUE))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1) + .addComponent(dirField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(recursiveBox) + .addComponent(jLabel2) + .addComponent(searchPatternField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(outputDirField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(outDirButton)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(okButton) + .addContainerGap()) + ); + + pack(); + }// //GEN-END:initComponents + + private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed + StringBuilder cmd = new StringBuilder("file_collector"); + if(dirField.getText().length() > 0) + cmd.append(" -d ").append(MsfguiApp.escapeBackslashes(dirField.getText())); + cmd.append(" -l ").append(outputDirField.getText()); + if(recursiveBox.isSelected()) + cmd.append(" -r "); + cmd.append(" -f ").append(searchPatternField.getText()); + String tempFileName = MsfguiApp.getTempFilename("foundfiles", ".txt"); + cmd.append(" -o ").append(MsfguiApp.escapeBackslashes(tempFileName)); + cmd.append(" -i ").append(MsfguiApp.escapeBackslashes(tempFileName)); + command = cmd.toString(); + doClose(); + }//GEN-LAST:event_okButtonActionPerformed + + /** Closes the dialog */ + private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog + doClose(); + }//GEN-LAST:event_closeDialog + + private void outDirButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_outDirButtonActionPerformed + JFileChooser choosy = MsfguiApp.fileChooser; + int mode = choosy.getFileSelectionMode(); + choosy.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + if(choosy.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) + outputDirField.setText(choosy.getCurrentDirectory().getPath()); + choosy.setFileSelectionMode(mode); + }//GEN-LAST:event_outDirButtonActionPerformed + + private void doClose() { + setVisible(false); + dispose(); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.ButtonGroup buttonGroup1; + private javax.swing.JTextField dirField; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JButton okButton; + private javax.swing.JButton outDirButton; + private javax.swing.JTextField outputDirField; + private javax.swing.JCheckBox recursiveBox; + private javax.swing.JTextField searchPatternField; + // End of variables declaration//GEN-END:variables + +} diff -Nru metasploit-gui-1.0/src/msfgui/SearchWindow.form metasploit-gui-1.0/src/msfgui/SearchWindow.form --- metasploit-gui-1.0/src/msfgui/SearchWindow.form 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/SearchWindow.form 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,237 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff -Nru metasploit-gui-1.0/src/msfgui/SearchWindow.java metasploit-gui-1.0/src/msfgui/SearchWindow.java --- metasploit-gui-1.0/src/msfgui/SearchWindow.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/SearchWindow.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,311 @@ +package msfgui; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import javax.swing.DefaultListModel; + +/** + * Window for searching for modules by name or details + * @author scriptjunkie + */ +public class SearchWindow extends MsfFrame { + public List modules; //list of type, name actor + private RpcConnection rpcConn; + protected DefaultListModel mod; + /** Creates new form SearchWindow */ + public SearchWindow(RpcConnection rpcConn) { + super("Module search window"); + this.rpcConn = rpcConn; + initComponents(); + loadSavedSize(); + modules = new ArrayList(600); + mod =new DefaultListModel(); + resultList.setModel(mod); + searchBox.getEditor().getEditorComponent().addKeyListener(new KeyAdapter() { + public void keyReleased(KeyEvent evt) { + String typed = searchBox.getEditor().getItem().toString(); + if (evt.getKeyCode() == KeyEvent.VK_ENTER) { + doAction(typed); + return; + } + if (evt.getKeyChar() == KeyEvent.CHAR_UNDEFINED || typed.equals(searchBox.getItemAt(0).toString())) + return; + //display items + searchBox.removeAllItems(); + searchBox.addItem(typed); + for (int i = 0; i < modules.size(); i++) + if (((Object[])modules.get(i))[1].toString().contains(typed)) + searchBox.addItem(((Object[])modules.get(i))[1]); + ((javax.swing.JTextField) (searchBox.getEditor().getEditorComponent())).select(typed.length(), + typed.length()); + searchBox.hidePopup(); + searchBox.showPopup(); + } + }); + } + + /** starts handler for named item, whether exploit, payload, or auxiliary */ + private boolean doAction(String typed) { + for (int i = 0; i < modules.size(); i++) { + Object[] info = (Object[])modules.get(i); + if (info[1].toString().equals(typed)) { + ((ActionListener) info[2]).actionPerformed(null); + return true; + } + } + return false; + } + /** 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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + typeGroup = new javax.swing.ButtonGroup(); + detailGroup = new javax.swing.ButtonGroup(); + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + exploitsRadioButton = new javax.swing.JRadioButton(); + auxiliaryRadioButton = new javax.swing.JRadioButton(); + payloadsRadioButton = new javax.swing.JRadioButton(); + searchBox = new javax.swing.JComboBox(); + jLabel3 = new javax.swing.JLabel(); + jLabel4 = new javax.swing.JLabel(); + descriptionRadioButton = new javax.swing.JRadioButton(); + referenceRadioButton = new javax.swing.JRadioButton(); + searchField = new javax.swing.JTextField(); + searchButton = new javax.swing.JButton(); + jScrollPane1 = new javax.swing.JScrollPane(); + resultList = new javax.swing.JList(); + launchButton = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + + org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(msfgui.MsfguiApp.class).getContext().getResourceMap(SearchWindow.class); + jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N + jLabel1.setName("jLabel1"); // NOI18N + + jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N + jLabel2.setName("jLabel2"); // NOI18N + + typeGroup.add(exploitsRadioButton); + exploitsRadioButton.setSelected(true); + exploitsRadioButton.setText(resourceMap.getString("exploitsRadioButton.text")); // NOI18N + exploitsRadioButton.setActionCommand(resourceMap.getString("exploitsRadioButton.actionCommand")); // NOI18N + exploitsRadioButton.setName("exploitsRadioButton"); // NOI18N + + typeGroup.add(auxiliaryRadioButton); + auxiliaryRadioButton.setText(resourceMap.getString("auxiliaryRadioButton.text")); // NOI18N + auxiliaryRadioButton.setActionCommand(resourceMap.getString("auxiliaryRadioButton.actionCommand")); // NOI18N + auxiliaryRadioButton.setName("auxiliaryRadioButton"); // NOI18N + + typeGroup.add(payloadsRadioButton); + payloadsRadioButton.setText(resourceMap.getString("payloadsRadioButton.text")); // NOI18N + payloadsRadioButton.setActionCommand(resourceMap.getString("payloadsRadioButton.actionCommand")); // NOI18N + payloadsRadioButton.setName("payloadsRadioButton"); // NOI18N + + searchBox.setEditable(true); + searchBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "type name here" })); + searchBox.setName("searchBox"); // NOI18N + searchBox.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + searchBoxActionPerformed(evt); + } + }); + + jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N + jLabel3.setName("jLabel3"); // NOI18N + + jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N + jLabel4.setName("jLabel4"); // NOI18N + + detailGroup.add(descriptionRadioButton); + descriptionRadioButton.setSelected(true); + descriptionRadioButton.setText(resourceMap.getString("descriptionRadioButton.text")); // NOI18N + descriptionRadioButton.setActionCommand(resourceMap.getString("descriptionRadioButton.actionCommand")); // NOI18N + descriptionRadioButton.setName("descriptionRadioButton"); // NOI18N + + detailGroup.add(referenceRadioButton); + referenceRadioButton.setText(resourceMap.getString("referenceRadioButton.text")); // NOI18N + referenceRadioButton.setActionCommand(resourceMap.getString("referenceRadioButton.actionCommand")); // NOI18N + referenceRadioButton.setName("referenceRadioButton"); // NOI18N + + searchField.setText(resourceMap.getString("searchField.text")); // NOI18N + searchField.setName("searchField"); // NOI18N + + searchButton.setText(resourceMap.getString("searchButton.text")); // NOI18N + searchButton.setName("searchButton"); // NOI18N + searchButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + searchButtonActionPerformed(evt); + } + }); + + jScrollPane1.setName("jScrollPane1"); // NOI18N + + resultList.setName("resultList"); // NOI18N + jScrollPane1.setViewportView(resultList); + + launchButton.setText(resourceMap.getString("launchButton.text")); // NOI18N + launchButton.setName("launchButton"); // NOI18N + launchButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + launchButtonActionPerformed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 578, Short.MAX_VALUE) + .addComponent(searchField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 578, Short.MAX_VALUE) + .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() + .addComponent(jLabel2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(searchBox, 0, 501, Short.MAX_VALUE)) + .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() + .addComponent(exploitsRadioButton) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(auxiliaryRadioButton) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(payloadsRadioButton)) + .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() + .addComponent(descriptionRadioButton) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(referenceRadioButton)) + .addComponent(searchButton) + .addComponent(launchButton)) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2) + .addComponent(searchBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addComponent(jLabel3) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(exploitsRadioButton) + .addComponent(auxiliaryRadioButton) + .addComponent(payloadsRadioButton)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel4) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(descriptionRadioButton) + .addComponent(referenceRadioButton)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(searchField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(searchButton) + .addGap(18, 18, 18) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 133, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(launchButton) + .addContainerGap()) + ); + + pack(); + }// //GEN-END:initComponents + + private void searchBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchBoxActionPerformed + if ((evt.getModifiers() & ActionEvent.MOUSE_EVENT_MASK) != 0) { + String typed = searchBox.getEditor().getItem().toString(); + doAction(typed); + } + }//GEN-LAST:event_searchBoxActionPerformed + + private void searchButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchButtonActionPerformed + mod.removeAllElements(); + String type = typeGroup.getSelection().getActionCommand(); + String detail = detailGroup.getSelection().getActionCommand(); + String toSearch = searchField.getText().toLowerCase(); + + //look through all modules of selected type. + for(Object module : modules){ + Object[] modInfo = (Object[])module; + if(!modInfo[0].equals(type)) + continue; + + try { //Get info + Map info = (Map) rpcConn.execute("module.info", modInfo[0], modInfo[1]); + if(detail.equals("reference")){ + Object references = info.get("references"); + if(references != null){ + List refArray = (List)references; + for(int i = 0; i < refArray.size(); i++){ + List ref = (List)refArray.get(i); + if(ref.get(1).toString().toLowerCase().contains(toSearch) + || (ref.get(0).toString().toLowerCase()+"-"+ref.get(1)).contains(toSearch)){ + mod.addElement(modInfo[1]+" - "+Rank.toString(info.get("rank"))); + break; + } + } + } + }else{ + if(info.get("name").toString().toLowerCase().contains(toSearch) + || info.get("description").toString().toLowerCase().contains(toSearch)) + mod.addElement(modInfo[1]+" - "+Rank.toString(info.get("rank"))); + } + } catch (MsfException ex) { + MsfguiApp.showMessage(rootPane, ex); + } + } + }//GEN-LAST:event_searchButtonActionPerformed + + private void launchButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_launchButtonActionPerformed + String type = typeGroup.getSelection().getActionCommand(); + String name = resultList.getSelectedValue().toString(); + for(Object module : modules){ + Object[] modInfo = (Object[])module; + if(modInfo[0].equals(type) && name.contains(modInfo[1].toString())){ + Map info = (Map) rpcConn.execute("module.info", modInfo[0], modInfo[1]); + if(name.equals(modInfo[1].toString()+" - "+Rank.toString(info.get("rank")))){ + ((ActionListener) modInfo[2]).actionPerformed(null); + break; + } + } + } + }//GEN-LAST:event_launchButtonActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JRadioButton auxiliaryRadioButton; + private javax.swing.JRadioButton descriptionRadioButton; + private javax.swing.ButtonGroup detailGroup; + private javax.swing.JRadioButton exploitsRadioButton; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JButton launchButton; + private javax.swing.JRadioButton payloadsRadioButton; + private javax.swing.JRadioButton referenceRadioButton; + private javax.swing.JList resultList; + private javax.swing.JComboBox searchBox; + private javax.swing.JButton searchButton; + private javax.swing.JTextField searchField; + private javax.swing.ButtonGroup typeGroup; + // End of variables declaration//GEN-END:variables + +} diff -Nru metasploit-gui-1.0/src/msfgui/SessionCommand.java metasploit-gui-1.0/src/msfgui/SessionCommand.java --- metasploit-gui-1.0/src/msfgui/SessionCommand.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/SessionCommand.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,61 @@ +package msfgui; + +import java.util.List; +import java.util.Map; +import javax.swing.JLabel; +import org.jdesktop.swingworker.SwingWorker; + +/** + * A class to simplify running a command on a collection of sessions and reporting progress. + * @author scriptjunkie + */ +public class SessionCommand { + protected String command; + protected String outputPrefix; + protected JLabel label; + public SessionCommand(){ + command = null; + outputPrefix = null; + label = null; + } + public SessionCommand(String cmd, String output, JLabel outputLabel){ + command = cmd; + outputPrefix = output; + label = outputLabel; + } + public String getCommand(Map session, SwingWorker parent){ + return command; + } + public void processResult(Map m) { + label.setText("Running "+outputPrefix + " on " + m.get("tunnel_peer") + ", session " + m.get("id")); + } + /** Starts a thread to iterate across active sessions, executing the given command on each, + * and updating the output label as progress is made. */ + public static void runOnAllMeterpreters(final SessionsTable sessionsTableModel, String cmd, String output, + JLabel outputLabel, final RpcConnection rpcConn) { + final SessionCommand sess = new SessionCommand(cmd,output,outputLabel); + new SwingWorker() { + protected Object doInBackground() throws Exception { + try{ + List currentSessions = sessionsTableModel.getSessionList(); + for (Object o : currentSessions) { + Map session = (Map) o; + if (!session.get("type").equals("meterpreter")) + continue; + publish(session); + rpcConn.execute("session.meterpreter_write", session.get("id"),("\n" + +sess.getCommand(session, this)+"\n")); + } + }catch (RuntimeException rex){ + if(!rex.getMessage().equals("cancelled")) + throw rex; + } + return null; + } + protected void process(List l) { + for(Object o : l) + sess.processResult((Map)o); + } + }.execute(); + } +} diff -Nru metasploit-gui-1.0/src/msfgui/SessionsTable.java metasploit-gui-1.0/src/msfgui/SessionsTable.java --- metasploit-gui-1.0/src/msfgui/SessionsTable.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/SessionsTable.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,63 @@ +package msfgui; + +import java.util.List; +import java.util.Map; +import javax.swing.table.*; + +/** + * + * @author scriptjunkie + */ +public class SessionsTable extends AbstractTableModel { + public static final int TITLE_INDEX = 0; + public static final int ARTIST_INDEX = 1; + public static final int ALBUM_INDEX = 2; + public static final int HIDDEN_INDEX = 3; + protected String[] columnNames; + protected List sessions; + + public SessionsTable(List sessions) { + //also have "desc", "workspace", "target_host", "username", "uuid", "tunnel_local", "exploit_uuid" + this.columnNames = new String[]{"id","type","tunnel_peer","info","platform","via_exploit","via_payload"}; + this.sessions = sessions; + } + + @Override + public String getColumnName(int column) { + return columnNames[column]; + } + + @Override + public boolean isCellEditable(int row, int column) { + return false; + } + + @Override + public Class getColumnClass(int column) { + return String.class; + } + + public Object getValueAt(int row, int column) { + return ((Map) sessions.get(row)).get(columnNames[column]); + } + + @Override + public void setValueAt(Object value, int row, int column) { + } + + public int getRowCount() { + return sessions.size(); + } + + public int getColumnCount() { + return columnNames.length; + } + + public void updateSessions(List newSessions) { + sessions = newSessions; + } + + public List getSessionList() { + return sessions; + } +} diff -Nru metasploit-gui-1.0/src/msfgui/TableHelper.java metasploit-gui-1.0/src/msfgui/TableHelper.java --- metasploit-gui-1.0/src/msfgui/TableHelper.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/TableHelper.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,69 @@ +package msfgui; + +import java.awt.Component; +import java.util.Vector; +import javax.swing.JTable; +import javax.swing.table.*; + +/** + * Provides methods to help format tables from data + * @author scriptjunkie + */ +public class TableHelper { + public static final int MARGIN = 4; + + /** Sets preferred column widths for the table based on header and data content. */ + public static void fitColumnWidths(TableModel model, JTable mainTable) { + for (int col = 0; col < model.getColumnCount();col++) { + TableColumn tc = mainTable.getColumnModel().getColumn(col); + TableCellRenderer tcr = mainTable.getTableHeader().getDefaultRenderer(); + int width = tcr.getTableCellRendererComponent(mainTable, + model.getColumnName(col), false, false, 0, col).getPreferredSize().width + MARGIN; + if(model.getRowCount() > 0) + tcr = mainTable.getDefaultRenderer(model.getColumnClass(col)); + for (int row = 0; row < model.getRowCount();row++) { + Component c = tcr.getTableCellRendererComponent(mainTable, + model.getValueAt(row, col), false, false, row, col); + if (width < c.getPreferredSize().width + MARGIN) + width = c.getPreferredSize().width + MARGIN; + } + tc.setPreferredWidth(width); + } + } + + /** Based on a header row demonstrating the length and position of the fields, + * break a line into column elements. */ + protected static Vector fill(String line, String headerRow){ + Vector output = new Vector(); + boolean lastWhitespace = false; + StringBuilder val = new StringBuilder(); + int max = Math.max(headerRow.length(), line.length()); + for(int i = 0; i < max; i++){ + if(headerRow.length() <= i){ + val.append(line.charAt(i)); + continue; + } + if(lastWhitespace && !Character.isWhitespace(headerRow.charAt(i))){ + //If it's a number, make it an integer; otherwise a string + String cell = val.toString().trim(); + try{ + output.add(Integer.parseInt(cell)); + }catch(NumberFormatException nex){ + output.add(cell); + } + val.delete(0, val.length()); + } + if(line.length() > i) + val.append(line.charAt(i)); + lastWhitespace = Character.isWhitespace(headerRow.charAt(i)); + } + //If it's a number, make it an integer; otherwise a string + String cell = val.toString().trim(); + try{ + output.add(Integer.parseInt(cell)); + }catch(NumberFormatException nex){ + output.add(cell); + } + return output; + } +} diff -Nru metasploit-gui-1.0/src/msfgui/UploadexecOptionsDialog.form metasploit-gui-1.0/src/msfgui/UploadexecOptionsDialog.form --- metasploit-gui-1.0/src/msfgui/UploadexecOptionsDialog.form 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/UploadexecOptionsDialog.form 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,160 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff -Nru metasploit-gui-1.0/src/msfgui/UploadexecOptionsDialog.java metasploit-gui-1.0/src/msfgui/UploadexecOptionsDialog.java --- metasploit-gui-1.0/src/msfgui/UploadexecOptionsDialog.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/UploadexecOptionsDialog.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,184 @@ +package msfgui; + +import javax.swing.JFileChooser; + +/** + * Options dialog for uploading and executing a file + * @author scriptjunkie + */ +public class UploadexecOptionsDialog extends OptionsDialog { + /** Creates new form UploadexecOptionsDialog */ + public UploadexecOptionsDialog(java.awt.Frame parent) { + super(parent, "Upload Exec Options", true); + 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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + okButton = new javax.swing.JButton(); + chooseButton = new javax.swing.JButton(); + fileField = new javax.swing.JTextField(); + jLabel1 = new javax.swing.JLabel(); + optionsField = new javax.swing.JTextField(); + pathField = new javax.swing.JTextField(); + jLabel2 = new javax.swing.JLabel(); + verboseBox = new javax.swing.JCheckBox(); + removeBox = new javax.swing.JCheckBox(); + jLabel3 = new javax.swing.JLabel(); + + addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosing(java.awt.event.WindowEvent evt) { + closeDialog(evt); + } + }); + + org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(msfgui.MsfguiApp.class).getContext().getResourceMap(UploadexecOptionsDialog.class); + okButton.setText(resourceMap.getString("okButton.text")); // NOI18N + okButton.setName("okButton"); // NOI18N + okButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + okButtonActionPerformed(evt); + } + }); + + chooseButton.setText(resourceMap.getString("chooseButton.text")); // NOI18N + chooseButton.setName("chooseButton"); // NOI18N + chooseButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + chooseButtonActionPerformed(evt); + } + }); + + fileField.setText(resourceMap.getString("fileField.text")); // NOI18N + fileField.setName("fileField"); // NOI18N + + jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N + jLabel1.setName("jLabel1"); // NOI18N + + optionsField.setText(resourceMap.getString("optionsField.text")); // NOI18N + optionsField.setName("optionsField"); // NOI18N + + pathField.setText(resourceMap.getString("pathField.text")); // NOI18N + pathField.setName("pathField"); // NOI18N + + jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N + jLabel2.setName("jLabel2"); // NOI18N + + verboseBox.setText(resourceMap.getString("verboseBox.text")); // NOI18N + verboseBox.setName("verboseBox"); // NOI18N + + removeBox.setText(resourceMap.getString("removeBox.text")); // NOI18N + removeBox.setName("removeBox"); // NOI18N + + jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N + jLabel3.setName("jLabel3"); // 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.TRAILING) + .addComponent(chooseButton) + .addComponent(jLabel1) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(verboseBox) + .addComponent(jLabel2))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addComponent(jLabel3) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(okButton, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(removeBox) + .addComponent(optionsField, javax.swing.GroupLayout.DEFAULT_SIZE, 281, Short.MAX_VALUE) + .addComponent(fileField, javax.swing.GroupLayout.DEFAULT_SIZE, 281, Short.MAX_VALUE) + .addComponent(pathField, javax.swing.GroupLayout.DEFAULT_SIZE, 281, Short.MAX_VALUE)) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(chooseButton) + .addComponent(fileField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(optionsField, 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.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(pathField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(removeBox) + .addComponent(verboseBox))) + .addComponent(jLabel2)) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 7, Short.MAX_VALUE) + .addComponent(okButton) + .addContainerGap()) + .addGroup(layout.createSequentialGroup() + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel3) + .addContainerGap()))) + ); + + pack(); + }// //GEN-END:initComponents + + private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed + StringBuilder cmd = new StringBuilder("uploadexec "); + if(optionsField.getText().length() > 0) + cmd.append(" -o ").append(MsfguiApp.escapeBackslashes(optionsField.getText())); + if(pathField.getText().length() > 0) + cmd.append(" -p ").append(MsfguiApp.escapeBackslashes(pathField.getText())); + cmd.append(" -e ").append(MsfguiApp.escapeBackslashes(fileField.getText())); + if(verboseBox.isSelected()) + cmd.append(" -v"); + if(removeBox.isSelected()) + cmd.append(" -r"); + command = cmd.toString(); + doClose(); + }//GEN-LAST:event_okButtonActionPerformed + + /** Closes the dialog */ + private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog + doClose(); + }//GEN-LAST:event_closeDialog + + private void chooseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chooseButtonActionPerformed + if(MsfguiApp.fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) + fileField.setText(MsfguiApp.fileChooser.getSelectedFile().getPath()); + }//GEN-LAST:event_chooseButtonActionPerformed + + private void doClose() { + setVisible(false); + dispose(); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton chooseButton; + private javax.swing.JTextField fileField; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JButton okButton; + private javax.swing.JTextField optionsField; + private javax.swing.JTextField pathField; + private javax.swing.JCheckBox removeBox; + private javax.swing.JCheckBox verboseBox; + // End of variables declaration//GEN-END:variables + +} diff -Nru metasploit-gui-1.0/src/msfgui/UserPassDialog.form metasploit-gui-1.0/src/msfgui/UserPassDialog.form --- metasploit-gui-1.0/src/msfgui/UserPassDialog.form 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/UserPassDialog.form 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,139 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff -Nru metasploit-gui-1.0/src/msfgui/UserPassDialog.java metasploit-gui-1.0/src/msfgui/UserPassDialog.java --- metasploit-gui-1.0/src/msfgui/UserPassDialog.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/UserPassDialog.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,162 @@ +package msfgui; + +import java.awt.Frame; + +/** + * Options dialog for username/password input + * @author scriptjunkie + */ +public class UserPassDialog extends OptionsDialog { + public boolean okd; + + //Opens dialog to get options for a persistence + public static String getUserPassOpts(Frame parent) { + String[] userPass = showUserPassDialog(parent); + if(userPass == null) + return " -e"; + else + return " -u "+userPass[0]+" -p "+userPass[1]; + } + + /** Shows dialog and returns username and password, or null if cancelled. */ + public static String[] showUserPassDialog(java.awt.Frame parent){ + String[] answers = new String[]{"metasploit","rocks"}; + UserPassDialog d = new UserPassDialog(parent,true); + d.setVisible(true); + if(d.okd){ + answers[0] = d.usernameField.getText(); + answers[1] = d.passwordField.getText(); + return answers; + }else return null; + } + + /** Creates new form UserPassDialog */ + public UserPassDialog(java.awt.Frame parent, boolean modal) { + super(parent, "Enter username and password", modal); + 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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + usernameLabel = new javax.swing.JLabel(); + passwordLabel = new javax.swing.JLabel(); + usernameField = new javax.swing.JTextField(); + passwordField = new javax.swing.JTextField(); + okButton = new javax.swing.JButton(); + jLabel1 = new javax.swing.JLabel(); + dontButton = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + + org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(msfgui.MsfguiApp.class).getContext().getResourceMap(UserPassDialog.class); + usernameLabel.setText(resourceMap.getString("usernameLabel.text")); // NOI18N + usernameLabel.setName("usernameLabel"); // NOI18N + + passwordLabel.setText(resourceMap.getString("passwordLabel.text")); // NOI18N + passwordLabel.setName("passwordLabel"); // NOI18N + + usernameField.setText(resourceMap.getString("usernameField.text")); // NOI18N + usernameField.setName("usernameField"); // NOI18N + usernameField.setPreferredSize(new java.awt.Dimension(50, 27)); + + passwordField.setText(resourceMap.getString("passwordField.text")); // NOI18N + passwordField.setName("passwordField"); // NOI18N + passwordField.setPreferredSize(new java.awt.Dimension(50, 27)); + + okButton.setText(resourceMap.getString("okButton.text")); // NOI18N + okButton.setName("okButton"); // NOI18N + okButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + okButtonActionPerformed(evt); + } + }); + + jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N + jLabel1.setName("jLabel1"); // NOI18N + + dontButton.setText(resourceMap.getString("dontButton.text")); // NOI18N + dontButton.setName("dontButton"); // NOI18N + dontButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + dontButtonActionPerformed(evt); + } + }); + + 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(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(44, 44, 44)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(passwordLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(usernameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(usernameField, javax.swing.GroupLayout.DEFAULT_SIZE, 312, Short.MAX_VALUE) + .addComponent(passwordField, javax.swing.GroupLayout.DEFAULT_SIZE, 312, Short.MAX_VALUE)) + .addContainerGap())) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addComponent(dontButton) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(okButton) + .addContainerGap()))) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(usernameLabel) + .addComponent(usernameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(passwordField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(okButton) + .addComponent(dontButton))) + .addComponent(passwordLabel)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + pack(); + }// //GEN-END:initComponents + + private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed + okd = true; + this.setVisible(false); + }//GEN-LAST:event_okButtonActionPerformed + + private void dontButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dontButtonActionPerformed + okd = false; + this.setVisible(false); + }//GEN-LAST:event_dontButtonActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton dontButton; + private javax.swing.JLabel jLabel1; + private javax.swing.JButton okButton; + private javax.swing.JTextField passwordField; + private javax.swing.JLabel passwordLabel; + private javax.swing.JTextField usernameField; + private javax.swing.JLabel usernameLabel; + // End of variables declaration//GEN-END:variables + +} diff -Nru metasploit-gui-1.0/src/msfgui/WebcamFrame.form metasploit-gui-1.0/src/msfgui/WebcamFrame.form --- metasploit-gui-1.0/src/msfgui/WebcamFrame.form 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/WebcamFrame.form 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,114 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff -Nru metasploit-gui-1.0/src/msfgui/WebcamFrame.java metasploit-gui-1.0/src/msfgui/WebcamFrame.java --- metasploit-gui-1.0/src/msfgui/WebcamFrame.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/WebcamFrame.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,206 @@ +package msfgui; + +import java.io.FileOutputStream; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.SocketException; +import java.util.Map; +import javax.swing.ImageIcon; +import javax.swing.SwingWorker; + +/** + * Frame to display images from a webcam. + * @author scriptjunkie + */ +public class WebcamFrame extends MsfFrame { + protected final Map session; + protected final RpcConnection rpcConn; + public static final int CAM_SOCK_PORT_NUM = 16235; + private SwingWorker sw; + public static final char POLL = 'r'; + public static final char STOP_POLLING = 's'; + private final StringBuffer imageCommand;//synchronized mutable object as command placeholder for polling thread + private byte[] imageData; + + /** Creates new form WebcamFrame */ + public WebcamFrame(final RpcConnection rpcConn, final Map session) { + initComponents(); + this.rpcConn = rpcConn; + this.session = session; + imageCommand = new StringBuffer("r"); + } + + /** Shows webcam window for a session, creating one if necessary */ + static void showWebcam(RpcConnection rpcConn, Map session, Map sessionWindowMap) { + Object webcamWindow = sessionWindowMap.get(session.get("id")+"webcam"); + if(webcamWindow == null){ + webcamWindow = new WebcamFrame(rpcConn,session); + sessionWindowMap.put(session.get("id")+"webcam",webcamWindow); + } + ((MsfFrame)webcamWindow).setVisible(true); + } + + /** 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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + startButton = new javax.swing.JButton(); + stopButton = new javax.swing.JButton(); + delayLabel = new javax.swing.JLabel(); + delayField = new javax.swing.JTextField(); + imageLabel = new javax.swing.JLabel(); + frameButton = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setName("Form"); // NOI18N + addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosing(java.awt.event.WindowEvent evt) { + formWindowClosing(evt); + } + }); + + org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(msfgui.MsfguiApp.class).getContext().getResourceMap(WebcamFrame.class); + startButton.setText(resourceMap.getString("startButton.text")); // NOI18N + startButton.setName("startButton"); // NOI18N + startButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + startButtonActionPerformed(evt); + } + }); + + stopButton.setText(resourceMap.getString("stopButton.text")); // NOI18N + stopButton.setName("stopButton"); // NOI18N + stopButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + stopButtonActionPerformed(evt); + } + }); + + delayLabel.setText(resourceMap.getString("delayLabel.text")); // NOI18N + delayLabel.setName("delayLabel"); // NOI18N + + delayField.setText(resourceMap.getString("delayField.text")); // NOI18N + delayField.setName("delayField"); // NOI18N + + imageLabel.setText(resourceMap.getString("imageLabel.text")); // NOI18N + imageLabel.setName("imageLabel"); // NOI18N + + frameButton.setText(resourceMap.getString("frameButton.text")); // NOI18N + frameButton.setName("frameButton"); // NOI18N + frameButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + frameButtonActionPerformed(evt); + } + }); + + 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) + .addComponent(imageLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE) + .addGroup(layout.createSequentialGroup() + .addComponent(delayLabel) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(delayField, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(startButton) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(stopButton) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(frameButton))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(delayLabel) + .addComponent(delayField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(startButton) + .addComponent(stopButton) + .addComponent(frameButton)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(imageLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 249, Short.MAX_VALUE) + .addContainerGap()) + ); + + pack(); + }// //GEN-END:initComponents + + private void startButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_startButtonActionPerformed + try { //Make socket + imageCommand.setCharAt(0, POLL); + final DatagramSocket camSock = new DatagramSocket(CAM_SOCK_PORT_NUM); + final WebcamFrame me = this; + rpcConn.execute("session.meterpreter_script", session.get("id"), + "webcam -g -d "+Integer.parseInt(delayField.getText())); + sw = new SwingWorker() { + private DatagramPacket dp = new DatagramPacket(new byte[100000], 100000); + protected Object doInBackground() throws Exception { + while (true) { + //Get each picture and send it to label to be displayed + camSock.receive(dp); + imageData = new byte[dp.getLength()]; + System.arraycopy(dp.getData(), 0, imageData, 0, imageData.length); + this.publish(imageData); + if (imageCommand.charAt(0) != POLL){ + //Stop it! + rpcConn.execute("session.meterpreter_script", session.get("id"), "webcam -s"); + camSock.close(); + return null; + } + } + } + protected void process(java.util.List values) { + for (Object o : values) + imageLabel.setIcon(new ImageIcon((byte[]) o)); + me.pack(); + } + }; + sw.execute(); + } catch(NumberFormatException nex){ + MsfguiApp.showMessage(this, "Please enter a valid delay interval between frames!"); + } catch(MsfException mex) { + MsfguiApp.showMessage(this, mex); + } catch (SocketException sox) { + MsfguiApp.showMessage(this, sox); + } + }//GEN-LAST:event_startButtonActionPerformed + + private void stopButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stopButtonActionPerformed + imageCommand.setCharAt(0, STOP_POLLING); + }//GEN-LAST:event_stopButtonActionPerformed + + private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing + imageCommand.setCharAt(0, STOP_POLLING); + }//GEN-LAST:event_formWindowClosing + + private void frameButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_frameButtonActionPerformed + if(MsfguiApp.fileChooser.showSaveDialog(this) != javax.swing.JFileChooser.APPROVE_OPTION) + return; + try{ + FileOutputStream fout = new FileOutputStream(MsfguiApp.fileChooser.getSelectedFile()); + fout.write(imageData); + fout.close(); + }catch(java.io.IOException ix){ + } + }//GEN-LAST:event_frameButtonActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JTextField delayField; + private javax.swing.JLabel delayLabel; + private javax.swing.JButton frameButton; + private javax.swing.JLabel imageLabel; + private javax.swing.JButton startButton; + private javax.swing.JButton stopButton; + // End of variables declaration//GEN-END:variables +} diff -Nru metasploit-gui-1.0/src/msfgui/WinbfOptionsDialog.form metasploit-gui-1.0/src/msfgui/WinbfOptionsDialog.form --- metasploit-gui-1.0/src/msfgui/WinbfOptionsDialog.form 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/WinbfOptionsDialog.form 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,154 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff -Nru metasploit-gui-1.0/src/msfgui/WinbfOptionsDialog.java metasploit-gui-1.0/src/msfgui/WinbfOptionsDialog.java --- metasploit-gui-1.0/src/msfgui/WinbfOptionsDialog.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/WinbfOptionsDialog.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,190 @@ +package msfgui; + +import javax.swing.JFileChooser; + +/** + * Options dialog to provide to winbf password brute-forcing script. + * @author scriptjunkie + */ +public class WinbfOptionsDialog extends OptionsDialog { + /** Creates new winbf dialog */ + public WinbfOptionsDialog(java.awt.Frame parent) { + super(parent, "Winbf Options", true); + 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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + okButton = new javax.swing.JButton(); + userButton = new javax.swing.JButton(); + userField = new javax.swing.JTextField(); + passwordField = new javax.swing.JTextField(); + loginField = new javax.swing.JTextField(); + jLabel2 = new javax.swing.JLabel(); + checkPolicyBox = new javax.swing.JCheckBox(); + targetField = new javax.swing.JTextField(); + jLabel3 = new javax.swing.JLabel(); + passwordButton = new javax.swing.JButton(); + + addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosing(java.awt.event.WindowEvent evt) { + closeDialog(evt); + } + }); + + org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(msfgui.MsfguiApp.class).getContext().getResourceMap(WinbfOptionsDialog.class); + okButton.setText(resourceMap.getString("okButton.text")); // NOI18N + okButton.setName("okButton"); // NOI18N + okButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + okButtonActionPerformed(evt); + } + }); + + userButton.setText(resourceMap.getString("userButton.text")); // NOI18N + userButton.setName("userButton"); // NOI18N + userButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + userButtonActionPerformed(evt); + } + }); + + userField.setText(resourceMap.getString("userField.text")); // NOI18N + userField.setName("userField"); // NOI18N + + passwordField.setText(resourceMap.getString("passwordField.text")); // NOI18N + passwordField.setName("passwordField"); // NOI18N + + loginField.setText(resourceMap.getString("loginField.text")); // NOI18N + loginField.setName("loginField"); // NOI18N + + jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N + jLabel2.setName("jLabel2"); // NOI18N + + checkPolicyBox.setText(resourceMap.getString("checkPolicyBox.text")); // NOI18N + checkPolicyBox.setName("checkPolicyBox"); // NOI18N + + targetField.setText(resourceMap.getString("targetField.text")); // NOI18N + targetField.setName("targetField"); // NOI18N + + jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N + jLabel3.setName("jLabel3"); // NOI18N + + passwordButton.setText(resourceMap.getString("passwordButton.text")); // NOI18N + passwordButton.setName("passwordButton"); // NOI18N + passwordButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + passwordButtonActionPerformed(evt); + } + }); + + 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.TRAILING) + .addComponent(jLabel3) + .addComponent(userButton) + .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 159, Short.MAX_VALUE) + .addComponent(passwordButton)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(checkPolicyBox, javax.swing.GroupLayout.DEFAULT_SIZE, 225, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(okButton, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(passwordField, javax.swing.GroupLayout.DEFAULT_SIZE, 295, Short.MAX_VALUE) + .addComponent(userField, javax.swing.GroupLayout.DEFAULT_SIZE, 295, Short.MAX_VALUE) + .addComponent(loginField, javax.swing.GroupLayout.DEFAULT_SIZE, 295, Short.MAX_VALUE) + .addComponent(targetField, javax.swing.GroupLayout.DEFAULT_SIZE, 295, Short.MAX_VALUE)) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(userField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(userButton)) + .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(passwordButton)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(loginField, 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(targetField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel3)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(checkPolicyBox) + .addComponent(okButton)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + pack(); + }// //GEN-END:initComponents + + private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed + StringBuilder cmd = new StringBuilder("winbf "); + if(targetField.getText().length() > 0) + cmd.append(" -t ").append(MsfguiApp.escapeBackslashes(targetField.getText())); + if(userField.getText().length() > 0) + cmd.append(" -L ").append(MsfguiApp.escapeBackslashes(userField.getText())); + if(passwordField.getText().length() > 0) + cmd.append(" -p ").append(MsfguiApp.escapeBackslashes(passwordField.getText())); + if(loginField.getText().length() > 0) + cmd.append(" -l ").append(MsfguiApp.escapeBackslashes(loginField.getText())); + if(checkPolicyBox.isSelected()) + cmd.append(" -cp"); + command = cmd.toString(); + doClose(); + }//GEN-LAST:event_okButtonActionPerformed + + /** Closes the dialog */ + private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog + doClose(); + }//GEN-LAST:event_closeDialog + + private void userButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_userButtonActionPerformed + if(MsfguiApp.fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) + userField.setText(MsfguiApp.fileChooser.getSelectedFile().getPath()); + }//GEN-LAST:event_userButtonActionPerformed + + private void passwordButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_passwordButtonActionPerformed + if(MsfguiApp.fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) + passwordField.setText(MsfguiApp.fileChooser.getSelectedFile().getPath()); + }//GEN-LAST:event_passwordButtonActionPerformed + + private void doClose() { + setVisible(false); + dispose(); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JCheckBox checkPolicyBox; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JTextField loginField; + private javax.swing.JButton okButton; + private javax.swing.JButton passwordButton; + private javax.swing.JTextField passwordField; + private javax.swing.JTextField targetField; + private javax.swing.JButton userButton; + private javax.swing.JTextField userField; + // End of variables declaration//GEN-END:variables + +} diff -Nru metasploit-gui-1.0/src/msfgui/XmlRpc.java metasploit-gui-1.0/src/msfgui/XmlRpc.java --- metasploit-gui-1.0/src/msfgui/XmlRpc.java 1970-01-01 00:00:00.000000000 +0000 +++ metasploit-gui-1.0/src/msfgui/XmlRpc.java 2014-05-20 19:41:40.000000000 +0000 @@ -0,0 +1,210 @@ +package msfgui; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; + +/** + * XMLRPC implementation of an RpcConnection. + * + * Implements a minimal XMLRPC client for our purposes. Reinventing the wheel is + * usually a bad idea, but CVE/description searching takes a long time and this + * implementation runs a CVE search twice as fast as the apache libs. It also + * results in a more responsive console. + * + * @author scriptjunkie + */ +public class XmlRpc extends RpcConnection { + + /** + * We're an XML RPC + */ + public XmlRpc(){ + super(); + } + /** Creates an XMLRPC call from the given method name and parameters and sends it */ + protected void writeCall(String methname, Object[] params) throws Exception{ + if(methname.endsWith("write")) + params[2] = Base64.encode(params[2].toString().getBytes()); + if(methname.startsWith("db.import_")) + ((Map)params[1]).put("data", Base64.encode((byte[])((Map)params[1]).get("data"))); + if(methname.equals("module.encode")) + params[1] = Base64.encode((byte[])params[1]); + Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); + Element methodCall = doc.createElement("methodCall"); + doc.appendChild(methodCall); + Element methodName = doc.createElement("methodName"); + methodName.appendChild(doc.createTextNode(methname)); + methodCall.appendChild(methodName); + Element paramsEl = doc.createElement("params"); + methodCall.appendChild(paramsEl); + //Add each parameter by type. Usually just the maps are difficult + for(Object param : params){ + Element paramEl = doc.createElement("param"); + paramEl.appendChild(objectToNode(doc,param)); + paramsEl.appendChild(paramEl); + } + ByteArrayOutputStream bout = new ByteArrayOutputStream(); + TransformerFactory.newInstance().newTransformer().transform(new DOMSource(doc), new StreamResult(bout)); + sout.write(bout.toByteArray()); + sout.write(0); + } + + /** + * Takes the object provided and recursively creates a node out of it suitable + * for xmlrpc transmission. + * @param doc + * @param param + * @return + */ + public static Node objectToNode(Document doc, Object param){ + Node valEl = doc.createElement("value"); + if(param instanceof Map){ //Reverse of the parseVal() struct-to-HashMap code + Element structEl = doc.createElement("struct"); + for(Object entryObj : ((Map)param).entrySet()){ + Map.Entry ent = (Map.Entry)entryObj; + Element membEl = doc.createElement("member"); + Element nameEl = doc.createElement("name"); + nameEl.appendChild(doc.createTextNode(ent.getKey().toString())); + membEl.appendChild(nameEl); + membEl.appendChild(objectToNode(doc,ent.getValue())); + structEl.appendChild(membEl); + } + valEl.appendChild(structEl); + }else if(param instanceof List || param instanceof Object[]){ //Reverse of the parseVal() array-to-HashMap code + Element arrayEl = doc.createElement("array"); + Element dataEl = doc.createElement("data"); + if(param instanceof Object[]) + for(Object obj : (Object[])param) + dataEl.appendChild(objectToNode(doc,obj)); + else + for(Object obj : (List)param) + dataEl.appendChild(objectToNode(doc,obj)); + arrayEl.appendChild(dataEl); + valEl.appendChild(arrayEl); + }else if(param instanceof Integer){ //not sure I even need this + Element i4El = doc.createElement("i4"); + i4El.appendChild(doc.createTextNode(param.toString())); + valEl.appendChild(i4El); + }else if(param instanceof Boolean){ //not sure I even need this + Element boolEl = doc.createElement("boolean"); + boolEl.appendChild(doc.createTextNode(param.toString())); + valEl.appendChild(boolEl); + }else{ + Element strEl = doc.createElement("string"); + strEl.appendChild(doc.createTextNode(param.toString())); + valEl.appendChild(strEl); + } + return valEl; + } + + /** Receives an XMLRPC response and converts to an object */ + protected Object readResp() throws Exception{ + //Will store our response + StringBuilder sb = new StringBuilder(); + int len; + do{ + //read bytes + ByteArrayOutputStream cache = new ByteArrayOutputStream(); + int val; + while((val = sin.read()) != 0){ + if(val == -1) + throw new MsfException("Stream died."); + cache.write(val); + } + //parse the response: ... + ByteArrayInputStream is = new ByteArrayInputStream(cache.toByteArray()); + int a = is.read(); + while(a != -1){ + if(!Character.isISOControl(a) || a == '\t') + sb.append((char)a); + //else + // sb.append("&#x").append(Integer.toHexString(a)).append(';'); + a = is.read(); + } + len = sb.length();//Check to make sure we aren't stopping on an embedded null + } while (sb.lastIndexOf("") < len - 20 || len < 30); + Document root = DocumentBuilderFactory.newInstance().newDocumentBuilder() + .parse(new ByteArrayInputStream(sb.toString().getBytes())); + + if(!root.getFirstChild().getNodeName().equals("methodResponse")) + throw new MsfException("Error reading response: not a response."); + Node methResp = root.getFirstChild(); + if(methResp.getFirstChild().getNodeName().equals("fault")){ + throw new MsfException(methResp.getFirstChild()//fault + .getFirstChild() // value + .getFirstChild() // struct + .getLastChild() // member + .getLastChild() // value + .getTextContent()); + } + Node params = methResp.getFirstChild(); + if(!params.getNodeName().equals("params")) + throw new MsfException("Error reading response: no params."); + Node param = params.getFirstChild(); + if(!param.getNodeName().equals("param")) + throw new MsfException("Error reading response: no param."); + Node value = param.getFirstChild(); + if(!value.getNodeName().equals("value")) + throw new MsfException("Error reading response: no value."); + return parseVal(value); + } + + /** Takes an XMLRPC DOM value node and creates a java object out of it recursively */ + public static Object parseVal(Node submemb) throws MsfException { + Node type = submemb.getFirstChild(); + String typeName = type.getNodeName(); + if(typeName.equals("string")){//jobs + return type.getTextContent(); //String returns java string + }else if (typeName.equals("array")){ //Array returns List + ArrayList arrgh = new ArrayList(); + Node data = type.getFirstChild(); + if(!data.getNodeName().equals("data")) + throw new MsfException("Error reading array: no data."); + for(Node val = data.getFirstChild(); val != null; val = val.getNextSibling()) + arrgh.add(parseVal(val)); + return arrgh; + }else if (typeName.equals("struct")){ //Struct returns a HashMap of name->value member pairs + HashMap structmembs = new HashMap(); + for(Node member = type.getFirstChild(); member != null; member = member.getNextSibling()){ + if(!member.getNodeName().equals("member")) + throw new MsfException("Error reading response: non struct member."); + Object name = null, membValue = null; + //get each member and put into output map + for(Node submember = member.getFirstChild(); submember != null; submember = submember.getNextSibling()){ + if(submember.getNodeName().equals("name")) + name = submember.getTextContent(); + else if (submember.getNodeName().equals("value")) + membValue = parseVal(submember); //Value can be arbitrarily complex + } + structmembs.put(name, membValue); + } + return structmembs; + }else if (typeName.equals("i4")){ + return new Integer(type.getTextContent()); + }else if (typeName.equals("boolean")){ + return type.getTextContent().equals("1") || Boolean.valueOf(type.getTextContent()); + }else if (typeName.equals("dateTime.iso8601")) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss"); + try{ + return sdf.parse(type.getTextContent()); + }catch(ParseException pex){ + return type.getTextContent(); + } + } else { + throw new MsfException("Error reading val: unknown type " + typeName); + } + } +} Binary files /tmp/S5OQQjp5SJ/metasploit-gui-1.0/swing-worker-1.1.jar and /tmp/kvQywBdWKJ/metasploit-gui-1.0/swing-worker-1.1.jar differ