First skeleton for the RESTful api using Sinatra (modular approach, not classic one).

This commit is contained in:
antisnatchor
2012-03-11 16:12:59 +01:00
parent e1652bf52e
commit 7dab21ff7f
4 changed files with 71 additions and 2 deletions

View File

@@ -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

View File

@@ -39,4 +39,8 @@ require 'core/module'
require 'core/modules'
require 'core/extension'
require 'core/extensions'
require 'core/hbmanager'
require 'core/hbmanager'
## @note Include RESTful API
require 'core/main/rest/handlers/rest'
require 'core/main/rest/api'

31
core/main/rest/api.rb Normal file
View File

@@ -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

View File

@@ -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