You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
IIS_BODY="<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\"http://www.w3.org/TR/html4/strict.dtd\">" +
23
+
"<HTML><HEAD><TITLE>The page cannot be found</TITLE>" +
"The page you are looking for might have been removed, had its name changed, or is temporarily unavailable." +
35
+
"<hr>" +
36
+
"<p>Please try the following:</p>" +
37
+
"<ul>" +
38
+
"<li>Make sure that the Web site address displayed in the address bar of your browser is spelled and formatted correctly.</li>" +
39
+
"<li>If you reached this page by clicking a link, contact" +
40
+
" the Web site administrator to alert them that the link is incorrectly formatted." +
41
+
"</li>" +
42
+
"<li>Click the <a href=\"javascript:history.back(1)\">Back</a> button to try another link.</li>" +
43
+
"</ul>" +
44
+
"<h2>HTTP Error 404 - File or directory not found.<br>Internet Information Services (IIS)</h2>" +
45
+
"<hr>" +
46
+
"<p>Technical Information (for support personnel)</p>" +
47
+
"<ul>" +
48
+
"<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>" +
49
+
"<li>Open <b>IIS Help</b>, which is accessible in IIS Manager (inetmgr)," +
50
+
"and search for topics titled <b>Web Site Setup</b>, <b>Common Administrative Tasks</b>, and <b>About Custom Error Messages</b>.</li>" +
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\"http://www.w3.org/TR/html4/strict.dtd\">" +
40
-
"<HTML><HEAD><TITLE>The page cannot be found</TITLE>" +
"The page you are looking for might have been removed, had its name changed, or is temporarily unavailable." +
52
-
"<hr>" +
53
-
"<p>Please try the following:</p>" +
54
-
"<ul>" +
55
-
"<li>Make sure that the Web site address displayed in the address bar of your browser is spelled and formatted correctly.</li>" +
56
-
"<li>If you reached this page by clicking a link, contact" +
57
-
" the Web site administrator to alert them that the link is incorrectly formatted." +
58
-
"</li>" +
59
-
"<li>Click the <a href=\"javascript:history.back(1)\">Back</a> button to try another link.</li>" +
60
-
"</ul>" +
61
-
"<h2>HTTP Error 404 - File or directory not found.<br>Internet Information Services (IIS)</h2>" +
62
-
"<hr>" +
63
-
"<p>Technical Information (for support personnel)</p>" +
64
-
"<ul>" +
65
-
"<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>" +
66
-
"<li>Open <b>IIS Help</b>, which is accessible in IIS Manager (inetmgr)," +
67
-
"and search for topics titled <b>Web Site Setup</b>, <b>Common Administrative Tasks</b>, and <b>About Custom Error Messages</b>.</li>" +
# Check if reverse proxy has been enabled and return the correct client IP address
84
+
#
85
+
defget_ip(request)
86
+
if !@config.get("beef.http.allow_reverse_proxy")
87
+
ua_ip=request.get_header('REMOTE_ADDR')# Get client remote ip address
88
+
else
89
+
ua_ip=request.ip# Get client x-forwarded-for ip address
90
+
end
91
+
ua_ip
92
+
end
93
+
40
94
41
95
#
42
96
# Handle HTTP requests and call the relevant functions in the derived classes
@@ -47,7 +101,12 @@ def run(request, response)
47
101
48
102
# Web UI base path, like http://beef_domain/<bp>/panel
49
103
auth_url="#{@bp}/authentication"
50
-
104
+
105
+
# If access to the UI is not permitted for the request IP address return a 404
106
+
if !authenticate_request(get_ip(@request))
107
+
return
108
+
end
109
+
51
110
# test if session is unauth'd and whether the auth functionality is requested
52
111
if not @session.valid_session?(@request)and not self.class.eql?(BeEF::Extension::AdminUI::Controllers::Authentication)
@body='{ success : false }'# attempt to fail closed
49
-
50
53
# check if source IP address is permitted to authenticate
51
54
if not permitted_source?(ua_ip)
52
55
BeEF::Core::Logger.instance.register('Authentication',"IP source address (#{@request.ip}) attempted to authenticate but is not within permitted subnet.")
0 commit comments