Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

½â¾öSQL Injection©¶´µÄÒ»¸öº¯Êý

½â¾öSQL Injection©¶´µÄÒ»¸öº¯Êý
http://blog.csdn.net/cncco/archive/2006/04/07/654254.aspx
º¯Êý
<%
Function CheckInput(str,strType)
   'º¯Êý¹¦ÄÜ£º¹ýÂË×Ö·û²ÎÊýÖеĵ¥ÒýºÅ£¬¶ÔÓÚÊý×Ö²ÎÊý½øÐÐÅжϣ¬Èç¹û²»ÊÇÊýÖµÀàÐÍ£¬Ôò¸³Öµ0
   '²ÎÊýÒâÒ壺  str        ---- Òª¹ýÂ˵IJÎÊý
   '                 strType ---- ²ÎÊýÀàÐÍ£¬·ÖΪ×Ö·ûÐͺÍÊý×ÖÐÍ£¬×Ö·ûÐÍΪ"s"£¬Êý×ÖÐÍΪ"i"
 Dim strTmp
 strTmp     = ""
 If strType ="s" Then
  strTmp = Replace(Trim(str),"'","'")
 ElseIf strType="i" Then
  If isNumeric(str)=False Then str="0"
  strTmp = str
 Else
  strTmp = str
 End If
 CheckInput = strTmp
End Function
%>
Õâ¸öº¯ÊýºÜ¼òµ¥£¬ Ö÷ÒªÊÇÕë¶Ô×Ö·û´®ºÍÊý×ÖÁ½ÖÖÀàÐ͵Ĵ«ÈëÊý¾Ý·Ö±ð½øÐÐÁË´¦Àí£¬¾ßÌåÓ÷¨£º
×Ö·ûÀàÐ͵Ä
strUsername = CheckInput(Request(“username“),“s“)
Êý×ÖÀàÐ͵Ä
ID = CheckInput(Request(“id“),“i“)
SQL InjectionµÄΣº¦ÊǺܴóµÄ£¬±ÈÈç¶ÔÓÚSQL Server£¬¿ÉÒÔ´´½¨¡¢É¾³ýÊý¾Ý¿â£¬Ö´ÐÐϵͳÃüÁîµÈµÈ£¬ Èçdrop table tbl_name, execute master.dbo.xp_cmdshell "command"ËùÒԺܶàÈËдµÄº¯Êý¾ÍÊÇÆ´ÃüµÄÈ¥¹ýÂËÕâЩ¿ÉÄÜÒýÆðΣº¦µÄ¹Ø¼ü´Ê£¬±ÈÈçdrop ,·ÖºÅ,and,exe,midµÈµÈ£¬ÂÞÁÐÁËÒ»´ó¶Ñ¡£
Æäʵ£¬¾¡¿ÉÒÔ²»±ØÄÇô·±Ëö£¬·ÇÒª°Ñ¼òµ¥µÄÊÂÇ鸴ÔÓ»¯¡£
¶ÔÓÚ¹ýÂË£¬ASPÖÐÖ»ÒªÕë¶Ô×Ö·ûÐͺÍÊý×ÖÐÍ·Ö±ð´¦Àí¾Í¿ÉÒÔÁË£¬
×Ö·ûÐ͵ģ¬°Ñµ¥ÒýºÅת»»³ÉÁ½¸öµ¥ÒýºÅ  strTmp = Replace(Trim(str),"'","'")
Êý×ÖÐ͵ģ¬¾ÍÅжÏÊÇ·ñÄܹ»×ª»»³ÉÊý×ÖÐ굀 £¬Óà isNumericº¯Êý
ÏÖÔÚÍøÉÏ˵µÄÄܹ»Èƹýµ¥ÒýºÅµÄ¹¥»÷£¬ÆäʵÊÇÕë¶ÔÊý×ÖÀàÐ͵Ä,Èç¹û¶ÔÓÚ¹ýÂËÁ˵¥ÒýºÅµÄ×Ö·ûÐÍ£¬»¹Óа취Èƹý£¬ÄǾÍûµÃÍæÁË........
±¾ÎÄÀ´×ÔCSDN²©¿Í£¬×ªÔØÇë±êÃ÷³ö´¦£ºhttp://blog.csdn.net/cncco/archive/2006/04/07/654254.aspx


Ïà¹ØÎĵµ£º

SQL»ù´¡Ìâ

Student(S#,Sname,Sage,Ssex) ѧÉú±í
Course(C#,Cname,T#) ¿Î³Ì±í
SC(S#,C#,score) ³É¼¨±í
Teacher(T#,Tname) ½Ìʦ±í
ÎÊÌ⣺
1¡¢²éѯ“001”¿Î³Ì±È“002”¿Î³Ì³É¼¨¸ßµÄËùÓÐѧÉúµÄѧºÅ£»
select a.S# from (select s#,score from SC where C#='001') a,(select s#,score
from SC wher ......

Sql»ù±¾Óï¾äµÄѧϰ

--²éѯÿ¸öÈ˶©·¹µÄ´ÎÊý
select  username as ÐÕÃû, count(*) as ´ÎÊý from orderitems  group by UserName having count(*)=1
order by ÐÕÃû desc
select distinct username as δע²áÐÕÃû from orderitems
where username not in (select [Name] from Person)
select distinct username as ÒÑ×¢²áÐÕÃû fr ......

SQL SERVER³£ÓÃÈÕÆÚº¯Êý


1.Ò»¸öÔµÚÒ»ÌìµÄ
Select DATEADD(mm, DATEDIFF(mm,0,getdate()), 0)
2.±¾ÖܵÄÐÇÆÚÒ»
Select DATEADD(wk, DATEDIFF(wk,0,getdate()), 0)
3.Ò»ÄêµÄµÚÒ»Ìì
Select DATEADD(yy, DATEDIFF(yy,0,getdate()), 0)
4.¼¾¶ÈµÄµÚÒ»Ìì
Select DATEADD(qq, DATEDIFF(qq,0,getdate()), 0)
5.µ±ÌìµÄ°ëÒ¹
Select DATEADD(dd, DAT ......

sql server back up database

sql server  »¹Ô­Ò»¸öÊý¾Ýµ½¾ßÌåµÄʱ¼ä
Êý¾Ý¿âµÄ¸½¼Ó:
sp_attach_db mark ,'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\mark.mdf'
Êý¾Ý¿âµÄ·ÖÀë:
sp_deattach_db mark ,'C:\Program Files\Microsoft SQL
Server\MSSQL.1\MSSQL\Data\mark.mdf'
Êý¾Ý¿âµÄÍêÈ«±¸·Ý:
backup database mark to disk ......

VBʵÏÖSQL ServerÊý¾Ý¿â±¸·Ý/»Ö¸´

VBʵÏÖSQL ServerÊý¾Ý¿â±¸·Ý/»Ö¸´
http://blog.csdn.net/cncco/archive/2006/05/15/729356.aspx
’**Ä£ ¿é Ãû£ºfBackupDatabase_a
’**Ãè    Êö£º±¸·ÝÊý¾Ý¿â,·µ»Ø³ö´íÐÅÏ¢,Õý³£»Ö¸´,·µ»Ø""
’**µ÷    ÓãºfBackupDatabase_a "±¸·ÝÎļþÃû","Êý¾Ý¿âÃû"
’**²ÎÊý˵Ã÷£ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ