diff --git a/core/main/router/router.rb b/core/main/router/router.rb index c21c089f5..439709210 100644 --- a/core/main/router/router.rb +++ b/core/main/router/router.rb @@ -24,7 +24,62 @@ module BeEF config = BeEF::Core::Configuration.instance configure do set :show_exceptions, false end - not_found do 'Not Found' 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.
  • " + + "
" + + "
" + + end + else + "Not Found." + end + end before do # @note Override Server HTTP response header @@ -32,23 +87,16 @@ module BeEF type = config.get("beef.http.web_server_imitation.type") case type when "apache" - headers "Server" => "Apache/2.2.3 (CentOS)" - - #todo https://github.com/beefproject/beef/issues/98 if web_server imitation is enabled - #todo the 404 response will be something like the following: - # - # - #404 Not Found - # - #

Not Found

- #

The requested URL /aaaa was not found on this server.

- #
- #
Apache/2.2.3 (CentOS)
- # + headers "Server" => "Apache/2.2.3 (CentOS)", + "Content-Type" => "text/html" when "iis" - headers "Server" => "Microsoft-IIS/7.0" + headers "Server" => "Microsoft-IIS/7.0", + "X-Powered-By" => "ASP.NET", + "Content-Type" => "text/html" end + else + print_error "You have and error in beef.http.web_server_imitation.type! Supported values are: apache, iis." end end end