making the metasploit xmlrpc client more pretty
git-svn-id: https://beef.googlecode.com/svn/trunk@511 b87d56ec-f9c0-11de-8c8a-61c5e9addfc9
This commit is contained in:
@@ -10,6 +10,7 @@ require 'parseconfig'
|
||||
require 'singleton'
|
||||
require 'ipaddr'
|
||||
require 'base64'
|
||||
require 'xmlrpc/client'
|
||||
|
||||
require 'lib/patches/webrick/httprequest'
|
||||
require 'lib/patches/webrick/cookie'
|
||||
|
||||
@@ -1,29 +1,31 @@
|
||||
require "xmlrpc/client"
|
||||
|
||||
module BeEF
|
||||
|
||||
|
||||
#
|
||||
# XML RPC Client for Metasploit
|
||||
#
|
||||
class MsfClient < ::XMLRPC::Client
|
||||
|
||||
attr_accessor :token
|
||||
|
||||
|
||||
# login into metasploit
|
||||
def login(user,pass)
|
||||
res = self.call("auth.login", user, pass)
|
||||
if(not (res and res['result'] == "success"))
|
||||
raise RuntimeError, "MSF Authentication failed"
|
||||
end
|
||||
if(not (res and res['result'] == "success")) raise RuntimeError, "MSF Authentication failed"
|
||||
self.token = res['token']
|
||||
|
||||
true
|
||||
end
|
||||
|
||||
|
||||
# sends commands to the metasploit xml rpc server
|
||||
def call(meth, *args)
|
||||
if(meth != "auth.login")
|
||||
if(not self.token)
|
||||
raise RuntimeError, "client not authenticated"
|
||||
end
|
||||
if(not self.token) raise RuntimeError, "client not authenticated"
|
||||
args.unshift(self.token)
|
||||
end
|
||||
|
||||
super(meth, *args)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user