# # Copyright (c) 2006-2015 Wade Alcorn - wade@bindshell.net # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # module BeEF module Core module Router #@note This is the main Router parent class. #@note All the HTTP handlers registered on BeEF will extend this class. class Router < Sinatra::Base config = BeEF::Core::Configuration.instance configure do set :show_exceptions, false end # @note Override default 404 HTTP response not_found do if config.get("beef.http.web_server_imitation.enable") type = config.get("beef.http.web_server_imitation.type") case type when "apache" #response body "" + "" + "404 Not Found" + "" + "

Not Found

" + "

The requested URL was not found on this server.

" + "
" + "
Apache/2.2.3 (CentOS)
" + ("" if config.get("beef.http.web_server_imitation.hook_404")).to_s + "" when "iis" #response body "" + "The page cannot be found" + "" + "" + "
" + "

The page cannot be found

" + "The page you are looking for might have been removed, had its name changed, or is temporarily unavailable." + "
" + "

Please try the following:

" + "
    " + "
  • Make sure that the Web site address displayed in the address bar of your browser is spelled and formatted correctly.
  • " + "
  • If you reached this page by clicking a link, contact" + " the Web site administrator to alert them that the link is incorrectly formatted." + "
  • " + "
  • Click the Back button to try another link.
  • " + "
" + "

HTTP Error 404 - File or directory not found.
Internet Information Services (IIS)

" + "
" + "

Technical Information (for support personnel)

" + "
    " + "
  • Go to Microsoft Product Support Services and perform a title search for the words HTTP and 404.
  • " + "
  • Open IIS Help, which is accessible in IIS Manager (inetmgr)," + "and search for topics titled Web Site Setup, Common Administrative Tasks, and About Custom Error Messages.
  • " + "
" + "
" + ("" if config.get("beef.http.web_server_imitation.hook_404")).to_s + "" when "nginx" #response body "\n"+ "404 Not Found\n" + "\n" + "

404 Not Found

\n" + "
nginx
\n" + ("" if config.get("beef.http.web_server_imitation.hook_404")).to_s + "\n" + "\n" else "Not Found." end else "Not Found." end end before do # @note Override Server HTTP response header if config.get("beef.http.web_server_imitation.enable") type = config.get("beef.http.web_server_imitation.type") case type when "apache" headers "Server" => "Apache/2.2.3 (CentOS)", "Content-Type" => "text/html; charset=UTF-8" when "iis" 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 an error in beef.http.web_server_imitation.type! Supported values are: apache, iis, nginx." end end # @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") allowed_domains = config.get("beef.http.restful_api.cors_allowed_domains") headers "Access-Control-Allow-Origin" => allowed_domains, "Access-Control-Allow-Methods" => "POST, GET", "Access-Control-Allow-Headers" => "Content-Type" halt 200 end # @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, "Access-Control-Allow-Methods" => "POST, GET" end end # @note Default root page get "/" do if config.get("beef.http.web_server_imitation.enable") bp = config.get "beef.http.web_ui_basepath" type = config.get("beef.http.web_server_imitation.type") case type when "apache" "" + "" + "Apache HTTP Server Test Page powered by CentOS" + "" + " " + " " + " " + "

Apache 2 Test Page
powered by CentOS

" + "
" +"
" + "

This page is used to test the proper operation of the Apache HTTP server after it has been installed. If you can read this page it means that the Apache HTTP server installed at this site is working properly.

" + "
" + "
" + "
" + "
" + "

If you are a member of the general public:

" + "

The fact that you are seeing this page indicates that the website you just visited is either experiencing problems or is undergoing routine maintenance.

" + "

If you would like to let the administrators of this website know that you've seen this page instead of the page you expected, you should send them e-mail. In general, mail sent to the name \"webmaster\" and directed to the website's domain should reach the appropriate person.

" + "

For example, if you experienced problems while visiting www.example.com, you should send e-mail to \"webmaster@example.com\".

" + "
" + "
" + "

If you are the website administrator:

" + "

You may now add content to the directory /var/www/html/. Note that until you do so, people visiting your website will see this page and not your content. To prevent this page from ever being used, follow the instructions in the file /etc/httpd/conf.d/welcome.conf.

" + "

You are free to use the images below on Apache and CentOS Linux powered HTTP servers. Thanks for using Apache and CentOS!

" + "

\"[ \"[

" + "
" + "
" + "
" + "
" + "

About CentOS:

The Community ENTerprise Operating System (CentOS) is an Enterprise-class Linux Distribution derived from sources freely provided to the public by a prominent North American Enterprise Linux vendor. CentOS conforms fully with the upstream vendors redistribution policy and aims to be 100% binary compatible. (CentOS mainly changes packages to remove upstream vendor branding and artwork.) The CentOS Project is the organization that builds CentOS.

" + "

For information on CentOS please visit the CentOS website.

" + "

Note:

CentOS is an Operating System and it is used to power this website; however, the webserver is owned by the domain owner and not the CentOS Project. If you have issues with the content of this site, contact the owner of the domain, not the CentOS project." + "

Unless this server is on the CentOS.org domain, the CentOS Project doesn't have anything to do with the content on this webserver or any e-mails that directed you to this site.

" + "

For example, if this website is www.example.com, you would find the owner of the example.com domain at the following WHOIS server:

" + "

http://www.internic.net/whois.html

" + "
" + "
" + ("" if config.get("beef.http.web_server_imitation.hook_root")).to_s + "" + "" when "iis" "" + "" + "" + "Under Construction" + "" + "" + "" + "" + "" + "" + "
" + "" + "" + "

" + "

Under Construction

" + "

" + "The site you are trying to view does not currently have a default page. It may be in the process of being upgraded and configured." + "

Please try this site again later. If you still experience the problem, try contacting the Web site administrator." + "


" + "

If you are the Web site administrator and feel you have received this message in error, please see "Enabling and Disabling Dynamic Content" in IIS Help." + "

To access IIS Help
" + "
    " + "
  1. Click Start, and then click Run." + "
  2. In the Open text box, type inetmgr. IIS Manager appears." + "
  3. From the Help menu, click Help Topics." + "
  4. Click Internet Information Services.
" + "
" + ("" if config.get("beef.http.web_server_imitation.hook_root")).to_s + "" + "" 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" + ("" if config.get("beef.http.web_server_imitation.hook_root")).to_s + "\n" + "\n" else "" end end end end end end end