OWASP-IG-006 错误代码的分析
在这一节中,我们将分析比较常见的代码(错误信息)。一个很好的集合可以有效的降低整体的执行渗透测试的时间。
Not Found
The requested URL /page.html was not found on this server.
Apache/2.2.3 (Unix) mod_ssl/2.2.3 OpenSSL/0.9.7g
DAV/2 PHP/5.1.2 Server at localhost Port 80
这是一个常见的 http 404 错误,但是它提供了有用的服务器版本、 OS 、模块和其它产品信息。
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[DBNETLIB][ConnectionOpen(Connect())] - SQL server does not exist or access denied
通过这个错误我们可以得到什么?
80004005
是一个标准的
IIS
错误码,描述是它不能建立连接到其相关的数据库。很多情况下,我们能得到数据库的类型信息。利用这样的信息,渗透测试者能够形成合适的安全测试策略。
By manipulating the variables that are passed to the database connect string
, we can invoke more detailed errors.
通
过
执行
传递
到数据
库
的
连
接字符串
变
量
,我们能得到更多的信息。
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Access 97 ODBC driver Driver]General error Unable to open registry key 'DriverId'
我们能看到数据库系统、和其依赖的 windows 操作系统的注册表键值。
通过 HTML 代码,我们找到隐藏的数据库 IP ,我们能在 URL 中修改数据库服务器的地址,从而欺骗应用程序,使其认为渗透测试者已登录。
另外一个例子:如果知道一个数据库提供 web 应用服务,我们可以尝试 SQL 注入或者 XSS 。
Error Handling in IIS and ASP .net
IIS 很常见,是被大范围使用的 web 服务器。我们试着利用所有的 IIS 错误消息,不过这其实很难。
IIS 的错误消息默认存储在 c:/winnt/help/iishelp/common ,但是默认页可以被修改。当 IIS 收到一个 aspx 页面请求,该请求将被递送到 .NET 框架。
错误处理在 ASP.NET 中的三个地方 :1 在 Web.config 中的 customErrors 节 2. Global.asax 的 Application_Error 3. 在 aspx 或相关的代码隐藏页中
Handling errors using web.config
<customErrors defaultRedirect="myerrorpagedefault.aspx" mode="On|Off|RemoteOnly">
<error statusCode="404" redirect="myerrorpagefor404.aspx"/>
<error statusCode="500" redirect="myerrorpagefor500.aspx"/>
</customErrors>
mode="On" 显示客户端错误, mode=RemoteOnly 显示客户端错误到远程 web 应用用户,本地用户可以查看完整的堆栈跟踪,但是无法看到客户端错误。所有的错误,除非明确规定,将被重定向,即 myerrorpagedefault.aspx 指定的资源重定向。
Handling errors in Global.asax
When an error occurs, the Application_Error sub is called. A developer can write code for error handling / page redirection in this sub.
Private Sub Application_Error (ByVal sender As Object, ByVal e As System.EventArgs)
Handles MyBase.Error
End Sub
Handling errors in Page_Error sub
This is similar to application error.
Private Sub Page_Error (ByVal sender As Object, ByVal e As System.EventArgs)
Handles MyBase.Error
End Sub
Error hierarchy in ASP .net
Page_Error sub will be processed first, followed by global.asax Application_Error sub, and, finally, customErrors section in web.config file.
How to test for ASP.net and IIS Error Handling
怎样来检测
asp.net
和
IIS
的错误处理
http://www.mywebserver.com/anyrandomname.asp
If the server returns
The page cannot be found
HTTP 404 - File not found
Internet Information Services
it means that IIS custom errors are not configured. Please note the .asp extension.
这意味着该
IIS
自定义错误未配置。请注意
asp
扩展名。
Test:
telnet <host target> 80
GET /<wrong page> HTTP/1.1
<CRLF><CRLF>
Result:
HTTP/1.1 404 Not Found
Date: Sat, 04 Nov 2006 15:26:48 GMT
Server: Apache/2.2.3 (Unix) mod_ssl/2.2.3 OpenSSL/0.9.7g
Content-Length: 310
Connection: close
Content-Type: text/html; charset=iso-8859-1
获得服务器型号版本信息。
Test:
1. network problems
2. bad configuration about host database address
Result:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005) '
[MySQL][ODBC 3.51 Driver]Unknown MySQL server host
Test:
1. Authentication failed
2. Credentials not inserted
Result:
Firewall version used for authentication:
用于认证的防火墙版本
Error 407
FW-1 at <firewall>: Unauthorized to access the document.
Authorization is needed for FW-1.
The authentication required by FW-1 is: unknown.
Reason for failure of last attempt: no user
Black Box testing and example
黑盒
测试示例
Test:
Enumeration of the directories with access denied.
枚举被拒绝访问的目录。
Result:
Directory Listing Denied
This Virtual Directory does not allow contents to be listed.
Forbidden
You don't have permission to access /<dir> on this server.
Gray Box testing and example
灰盒测试示例