Issue #886: Added support for CORS on the Router object. The RESTful aPI can not be called from JS x-domain.
This commit is contained in:
@@ -33,6 +33,12 @@ beef:
|
|||||||
hook_session_name: "BEEFHOOK"
|
hook_session_name: "BEEFHOOK"
|
||||||
session_cookie_name: "BEEFSESSION"
|
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.
|
# Prefer WebSockets over XHR-polling when possible.
|
||||||
websocket:
|
websocket:
|
||||||
enable: false
|
enable: false
|
||||||
|
|||||||
@@ -81,16 +81,23 @@ module BeEF
|
|||||||
case type
|
case type
|
||||||
when "apache"
|
when "apache"
|
||||||
headers "Server" => "Apache/2.2.3 (CentOS)",
|
headers "Server" => "Apache/2.2.3 (CentOS)",
|
||||||
"Content-Type" => "text/html"
|
"Content-Type" => "text/html; charset=UTF-8"
|
||||||
|
|
||||||
when "iis"
|
when "iis"
|
||||||
headers "Server" => "Microsoft-IIS/6.0",
|
headers "Server" => "Microsoft-IIS/6.0",
|
||||||
"X-Powered-By" => "ASP.NET",
|
"X-Powered-By" => "ASP.NET",
|
||||||
"Content-Type" => "text/html"
|
"Content-Type" => "text/html; charset=UTF-8"
|
||||||
else
|
else
|
||||||
print_error "You have and error in beef.http.web_server_imitation.type! Supported values are: apache, iis."
|
print_error "You have and error in beef.http.web_server_imitation.type! Supported values are: apache, iis."
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
# @note Default root page
|
# @note Default root page
|
||||||
|
|||||||
Reference in New Issue
Block a user