SQL×¢ÈëÒ»ÈÕͨ£¨Ï£©|Findnet.com.cn
Îå¡¢ÉÏ´«ASPľÂí
ËùνASPľÂí£¬¾ÍÊÇÒ»¶ÎÓÐÌØÊ⹦ÄܵÄASP´úÂ룬²¢·ÅÈëWEBÐéÄâĿ¼µÄScriptsÏ£¬Ô¶³Ì¿Í»§Í¨¹ýIE¾Í¿ÉÖ´ÐÐËü£¬½ø¶øµÃµ½ÏµÍ³µÄUSERȨÏÞ£¬ÊµÏÖ¶ÔϵͳµÄ³õ²½¿ØÖÆ¡£ÉÏ´«ASPľÂíÒ»°ãÓÐÁ½ÖֱȽÏÓÐЧµÄ·½·¨£º
1¡¢ÀûÓÃWEBµÄÔ¶³Ì¹ÜÀí¹¦ÄÜ
Ðí¶àWEBÕ¾µã£¬ÎªÁËά»¤µÄ·½±ã£¬¶¼ÌṩÁËÔ¶³Ì¹ÜÀíµÄ¹¦ÄÜ£»Ò²Óв»ÉÙWEBÕ¾µã£¬ÆäÄÚÈÝÊǶÔÓÚ²»Í¬µÄÓû§Óв»Í¬µÄ·ÃÎÊȨÏÞ¡£ÎªÁË´ïµ½¶ÔÓû§È¨Ï޵ĿØÖÆ£¬¶¼ÓÐÒ»¸öÍøÒ³£¬ÒªÇóÓû§ÃûÓëÃÜÂ룬ֻÓÐÊäÈëÁËÕýÈ·µÄÖµ£¬²ÅÄܽøÐÐÏÂÒ»²½µÄ²Ù×÷,¿ÉÒÔʵÏÖ¶ÔWEBµÄ¹ÜÀí£¬ÈçÉÏ´«¡¢ÏÂÔØÎļþ£¬Ä¿Â¼ä¯ÀÀ¡¢ÐÞ¸ÄÅäÖõȡ£
Òò´Ë£¬Èô»ñÈ¡ÕýÈ·µÄÓû§ÃûÓëÃÜÂ룬²»½ö¿ÉÒÔÉÏ´«ASPľÂí£¬ÓÐʱÉõÖÁÄܹ»Ö±½ÓµÃµ½USERȨÏÞ¶øä¯ÀÀϵͳ£¬ÉÏÒ»²½µÄ“·¢ÏÖWEBÐéÄâĿ¼”µÄ¸´ÔÓ²Ù×÷¶¼¿ÉÊ¡ÂÔ¡£
Óû§Ãû¼°ÃÜÂëÒ»°ã´æ·ÅÔÚÒ»ÕűíÖУ¬·¢ÏÖÕâÕÅ±í²¢¶ÁÈ¡ÆäÖÐÄÚÈݱã½â¾öÁËÎÊÌâ¡£ÒÔϸø³öÁ½ÖÖÓÐЧ·½·¨¡£
A¡¢ ×¢Èë·¨£º
´ÓÀíÂÛÉÏ˵£¬ÈÏÖ¤ÍøÒ³ÖлáÓÐÐÍÈ磺
select * from admin where username='XXX' and password='YYY' µÄÓï¾ä£¬ÈôÔÚÕýʽÔËÐд˾ä֮ǰ£¬Ã»ÓнøÐбØÒªµÄ×Ö·û¹ýÂË£¬ÔòºÜÈÝÒ×ʵʩSQL×¢Èë¡£
ÈçÔÚÓû§ÃûÎı¾¿òÄÚÊäÈ룺abc’ or 1=1-- ÔÚÃÜÂë¿òÄÚÊäÈ룺123 ÔòSQLÓï¾ä±ä³É£º
select * from admin where username='abc’ or 1=1 and password='123’ ²»¹ÜÓû§ÊäÈëÈκÎÓû§ÃûÓëÃÜÂ룬´ËÓï¾äÓÀÔ¶¶¼ÄÜÕýÈ·Ö´ÐУ¬Óû§ÇáÒ×ƹýϵͳ£¬»ñÈ¡ºÏ·¨Éí·Ý¡£
B¡¢²Â½â·¨£º
»ù±¾Ë¼Â·ÊÇ£º²Â½âËùÓÐÊý¾Ý¿âÃû³Æ£¬²Â³ö¿âÖеÄÿÕűíÃû£¬·ÖÎö¿ÉÄÜÊÇ´æ·ÅÓû§ÃûÓëÃÜÂëµÄ±íÃû£¬²Â³ö±íÖеÄÿ¸ö×Ö¶ÎÃû£¬²Â³ö±íÖеÄÿÌõ¼Ç¼ÄÚÈÝ¡£
²Â½âËùÓÐÊý¾Ý¿âÃû ³Æ
HTTP://xxx.xxx.xxx/abc.asp?p=YY and (select count(*) from master.dbo.sysdatabases where name>1 and dbid=6) <>0 ÒòΪ dbid µÄÖµ´Ó1µ½5£¬ÊÇϵͳÓÃÁË¡£ËùÒÔÓû§×Ô¼º½¨µÄÒ»¶¨ÊÇ´Ó6¿ªÊ¼µÄ¡£²¢ÇÒÎÒÃÇÌá½»ÁË name>1 (name×Ö¶ÎÊÇÒ»¸ö×Ö·ûÐ͵Ä×ֶκÍÊý×ֱȽϻá³ö´í),abc.asp¹¤×÷Òì³££¬¿ÉµÃµ½µÚÒ»¸öÊý¾Ý¿âÃû£¬Í¬Àí°ÑDBID·Ö±ð¸Ä³É7,8£¬9,10,11,12…¾Í¿ÉµÃµ½ËùÓÐÊý¾Ý¿âÃû¡£
ÒÔϼÙÉèµÃµ½µÄÊý¾Ý¿âÃûÊÇTestDB¡£
²Â½âÊý¾Ý¿âÖÐÓû§Ãû ±íµÄÃû ³Æ
²Â½â·¨£º´
Ïà¹ØÎĵµ£º
1.²éѯµÄÄ£ºýÆ¥Åä
¾¡Á¿±ÜÃâÔÚÒ»¸ö¸´ÔÓ²éѯÀïÃæʹÓà LIKE '%parm1%'—— ºìÉ«±êʶλÖõİٷֺŻᵼÖÂÏà¹ØÁеÄË÷ÒýÎÞ·¨Ê¹Óã¬×îºÃ²»ÒªÓÃ.
½â¾ö°ì·¨:
ÆäʵֻÐèÒª¶Ô¸Ã½Å±¾ÂÔ×ö¸Ä½ø£¬²éѯËٶȱã»áÌá¸ß½ü°Ù±¶¡£¸Ä½ø·½·¨ÈçÏ£º
a¡¢ÐÞ¸Äǰ̨³ÌÐò——°Ñ²éѯÌõ¼þµÄ¹©Ó¦ÉÌÃû³ÆÒ»À¸ÓÉÔÀ´µÄÎı¾ÊäÈë¸ÄΪÏÂÀÁб ......
Ò»¡¢SQLƴд½¨Òé 1¡¢²éѯʱ²»·µ»Ø²»ÐèÒªµÄÐС¢ÁÐ ÒµÎñ´úÂëÒª¸ù¾Ýʵ¼ÊÇé¿ö¾¡Á¿¼õÉÙ¶Ô±íµÄ·ÃÎÊÐÐÊý£¬×îС»¯½á¹û¼¯£¬ÔÚ²éѯʱ£¬²»Òª¹ý¶àµØʹÓÃͨÅä·ûÈ磺select * from table1Óï¾ä£¬ÒªÓõ½¼¸ÁоÍÑ¡Ôñ¼¸ÁУ¬È磺select col1,col2 from table1;ÔÚ¿ÉÄܵÄÇé¿öϾ¡Á¿ÏÞÖƽá¹û¼¯ÐÐÊýÈ磺se ......
×÷Ϊһ¸öB/S¿ª·¢Õߣ¬»ò¶à»òÉÙ¶¼µÃºÍÊý¾Ý¿â´ò½»µÀ£¬¶ø¶ÔÊý¾Ý¿âµÄ²Ù×÷¹é¸ùµ½µ×¶¼ÊÇqueryÓï¾ä£¬ËùÓе½×îºó¶¼ÊÇΪÁ˲éѯ£¬ÄÇô²é¿´sqlÐÔÄÜÓÖ³ÉÁËÎÒÃÇ¿ª·¢ÖеÄÒ»¼þȤÊ¡£ÏÂÃæ¼òµ¥½éÉÜÏÂsql_traceµÄʹÓãº
alter session set sql_trace =true ;--´ò¿ªsql_trace
select * from (select * from t order by id) where rownum <= ......
°´Ö¸¶¨´ÎÊýÖظ´×Ö·û±í´ïʽ¡£
Óï·¨
REPLICATE ( character_expression, integer_expression)
²ÎÊý
character_expression
×Ö·ûÊý¾ÝÐ͵Ä×ÖĸÊý×Ö±í´ïʽ£¬»òÕß¿ÉÒÔÒþʽת»»Îª nvarchar »ò ntext µÄÆäËûÊý¾ÝÀàÐ͵Ä×ÖĸÊý×Ö±í´ïʽ¡£
integer_expression
¿ÉÒÔÒþʽת»»Îª int µÄ±í´ïʽ¡£Èç¹û integer_expression Ϊ ......