From 2ee9fb6ccc8dbce3501f8c7386a622929b757a0d Mon Sep 17 00:00:00 2001 From: bcoles Date: Tue, 22 Apr 2014 22:49:21 +0930 Subject: [PATCH] Add nginx imitation --- config.yaml | 2 +- core/main/router/router.rb | 44 ++++++++++++++++++++++++++++++++++---- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/config.yaml b/config.yaml index 144c6989e..00d5f90b7 100644 --- a/config.yaml +++ b/config.yaml @@ -72,7 +72,7 @@ beef: # Imitate a specified web server (default root page, 404 default error page, 'Server' HTTP response header) web_server_imitation: enable: true - type: "apache" #supported: apache, iis + type: "apache" # Supported: apache, iis, nginx # Experimental HTTPS support for the hook / admin / all other Thin managed web services https: diff --git a/core/main/router/router.rb b/core/main/router/router.rb index d9197c7af..0c851af18 100644 --- a/core/main/router/router.rb +++ b/core/main/router/router.rb @@ -66,6 +66,15 @@ module BeEF "and search for topics titled Web Site Setup, Common Administrative Tasks, and About Custom Error Messages." + "" + "" + when "nginx" + #response body + "\n"+ + "404 Not Found\n" + + "\n" + + "

404 Not Found

\n" + + "
nginx
\n" + + "\n" + + "\n" else "Not Found." end @@ -87,12 +96,15 @@ module BeEF headers "Server" => "Microsoft-IIS/6.0", "X-Powered-By" => "ASP.NET", "Content-Type" => "text/html; charset=UTF-8" + when "nginx" + headers "Server" => "nginx", + "Content-Type" => "text/html" else - print_error "You have and error in beef.http.web_server_imitation.type! Supported values are: apache, iis." + print_error "You have an error in beef.http.web_server_imitation.type! Supported values are: apache, iis, nginx." end end - # @note If CORS are enabled, expose the appropriate headers + # @note If CORS is enabled, expose the appropriate headers # this apparently duplicate code is needed to reply to preflight OPTIONS requests, which need to respond with a 200 # and be able to handle requests with a JSON content-type if request.request_method == 'OPTIONS' && config.get("beef.http.restful_api.allow_cors") @@ -103,7 +115,7 @@ module BeEF halt 200 end - # @note If CORS are enabled, expose the appropriate headers + # @note If CORS is 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, @@ -255,6 +267,30 @@ module BeEF "" + "" + "" + when "nginx" + "\n" + + "\n" + + "\n" + + "Welcome to nginx!\n" + + "\n" + + "\n" + + "\n" + + "

Welcome to nginx!

\n" + + "

If you see this page, the nginx web server is successfully installed and\n" + + "working. Further configuration is required.

\n\n" + + "

For online documentation and support please refer to\n" + + "nginx.org.
\n" + + "Commercial support is available at\n" + + "nginx.com.

\n\n" + + "

Thank you for using nginx.

\n" + + "\n" + + "\n" else "" end @@ -264,4 +300,4 @@ module BeEF end end end -end \ No newline at end of file +end