Merge pull request #1664 from scriptjunkie/msfguiKaliConnect
MSFGUI service autoconnect, DB fixesunstable
commit
ee199f64cb
Binary file not shown.
|
@ -295,6 +295,9 @@ public class DbConnectDialog extends OptionsDialog {
|
|||
}
|
||||
/** Tries to connect to the database with given credentials */
|
||||
private boolean tryConnect() throws MsfException{
|
||||
Map status = (Map) rpcConn.execute("db.status");
|
||||
if(status.containsKey("db"))
|
||||
return true; // already connected
|
||||
HashMap opts = new HashMap();
|
||||
addNonempty("host", hostField, opts);
|
||||
addNonempty("port", portField, opts);
|
||||
|
|
|
@ -171,7 +171,7 @@ public class MainFrame extends FrameView {
|
|||
MsfguiApp.shuttingDown = true;
|
||||
if(choice == JOptionPane.YES_OPTION)
|
||||
rpcConn.execute("core.stop");
|
||||
else if(choice == JOptionPane.NO_OPTION)
|
||||
else if(choice == JOptionPane.NO_OPTION && rpcConn.username.length() > 0)
|
||||
rpcConn.execute("auth.logout");
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
|
|
|
@ -3,7 +3,10 @@ import java.awt.event.ActionEvent;
|
|||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Map;
|
||||
import javax.swing.JFileChooser;
|
||||
|
@ -120,6 +123,19 @@ public class OpenConnectionDialog extends javax.swing.JDialog {
|
|||
} catch (NullPointerException nex) {//generated when attributes dont exist.
|
||||
} catch (Exception ex) { //for weird msg exceptions
|
||||
}
|
||||
//Try service token on default 3790
|
||||
BufferedReader fin = null;
|
||||
try{
|
||||
try{
|
||||
fin = new BufferedReader(new FileReader(MsfguiApp.getMsfRoot().getParent()+"/apps/pro/engine/tmp/servicekey.txt"));
|
||||
}catch(Exception iox2){
|
||||
fin = new BufferedReader(new FileReader("/opt/metasploit/apps/pro/engine/tmp/servicekey.txt"));
|
||||
}
|
||||
RpcConnection rpc = RpcConnection.getConn("", fin.readLine().toCharArray(), "localhost", 3790, true);
|
||||
if(javax.swing.JOptionPane.showConfirmDialog(null, "Connect to local rpcd?") == javax.swing.JOptionPane.YES_OPTION)
|
||||
return rpc;
|
||||
}catch(Exception iox){//file not found/unreadable/bad creds/etc. - ignore
|
||||
}
|
||||
//Darn. open the gui anyway
|
||||
OpenConnectionDialog diag = new OpenConnectionDialog(true, mainframe);
|
||||
diag.setVisible(true);
|
||||
|
|
|
@ -84,9 +84,15 @@ public abstract class RpcConnection {
|
|||
String message = "";
|
||||
try {
|
||||
connect();
|
||||
Map results = (Map)exec("auth.login",new Object[]{username, this.password});
|
||||
rpcToken=results.get("token").toString();
|
||||
haveRpcd=results.get("result").equals("success");
|
||||
if(username == null || username.equals("")){
|
||||
rpcToken = this.password;
|
||||
execute("core.version"); //throws error if unsuccessful
|
||||
haveRpcd = true;
|
||||
}else{
|
||||
Map results = (Map)exec("auth.login",new Object[]{username, this.password});
|
||||
rpcToken=results.get("token").toString();
|
||||
haveRpcd=results.get("result").equals("success");
|
||||
}
|
||||
} catch (MsfException xre) {
|
||||
message = xre.getLocalizedMessage();
|
||||
} catch (IOException io){
|
||||
|
|
Loading…
Reference in New Issue