Remove XML RPC option for msfgui.

This commit is contained in:
scriptjunkie 2011-12-11 14:44:12 -06:00
parent 1d244c4b27
commit e34555dc22
9 changed files with 47 additions and 141 deletions

Binary file not shown.

View File

@ -97,15 +97,9 @@ public class MsfTable extends javax.swing.JTable {
if(!force && !DraggableTabbedPane.isVisible(this))
return; //Don't re-add if not visible
try {
Object arg;
if(rpcConn.type.equals("XML") && (dbTable.equals("events") || dbTable.equals("loots"))){
arg = MsfguiApp.workspace;
} else {
HashMap argM = new HashMap(10);
argM.put("workspace", MsfguiApp.workspace);
argM.put("offset", offset);
arg = argM;
}
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;

View File

@ -44,24 +44,18 @@
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="disableDbButton" min="-2" max="-2" attributes="0"/>
<Component id="usernameField" alignment="0" pref="427" max="32767" attributes="0"/>
<Component id="hostField" alignment="0" pref="427" max="32767" attributes="0"/>
<Component id="passwordField" alignment="0" pref="427" max="32767" attributes="0"/>
<Component id="portField" alignment="0" pref="427" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="sslBox" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="250" max="32767" attributes="0"/>
<Component id="xmlButton" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="msgpackButton" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="usernameField" alignment="0" pref="433" max="32767" attributes="0"/>
<Component id="hostField" alignment="0" pref="433" max="32767" attributes="0"/>
<Component id="passwordField" alignment="0" pref="433" max="32767" attributes="0"/>
<Component id="portField" alignment="0" pref="433" max="32767" attributes="0"/>
<Component id="sslBox" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="startNewButton" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="pathButton" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="126" max="32767" attributes="0"/>
<EmptySpace pref="132" max="32767" attributes="0"/>
<Component id="cancelButton" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="connectButton" min="-2" max="-2" attributes="0"/>
@ -97,22 +91,14 @@
<Component id="portLabel" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="1" max="-2" attributes="0">
<Component id="sslBox" alignment="0" min="0" pref="0" max="32767" attributes="1"/>
<Component id="sslLabel" alignment="0" max="32767" attributes="1"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="disableDbLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="disableDbButton" alignment="3" min="-2" pref="18" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="103" alignment="0" groupAlignment="3" attributes="0">
<Component id="msgpackButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="xmlButton" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="103" groupAlignment="1" max="-2" attributes="0">
<Component id="sslBox" alignment="0" min="0" pref="0" max="32767" attributes="1"/>
<Component id="sslLabel" alignment="0" max="32767" attributes="1"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="disableDbLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="disableDbButton" alignment="3" min="-2" pref="18" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
@ -268,24 +254,5 @@
<Property name="name" type="java.lang.String" value="disableDbButton" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JRadioButton" name="xmlButton">
<Properties>
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
<ComponentRef name="buttonGroup1"/>
</Property>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" resourceKey="xmlButton.text"/>
<Property name="name" type="java.lang.String" value="xmlButton" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JRadioButton" name="msgpackButton">
<Properties>
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
<ComponentRef name="buttonGroup1"/>
</Property>
<Property name="text" type="java.lang.String" resourceKey="msgpackButton.text"/>
<Property name="name" type="java.lang.String" value="msgpackButton" noResource="true"/>
</Properties>
</Component>
</SubComponents>
</Form>

View File

@ -104,7 +104,7 @@ public class OpenConnectionDialog extends javax.swing.JDialog {
int port = Integer.parseInt(info.get("port").toString());
boolean ssl = Boolean.parseBoolean(info.get("ssl").toString());
String type = info.get("type").toString();
RpcConnection rpc = RpcConnection.getConn(type, username, password.toCharArray(), host, port, ssl);
RpcConnection rpc = RpcConnection.getConn(username, password.toCharArray(), host, port, ssl);
if(javax.swing.JOptionPane.showConfirmDialog(null, "Connect to last remembered rpcd?") == javax.swing.JOptionPane.YES_OPTION)
return rpc;
rpc.execute("auth.logout");
@ -154,8 +154,6 @@ public class OpenConnectionDialog extends javax.swing.JDialog {
sslLabel = new javax.swing.JLabel();
disableDbLabel = new javax.swing.JLabel();
disableDbButton = new javax.swing.JCheckBox();
xmlButton = new javax.swing.JRadioButton();
msgpackButton = new javax.swing.JRadioButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(msfgui.MsfguiApp.class).getContext().getResourceMap(OpenConnectionDialog.class);
@ -255,15 +253,6 @@ public class OpenConnectionDialog extends javax.swing.JDialog {
disableDbButton.setText(resourceMap.getString("disableDbButton.text")); // NOI18N
disableDbButton.setName("disableDbButton"); // NOI18N
buttonGroup1.add(xmlButton);
xmlButton.setSelected(true);
xmlButton.setText(resourceMap.getString("xmlButton.text")); // NOI18N
xmlButton.setName("xmlButton"); // NOI18N
buttonGroup1.add(msgpackButton);
msgpackButton.setText(resourceMap.getString("msgpackButton.text")); // NOI18N
msgpackButton.setName("msgpackButton"); // NOI18N
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
@ -284,21 +273,16 @@ public class OpenConnectionDialog extends javax.swing.JDialog {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(disableDbButton)
.addComponent(usernameField, javax.swing.GroupLayout.DEFAULT_SIZE, 427, Short.MAX_VALUE)
.addComponent(hostField, javax.swing.GroupLayout.DEFAULT_SIZE, 427, Short.MAX_VALUE)
.addComponent(passwordField, javax.swing.GroupLayout.DEFAULT_SIZE, 427, Short.MAX_VALUE)
.addComponent(portField, javax.swing.GroupLayout.DEFAULT_SIZE, 427, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(sslBox)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 250, Short.MAX_VALUE)
.addComponent(xmlButton)
.addGap(18, 18, 18)
.addComponent(msgpackButton))))
.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, 126, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 132, Short.MAX_VALUE)
.addComponent(cancelButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(connectButton)))
@ -326,18 +310,13 @@ public class OpenConnectionDialog extends javax.swing.JDialog {
.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.LEADING)
.addGroup(layout.createSequentialGroup()
.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)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(msgpackButton)
.addComponent(xmlButton)))
.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)
@ -356,11 +335,8 @@ public class OpenConnectionDialog extends javax.swing.JDialog {
String host = hostField.getText();
int port = Integer.parseInt(portField.getText());
boolean ssl = checkCrypto(sslBox.isSelected());
String type = "xml";
if(msgpackButton.isSelected())
type = "msg";
try {
rpcConn = RpcConnection.getConn(type, username, password, host, port, ssl);
rpcConn = RpcConnection.getConn(username, password, host, port, ssl);
} catch (MsfException mex) {
rpcConn = null;
}
@ -390,10 +366,6 @@ public class OpenConnectionDialog extends javax.swing.JDialog {
private void startNewButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_startNewButtonActionPerformed
//Setup defaults
if(msgpackButton.isSelected())
RpcConnection.defaultType = "msg";
else
RpcConnection.defaultType = "xml";
RpcConnection.defaultUser = usernameField.getText();
if(passwordField.getPassword().length > 0)
RpcConnection.defaultPass = new String(passwordField.getPassword());
@ -434,7 +406,6 @@ public class OpenConnectionDialog extends javax.swing.JDialog {
private javax.swing.JLabel disableDbLabel;
private javax.swing.JTextField hostField;
private javax.swing.JLabel hostLabel;
private javax.swing.JRadioButton msgpackButton;
private javax.swing.JPasswordField passwordField;
private javax.swing.JLabel passwordLabel;
private javax.swing.JButton pathButton;
@ -446,6 +417,5 @@ public class OpenConnectionDialog extends javax.swing.JDialog {
private javax.swing.JLabel titleLabel;
private javax.swing.JTextField usernameField;
private javax.swing.JLabel usernameLabel;
private javax.swing.JRadioButton xmlButton;
// End of variables declaration//GEN-END:variables
}

View File

@ -73,14 +73,14 @@
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="outputPathField" pref="453" max="32767" attributes="1"/>
<Component id="outputPathField" pref="853" max="32767" attributes="1"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="choosePathButton" min="-2" pref="91" max="-2" attributes="0"/>
</Group>
<Component id="archField" alignment="0" pref="550" max="32767" attributes="1"/>
<Component id="badcharsField" alignment="0" pref="550" max="32767" attributes="1"/>
<Component id="timesField" alignment="0" pref="550" max="32767" attributes="1"/>
<Component id="outputCombo" alignment="0" pref="550" max="32767" attributes="1"/>
<Component id="archField" alignment="0" pref="950" max="32767" attributes="1"/>
<Component id="badcharsField" alignment="0" pref="950" max="32767" attributes="1"/>
<Component id="timesField" alignment="0" pref="950" max="32767" attributes="1"/>
<Component id="outputCombo" alignment="0" pref="950" max="32767" attributes="1"/>
<Component id="encoderCombo" alignment="0" min="-2" pref="540" max="-2" attributes="1"/>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="0" max="-2" attributes="0">
@ -89,8 +89,8 @@
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="addCodeButton" pref="97" max="32767" attributes="1"/>
<Component id="templateButton" alignment="0" pref="97" max="32767" attributes="1"/>
<Component id="addCodeButton" pref="497" max="32767" attributes="1"/>
<Component id="templateButton" alignment="0" pref="497" max="32767" attributes="1"/>
</Group>
</Group>
</Group>
@ -112,7 +112,6 @@
<Component id="handleButton" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="handleConsoleButton" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="121" max="-2" attributes="0"/>
</Group>
<Component id="outputScrollPane" alignment="0" min="-2" pref="691" max="-2" attributes="0"/>
</Group>

View File

@ -540,23 +540,14 @@ public class PayloadPopup extends ModuleInfoWindow {
hash.put("Encoder", "generic/none");
Map data = (Map) rpcConn.execute("module.execute", "payload", fullName,hash);
//Basic info
byte[] buffer;
String rawHex;
if(rpcConn.type.equals("msg")){
buffer = (byte[])data.get("payload");
}else{
rawHex = data.get("payload").toString();
buffer = new byte[rawHex.length() / 2];
for (int i = 0; i < rawHex.length(); i += 2)
buffer[i/2] = (byte)Integer.parseInt(rawHex.substring(i, i + 2),16);
}
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){
StringBuffer badbinary = new StringBuffer();
StringBuilder badbinary = new StringBuilder();
for(String s : badcharsField.getText().split("\\\\x"))
if(s.length() > 0)
badbinary.append((char)Integer.parseInt(s, 16));
@ -574,10 +565,7 @@ public class PayloadPopup extends ModuleInfoWindow {
if(!outputCombo.getSelectedItem().toString().equals("jar")){ //jars don't get encoded
Map encoded = (Map) rpcConn.execute("module.encode", buffer,
encoderCombo.getSelectedItem().toString(),hash);
if(rpcConn.type.equals("msg"))
buffer = (byte[])encoded.get("encoded");
else
buffer = Base64.decode(encoded.get("encoded").toString());
buffer = (byte[])encoded.get("encoded");
}
FileOutputStream fout = new FileOutputStream(outputPathField.getText());
fout.write(buffer);

View File

@ -27,10 +27,9 @@ import org.jdesktop.application.Task;
* @author scriptjunkie
*/
public abstract class RpcConnection {
public String type = "msg";
protected String rpcToken;
protected Map callCache = new HashMap();
public static String defaultUser = "msf",defaultPass = null, defaultHost = "127.0.0.1", defaultType = "msg";
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;
@ -56,12 +55,8 @@ public abstract class RpcConnection {
* @return A new RPC connection
* @throws MsfException
*/
public static RpcConnection getConn(String type, String username, char[] password, String host, int port, boolean ssl) throws MsfException{
RpcConnection conn;
if(type.toLowerCase().equals("xml"))
conn = new XmlRpc();
else
conn = new MsgRpc();
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;
}
@ -109,7 +104,6 @@ public abstract class RpcConnection {
root.put("port", port);
root.put("ssl", ssl);
root.put("disableDb", disableDb);
root.put("type", type);
MsfguiApp.savePreferences();
}
@ -169,7 +163,6 @@ public abstract class RpcConnection {
public String toString(){
return "RPC connection "
+ "\ntype: "+type
+ "\nusername: "+username
+ "\npassword: " + password
+ "\nhost: " + host
@ -265,10 +258,8 @@ public abstract class RpcConnection {
// Don't fork cause we'll check if it dies
String rpcType = "Basic";
if(defaultType.toLowerCase().equals("msg"))
rpcType = "Msg";
java.util.List args = new java.util.ArrayList(java.util.Arrays.asList(new String[]{
"msfrpcd","-f","-P",defaultPass,"-t",rpcType,"-U",defaultUser,"-a","127.0.0.1"}));
"msfrpcd","-f","-P",defaultPass,"-t","Msg","-U",defaultUser,"-a","127.0.0.1"}));
if(!defaultSsl)
args.add("-S");
if(disableDb)
@ -296,7 +287,7 @@ public abstract class RpcConnection {
} //Nope. We're good.
try {
myRpcConn = RpcConnection.getConn(defaultType, defaultUser, defaultPass.toCharArray(), "127.0.0.1", defaultPort, defaultSsl);
myRpcConn = RpcConnection.getConn(defaultUser, defaultPass.toCharArray(), "127.0.0.1", defaultPort, defaultSsl);
connected = true;
break;
} catch (MsfException mex) {

View File

@ -33,7 +33,6 @@ public class XmlRpc extends RpcConnection {
*/
public XmlRpc(){
super();
type = "XML";
}
/** Creates an XMLRPC call from the given method name and parameters and sends it */
protected void writeCall(String methname, Object[] params) throws Exception{

View File

@ -17,5 +17,3 @@ sslBox.text=
sslLabel.text=SSL
disableDbButton.text=
disableDbLabel.text=Disable DB
xmlButton.text=XML
msgpackButton.text=MsgPack