Unify option handling code, reducing duplicate code while improving payload option handling and enabling payload handlers to be run in console.

git-svn-id: file:///home/svn/framework3/trunk@11895 4d416f70-5f16-0410-b530-b9f4589650da
unstable
Matt Weeks 2011-03-08 02:53:04 +00:00
parent 79903eb724
commit dafb085772
9 changed files with 417 additions and 478 deletions

Binary file not shown.

View File

@ -1511,20 +1511,19 @@ nameloop: for (int i = 0; i < names.length; i++) {
} }
}); });
jobsList.addMouseListener( new PopupMouseListener() { jobsList.addMouseListener( new PopupMouseListener() {
public void doubleClicked(MouseEvent e){ //show interaction window on double-click public void mouseClicked(MouseEvent e){
try{
Object obj = ((Map)rpcConn.execute("job.info", clickedJob)).get("info");
(new JobInfoPopup(null, true, obj)).setVisible(true);
}catch (MsfException xre) {
JOptionPane.showMessageDialog(null, "info failed " + xre);
}
}
public void showPopup(MouseEvent e) {
int indx = jobsList.locationToIndex(e.getPoint()); int indx = jobsList.locationToIndex(e.getPoint());
if(indx == -1) if (indx == -1)
return; return;
jobsList.setSelectedIndex(indx); jobsList.setSelectedIndex(indx);
clickedJob = jobsList.getSelectedValue().toString().split(" ")[0]; clickedJob = jobsList.getSelectedValue().toString().split(" ")[0];
if(e.getClickCount() > 1)
(new JobInfoPopup(null, true,
((Map)rpcConn.execute("job.info", clickedJob)).get("info"))).setVisible(true);
}
public void doubleClicked(MouseEvent e){
}
public void showPopup(MouseEvent e) {
jobPopupMenu.show(jobsList, e.getX(), e.getY() ); jobPopupMenu.show(jobsList, e.getX(), e.getY() );
} }
}); });

View File

@ -0,0 +1,275 @@
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.JOptionPane;
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);
titleLabel.setText("<html><h2>"+info.get("name")+ "</h2> <b>Rank:</b> "+Rank.toString(info.get("rank"))+"</html>");
Object references = info.get("references");
StringBuilder referenceString = new StringBuilder();
if(references != null){
List refList = (List)references;
if(refList.size() > 0)
referenceString.append("<br>References:<br>");
for(Object refo : refList){
List ref = (List)refo;
referenceString.append(ref.get(0)).append(": ").append(ref.get(1)).append("<br> ");
}
referenceString.append("<br>");
}
//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,
"<html><b>Description</b> "+info.get("description").toString().replaceAll("\\s+", " ")+referenceString+"</html>");
}catch(Exception ex){
javax.swing.JOptionPane.showMessageDialog(this, ex);
}
if(info.get("license") instanceof String){
licenseLabel.setText("<html><b>License:</b> "+ info.get("license")+"</html>");
}else{
List license = (List) info.get("license");
StringBuilder licenseString = new StringBuilder();
for(Object lic : license)
licenseString.append(lic).append(" ");
licenseLabel.setText("<html><b>License:</b> "+ licenseString+"</html>");
}
versionLabel.setText("<html><b>Version:</b> "+ info.get("version")+"</html>");
//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("<html><b>Authors:</b> "+ authorLine.toString()+"</html>");
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("<html><b>"+optionName.toString()+"</b> " + option.get("desc") + "</html>");
tempText.setBorder(null);
if(licenseLabel.getWidth() > 0)
tempText.setPreferredSize(new java.awt.Dimension(licenseLabel.getWidth(),authorsLabel.getHeight()*2));
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) {
JOptionPane.showMessageDialog(rootPane, ex);
}
}
/**
* 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"))
|| (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(boolean console, Map hash) throws MsfException, HeadlessException {
run(console,hash, moduleType, fullName);
}
/**
* Takes options the user has provided and runs the specified module
* @param console
* @param hash
* @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 (hash.containsKey("TARGET")
&& ((!options.containsKey("TARGET") && !hash.get("TARGET").equals("0"))
|| (options.containsKey("TARGET")
&& !hash.get("TARGET").equals(((Map) options.get("TARGET")).get("default"))))){
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() + " " + ent.getValue());
}
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"))
JOptionPane.showMessageDialog(rootPane, info);
}
MsfguiApp.addRecentModule(java.util.Arrays.asList(new Object[]{moduleType, fullName, hash}), rpcConn, parentFrame);
}
}

View File

@ -55,12 +55,8 @@
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="descriptionPane" alignment="0" pref="500" max="32767" attributes="0"/> <Component id="descriptionPane" alignment="0" pref="500" max="32767" attributes="0"/>
<Component id="authorsLabel" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="licenseLabel" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="versionLabel" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="targetsLabel" alignment="0" min="-2" pref="431" max="-2" attributes="0"/> <Component id="targetsLabel" alignment="0" min="-2" pref="431" max="-2" attributes="0"/>
<Component id="payloadScrollPane" alignment="0" pref="500" max="32767" attributes="0"/> <Component id="payloadScrollPane" alignment="0" pref="500" max="32767" attributes="0"/>
<Component id="titleLabel" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="requiredLabel" alignment="0" min="-2" max="-2" attributes="0"/> <Component id="requiredLabel" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="optionalLabel" alignment="0" min="-2" max="-2" attributes="0"/> <Component id="optionalLabel" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="advancedLabel" alignment="0" min="-2" max="-2" attributes="0"/> <Component id="advancedLabel" alignment="0" min="-2" max="-2" attributes="0"/>
@ -82,17 +78,9 @@
<DimensionLayout dim="1"> <DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/> <EmptySpace min="-2" pref="36" max="-2" attributes="0"/>
<Component id="titleLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="descriptionPane" min="-2" pref="122" max="-2" attributes="0"/> <Component id="descriptionPane" min="-2" pref="122" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace min="-2" pref="78" max="-2" attributes="0"/>
<Component id="authorsLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="licenseLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="versionLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="targetsLabel" min="-2" max="-2" attributes="0"/> <Component id="targetsLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="payloadScrollPane" min="-2" pref="296" max="-2" attributes="0"/> <Component id="payloadScrollPane" min="-2" pref="296" max="-2" attributes="0"/>
@ -118,30 +106,6 @@
</DimensionLayout> </DimensionLayout>
</Layout> </Layout>
<SubComponents> <SubComponents>
<Component class="javax.swing.JLabel" name="titleLabel">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="titleLabel.text"/>
<Property name="name" type="java.lang.String" value="titleLabel" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="authorsLabel">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="authorsLabel.text"/>
<Property name="name" type="java.lang.String" value="authorsLabel" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="licenseLabel">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="licenseLabel.text"/>
<Property name="name" type="java.lang.String" value="licenseLabel" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="versionLabel">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="versionLabel.text"/>
<Property name="name" type="java.lang.String" value="versionLabel" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="targetsLabel"> <Component class="javax.swing.JLabel" name="targetsLabel">
<Properties> <Properties>
<Property name="text" type="java.lang.String" resourceKey="targetsLabel.text"/> <Property name="text" type="java.lang.String" resourceKey="targetsLabel.text"/>
@ -206,6 +170,9 @@
<Property name="editable" type="boolean" value="false"/> <Property name="editable" type="boolean" value="false"/>
<Property name="name" type="java.lang.String" value="descriptionBox" noResource="true"/> <Property name="name" type="java.lang.String" value="descriptionBox" noResource="true"/>
</Properties> </Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="1"/>
</AuxValues>
</Component> </Component>
</SubComponents> </SubComponents>
</Container> </Container>

View File

@ -32,18 +32,10 @@ import javax.swing.tree.TreeSelectionModel;
* Displays a window showing options for a module, and support for running the module. * Displays a window showing options for a module, and support for running the module.
* @author scriptjunkie * @author scriptjunkie
*/ */
public class ModulePopup extends MsfFrame implements TreeSelectionListener{ public class ModulePopup extends ModuleInfoWindow implements TreeSelectionListener{
private JMenu recentMenu; private JMenu recentMenu;
private String moduleType;
private String fullName;
private RpcConnection rpcConn;
private String payload; private String payload;
private String target; private String target;
private ArrayList requiredOpts; // I love how these options aren't optional
private ArrayList optionalOpts;
private ArrayList advancedOpts;
private Map options;
private MainFrame parentFrame;
/** Creates new ModulePopup from recent run */ /** Creates new ModulePopup from recent run */
public ModulePopup(RpcConnection rpcConn, Object[] args, MainFrame parentFrame) { public ModulePopup(RpcConnection rpcConn, Object[] args, MainFrame parentFrame) {
@ -88,6 +80,10 @@ public class ModulePopup extends MsfFrame implements TreeSelectionListener{
initComponents(); initComponents();
exploitButton.setText("Run "+moduleType); exploitButton.setText("Run "+moduleType);
exploitButton1.setText("Run "+moduleType); exploitButton1.setText("Run "+moduleType);
exploitButton.setEnabled(false);
exploitButton1.setEnabled(false);
consoleRunButton.setEnabled(false);
consoleRunButton1.setEnabled(false);
this.moduleType = moduleType; this.moduleType = moduleType;
requiredOpts = new ArrayList(); requiredOpts = new ArrayList();
optionalOpts = new ArrayList(); optionalOpts = new ArrayList();
@ -127,40 +123,7 @@ public class ModulePopup extends MsfFrame implements TreeSelectionListener{
/** Displays targetsMap on frame */ /** Displays targetsMap on frame */
private void showModuleInfo(final RpcConnection rpcConn, final String fullName) throws HeadlessException { private void showModuleInfo(final RpcConnection rpcConn, final String fullName) throws HeadlessException {
try { //Get info try { //Get info
Map info = (Map) rpcConn.execute("module.info", moduleType, fullName); Map info = showBasicInfo(rpcConn, fullName);
//Basic info
setTitle(info.get("name") + " " + fullName);
titleLabel.setText("<html><h2>"+info.get("name")+ "</h2> <b>Rank:</b> "+Rank.toString(info.get("rank"))+"</html>");
Object references = info.get("references");
StringBuilder referenceString = new StringBuilder();
if(references != null){
List refList = (List)references;
referenceString.append("<br>References:<br>");
for(Object refo : refList){
List ref = (List)refo;
referenceString.append(ref.get(0)).append(": ").append(ref.get(1)).append("<br> ");
}
referenceString.append("<br>");
}
descriptionBox.setText("<html><b>Description</b> "+info.get("description").toString().replaceAll("\\s+", " ")+referenceString+"</html>");
if(info.get("license") instanceof String){
licenseLabel.setText("<html><b>License:</b> "+ info.get("license")+"</html>");
}else{
List license = (List) info.get("license");
StringBuilder licenseString = new StringBuilder();
for(Object lic : license)
licenseString.append(lic).append(" ");
licenseLabel.setText("<html><b>License:</b> "+ licenseString+"</html>");
}
versionLabel.setText("<html><b>Version:</b> "+ info.get("version")+"</html>");
//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("<html><b>Authors:</b> "+ authorLine.toString()+"</html>");
if(moduleType.equals("exploit")){ if(moduleType.equals("exploit")){
//Targets //Targets
Map targetsMap = (Map) info.get("targets"); Map targetsMap = (Map) info.get("targets");
@ -257,104 +220,20 @@ public class ModulePopup extends MsfFrame implements TreeSelectionListener{
/** Displays exploit and payload options. */ /** Displays exploit and payload options. */
private void showOptions() { private void showOptions() {
for(Object o : requiredOpts) exploitButton.setEnabled(true);
mainPanel.remove((Component)o); exploitButton1.setEnabled(true);
requiredOpts.clear(); consoleRunButton.setEnabled(true);
for(Object o : optionalOpts) consoleRunButton1.setEnabled(true);
mainPanel.remove((Component)o); showOptions(mainPanel, payload);
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")){
if(payload.length() <= 0){
JOptionPane.showMessageDialog(this, "You must select a payload.");
return;
}
options.putAll((Map) rpcConn.execute("module.options", "payload", payload.toString()));
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("<html><b>"+optionName.toString()+"</b> " + option.get("desc") + "</html>");
tempText.setBorder(null);
tempText.setPreferredSize(new java.awt.Dimension(descriptionBox.getWidth(),authorsLabel.getHeight()*2));
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) {
JOptionPane.showMessageDialog(rootPane, ex);
}
reGroup(); reGroup();
} }
/** Runs the exploit with given options and payload. Closes window if successful. */ /** Runs the exploit with given options and payload. Closes window if successful. */
private void runModule(boolean console) { private void runModule(boolean console) {
try{ try{// Get options
//Put options into request HashMap hash = getOptions(mainPanel);
HashMap hash = new HashMap();
//Exploit only stuff //Add exploit only options
if(moduleType.equals("exploit")){ if(moduleType.equals("exploit")){
if(payload.length() <= 0){ if(payload.length() <= 0){
JOptionPane.showMessageDialog(rootPane, "You must select a payload"); JOptionPane.showMessageDialog(rootPane, "You must select a payload");
@ -364,51 +243,8 @@ public class ModulePopup extends MsfFrame implements TreeSelectionListener{
target = buttonGroup.getSelection().getActionCommand(); target = buttonGroup.getSelection().getActionCommand();
hash.put("TARGET",target); hash.put("TARGET",target);
} }
//Get all options by looping over all components, and checking name //Actually run the module
for(Component comp : mainPanel.getComponents()){ run(console, hash);
if(!(comp instanceof JTextField) && !(comp instanceof JCheckBox))
continue;
JComponent optionField = (JComponent)comp;
String optName = optionField.getName().substring("field".length());
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"))
|| (defaultVal != null && ! optVal.toString().equals(defaultVal.toString())))
hash.put(optName, optVal.toString()); //msfrpcd likes strings. Give them strings.
}
//Execute and get results
if(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(hash.containsKey("TARGET") && ((!options.containsKey("TARGET") && !hash.get("TARGET").equals("0"))
|| (options.containsKey("TARGET") && !hash.get("TARGET").equals(((Map)options.get("TARGET")).get("default")))))
autoCommands.add("set TARGET "+hash.get("TARGET"));
if(hash.containsKey("PAYLOAD"))
autoCommands.add("set PAYLOAD "+hash.get("PAYLOAD"));
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()+" "+ent.getValue());
}
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{
Map info = (Map) rpcConn.execute("module.execute",moduleType, fullName,hash);
if(!info.get("result").equals("success"))
JOptionPane.showMessageDialog(rootPane, info);
}
MsfguiApp.addRecentModule(java.util.Arrays.asList(new Object[]{moduleType, fullName,hash}), rpcConn, parentFrame);
//close out //close out
this.setVisible(false); this.setVisible(false);
@ -509,10 +345,6 @@ public class ModulePopup extends MsfFrame implements TreeSelectionListener{
buttonGroup = new javax.swing.ButtonGroup(); buttonGroup = new javax.swing.ButtonGroup();
mainScrollPane = new javax.swing.JScrollPane(); mainScrollPane = new javax.swing.JScrollPane();
mainPanel = new javax.swing.JPanel(); mainPanel = new javax.swing.JPanel();
titleLabel = new javax.swing.JLabel();
authorsLabel = new javax.swing.JLabel();
licenseLabel = new javax.swing.JLabel();
versionLabel = new javax.swing.JLabel();
targetsLabel = new javax.swing.JLabel(); targetsLabel = new javax.swing.JLabel();
payloadScrollPane = new javax.swing.JScrollPane(); payloadScrollPane = new javax.swing.JScrollPane();
payloadTree = new javax.swing.JTree(); payloadTree = new javax.swing.JTree();
@ -533,18 +365,6 @@ public class ModulePopup extends MsfFrame implements TreeSelectionListener{
mainPanel.setName("mainPanel"); // NOI18N mainPanel.setName("mainPanel"); // NOI18N
org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(msfgui.MsfguiApp.class).getContext().getResourceMap(ModulePopup.class); org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(msfgui.MsfguiApp.class).getContext().getResourceMap(ModulePopup.class);
titleLabel.setText(resourceMap.getString("titleLabel.text")); // NOI18N
titleLabel.setName("titleLabel"); // NOI18N
authorsLabel.setText(resourceMap.getString("authorsLabel.text")); // NOI18N
authorsLabel.setName("authorsLabel"); // NOI18N
licenseLabel.setText(resourceMap.getString("licenseLabel.text")); // NOI18N
licenseLabel.setName("licenseLabel"); // NOI18N
versionLabel.setText(resourceMap.getString("versionLabel.text")); // NOI18N
versionLabel.setName("versionLabel"); // NOI18N
targetsLabel.setText(resourceMap.getString("targetsLabel.text")); // NOI18N targetsLabel.setText(resourceMap.getString("targetsLabel.text")); // NOI18N
targetsLabel.setName("targetsLabel"); // NOI18N targetsLabel.setName("targetsLabel"); // NOI18N
@ -612,13 +432,9 @@ public class ModulePopup extends MsfFrame implements TreeSelectionListener{
.addGroup(mainPanelLayout.createSequentialGroup() .addGroup(mainPanelLayout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(descriptionPane, javax.swing.GroupLayout.DEFAULT_SIZE, 497, Short.MAX_VALUE) .addComponent(descriptionPane, javax.swing.GroupLayout.DEFAULT_SIZE, 500, Short.MAX_VALUE)
.addComponent(authorsLabel)
.addComponent(licenseLabel)
.addComponent(versionLabel)
.addComponent(targetsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 431, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(targetsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 431, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(payloadScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 497, Short.MAX_VALUE) .addComponent(payloadScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 500, Short.MAX_VALUE)
.addComponent(titleLabel)
.addComponent(requiredLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .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(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) .addComponent(advancedLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
@ -635,17 +451,9 @@ public class ModulePopup extends MsfFrame implements TreeSelectionListener{
mainPanelLayout.setVerticalGroup( mainPanelLayout.setVerticalGroup(
mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(mainPanelLayout.createSequentialGroup() .addGroup(mainPanelLayout.createSequentialGroup()
.addContainerGap() .addGap(36, 36, 36)
.addComponent(titleLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(descriptionPane, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(descriptionPane, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGap(78, 78, 78)
.addComponent(authorsLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(licenseLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(versionLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(targetsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(targetsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(payloadScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 296, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(payloadScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 296, javax.swing.GroupLayout.PREFERRED_SIZE)
@ -700,15 +508,13 @@ public class ModulePopup extends MsfFrame implements TreeSelectionListener{
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel advancedLabel; private javax.swing.JLabel advancedLabel;
private javax.swing.JLabel authorsLabel;
private javax.swing.ButtonGroup buttonGroup; private javax.swing.ButtonGroup buttonGroup;
private javax.swing.JButton consoleRunButton; private javax.swing.JButton consoleRunButton;
private javax.swing.JButton consoleRunButton1; private javax.swing.JButton consoleRunButton1;
private javax.swing.JEditorPane descriptionBox; public javax.swing.JEditorPane descriptionBox;
private javax.swing.JScrollPane descriptionPane; private javax.swing.JScrollPane descriptionPane;
private javax.swing.JButton exploitButton; private javax.swing.JButton exploitButton;
private javax.swing.JButton exploitButton1; private javax.swing.JButton exploitButton1;
private javax.swing.JLabel licenseLabel;
private javax.swing.JPanel mainPanel; private javax.swing.JPanel mainPanel;
private javax.swing.JScrollPane mainScrollPane; private javax.swing.JScrollPane mainScrollPane;
private javax.swing.JLabel optionalLabel; private javax.swing.JLabel optionalLabel;
@ -716,7 +522,5 @@ public class ModulePopup extends MsfFrame implements TreeSelectionListener{
private javax.swing.JTree payloadTree; private javax.swing.JTree payloadTree;
private javax.swing.JLabel requiredLabel; private javax.swing.JLabel requiredLabel;
private javax.swing.JLabel targetsLabel; private javax.swing.JLabel targetsLabel;
private javax.swing.JLabel titleLabel;
private javax.swing.JLabel versionLabel;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
} }

View File

@ -57,16 +57,12 @@
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<Component id="outputScrollPane" pref="1077" max="32767" attributes="0"/> <Component id="outputScrollPane" pref="1115" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
</Group> </Group>
<Group type="102" alignment="1" attributes="0"> <Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="1" attributes="0"> <Group type="103" groupAlignment="1" attributes="0">
<Component id="titleLabel" alignment="0" min="-2" max="-2" attributes="0"/> <Component id="descriptionBox" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="descriptionLabel" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="authorsLabel" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="licenseLabel" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="versionLabel" alignment="0" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<Component id="generateButton" min="-2" max="-2" attributes="0"/> <Component id="generateButton" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
@ -75,6 +71,8 @@
<Component id="saveButton" min="-2" max="-2" attributes="0"/> <Component id="saveButton" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="handleButton" min="-2" max="-2" attributes="0"/> <Component id="handleButton" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="handleConsoleButton" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<Group type="102" alignment="1" attributes="0"> <Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
@ -118,22 +116,15 @@
<DimensionLayout dim="1"> <DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/> <EmptySpace min="-2" pref="36" max="-2" attributes="0"/>
<Component id="titleLabel" min="-2" max="-2" attributes="0"/> <Component id="descriptionBox" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace min="-2" pref="78" max="-2" attributes="0"/>
<Component id="descriptionLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="authorsLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="licenseLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="versionLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="3" attributes="0">
<Component id="generateButton" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="generateButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="displayButton" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="displayButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="saveButton" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="saveButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="handleButton" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="handleButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="handleConsoleButton" alignment="3" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="outputScrollPane" pref="437" max="32767" attributes="0"/> <Component id="outputScrollPane" pref="437" max="32767" attributes="0"/>
@ -259,17 +250,14 @@
<Property name="name" type="java.lang.String" value="archField" noResource="true"/> <Property name="name" type="java.lang.String" value="archField" noResource="true"/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JLabel" name="descriptionLabel"> <Component class="javax.swing.JLabel" name="descriptionBox">
<Properties> <Properties>
<Property name="text" type="java.lang.String" resourceKey="descriptionLabel.text"/> <Property name="text" type="java.lang.String" resourceKey="descriptionBox.text"/>
<Property name="name" type="java.lang.String" value="descriptionLabel" noResource="true"/> <Property name="name" type="java.lang.String" value="descriptionBox" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="titleLabel">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="titleLabel.text"/>
<Property name="name" type="java.lang.String" value="titleLabel" noResource="true"/>
</Properties> </Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="1"/>
</AuxValues>
</Component> </Component>
<Component class="javax.swing.JLabel" name="encoderLabel"> <Component class="javax.swing.JLabel" name="encoderLabel">
<Properties> <Properties>
@ -286,24 +274,6 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="generateButtonActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="generateButtonActionPerformed"/>
</Events> </Events>
</Component> </Component>
<Component class="javax.swing.JLabel" name="versionLabel">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="versionLabel.text"/>
<Property name="name" type="java.lang.String" value="versionLabel" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="licenseLabel">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="licenseLabel.text"/>
<Property name="name" type="java.lang.String" value="licenseLabel" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="authorsLabel">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="authorsLabel.text"/>
<Property name="name" type="java.lang.String" value="authorsLabel" noResource="true"/>
</Properties>
</Component>
<Container class="javax.swing.JScrollPane" name="outputScrollPane"> <Container class="javax.swing.JScrollPane" name="outputScrollPane">
<Properties> <Properties>
<Property name="horizontalScrollBarPolicy" type="int" value="31"/> <Property name="horizontalScrollBarPolicy" type="int" value="31"/>
@ -391,6 +361,15 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="handleButtonActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="handleButtonActionPerformed"/>
</Events> </Events>
</Component> </Component>
<Component class="javax.swing.JButton" name="handleConsoleButton">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="handleConsoleButton.text"/>
<Property name="name" type="java.lang.String" value="handleConsoleButton" noResource="true"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="handleConsoleButtonActionPerformed"/>
</Events>
</Component>
</SubComponents> </SubComponents>
</Container> </Container>
</SubComponents> </SubComponents>

View File

@ -13,28 +13,24 @@ import javax.swing.GroupLayout;
import javax.swing.GroupLayout.ParallelGroup; import javax.swing.GroupLayout.ParallelGroup;
import javax.swing.GroupLayout.SequentialGroup; import javax.swing.GroupLayout.SequentialGroup;
import javax.swing.JFileChooser; import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.JTextField;
/** /**
* Popup for generating payloads and starting handlers. * Popup for generating payloads and starting handlers.
* @author scriptjunkie * @author scriptjunkie
*/ */
public class PayloadPopup extends MsfFrame { public class PayloadPopup extends ModuleInfoWindow {
private RpcConnection rpcConn;
private ArrayList elementVector;
private String fullName;
private MainFrame mainFrame;
private Map options;
/** Creates new form PayloadPopup */ /** Creates new form PayloadPopup */
public PayloadPopup(String fullName, RpcConnection rpcConn, MainFrame frame) { public PayloadPopup(String fullName, RpcConnection rpcConn, MainFrame frame) {
mainFrame = frame; moduleType = "payload";
parentFrame = frame;
initComponents(); initComponents();
outputPathField.setText(MsfguiApp.getTempFolder()+File.separator+"msf.exe"); outputPathField.setText(MsfguiApp.getTempFolder()+File.separator+"msf.exe");
this.rpcConn = rpcConn; this.rpcConn = rpcConn;
elementVector = new ArrayList(); requiredOpts = new ArrayList();
optionalOpts = requiredOpts;
advancedOpts = requiredOpts;
this.fullName = fullName; this.fullName = fullName;
showOptions(fullName); showOptions(fullName);
@ -52,6 +48,13 @@ public class PayloadPopup extends MsfFrame {
setSize(800, 700); setSize(800, 700);
} }
private void doRun(boolean console) {
Map hash = getOptions(mainPanel);
hash.put("PAYLOAD", fullName);
hash.put("TARGET", "0");
run(console, hash, "exploit", "multi/handler");
}
/** Resets group layout displaying appropriate elements */ /** Resets group layout displaying appropriate elements */
private void resetLayout(){ private void resetLayout(){
boolean saving = saveButton.isSelected(); boolean saving = saveButton.isSelected();
@ -76,12 +79,12 @@ public class PayloadPopup extends MsfFrame {
//HORIZONTAL GROUPING //HORIZONTAL GROUPING
ParallelGroup labelGroup = mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING); ParallelGroup labelGroup = mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING);
//make label group //make label group
for(int i = 0; i < elementVector.size(); i++) for(int i = 0; i < optionalOpts.size(); i+= 2)
labelGroup = labelGroup.addComponent(((Component[])elementVector.get(i))[0], javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE); labelGroup = labelGroup.addComponent((Component)optionalOpts.get(i), javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE);
//make text box group //make text box group
ParallelGroup textBoxGroup = mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING); ParallelGroup textBoxGroup = mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING);
for(int i = 0; i < elementVector.size(); i++) for(int i = 1; i < optionalOpts.size(); i+= 2)
textBoxGroup = textBoxGroup.addComponent(((Component[])elementVector.get(i))[1]); textBoxGroup = textBoxGroup.addComponent((Component)optionalOpts.get(i));
//put it together //put it together
mainPanelLayout.setHorizontalGroup( mainPanelLayout.setHorizontalGroup(
mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -89,7 +92,7 @@ public class PayloadPopup extends MsfFrame {
.addContainerGap() .addContainerGap()
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(titleLabel) .addComponent(titleLabel)
.addComponent(descriptionLabel) .addComponent(descriptionBox)
.addComponent(authorsLabel) .addComponent(authorsLabel)
.addComponent(licenseLabel) .addComponent(licenseLabel)
.addComponent(versionLabel) .addComponent(versionLabel)
@ -105,7 +108,9 @@ public class PayloadPopup extends MsfFrame {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(saveButton) .addComponent(saveButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(handleButton)) .addComponent(handleButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(handleConsoleButton))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup()
.addComponent(outputScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 40, Short.MAX_VALUE) .addComponent(outputScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 40, Short.MAX_VALUE)
.addContainerGap()) .addContainerGap())
@ -139,18 +144,18 @@ public class PayloadPopup extends MsfFrame {
SequentialGroup groupie = mainPanelLayout.createSequentialGroup(). SequentialGroup groupie = mainPanelLayout.createSequentialGroup().
addComponent(titleLabel). addComponent(titleLabel).
addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED). addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).
addComponent(descriptionLabel). addComponent(descriptionBox).
addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED). addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).
addComponent(authorsLabel). addComponent(authorsLabel).
addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED). addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).
addComponent(licenseLabel). addComponent(licenseLabel).
addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED). addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).
addComponent(versionLabel); addComponent(versionLabel);
for(int i = 0; i < elementVector.size(); i++){ for(int i = 0; i < optionalOpts.size(); i+=2){
groupie = groupie.addGroup(mainPanelLayout.createParallelGroup( groupie = groupie.addGroup(mainPanelLayout.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE) javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(((Component[])elementVector.get(i))[0]) //LABEL .addComponent((Component)optionalOpts.get(i)) //LABEL
.addComponent(((Component[])elementVector.get(i))[1], //TEXT BOX .addComponent((Component)optionalOpts.get(i+1), //TEXT BOX
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)) javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED); .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED);
@ -160,7 +165,8 @@ public class PayloadPopup extends MsfFrame {
.addComponent(generateButton) .addComponent(generateButton)
.addComponent(displayButton) .addComponent(displayButton)
.addComponent(saveButton) .addComponent(saveButton)
.addComponent(handleButton)) .addComponent(handleButton)
.addComponent(handleConsoleButton))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(outputScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 30, Short.MAX_VALUE) .addComponent(outputScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 30, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
@ -196,55 +202,9 @@ public class PayloadPopup extends MsfFrame {
} }
/** Displays payload info and options. */ /** Displays payload info and options. */
private void showOptions(String fullName) { private void showOptions(String fullName) {
try { Map info = showBasicInfo(rpcConn, fullName);
Map info = (Map) rpcConn.execute("module.info", "payload", fullName); showOptions(mainPanel, null);
//Basic info
setTitle(info.get("name") + " " + fullName);
titleLabel.setText("<html><h2>"+info.get("name")+ "</h2></html>");
//wrapLabelText(descriptionLabel, info.get("description").toString().replace("\n", " "));
descriptionLabel.setText(info.get("description").toString().replace("\n", " "));
if(info.get("license") instanceof String){
licenseLabel.setText("<html><b>License:</b> "+ info.get("license")+"</html>");
}else{
List license = (List) info.get("license");
StringBuilder licenseString = new StringBuilder();
for(Object lic : license)
licenseString.append(lic).append(" ");
licenseLabel.setText("<html><b>License:</b> "+ licenseString+"</html>");
}
versionLabel.setText("<html><b>Version:</b> "+ info.get("version")+"</html>");
//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("<html><b>Authors:</b> "+ authorLine.toString()+"</html>");
//display options
options = (Map) rpcConn.execute("module.options", "payload", fullName);
for (Object optionName : options.keySet())
addOption(optionName, (Map)options.get(optionName));
resetLayout(); resetLayout();
} catch (MsfException ex) {
JOptionPane.showMessageDialog(rootPane, ex);
}
}
private void addOption(Object optionName, Map option) {
JLabel lab = new JLabel();
mainPanel.add(lab);
lab.setText("<html><b>"+optionName.toString()+"</b> " + option.get("desc") + "</html>");
lab.setName(optionName.toString());
JTextField optionField = new JTextField();
if (option.get("default") != null)
optionField.setText(option.get("default").toString());
else if (optionName.equals("LHOST"))
optionField.setText(MsfguiApp.getLocalIp());
optionField.setName("field" + optionName);
mainPanel.add(optionField);
elementVector.add(new Component[]{lab,optionField});
} }
/** This method is called from within the constructor to /** This method is called from within the constructor to
@ -268,13 +228,9 @@ public class PayloadPopup extends MsfFrame {
outputLabel = new javax.swing.JLabel(); outputLabel = new javax.swing.JLabel();
timesLabel = new javax.swing.JLabel(); timesLabel = new javax.swing.JLabel();
archField = new javax.swing.JTextField(); archField = new javax.swing.JTextField();
descriptionLabel = new javax.swing.JLabel(); descriptionBox = new javax.swing.JLabel();
titleLabel = new javax.swing.JLabel();
encoderLabel = new javax.swing.JLabel(); encoderLabel = new javax.swing.JLabel();
generateButton = new javax.swing.JButton(); generateButton = new javax.swing.JButton();
versionLabel = new javax.swing.JLabel();
licenseLabel = new javax.swing.JLabel();
authorsLabel = new javax.swing.JLabel();
outputScrollPane = new javax.swing.JScrollPane(); outputScrollPane = new javax.swing.JScrollPane();
outputPane = new javax.swing.JTextArea(); outputPane = new javax.swing.JTextArea();
displayButton = new javax.swing.JRadioButton(); displayButton = new javax.swing.JRadioButton();
@ -285,6 +241,7 @@ public class PayloadPopup extends MsfFrame {
templateLabel = new javax.swing.JLabel(); templateLabel = new javax.swing.JLabel();
templateField = new javax.swing.JTextField(); templateField = new javax.swing.JTextField();
handleButton = new javax.swing.JButton(); handleButton = new javax.swing.JButton();
handleConsoleButton = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setName("Form"); // NOI18N setName("Form"); // NOI18N
@ -328,11 +285,8 @@ public class PayloadPopup extends MsfFrame {
archField.setText(resourceMap.getString("archField.text")); // NOI18N archField.setText(resourceMap.getString("archField.text")); // NOI18N
archField.setName("archField"); // NOI18N archField.setName("archField"); // NOI18N
descriptionLabel.setText(resourceMap.getString("descriptionLabel.text")); // NOI18N descriptionBox.setText(resourceMap.getString("descriptionBox.text")); // NOI18N
descriptionLabel.setName("descriptionLabel"); // NOI18N descriptionBox.setName("descriptionBox"); // NOI18N
titleLabel.setText(resourceMap.getString("titleLabel.text")); // NOI18N
titleLabel.setName("titleLabel"); // NOI18N
encoderLabel.setText(resourceMap.getString("encoderLabel.text")); // NOI18N encoderLabel.setText(resourceMap.getString("encoderLabel.text")); // NOI18N
encoderLabel.setName("encoderLabel"); // NOI18N encoderLabel.setName("encoderLabel"); // NOI18N
@ -345,15 +299,6 @@ public class PayloadPopup extends MsfFrame {
} }
}); });
versionLabel.setText(resourceMap.getString("versionLabel.text")); // NOI18N
versionLabel.setName("versionLabel"); // NOI18N
licenseLabel.setText(resourceMap.getString("licenseLabel.text")); // NOI18N
licenseLabel.setName("licenseLabel"); // NOI18N
authorsLabel.setText(resourceMap.getString("authorsLabel.text")); // NOI18N
authorsLabel.setName("authorsLabel"); // NOI18N
outputScrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); outputScrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
outputScrollPane.setName("outputScrollPane"); // NOI18N outputScrollPane.setName("outputScrollPane"); // NOI18N
@ -409,6 +354,14 @@ public class PayloadPopup extends MsfFrame {
} }
}); });
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);
}
});
javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel); javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
mainPanel.setLayout(mainPanelLayout); mainPanel.setLayout(mainPanelLayout);
mainPanelLayout.setHorizontalGroup( mainPanelLayout.setHorizontalGroup(
@ -417,15 +370,11 @@ public class PayloadPopup extends MsfFrame {
.addContainerGap() .addContainerGap()
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(mainPanelLayout.createSequentialGroup() .addGroup(mainPanelLayout.createSequentialGroup()
.addComponent(outputScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 1026, Short.MAX_VALUE) .addComponent(outputScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 1115, Short.MAX_VALUE)
.addContainerGap()) .addContainerGap())
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup()
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(titleLabel, javax.swing.GroupLayout.Alignment.LEADING) .addComponent(descriptionBox, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(descriptionLabel, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(authorsLabel, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(licenseLabel, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(versionLabel, javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, mainPanelLayout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.LEADING, mainPanelLayout.createSequentialGroup()
.addComponent(generateButton) .addComponent(generateButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
@ -433,7 +382,9 @@ public class PayloadPopup extends MsfFrame {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(saveButton) .addComponent(saveButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(handleButton)) .addComponent(handleButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(handleConsoleButton))
.addGroup(mainPanelLayout.createSequentialGroup() .addGroup(mainPanelLayout.createSequentialGroup()
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
@ -446,13 +397,13 @@ public class PayloadPopup extends MsfFrame {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(mainPanelLayout.createSequentialGroup() .addGroup(mainPanelLayout.createSequentialGroup()
.addComponent(templateField, javax.swing.GroupLayout.DEFAULT_SIZE, 218, Short.MAX_VALUE) .addComponent(templateField, javax.swing.GroupLayout.DEFAULT_SIZE, 269, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(templateButton, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(templateButton, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(archField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 311, Short.MAX_VALUE) .addComponent(archField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 362, Short.MAX_VALUE)
.addComponent(timesField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 311, Short.MAX_VALUE) .addComponent(timesField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 362, Short.MAX_VALUE)
.addComponent(outputCombo, javax.swing.GroupLayout.Alignment.LEADING, 0, 311, Short.MAX_VALUE) .addComponent(outputCombo, javax.swing.GroupLayout.Alignment.LEADING, 0, 362, Short.MAX_VALUE)
.addComponent(encoderCombo, javax.swing.GroupLayout.Alignment.LEADING, 0, 311, Short.MAX_VALUE) .addComponent(encoderCombo, javax.swing.GroupLayout.Alignment.LEADING, 0, 362, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, mainPanelLayout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.LEADING, mainPanelLayout.createSequentialGroup()
.addComponent(outputPathField, javax.swing.GroupLayout.PREFERRED_SIZE, 213, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(outputPathField, javax.swing.GroupLayout.PREFERRED_SIZE, 213, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
@ -465,24 +416,17 @@ public class PayloadPopup extends MsfFrame {
mainPanelLayout.setVerticalGroup( mainPanelLayout.setVerticalGroup(
mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(mainPanelLayout.createSequentialGroup() .addGroup(mainPanelLayout.createSequentialGroup()
.addContainerGap() .addGap(36, 36, 36)
.addComponent(titleLabel) .addComponent(descriptionBox)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGap(78, 78, 78)
.addComponent(descriptionLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(authorsLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(licenseLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(versionLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(generateButton) .addComponent(generateButton)
.addComponent(displayButton) .addComponent(displayButton)
.addComponent(saveButton) .addComponent(saveButton)
.addComponent(handleButton)) .addComponent(handleButton)
.addComponent(handleConsoleButton))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(outputScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 374, Short.MAX_VALUE) .addComponent(outputScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 437, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(outputPathLabel) .addComponent(outputPathLabel)
@ -531,14 +475,8 @@ public class PayloadPopup extends MsfFrame {
private void generateButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_generateButtonActionPerformed private void generateButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_generateButtonActionPerformed
try { try {
Map options = new HashMap(); HashMap hash = getOptions(mainPanel);
for(Object obj : elementVector){ Map data = (Map) rpcConn.execute("module.execute", "payload", fullName,hash);
String name = ((JLabel)((Component[])obj)[0]).getName();
String val = ((JTextField)((Component[])obj)[1]).getText();
if(val.length() > 0)
options.put(name, val);
}
Map data = (Map) rpcConn.execute("module.execute", "payload", fullName,options);
//Basic info //Basic info
if(!data.get("result").equals("success")) if(!data.get("result").equals("success"))
return; return;
@ -549,25 +487,25 @@ public class PayloadPopup extends MsfFrame {
for (int i = 0; i < rawHex.length(); i += 2) for (int i = 0; i < rawHex.length(); i += 2)
buffer[i/2] = (byte)Integer.parseInt(rawHex.substring(i, i + 2),16); buffer[i/2] = (byte)Integer.parseInt(rawHex.substring(i, i + 2),16);
options.put("format", outputCombo.getSelectedItem().toString()); hash.put("format", outputCombo.getSelectedItem().toString());
if(timesField.getText().length() > 0) if(timesField.getText().length() > 0)
options.put("ecount", timesField.getText()); hash.put("ecount", timesField.getText());
if(archField.getText().length() > 0) if(archField.getText().length() > 0)
options.put("arch", archField.getText()); hash.put("arch", archField.getText());
if(templateField.getText().length() > 0){ if(templateField.getText().length() > 0){
options.put("altexe", templateField.getText()); hash.put("altexe", templateField.getText());
if(templateWorkingCheck.isSelected()) if(templateWorkingCheck.isSelected())
options.put("inject", true); hash.put("inject", true);
} }
Map encoded = (Map) rpcConn.execute("module.encode", Base64.encode(buffer), Map encoded = (Map) rpcConn.execute("module.encode", Base64.encode(buffer),
encoderCombo.getSelectedItem().toString(),options); encoderCombo.getSelectedItem().toString(),hash);
FileOutputStream fout = new FileOutputStream(outputPathField.getText()); FileOutputStream fout = new FileOutputStream(outputPathField.getText());
fout.write(Base64.decode(encoded.get("encoded").toString())); fout.write(Base64.decode(encoded.get("encoded").toString()));
fout.close(); fout.close();
return; return;
} }
outputPane.setText("Payload "+fullName+" "+options+" "+(rawHex.length()/2)+" bytes."); outputPane.setText("Payload "+fullName+" "+hash+" "+(rawHex.length()/2)+" bytes.");
boolean isPlain = true; boolean isPlain = true;
StringBuilder plain = new StringBuilder(""); StringBuilder plain = new StringBuilder("");
for(int i = 0; i < rawHex.length(); i += 2){ for(int i = 0; i < rawHex.length(); i += 2){
@ -616,40 +554,26 @@ public class PayloadPopup extends MsfFrame {
}//GEN-LAST:event_templateButtonActionPerformed }//GEN-LAST:event_templateButtonActionPerformed
private void handleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_handleButtonActionPerformed private void handleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_handleButtonActionPerformed
Map hash = new HashMap(); doRun(false);
for(Object obj : elementVector){
String optName = ((JLabel)((Component[])obj)[0]).getName();
String optVal = ((JTextField)((Component[])obj)[1]).getText();
Object defaultVal = ((Map)options.get(optName)).get("default");
//only need non-default vals
if(defaultVal == null && optVal.length() > 0 && (!optName.equals("WORKSPACE") || !optVal.equals("default"))
|| (defaultVal != null && !optVal.equals(defaultVal.toString())))
hash.put(optName, optVal);
}
hash.put("PAYLOAD",fullName);
hash.put("TARGET","0");
try{
rpcConn.execute("module.execute","exploit", "multi/handler", hash);
MsfguiApp.addRecentModule(java.util.Arrays.asList(new Object[]{"exploit", "multi/handler", hash}), rpcConn, mainFrame);
}catch (MsfException ex){
JOptionPane.showMessageDialog(this, ex);
}
}//GEN-LAST:event_handleButtonActionPerformed }//GEN-LAST:event_handleButtonActionPerformed
private void handleConsoleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_handleConsoleButtonActionPerformed
doRun(true);
}//GEN-LAST:event_handleConsoleButtonActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTextField archField; private javax.swing.JTextField archField;
private javax.swing.JLabel archLabel; private javax.swing.JLabel archLabel;
private javax.swing.JLabel authorsLabel;
private javax.swing.ButtonGroup buttonGroup1; private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.JButton choosePathButton; private javax.swing.JButton choosePathButton;
private javax.swing.JLabel descriptionLabel; public javax.swing.JLabel descriptionBox;
private javax.swing.JRadioButton displayButton; private javax.swing.JRadioButton displayButton;
private javax.swing.JComboBox encoderCombo; private javax.swing.JComboBox encoderCombo;
private javax.swing.JLabel encoderLabel; private javax.swing.JLabel encoderLabel;
private javax.swing.JButton generateButton; private javax.swing.JButton generateButton;
private javax.swing.JButton handleButton; private javax.swing.JButton handleButton;
private javax.swing.JButton handleConsoleButton;
private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JLabel licenseLabel;
private javax.swing.JPanel mainPanel; private javax.swing.JPanel mainPanel;
private javax.swing.JComboBox outputCombo; private javax.swing.JComboBox outputCombo;
private javax.swing.JLabel outputLabel; private javax.swing.JLabel outputLabel;
@ -664,8 +588,6 @@ public class PayloadPopup extends MsfFrame {
private javax.swing.JCheckBox templateWorkingCheck; private javax.swing.JCheckBox templateWorkingCheck;
private javax.swing.JTextField timesField; private javax.swing.JTextField timesField;
private javax.swing.JLabel timesLabel; private javax.swing.JLabel timesLabel;
private javax.swing.JLabel titleLabel;
private javax.swing.JLabel versionLabel;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
} }

View File

@ -1,9 +1,5 @@
authorsLabel.text=Authors
licenseLabel.text=License
versionLabel.text=Version
targetsLabel.text=<html><h2>Targets</h2></html> targetsLabel.text=<html><h2>Targets</h2></html>
exploitButton.text=Run Exploit exploitButton.text=Run Exploit
titleLabel.text=Title
requiredLabel.text=<html><h2>Required</h2></html> requiredLabel.text=<html><h2>Required</h2></html>
optionalLabel.text=<html><h2>Optional</h2></html> optionalLabel.text=<html><h2>Optional</h2></html>
main.icon=msf_file.png main.icon=msf_file.png

View File

@ -1,8 +1,3 @@
versionLabel.text=Version
licenseLabel.text=License
authorsLabel.text=Authors
descriptionLabel.text=Description
titleLabel.text=Title
main.icon=msf_file.png main.icon=msf_file.png
jScrollPane2.TabConstraints.tabTitle=payload jScrollPane2.TabConstraints.tabTitle=payload
jLabel6.text=Platform jLabel6.text=Platform
@ -22,3 +17,5 @@ choosePathButton.text=Choose...
outputPathLabel.text=Output Path outputPathLabel.text=Output Path
templateLabel.text=(win32 only) exe template templateLabel.text=(win32 only) exe template
handleButton.text=Start handler handleButton.text=Start handler
handleConsoleButton.text=Start handler in console
descriptionBox.text=Description