git-svn-id: https://beef.googlecode.com/svn/trunk@1068 b87d56ec-f9c0-11de-8c8a-61c5e9addfc9
106 lines
3.2 KiB
Ruby
Executable File
106 lines
3.2 KiB
Ruby
Executable File
#!/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.
|
|
#
|
|
|
|
# check version supported
|
|
if RUBY_VERSION < '1.9'
|
|
puts "\n"
|
|
puts "Ruby version " + RUBY_VERSION + " is no longer supported. Please upgrade 1.9 or later."
|
|
puts "\n"
|
|
exit
|
|
end
|
|
|
|
$:.unshift(File.join(File.expand_path(File.dirname(__FILE__)), '.'))
|
|
|
|
$root_dir = File.expand_path('..', __FILE__)
|
|
|
|
# prevent some errors on encoding: encoding handling changed (improved) from 1.8.7 to 1.9.1/2.
|
|
if RUBY_VERSION =~ /1.9/
|
|
Encoding.default_external = Encoding::UTF_8
|
|
Encoding.default_internal = Encoding::UTF_8
|
|
end
|
|
|
|
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.driver")
|
|
when "sqlite"
|
|
DataMapper.setup(:default, "sqlite3://#{$root_dir}/#{config.get("beef.database.db_file")}")
|
|
when "mysql","postgres"
|
|
# === Remove comment of next line for logging queries (very verbose) ===
|
|
# DataMapper::Logger.new($stdout, :debug)
|
|
#
|
|
DataMapper.setup(:default,
|
|
:adapter => config.get("beef.database.driver"),
|
|
:host => config.get("beef.database.db_host"),
|
|
:username => config.get("beef.database.db_user"),
|
|
:password => config.get("beef.database.db_passwd"),
|
|
:database => config.get("beef.database.db_name"),
|
|
:encoding => config.get("beef.database.db_encoding")
|
|
)
|
|
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
|