diff --git a/config.yaml b/config.yaml index 0cf0ff621..4e6440c09 100644 --- a/config.yaml +++ b/config.yaml @@ -33,6 +33,12 @@ beef: hook_session_name: "BEEFHOOK" session_cookie_name: "BEEFSESSION" + # Allow one or multiple domains to access the RESTful API using CORS + # For multiple domains use: "http://browserhacker.com, http://domain2.com" + restful_api: + allow_cors: false + cors_allowed_domains: "http://browserhacker.com" + # Prefer WebSockets over XHR-polling when possible. websocket: enable: false diff --git a/core/main/router/router.rb b/core/main/router/router.rb index 10e5d452c..4c155680d 100644 --- a/core/main/router/router.rb +++ b/core/main/router/router.rb @@ -81,16 +81,23 @@ module BeEF case type when "apache" headers "Server" => "Apache/2.2.3 (CentOS)", - "Content-Type" => "text/html" + "Content-Type" => "text/html; charset=UTF-8" when "iis" headers "Server" => "Microsoft-IIS/6.0", "X-Powered-By" => "ASP.NET", - "Content-Type" => "text/html" + "Content-Type" => "text/html; charset=UTF-8" else print_error "You have and error in beef.http.web_server_imitation.type! Supported values are: apache, iis." end end + + # @note If CORS are enabled, expose the appropriate headers + if config.get("beef.http.restful_api.allow_cors") + allowed_domains = config.get("beef.http.restful_api.cors_allowed_domains") + headers "Access-Control-Allow-Origin" => allowed_domains, + "Access-Control-Allow-Methods" => "POST, GET" + end end # @note Default root page