OWASP-IG-006

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 擴展名。

 

Black Box testing and example 黑盒 測試示例

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

 

 

Gray Box testing and example 灰盒測試示例

Test:

Enumeration of the directories with access denied.

枚舉被拒絕訪問的目錄。

 

http://<host>/<dir>

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.

 

 

 

 

 

 

 

 

 

 

發佈了40 篇原創文章 · 獲贊 2 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章