Cleaned up pre_http_start + mount_handlers. Added direct call API options for mounting and unmounting http handlers

git-svn-id: https://beef.googlecode.com/svn/trunk@1184 b87d56ec-f9c0-11de-8c8a-61c5e9addfc9
This commit is contained in:
passbe
2011-08-12 00:13:36 +00:00
parent d870c423fd
commit 0067a9c088
12 changed files with 37 additions and 31 deletions

2
beef
View File

@@ -99,7 +99,7 @@ BeEF::Extension::Console::Banners.print_network_interfaces_count
BeEF::Extension::Console::Banners.print_network_interfaces_routes
# We dynamically get the list of all browser hook handler using the API and register them
BeEF::API.fire(BeEF::API::Server::Handler, 'pre_http_start', http_hook_server)
BeEF::API.fire(BeEF::API::Server, 'pre_http_start', http_hook_server)
# starts the web server
http_hook_server.start

View File

@@ -58,7 +58,7 @@ require 'core/api/extension'
require 'core/api/extensions'
require 'core/api/main/migration'
require 'core/api/main/network_stack/assethandler.rb'
require 'core/api/main/server/handler'
require 'core/api/main/server'
require 'core/api/main/server/hook'
require 'core/api/main/configuration'

View File

@@ -16,18 +16,24 @@
module BeEF
module API
module Server
module Handler
API_PATHS = {
'pre_http_start' => :pre_http_start,
'mount_handlers' => :mount_handlers
'mount_handler' => :mount_handler,
'pre_http_start' => :pre_http_start
}
def mount_handlers(beef_server); end
def pre_http_start(http_hook_server); end
def mount_handler(server); end
def self.mount(url, hard, http_handler_class, args = nil)
BeEF::Core::Server.instance.mount(url, hard, http_handler_class, *args)
end
def self.unmount(url, hard)
BeEF::Core::Server.instance.unmount(url, hard)
end
end
end
end

View File

@@ -19,18 +19,18 @@ module NetworkStack
module RegisterHttpHandler
# use of the API right here
extend BeEF::API::Server::Handler
extend BeEF::API::Server
#
# Register the http handler for the network stack
#
def self.mount_handlers(beef_server)
def self.mount_handler(server)
#dynamic handler
beef_server.mount('/dh', true, BeEF::Core::NetworkStack::Handlers::DynamicReconstruction)
server.mount('/dh', true, BeEF::Core::NetworkStack::Handlers::DynamicReconstruction)
end
end
end
end
end
end

View File

@@ -96,7 +96,7 @@ module Core
#
# We dynamically get the list of all http handler using the API and register them
#
BeEF::API.fire(BeEF::API::Server::Handler, 'mount_handlers', self)
BeEF::API.fire(BeEF::API::Server, 'mount_handler', self)
end
end

View File

@@ -24,12 +24,12 @@ module API
module Handler
# use of the API right here
extend BeEF::API::Server::Handler
extend BeEF::API::Server
#
# This function gets called automatically by the server.
#
def self.mount_handlers(beef_server)
def self.mount_handler(beef_server)
# retrieve the configuration class instance
configuration = BeEF::Core::Configuration.instance

View File

@@ -19,9 +19,9 @@ module Demos
module RegisterHttpHandlers
extend BeEF::API::Server::Handler
extend BeEF::API::Server
def self.mount_handlers(beef_server)
def self.mount_handler(beef_server)
# mount the handler to support the demos
dir = File.dirname(__FILE__)+'/html/'
@@ -32,4 +32,4 @@ module Demos
end
end
end
end

View File

@@ -19,13 +19,13 @@ module Events
module RegisterHttpHandler
# use of the API right here
extend BeEF::API::Server::Handler
extend BeEF::API::Server
#
# Mounts the http handlers for the events extension. We use that to retrieve stuff
# like keystroke, mouse clicks and form submission.
#
def self.mount_handlers(beef_server)
def self.mount_handler(beef_server)
beef_server.mount('/event', false, BeEF::Extension::Events::Handler)
end
@@ -33,4 +33,4 @@ module Events
end
end
end
end

View File

@@ -19,13 +19,13 @@ module Initialization
module RegisterHttpHandler
# use of the API right here
extend BeEF::API::Server::Handler
extend BeEF::API::Server
#
# Register the http handler for the initialization script that retrieves
# all the information about hooked browsers.
#
def self.mount_handlers(beef_server)
def self.mount_handler(beef_server)
beef_server.mount('/init', false, BeEF::Extension::Initialization::Handler)
end
@@ -33,4 +33,4 @@ module Initialization
end
end
end
end

View File

@@ -21,7 +21,7 @@ module API
module RegisterHttpHandler
# use of the API
extend BeEF::API::Server::Handler
extend BeEF::API::Server
def self.pre_http_start(http_hook_server)
proxy = BeEF::Extension::Proxy::HttpProxyZombie.instance
@@ -30,7 +30,7 @@ module API
print_success "HTTP Proxy: http://#{config.get('beef.extension.proxy.address')}:#{config.get('beef.extension.proxy.port')}"
end
def self.mount_handlers(beef_server)
def self.mount_handler(beef_server)
beef_server.mount('/proxy', false, BeEF::Extension::Events::Handler)
end

View File

@@ -20,11 +20,11 @@ module Requester
module RegisterHttpHandler
# use of the API
extend BeEF::API::Server::Handler
extend BeEF::API::Server
# We register the http handler for the requester.
# This http handler will retrieve the http responses for all requests
def self.mount_handlers(beef_server)
def self.mount_handler(beef_server)
beef_server.mount('/requester', false, BeEF::Extension::Requester::Handler)
end

View File

@@ -20,11 +20,11 @@ module Xssrays
module RegisterHttpHandler
# use of the API
extend BeEF::API::Server::Handler
extend BeEF::API::Server
# We register the http handler for the requester.
# This http handler will retrieve the http responses for all requests
def self.mount_handlers(beef_server)
def self.mount_handler(beef_server)
beef_server.mount('/xssrays', false, BeEF::Extension::Xssrays::Handler)
end