Added default 404 HTTP response bodies for Apache 2.2.3 and IIS 6

This commit is contained in:
antisnatchor
2012-04-04 15:47:21 +01:00
parent e528375e3d
commit 6bebb80f61

View File

@@ -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
"<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">" +
"<html><head>" +
"<title>404 Not Found</title>" +
"</head><body>" +
"<h1>Not Found</h1>" +
"<p>The requested URL was not found on this server.</p>" +
"<hr>" +
"<address>Apache/2.2.3 (CentOS)</address>" +
"</body></html>"
when "iis"
#response body
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">" +
"<HTML><HEAD><TITLE>The page cannot be found</TITLE>" +
"<META HTTP-EQUIV=\"Content-Type\" Content=\"text/html; charset=Windows-1252\">" +
"<STYLE type=\"text/css\">" +
" BODY { font: 8pt/12pt verdana } " +
" H1 { font: 13pt/15pt verdana }" +
" H2 { font: 8pt/12pt verdana }" +
" A:link { color: red }" +
" A:visited { color: maroon }" +
"</STYLE>" +
"</HEAD><BODY><TABLE width=500 border=0 cellspacing=10><TR><TD>" +
"<h1>The page cannot be found</h1>" +
"The page you are looking for might have been removed, had its name changed, or is temporarily unavailable." +
"<hr>" +
"<p>Please try the following:</p>" +
"<ul>" +
"<li>Make sure that the Web site address displayed in the address bar of your browser is spelled and formatted correctly.</li>" +
"<li>If you reached this page by clicking a link, contact" +
" the Web site administrator to alert them that the link is incorrectly formatted." +
"</li>" +
"<li>Click the <a href=\"javascript:history.back(1)\">Back</a> button to try another link.</li>" +
"</ul>" +
"<h2>HTTP Error 404 - File or directory not found.<br>Internet Information Services (IIS)</h2>" +
"<hr>" +
"<p>Technical Information (for support personnel)</p>" +
"<ul>" +
"<li>Go to <a href=\"http://go.microsoft.com/fwlink/?linkid=8180\">Microsoft Product Support Services</a> and perform a title search for the words <b>HTTP</b> and <b>404</b>.</li>" +
"<li>Open <b>IIS Help</b>, which is accessible in IIS Manager (inetmgr)," +
"and search for topics titled <b>Web Site Setup</b>, <b>Common Administrative Tasks</b>, and <b>About Custom Error Messages</b>.</li>" +
"</ul>" +
"</TD></TR></TABLE></BODY></HTML>"
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:
#<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
#<html><head>
#<title>404 Not Found</title>
#</head><body>
#<h1>Not Found</h1>
#<p>The requested URL /aaaa was not found on this server.</p>
# <hr>
# <address>Apache/2.2.3 (CentOS)</address>
# </body></html>
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