{"id":2120,"date":"2021-10-03T10:52:40","date_gmt":"2021-10-03T01:52:40","guid":{"rendered":"https:\/\/sirius10.net\/blog\/wordpress\/?p=2120"},"modified":"2022-02-07T12:53:08","modified_gmt":"2022-02-07T03:53:08","slug":"post-2120","status":"publish","type":"post","link":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/2021\/10\/03\/2120\/","title":{"rendered":"fake_bot \u3092\u4fee\u6b63"},"content":{"rendered":"\n<p>\u3000\u4ee5\u524d\u3001gogglebot \u3084 bingbot \u3092\u8a50\u79f0\u3059\u308b\u30db\u30b9\u30c8\u3092\u3001.htacces \u3067\u62d2\u5426\u3059\u308b\u3088\u3046\u306b\u3057\u305f SHELL \u30b9\u30af\u30ea\u30d7\u30c8\u3092\u4f5c\u308a\u307e\u3057\u305f<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-sirius-\u306e\u30d6\u30ed\u30b0 wp-block-embed-sirius-\u306e\u30d6\u30ed\u30b0\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"t22gUgKsQL\"><a href=\"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/2021\/09\/08\/1957\/\">\u507d\u306e gogglebot \u3084 bingbot \u306b\u5bfe\u51e6\u3059\u308b<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;\u507d\u306e gogglebot \u3084 bingbot \u306b\u5bfe\u51e6\u3059\u308b&#8221; &#8212; Sirius \u306e\u30d6\u30ed\u30b0\" src=\"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/2021\/09\/08\/1957\/embed\/#?secret=s4CxUjYEIo#?secret=t22gUgKsQL\" data-secret=\"t22gUgKsQL\" width=\"500\" height=\"282\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><figcaption>fake-bot<\/figcaption><\/figure>\n\n\n\n<p>\u3000\u4e00\u90e8\u3092\u4fee\u6b63\u3057\u307e\u3057\u305f\u3002\u3000\u4fee\u6b63\u3057\u305f\u306e\u306f\u3001\u4ee5\u4e0b\u306e\u8272\u3092\u4ed8\u3051\u305f\u90e8\u5206\u3067\u3059\u3002<\/p>\n\n\n\n<p>(2022.02.27 \u8ffd\u8a18) <span style=\"color: #ff0000\" class=\"text-color\">\u4ee5\u4e0b\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u306b\u4e0d\u5177\u5408\u304c\u3042\u308b\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3057\u305f\u3002\u4f7f\u7528\u3057\u306a\u3044\u3067\u304f\u3060\u3055\u3044\u3002<\/span><\/p>\n\n\n\n<pre class=\"wp-block-preformatted file\"><strike>#!\/bin\/bash\n\ntrap 'rm -f ${tmpfile}; exit 1' 1 2 3 15\n\ntmpfile=\/tmp\/fake_bot$$\nif [ -f \"${tmpfile}\" ]; then\n    rm -f \"${tmpfile}\"\nfi\n\nedit_htaccess () {\n    newip=$1\n    htaccess_list=\".htaccess blog\/wordpress\/.htaccess\"\n\n    for htaccess in ${htaccess_list}\n    do\n        target=\"\/var\/www\/sirius10\/${htaccess}\"\n        if\n            ! grep \"${newip}\" \"${target}\" &gt; \/dev\/null\n        then\n            echo \"Add new deny ${newip} to ${htaccess}.\"\n            sed -e \"s\/^\\(&lt;\\\/RequireAll&gt;\\)$\/  Require not ip ${newip}\\n\\1\/\" -i \"${target}\"\n        fi\n    done\n}\n\napache_log=\"\u30ed\u30b0\u30d5\u30a1\u30a4\u30eb\u540d\"\nsafe_domain=\"googlebot.com\"\nua=\"Googlebot\"\n\nif [ $# -eq 2 ]; then\n    ua=$1\n    safe_domain=$2\nelif [ $# -ne 0 ]; then\n    echo \"Usage: $0 [&lt;ua&gt; &lt;safe domain&gt;]\"\n    exit\nfi\n\nfor log in ${apache_log}\ndo\n    grep \"${ua}\" \/var\/log\/apache2\/${log} | sed -e 's\/\\(^.*\\) - - \\[.*\/\\1\/' | grep -v \"${safe_domain}$\" &gt;&gt; ${tmpfile}\ndone\n\nfor ip in $(sort -u ${tmpfile})\ndo\n<span style=\"background-color: #adff2f\" class=\"background-color\">    if\n        ! expr \"${ip}\" : '[0-9][0-9]*\\.[0-9][0-9]*\\.[0-9][0-9]*\\.[0-9][0-9]*' &gt; \/dev\/null\n    then\n        domain=${ip}\n        ina=$(dig \"${domain}\" | grep '^[^;].* IN A ')\n        ip=${ina##*IN A}\n        ip=$(echo ${ip})\n    else\n        ptr=$(dig -x ${ip} | grep \"^[^;].*PTR\")\n        domain=${ptr##*PTR}\n        domain=$(echo ${domain})\n    fi<\/span>\n    if [ \"${domain}\" != \"\" ]; then\n        if\n            ! echo ${domain} | grep \"${safe_domain}.$\" &gt;\/dev\/null\n        then\n            echo \"Fake ${ua} ${ip} ${domain}\"\n            edit_htaccess ${ip}\n        fi\n    else\n        echo \"Fake $ua ${ip}\"\n        edit_htaccess ${ip}\n    fi\ndone\n\nif [ -f \"${tmpfile}\" ]; then\n    rm -f \"${tmpfile}\"\nfi<\/strike><\/pre>\n\n\n\n<p>\u3000\u6b63\u898f\u306e\u30c9\u30e1\u30a4\u30f3\u4ee5\u5916\u3067\u3082 Apache \u3067\u540d\u524d\u89e3\u6c7a\u3067\u304d\u305f\u3082\u306e\u304c\u6709\u3063\u305f\u306e\u3067\u3001\u305d\u308c\u306b\u5bfe\u51e6\u3057\u307e\u3057\u305f\u3002Fake bot \u306f\u305d\u308c\u307b\u3069\u591a\u304f\u306a\u3044\u306e\u304b\u3001\u62d2\u5426\u3057\u3066\u3044\u308b IP \u306f\u4eca\u306e\u6240 7 \u3064\u3060\u3051\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3000\u4ee5\u524d\u3001gogglebot \u3084 bingbot \u3092\u8a50\u79f0\u3059\u308b\u30db\u30b9\u30c8\u3092\u3001.htacces \u3067\u62d2\u5426\u3059\u308b\u3088\u3046\u306b\u3057\u305f SHELL \u30b9\u30af\u30ea\u30d7\u30c8\u3092\u4f5c\u308a\u307e\u3057\u305f \u3000\u4e00\u90e8\u3092\u4fee\u6b63\u3057\u307e\u3057\u305f\u3002\u3000\u4fee\u6b63\u3057\u305f\u306e\u306f\u3001\u4ee5\u4e0b\u306e\u8272\u3092\u4ed8\u3051\u305f\u90e8\u5206\u3067\u3059\u3002 (2022 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-2120","post","type-post","status-publish","format-standard","hentry","category-server-config"],"_links":{"self":[{"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/2120","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/comments?post=2120"}],"version-history":[{"count":4,"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/2120\/revisions"}],"predecessor-version":[{"id":2570,"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/2120\/revisions\/2570"}],"wp:attachment":[{"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=2120"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/categories?post=2120"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/tags?post=2120"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}