# # Copyright 2012 Wade Alcorn wade@bindshell.net # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # 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)
" + "" 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.
  • " + "
" + "
" 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" when "iis" headers "Server" => "Microsoft-IIS/6.0", "X-Powered-By" => "ASP.NET", "Content-Type" => "text/html" else print_error "You have and error in beef.http.web_server_imitation.type! Supported values are: apache, iis." end end end # @note Default root page get "/" do if config.get("beef.http.web_server_imitation.enable") 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

" + "
" + "
" + "" + "" 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.
" + "
" + "" + "" else "" end end end end end end end