{"id":6983,"date":"2024-11-14T09:54:30","date_gmt":"2024-11-14T01:54:30","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6983\/"},"modified":"2024-11-14T09:54:30","modified_gmt":"2024-11-14T01:54:30","slug":"mysql-sql-%e8%af%ad%e5%8f%a5%e4%b8%ad-11-%e7%9a%84%e5%a6%99%e7%94%a8%ef%bc%9a%e4%b8%ba%e4%bb%80%e4%b9%88%e9%9c%80%e8%a6%81%e6%b7%bb%e5%8a%a0-11%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6983\/","title":{"rendered":"MySQL SQL \u8bed\u53e5\u4e2d 1=1 \u7684\u5999\u7528\uff1a\u4e3a\u4ec0\u4e48\u9700\u8981\u6dfb\u52a0 &#8220;1=1&#8243;\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173025001327529.jpg\" class=\"aligncenter\" title=\"MySQL SQL \u8bed\u53e5\u4e2d 1=1 \u7684\u5999\u7528\uff1a\u4e3a\u4ec0\u4e48\u9700\u8981\u6dfb\u52a0 &#8220;1=1&#8243;\uff1f\u63d2\u56fe\" alt=\"MySQL SQL \u8bed\u53e5\u4e2d 1=1 \u7684\u5999\u7528\uff1a\u4e3a\u4ec0\u4e48\u9700\u8981\u6dfb\u52a0 &#8220;1=1&#8243;\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong> sql \u8bed\u53e5\u4e2d1=1 \u7684\u5999\u7528<\/strong><\/p>\n<p>\u5728mysql \u7684\u539f\u751fsql \u8bed\u53e5\u6216mybatis \u4e2d\uff0c\u7ecf\u5e38\u4f1a\u770b\u5230\u7c7b\u4f3c\u4e8e\u4ee5\u4e0b\u7684\u4ee3\u7801\uff1a<\/p>\n<pre>select ...\nfrom table\nwhere 1=1\nand \u6761\u4ef6a<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5bf9\u4e8e\u521d\u5b66\u8005\u6765\u8bf4\uff0c\u8fd9\u53ef\u80fd\u4f1a\u5f15\u8d77\u7591\u60d1\uff1a\u4e3a\u4ec0\u4e48\u9700\u8981\u6dfb\u52a0&#8221;1=1&#8243;\uff1f <\/p>\n<p><strong>\u539f\u56e0<\/strong><\/p>\n<p>\u4f7f\u7528&#8221;1=1&#8243; \u7684\u76ee\u7684\u662f\u4e3a\u4e86\u907f\u514d\u4ee5\u4e0b\u60c5\u51b5\uff1a<\/p>\n<ul>\n<li> <strong>\u6761\u4ef6a \u5224\u65ad\u51fa\u9519\uff1a <\/strong>\u5f53\u6761\u4ef6a \u4e3afalse \u65f6\uff0c\u6574\u4e2awhere \u8bed\u53e5\u5c06\u4e3afalse\uff0c\u5bfc\u81f4\u67e5\u8be2\u8fd4\u56de0 \u6761\u8bb0\u5f55\u3002 <\/li>\n<li> <strong>\u5411\u6761\u4ef6 a \u4f20\u5165\u7a7a\u503c\uff1a<\/strong>\u5982\u679c\u6761\u4ef6 a \u662f\u4e00\u4e2a\u52a8\u6001\u53c2\u6570\uff0c\u5f53\u5176\u503c\u4e3a\u7a7a\u65f6\uff0c\u5b83\u5c06\u4f7f where \u8bed\u53e5\u65e0\u6548\uff0c\u5bfc\u81f4\u67e5\u8be2\u8fd4\u56de\u9519\u8bef\u3002 <\/li>\n<\/ul>\n<p><strong>\u4e3a\u4ec0\u4e48 1=1 \u4e0d\u5f71\u54cd\u6027\u80fd\uff1f <\/strong><\/p>\n<p>\u6709\u4eba\u53ef\u80fd\u4f1a\u62c5\u5fc3 &#8220;1=1&#8221; \u4f1a\u5f71\u54cd\u67e5\u8be2\u6027\u80fd\u3002\u7136\u800c\uff0c\u6d4b\u8bd5\u8868\u660e\uff0c\u7531\u4e8e &#8220;1=1&#8221; \u603b\u4e3a true\uff0c\u6570\u636e\u5e93\u4f18\u5316\u5668\u4f1a\u5ffd\u7565\u8be5\u6761\u4ef6\u3002\u56e0\u6b64\uff0c\u5728 sql server\u3001\u3001mysql \u548c postgresql \u4e2d\uff0c\u5b83\u4e0d\u4f1a\u5bf9\u6027\u80fd\u4ea7\u751f\u663e\u7740\u5f71\u54cd\u3002 <\/p>\n<p><strong>\u907f\u514d\u4f20\u9012\u7a7a\u503c<\/strong><\/p>\n<p>\u6b63\u5982\u95ee\u9898\u4e2d\u6240\u63d0\u5230\u7684\uff0c\u4f20\u7a7a\u503c\u662f\u4e00\u4e2a\u9700\u8981\u8003\u8651\u7684\u95ee\u9898\u3002\u4e3a\u4e86\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\uff0c\u53ef\u4ee5\u5728sql \u6267\u884c\u524d\u8fdb\u884c\u9002\u5f53\u6027\u68c0\u67e5\uff0c\u6216\u8005\u5728\u6761\u4ef6\u4e3a\u771f\u65f6\u624d\u5c06\u5176\u6dfb\u52a0\u5230where \u8bed\u53e5\u4e2d\uff1a<\/p>\n<pre>WHERE 1=1\nIF A IS TRUE\n  AND xxxx  A\nEND IF<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u603b\u4e4b\uff0c\u5728mysql sql \u8bed\u53e5\u4e2d\u4f7f\u7528&#8221;1=1 &#8221; \u662f\u4e3a\u4e86\u786e\u4fddwhere \u8bed\u53e5\u7684\u8bed\u6cd5\u6b63\u786e\u6027\uff0c\u907f\u514d\u6761\u4ef6\u5224\u65ad\u51fa\u9519\u6216\u7a7a\u503c\u4f20\u9012\u5bfc\u81f4\u7684\u67e5\u8be2\u5931\u8d25\u3002\u5b83\u5bf9\u6027\u80fd\u5f71\u54cd\u5fae\u4e4e\u5176\u5fae\uff0c\u5e76\u4e14\u662f\u7f16\u5199\u52a8\u6001 sql \u8bed\u53e5\u65f6\u7684\u4e00\u79cd\u5e38\u89c1\u4e14\u6709\u7528\u7684\u6280\u672f\u3002 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fMySQL SQL \u8bed\u53e5\u4e2d 1=1 \u7684\u5999\u7528\uff1a\u4e3a\u4ec0\u4e48\u9700\u8981\u6dfb\u52a0 &#8220;1=1&#8243;\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>sql \u8bed\u53e5\u4e2d1=1 \u7684\u5999\u7528 \u5728mysql \u7684\u539f\u751fsql \u8bed\u53e5\u6216mybatis \u4e2d\uff0c\u7ecf\u5e38\u4f1a\u770b\u5230\u7c7b\u4f3c\u4e8e\u4ee5\u4e0b\u7684\u4ee3\u7801\uff1a select &#8230; from table where 1=1 and \u6761\u4ef6a \u767b\u5f55\u540e\u590d\u5236 \u5bf9\u4e8e\u521d\u5b66\u8005\u6765\u8bf4\uff0c\u8fd9\u53ef\u80fd\u4f1a\u5f15\u8d77\u7591\u60d1\uff1a\u4e3a\u4ec0\u4e48\u9700\u8981\u6dfb\u52a0&#8221;1=1&#8243;\uff1f \u539f\u56e0 \u4f7f\u7528&#8221;1=1&#8243; \u7684\u76ee\u7684\u662f\u4e3a\u4e86\u907f\u514d\u4ee5\u4e0b\u60c5\u51b5\uff1a \u6761\u4ef6a \u5224\u65ad\u51fa\u9519\uff1a \u5f53\u6761\u4ef6a \u4e3afalse \u65f6\uff0c\u6574\u4e2awhere \u8bed\u53e5\u5c06\u4e3afalse\uff0c\u5bfc\u81f4\u67e5\u8be2\u8fd4\u56de0 \u6761\u8bb0\u5f55\u3002 \u5411\u6761\u4ef6 a \u4f20\u5165\u7a7a\u503c\uff1a\u5982\u679c\u6761\u4ef6 a \u662f\u4e00\u4e2a\u52a8\u6001\u53c2\u6570\uff0c\u5f53\u5176\u503c\u4e3a\u7a7a\u65f6\uff0c\u5b83\u5c06\u4f7f where \u8bed\u53e5\u65e0\u6548\uff0c\u5bfc\u81f4\u67e5\u8be2\u8fd4\u56de\u9519\u8bef\u3002 \u4e3a\u4ec0\u4e48 1=1 \u4e0d\u5f71\u54cd\u6027\u80fd\uff1f \u6709\u4eba\u53ef\u80fd\u4f1a\u62c5\u5fc3 &#8220;1=1&#8221; \u4f1a\u5f71\u54cd\u67e5\u8be2\u6027\u80fd\u3002\u7136\u800c\uff0c\u6d4b\u8bd5\u8868\u660e\uff0c\u7531\u4e8e &#8220;1=1&#8221; \u603b\u4e3a true\uff0c\u6570\u636e\u5e93\u4f18\u5316\u5668\u4f1a\u5ffd\u7565\u8be5\u6761\u4ef6\u3002\u56e0\u6b64\uff0c\u5728 sql server\u3001\u3001mysql \u548c postgresql \u4e2d\uff0c\u5b83\u4e0d\u4f1a\u5bf9\u6027\u80fd\u4ea7\u751f\u663e\u7740\u5f71\u54cd\u3002 \u907f\u514d\u4f20\u9012\u7a7a\u503c \u6b63\u5982\u95ee\u9898\u4e2d\u6240\u63d0\u5230\u7684\uff0c\u4f20\u7a7a\u503c\u662f\u4e00\u4e2a\u9700\u8981\u8003\u8651\u7684\u95ee\u9898\u3002\u4e3a\u4e86\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\uff0c\u53ef\u4ee5\u5728sql \u6267\u884c\u524d\u8fdb\u884c\u9002\u5f53\u6027\u68c0\u67e5\uff0c\u6216\u8005\u5728\u6761\u4ef6\u4e3a\u771f\u65f6\u624d\u5c06\u5176\u6dfb\u52a0\u5230where \u8bed\u53e5\u4e2d\uff1a WHERE 1=1 IF [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-6983","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6983","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=6983"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6983\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6983"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6983"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6983"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}