diff --git a/config.yaml b/config.yaml index 679d183f6..c8f530075 100644 --- a/config.yaml +++ b/config.yaml @@ -27,7 +27,7 @@ beef: permitted_ui_subnet: "0.0.0.0/0" http: - debug: false #Thin::Logging.debug, very verbose. Prints also full exception stack trace. + debug: true #Thin::Logging.debug, very verbose. Prints also full exception stack trace. host: "0.0.0.0" port: "3000" # if running behind a nat set the public ip address here diff --git a/core/bootstrap.rb b/core/bootstrap.rb index 68c6df8dd..c7169eecd 100644 --- a/core/bootstrap.rb +++ b/core/bootstrap.rb @@ -39,4 +39,8 @@ require 'core/module' require 'core/modules' require 'core/extension' require 'core/extensions' -require 'core/hbmanager' \ No newline at end of file +require 'core/hbmanager' + +## @note Include RESTful API +require 'core/main/rest/handlers/rest' +require 'core/main/rest/api' \ No newline at end of file diff --git a/core/main/rest/api.rb b/core/main/rest/api.rb new file mode 100644 index 000000000..51b470af9 --- /dev/null +++ b/core/main/rest/api.rb @@ -0,0 +1,31 @@ +# +# 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 Core + module Rest + + module RegisterHttpHandler + + def self.mount_handler(server) + server.mount('/api', BeEF::Core::Rest::Rest.new) + end + end + + BeEF::API::Registrar.instance.register(BeEF::Core::Rest::RegisterHttpHandler, BeEF::API::Server, 'mount_handler') + + end + end +end diff --git a/core/main/rest/handlers/rest.rb b/core/main/rest/handlers/rest.rb new file mode 100644 index 000000000..3746ae8e6 --- /dev/null +++ b/core/main/rest/handlers/rest.rb @@ -0,0 +1,34 @@ +# +# 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 Core + module Rest + class Rest < Sinatra::Base + + get '/sinatra' do + "Sinatra! v.#{Sinatra::VERSION}" + end + + get '/modules' do + puts Sinatra::VERSION + "List all modules!" + end + + end + end + end +end \ No newline at end of file