SQL injection vulnerability full contact - Getting Started (2)

xiaoxiao2021-03-06  56

So, what kind of test method is more accurate? The answer is as follows:

1 http://www.19cn.com/showdetail.asp?id=49

2 http://www.19cn.com/showdetail.asp?id=49 and 1 = 1

3 http://www.19cn.com/showdetail.asp?id=49 and 1 = 2

This is the classic 1 = 1, 1 = 2 test method, how to judge? See what the three URLs returned above:

Performance of can be injected:

1 Normal display (this is inevitable, otherwise it is wrong)

2 Normal display, content is basically the same as 1

3 prompts BOF or EOF (when the program does not do any judgment), or the record is not found (judge RS.eof), or the display is empty (the program adds an ON Error Resume next)

It is easier to judge if it cannot be injected, and 1 is also normal display, 2 and 3 generally have a program defined error message, or an error occurred during the prompt type.

Of course, this is just the incoming parameter is the judgment method used by the digital type. When actual application, there will be character types and search type parameters, I will analyze the "SQL Injecting General Steps" in the intermediate level.

In the third quarter, judgment the database type and injection method

Different database functions, the injection method is different, so before the injection, we must also judge the type of database. General ASP's most frequently matched databases are ACCESS and SQLSERVER, one of more than 99% of websites online.

How to let the program tell you what database it uses? come and see:

SQLServer has some system variables, if the server IIS prompt is not closed, and SQL Server returns an error prompt, you can get directly from the error information, the method is as follows:

http://www.19cn.com/showdetail.asp?id=49 and user> 0

This sentence is very simple, but it contains the essence of SQLServer's unique injection method. I also found this efficient susceptibility in a unintentional test. Let me see its meaning: First, the front statement is normal, focus on and user> 0, we know, User is a built-in variable of SQL Server, which is the user name currently connected, type NVARCHAR . Take a nVarchar value to the intra 0 comparison, the system will try to turn nvarchar's value to int type. Of course, the process will definitely errors in the process, and SQL Server error prompt is: convert the nVARCHAR value "ABC" conversion data type When INT's column, the syntax error occurs, huh, ABC is the value of the variable user, so that the power of the database is not scrapped. In the subsequent space, everyone will see a lot of statements with this method.

By the way, it is well known that SQLServer's user sa is a role of equivominstrators permissions, got SA permissions, almost certainly gets the host's Administrator. The above method can be very convenient to test whether it is logged in with sa, if it is the SA login, the prompt is a column that converts "DBO" into an int to errors, not "SA".

If the server IIS is not allowed to return an error prompt, how do you determine the database type? We can start from Access and SQL Server and distinguish, Access and Sql Server have its own system table, such as storing all objects in the database, Access is in system table [msysObjects], but read the table in the web environment " No permissions, "SQL Server is in the table [sysObjects], which can be read normally in a web environment. In the case where you can inject, use the following statement:

http://www.19cn.com/showdetail.asp?id=49 and (select count (*) from sysobjects> 0

http://www.19cn.com/showdetail.asp?id=49 and (Select Count (*) from MsysObjects> 0

If the database is SQL Server, the page of the first URL is approximately the same as the original page http://www.19cn.com/showdetail.asp?id=49; and the second URL, because the table MsysObjects is not found, Will prompt an error, even if the program has fault tolerance, the page is completely different from the original page.

If the database uses Access, then the situation is different, the page of the first URL is completely different from the original page; the second URL, depending on whether the database settings are allowed to read the system table, generally not allowed Therefore, it is also completely different from the original website. In most cases, use the first URL to know the database type used by the system, and the second URL only uses authentication when IIS error prompt.

(Source: 9cbs)

转载请注明原文地址:https://www.9cbs.com/read-115568.html

New Post(0)