Skip to content

Commit

Permalink
Fixed bug in binding local files.
Browse files Browse the repository at this point in the history
  • Loading branch information
antisnatchor committed Jun 9, 2015
1 parent f66a08f commit 518fb5d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
16 changes: 13 additions & 3 deletions core/main/network_stack/assethandler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,20 @@ def bind_raw(status, header, body, path=nil, count=-1)
# @todo This function should accept a hooked browser session to limit the mounted file to a certain session
def bind(file, path=nil, extension=nil, count=-1)
url = build_url(path, extension)
@allocations[url] = {'file' => "#{root_dir}"+file, 'path' => path, 'extension' => extension, 'count' => count}
@http_server.mount(url, Rack::File.new(@allocations[url]['file']))
@allocations[url] = {'file' => "#{root_dir}"+file,
'path' => path,
'extension' => extension,
'count' => count}

resp_body = File.read("#{root_dir}#{file}")
@http_server.mount(
url,
BeEF::Core::NetworkStack::Handlers::Raw.new('200', {'Content-Type'=>'text/plain'}, resp_body)
)

@http_server.remap
print_info "File [" + "#{root_dir}"+file + "] bound to url [" + url + "]"
print_info "File [#{file}] bound to url [#{url}]"

url
end

Expand Down
13 changes: 9 additions & 4 deletions core/main/network_stack/handlers/raw.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,19 @@ module Handlers

class Raw

def initialize(status, header={}, body)
def initialize(status, header={}, body=nil)
@status = status
@header = header
@body = body
@header = header
@body = body
end

def call(env)
[@status, @header, @body]
# [@status, @header, @body]
@response = Rack::Response.new(
body = @body,
status = @status,
header = @header
)
end

private
Expand Down
9 changes: 3 additions & 6 deletions extensions/admin_ui/api/handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,16 @@ def self.mount_handler(beef_server)
media_dir = File.dirname(__FILE__)+'/../media/'
beef_server.mount("#{bp}/media", Rack::File.new(media_dir))


# mount the favicon file, if we're not imitating a web server.
if !config.get("beef.http.web_server_imitation.enable")
beef_server.mount('/favicon.ico', Rack::File.new("#{media_dir}#{config.get("beef.extension.admin_ui.favicon_dir")}/#{config.get("beef.extension.admin_ui.favicon_file_name")}"))
BeEF::Core::NetworkStack::Handlers::AssetHandler.instance.bind(
"/extensions/admin_ui/media#{config.get("beef.extension.admin_ui.favicon_dir")}/#{config.get("beef.extension.admin_ui.favicon_file_name")}",
'/favicon.ico')
end

self.build_javascript_ui beef_server
end



end

end
end
end
Expand Down

0 comments on commit 518fb5d

Please sign in to comment.