diff --git a/core/bootstrap.rb b/core/bootstrap.rb index 290b4a554..b48ef93a0 100644 --- a/core/bootstrap.rb +++ b/core/bootstrap.rb @@ -30,6 +30,7 @@ require 'core/main/handlers/modules/beefjs' require 'core/main/handlers/modules/command' require 'core/main/handlers/commands' require 'core/main/handlers/hookedbrowsers' +require 'core/main/handlers/browserdetails' # @note Include the network stack require 'core/main/network_stack/handlers/dynamicreconstruction' diff --git a/core/core.rb b/core/core.rb index bc655694c..dc554314b 100644 --- a/core/core.rb +++ b/core/core.rb @@ -27,6 +27,7 @@ require 'core/main/models/log' require 'core/main/models/command' require 'core/main/models/result' require 'core/main/models/optioncache' +require 'core/main/models/browserdetails' # @note Include the constants require 'core/main/constants/browsers' diff --git a/extensions/initialization/handler.rb b/core/main/handlers/browserdetails.rb similarity index 97% rename from extensions/initialization/handler.rb rename to core/main/handlers/browserdetails.rb index a56fae3fb..862e20770 100644 --- a/extensions/initialization/handler.rb +++ b/core/main/handlers/browserdetails.rb @@ -14,18 +14,15 @@ # limitations under the License. # module BeEF - module Extension - module Initialization - - # - # The http handler that manages the return of the initial browser details. - # - class Handler + module Core + module Handlers + # @note Retrieves information about the browser (type, version, plugins etc.) + class BrowserDetails @data = {} HB = BeEF::Core::Models::HookedBrowser - BD = BeEF::Extension::Initialization::Models::BrowserDetails + BD = BeEF::Core::Models::BrowserDetails def initialize(data) @data = data @@ -33,7 +30,7 @@ module BeEF end def err_msg(error) - print_error "[INITIALIZATION] #{error}" + print_error "[Browser Details] #{error}" end def setup() diff --git a/extensions/initialization/models/browserdetails.rb b/core/main/models/browserdetails.rb similarity index 93% rename from extensions/initialization/models/browserdetails.rb rename to core/main/models/browserdetails.rb index f2ac1edb6..0cd114c75 100644 --- a/extensions/initialization/models/browserdetails.rb +++ b/core/main/models/browserdetails.rb @@ -14,8 +14,7 @@ # limitations under the License. # module BeEF -module Extension -module Initialization +module Core module Models # # Table stores the details of browsers. @@ -26,16 +25,7 @@ module Models include DataMapper::Resource - storage_names[:default] = 'extension_initialization_browserdetails' - - - # - # Class constructor - # - def initialize(config) - super(config) - end - + storage_names[:default] = 'core_browserdetails' property :session_id, String, :length => 255, :key => true property :detail_key, String, :length => 255, :lazy => false, :key => true property :detail_value, Text, :lazy => false @@ -59,7 +49,7 @@ module Models return nil if not get(session_id, detail_key).nil? # store the returned browser details - browserdetails = BeEF::Extension::Initialization::Models::BrowserDetails.new( + browserdetails = BeEF::Core::Models::BrowserDetails.new( :session_id => session_id, :detail_key => detail_key, :detail_value => detail_value) @@ -120,4 +110,3 @@ module Models end end end -end diff --git a/core/main/rest/handlers/hookedbrowsers.rb b/core/main/rest/handlers/hookedbrowsers.rb index 89379ac7f..aedc3fe34 100644 --- a/core/main/rest/handlers/hookedbrowsers.rb +++ b/core/main/rest/handlers/hookedbrowsers.rb @@ -55,7 +55,7 @@ module BeEF end def get_hb_details(hb) - details = BeEF::Extension::Initialization::Models::BrowserDetails + details = BeEF::Core::Models::BrowserDetails { 'name' => details.get(hb.session, 'BrowserName'), diff --git a/core/main/server.rb b/core/main/server.rb index e47eb1fd1..86ae23e74 100644 --- a/core/main/server.rb +++ b/core/main/server.rb @@ -82,6 +82,9 @@ module BeEF # Create http handler for the javascript hook file self.mount("#{@configuration.get("beef.http.hook_file")}", BeEF::Core::Handlers::HookedBrowsers.new) + # Create handler for the initialization checks (Browser Details) + self.mount("/init", BeEF::Core::Handlers::BrowserDetails) + # Dynamically get the list of all the http handlers using the API and register them BeEF::API::Registrar.instance.fire(BeEF::API::Server, 'mount_handler', self) diff --git a/extensions/console/lib/shellinterface.rb b/extensions/console/lib/shellinterface.rb index 78f099e53..927686cb7 100644 --- a/extensions/console/lib/shellinterface.rb +++ b/extensions/console/lib/shellinterface.rb @@ -19,7 +19,7 @@ module Console class ShellInterface - BD = BeEF::Extension::Initialization::Models::BrowserDetails + BD = BeEF::Core::Models::BrowserDetails def initialize(config) self.config = config diff --git a/extensions/initialization/api.rb b/extensions/initialization/api.rb deleted file mode 100644 index ea3138e9d..000000000 --- a/extensions/initialization/api.rb +++ /dev/null @@ -1,38 +0,0 @@ -# -# Copyright 2012 Wade Alcorn wade@bindshell.net -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -module BeEF -module Extension -module Initialization - - module RegisterHttpHandler - - # Register API calls - BeEF::API::Registrar.instance.register(BeEF::Extension::Initialization::RegisterHttpHandler, BeEF::API::Server, 'mount_handler') - - # - # Register the http handler for the initialization script that retrieves - # all the information about hooked browsers. - # - def self.mount_handler(beef_server) - beef_server.mount('/init', BeEF::Extension::Initialization::Handler) - end - - end - - -end -end -end diff --git a/extensions/initialization/config.yaml b/extensions/initialization/config.yaml deleted file mode 100644 index d83ae154c..000000000 --- a/extensions/initialization/config.yaml +++ /dev/null @@ -1,21 +0,0 @@ -# -# Copyright 2012 Wade Alcorn wade@bindshell.net -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -beef: - extension: - initialization: - enable: true - name: 'Initialization' - diff --git a/extensions/initialization/extension.rb b/extensions/initialization/extension.rb deleted file mode 100644 index e13f67fe0..000000000 --- a/extensions/initialization/extension.rb +++ /dev/null @@ -1,32 +0,0 @@ -# -# Copyright 2012 Wade Alcorn wade@bindshell.net -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -module BeEF -module Extension -module Initialization - - extend BeEF::API::Extension - - @short_name = @full_name = 'initialization' - - @description = 'retrieves information about the browser (type, version, plugins etc.)' - -end -end -end - -require 'extensions/initialization/models/browserdetails' -require 'extensions/initialization/handler' -require 'extensions/initialization/api'