#!/usr/bin/env ruby # # Copyright 2011 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. # $:.unshift(File.join(File.expand_path(File.dirname(__FILE__)), '.')) $root_dir = File.expand_path('..', __FILE__) require 'core/loader' # load config config = BeEF::Core::Configuration.instance # Loads extensions BeEF::Extensions.load #prints welcome message #BeEF::Extension::Console::Banners.print_ascii_art BeEF::Extension::Console::Banners.print_welcome_msg # Loads modules BeEF::Modules.load # disable reverse dns Socket.do_not_reverse_lookup = true # setup database case config.get("beef.database.default") when "sqlite" DataMapper.setup(:default, "sqlite3://#{$root_dir}/#{config.get("beef.database.sqlite.db_name")}") when "mysql" DataMapper.setup(:default, "mysql://#{config.get("beef.database.mysql.db_user")}:#{config.get("beef.database.mysql.db_passwd")}@#{config.get("beef.database.mysql.db_host")}/#{config.get("beef.database.mysql.db_name")}") else print_error 'No default database selected. Please add one in config.yaml' end if BeEF::Extension::Console.resetdb? print_info 'Resetting the database for BeEF.' DataMapper.auto_migrate! else DataMapper.auto_upgrade! end # if metasploit is unreachable it can take 10/15 seconds to load print_info 'BeEF is loading. Wait a few seconds...' # check for new command modules BeEF::Core::Migration.instance.update_db! # prepare the web server to run http_hook_server = BeEF::Core::Server.instance http_hook_server.prepare # prints information back to the user before running the server BeEF::Extension::Console::Banners.print_loaded_extensions BeEF::Extension::Console::Banners.print_loaded_modules 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) # starts the web server http_hook_server.start