Add "crack passwords" option.

git-svn-id: file:///home/svn/framework3/trunk@13169 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
Matt Weeks 2011-07-14 03:06:07 +00:00
parent fdf6660a55
commit 8f79fd1e5f
8 changed files with 75 additions and 37 deletions

Binary file not shown.

View File

@ -610,6 +610,16 @@
<Property name="name" type="java.lang.String" value="menuRunAllMeterp" noResource="true"/>
</Properties>
</Menu>
<MenuItem class="javax.swing.JMenuItem" name="crackPasswordsItem">
<Properties>
<Property name="mnemonic" type="int" value="67"/>
<Property name="text" type="java.lang.String" resourceKey="crackPasswordsItem.text"/>
<Property name="name" type="java.lang.String" value="crackPasswordsItem" noResource="true"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="crackPasswordsItemActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="killSessionsMenuItem">
<Properties>
<Property name="mnemonic" type="int" value="75"/>

View File

@ -524,6 +524,7 @@ nameloop: for (int i = 0; i < names.length; i++) {
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();
@ -907,6 +908,16 @@ nameloop: for (int i = 0; i < names.length; i++) {
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
@ -1577,6 +1588,10 @@ nameloop: for (int i = 0; i < names.length; i++) {
}
}//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);
@ -1858,6 +1873,7 @@ nameloop: for (int i = 0; i < names.length; i++) {
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;
@ -1918,7 +1934,7 @@ nameloop: for (int i = 0; i < names.length; i++) {
private javax.swing.JMenuItem soundItem;
private javax.swing.JMenuItem startRpcMenuItem;
public javax.swing.JLabel statusAnimationLabel;
private javax.swing.JLabel statusMessageLabel;
javax.swing.JLabel statusMessageLabel;
private javax.swing.JPanel statusPanel;
public javax.swing.JTabbedPane tabbedPane;
private javax.swing.JMenuItem unloadPluginItem;

View File

@ -240,8 +240,8 @@ public abstract class ModuleInfoWindow extends MsfFrame {
* @throws MsfException
* @throws HeadlessException
*/
protected void run(boolean console, Map hash) throws MsfException, HeadlessException {
run(console,hash, moduleType, fullName);
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
@ -250,37 +250,7 @@ public abstract class ModuleInfoWindow extends MsfFrame {
* @throws MsfException
* @throws HeadlessException
*/
protected void run(boolean console, Map hash, String moduleType, String fullName) throws MsfException, HeadlessException {
//Execute and get results
if (console) { // Create a list of commands to run in the console
Map res = (Map) rpcConn.execute("console.create");
ArrayList autoCommands = new 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.get("result").equals("success"))
MsfguiApp.showMessage(rootPane, info);
}
MsfguiApp.addRecentModule(java.util.Arrays.asList(new Object[]{moduleType, fullName, hash}), rpcConn, parentFrame);
protected void run(String moduleType, String fullName, Map hash, boolean console) throws MsfException, HeadlessException {
MsfguiApp.runModule(moduleType,fullName,hash,rpcConn,parentFrame,console);
}
}

View File

@ -242,7 +242,7 @@ public class ModulePopup extends ModuleInfoWindow implements TreeSelectionListen
hash.put("TARGET",target);
}
//Actually run the module
run(console, hash);
run(hash, console);
//close out
this.setVisible(false);

View File

@ -179,6 +179,47 @@ public class MsfguiApp extends SingleFrameApplication {
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.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;

View File

@ -51,7 +51,7 @@ public class PayloadPopup extends ModuleInfoWindow {
Map hash = getOptions(mainPanel);
hash.put("PAYLOAD", fullName);
hash.put("TARGET", "0");
run(console, hash, "exploit", "multi/handler");
run("exploit", "multi/handler", hash, console);
}
/** Resets group layout displaying appropriate elements */

View File

@ -92,3 +92,4 @@ hostsViewItem.text=Hosts
nmapItem.text=Nmap
viewPrefsItem.text=Preferences...
dbExportItem.text=Export
crackPasswordsItem.text=Crack Passwords