This library should contain all methods to communicate with msfrpc. See framework/documentation/msfrpc.txt for further information. msfrpcd -S -U wpscan -P wpscan -f -t Web -u /RPC2 name = exploit/unix/webapp/php_include
# File lib/wpscan/msfrpc_client.rb, line 28 def initialize @config = {} @config['host'] = "127.0.0.1" @config['path'] = "/RPC2" @config['port'] = 55553 @config['user'] = "wpscan" @config['pass'] = "wpscan" @auth_token = nil @last_auth = nil begin @server = XMLRPC::Client.new3( :host => @config["host"], :path => @config["path"], :port => @config["port"], :user => @config["user"], :password => @config["pass"]) rescue => e puts "[ERROR] Could not create XMLRPC object." puts e.faultCode puts e.faultString end end
check authentication
# File lib/wpscan/msfrpc_client.rb, line 65 def authenticate() login() if @auth_token.nil? login() if (Time.now - @last_auth > 600) end
execute exploit
# File lib/wpscan/msfrpc_client.rb, line 93 def exploit(name, opts) authenticate() @server.call('module.execute', @auth_token, 'exploit', name, opts) end
retrieve information about the exploit
# File lib/wpscan/msfrpc_client.rb, line 72 def get_exploit_info(name) authenticate() @server.call('module.info', @auth_token, 'exploit', name) end
retrieve exploit options
# File lib/wpscan/msfrpc_client.rb, line 79 def get_options(name) authenticate() @server.call('module.options', @auth_token, 'exploit',name) end
retrieve the exploit payloads
# File lib/wpscan/msfrpc_client.rb, line 86 def get_payloads(name) authenticate() @server.call('module.compatible_payloads', @auth_token, name) end
list msf jobs
# File lib/wpscan/msfrpc_client.rb, line 100 def jobs() authenticate() @server.call('job.list', @auth_token) end
kill msf session
# File lib/wpscan/msfrpc_client.rb, line 114 def kill_session(id) authenticate() @server.call('session.stop', @auth_token, id) end
login to msfrpcd
# File lib/wpscan/msfrpc_client.rb, line 49 def login() result = @server.call("auth.login", @config['user'], @config['pass']) if result['result'] == "success" @auth_token = result['token'] @last_auth = Time.new logged_in = true else puts "[ERROR] Invalid login credentials provided to msfrpcd." logged_in = false end end
# File lib/wpscan/msfrpc_client.rb, line 133 def meterpreter_read(id) authenticate() @server.call('session.meterpreter_read', @auth_token, id) end
# File lib/wpscan/msfrpc_client.rb, line 138 def meterpreter_write(id, data) authenticate() @server.call('session.meterpreter_write', @auth_token, id, data) end
reads any pending output from session
# File lib/wpscan/msfrpc_client.rb, line 121 def read_shell(id) authenticate() @server.call('session.shell_read', @auth_token, id) end
Generated with the Darkfish Rdoc Generator 2.