Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #
- # $Id$
- # Created by scriptjunkie
- #
- require "msf/core/rpc"
- module Msf
- ###
- #
- # This file illustrates a sample RPC plugin.
- #
- # $Revision$
- ###
- #
- # This class handles the RPC side of the plugin
- #
- class Test < RPC::Base
- # Each method here will be accessible from RPC
- #
- # The methods must begin with authenticate(token) otherwise unauthenticated users
- # will be able to execute it. The first argument must
- # always be token but is usually not added explicitly by the client.
- #
- # This example method can be executed as "test.info"; i.e. rpc.call("test.info")
- def info(token)
- authenticate(token)
- # The methods should return a hash that can have nested hashes,
- # arrays, strings, or integers.
- { "result" => "success" }
- end
- # This example method shows arguments passed and could be called
- # with rpc.call("test.argcheck","argument")
- def argcheck(token, argh)
- authenticate(token)
- { "result" => "success" , "argument" => argh }
- end
- end
- #
- # This class handles the "plugin" side of the plugin. See sample.rb for more info.
- #
- class Plugin::Test < Msf::Plugin
- def name
- "rpcexample"
- end
- def desc
- "Example plugin for adding RPC methods."
- end
- def initialize(framework, opts)
- super
- # Find XMLRPC plugin
- framework.plugins.each { |plugin|
- if (plugin.name == "xmlrpc")
- # Register our RPC class. The name we provide here will be the module
- # name that the RPC client must use
- plugin.server.add_handler(::XMLRPC::iPIMethods("test"),
- ::Msf::RPC::Test.new(framework,plugin.tokens,plugin.users)
- )
- return
- end
- }
- # we shouldn't get here, but just in case
- raise "XMLRPC plugin not found!"
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement