{"id":9773,"date":"2023-03-20T01:38:10","date_gmt":"2023-03-19T16:38:10","guid":{"rendered":"https:\/\/takashi.5252.jp\/blog\/?p=9773"},"modified":"2025-09-25T18:26:24","modified_gmt":"2025-09-25T09:26:24","slug":"%e8%87%aa%e5%8b%95%e7%9a%84%e3%81%ab%e3%83%96%e3%83%a9%e3%83%83%e3%82%af%e3%83%aa%e3%82%b9%e3%83%88%e3%81%ab%e7%99%bb%e9%8c%b2","status":"publish","type":"post","link":"https:\/\/takashi.5252.jp\/blog\/archives\/2023\/03\/20\/013810\/9773.html","title":{"rendered":"\u81ea\u52d5\u7684\u306b\u30d6\u30e9\u30c3\u30af\u30ea\u30b9\u30c8\u306b\u767b\u9332"},"content":{"rendered":"\n<p><a href=\"https:\/\/takashi.5252.jp\/blog\/archives\/2023\/03\/20\/010437\/9762.html\" title=\"web\u6539\u3056\u3093\u3055\u308c\u307e\u3057\u305f\u3002\">SPAM\u306e\u8e0f\u307f\u53f0\u306b\u3055\u308c\u305f\u4ef6<\/a><br \/>\u305d\u306e\u5f8c\u306e\u30ed\u30b0\u3092\u898b\u308b\u3068\u3001403.php\u3078\u306e\u30a2\u30af\u30bb\u30b9\u304c\u307e\u3060\u305f\u304f\u3055\u3093\u6765\u307e\u3059\u3002<br \/>\u3053\u308c\u306f\u3046\u3063\u3068\u304a\u3057\u3059\u304e\u3002<br \/>\u3067\u3001<a href=\"https:\/\/chat.openai.com\/chat\">chatGPT<\/a>\u306e\u529b\u3092\u501f\u308a\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>\u4ee5\u524d\u304b\u3089spam\u3088\u3051\u3067.htaccess \u3092\u4f7f\u3063\u3066\u30a2\u30af\u7981\u5bfe\u5fdc\u3057\u3066\u3044\u308b\u306e\u3067<br \/>\n\u300cweb\u30da\u30fc\u30b8\u3067\u3001\u3042\u308b\u30d5\u30a1\u30a4\u30eb\u306b\u30a2\u30af\u30bb\u30b9\u3057\u305f\u3089\u3001\u30a2\u30af\u30bb\u30b9\u3057\u3066\u304d\u305f\u76f8\u624b\u306eIP\u30a2\u30c9\u30ec\u30b9\u3092.htaccess\u306e\u30a2\u30af\u30bb\u30b9\u7981\u6b62\u30ea\u30b9\u30c8\u306b\u8ffd\u52a0\u3059\u308b\u3088\u3046\u306aPHP\u306e\u30b3\u30fc\u30c9\u3070\u66f8\u3051\u307e\u305b\u3093\u304b?\u300d<br \/>\n\u3068\u5c0b\u306d\u3066\u307f\u308b\u3068<br \/>\n\u300c\u4ee5\u4e0b\u306f\u3001\u30a2\u30af\u30bb\u30b9\u3057\u305f\u76f8\u624b\u306eIP\u30a2\u30c9\u30ec\u30b9\u3092\u53d6\u5f97\u3057\u3001\u305d\u308c\u3092.htaccess\u30d5\u30a1\u30a4\u30eb\u306e\u30a2\u30af\u30bb\u30b9\u7981\u6b62\u30ea\u30b9\u30c8\u306b\u8ffd\u52a0\u3059\u308bPHP\u30b3\u30fc\u30c9\u306e\u4f8b\u3067\u3059\u3002\u300d<br \/>\n\u3068\u6559\u3048\u3066\u304f\u308c\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\/\/ \u30a2\u30af\u30bb\u30b9\u3057\u305f\u76f8\u624b\u306eIP\u30a2\u30c9\u30ec\u30b9\u3092\u53d6\u5f97\n$ip_address = $_SERVER&#91;'REMOTE_ADDR'];\n\n\/\/ \u8ffd\u52a0\u3059\u308b.htaccess\u30d5\u30a1\u30a4\u30eb\u306e\u30d1\u30b9\n$htaccess_file_path = '\/path\/to\/.htaccess';\n\n\/\/ \u30a2\u30af\u30bb\u30b9\u7981\u6b62\u30ea\u30b9\u30c8\u306b\u8ffd\u52a0\u3059\u308bIP\u30a2\u30c9\u30ec\u30b9\n$deny_ip = \"deny from \" . $ip_address . \"\\n\";\n\n\/\/ .htaccess\u30d5\u30a1\u30a4\u30eb\u304c\u66f8\u304d\u8fbc\u307f\u53ef\u80fd\u304b\u3069\u3046\u304b\u78ba\u8a8d\nif(is_writable($htaccess_file_path)){\n  \/\/ \u30d5\u30a1\u30a4\u30eb\u3092\u958b\u3044\u3066\u3001\u65e2\u5b58\u306e\u5185\u5bb9\u306b\u8ffd\u52a0\n  $htaccess_file = fopen($htaccess_file_path, 'a');\n  fwrite($htaccess_file, $deny_ip);\n  fclose($htaccess_file);\n  echo \"IP address \".$ip_address.\" has been added to the access blacklist.\";\n} else {\n  echo \"Could not write to .htaccess file. Please check file permissions.\";\n}\n?&gt;\n<\/code><\/pre>\n\n\n\n<p>.htaccess\u30d5\u30a1\u30a4\u30eb\u306e\u30d1\u30b9\u306f\u3072\u3068\u307e\u305a\u300c.\/.htaccess\u300d\u306b\u3057\u3066\u3001<br \/>\n&lt;html&gt;&lt;body&gt; \uff5e\u6559\u3048\u3066\u3082\u3089\u3063\u305f\u30b3\u30fc\u30c9\uff5e&lt;\/body&gt;&lt;\/html&gt;<br \/>\n\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u3063\u3066 403.php\u3068\u3044\u3046\u540d\u524d\u3067\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3057\u3066\u30a2\u30af\u30bb\u30b9\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3059\u308b\u3068\u30011\u5ea6\u76ee\u306b\u300c\u30d6\u30e9\u30c3\u30af\u30ea\u30b9\u30c8\u306b\u8f09\u305b\u305f\u3088\u300d\u3068\u51fa\u3066\u30012\u5ea6\u3081\u304b\u3089\u306f403\u30a8\u30e9\u30fc\u3067\u30a2\u30af\u30bb\u30b9\u3067\u304d\u306a\u304f\u306a\u308a\u307e\u3057\u305f\u3002<br \/>\n.htaccess\u306e\u4e2d\u8eab\u3092\u307f\u3066\u3082\u3061\u3083\u3093\u3068\u8ffd\u52a0\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3046\u307e\u304f\u884c\u3063\u305f\u3088\u3046\u306a\u306e\u3067\u3001403.php\u3084DKIZ.php\u3001lfix.php \u306e\u540d\u524d\u3067\u3001\u5404\u30b5\u30a4\u30c8\u306e\u30eb\u30fc\u30c8\u306b\u7f6e\u3044\u3066\u304a\u304d\u307e\u3057\u305f\u3002<br \/>\u5404\u30b5\u30a4\u30c8\u306e\u30eb\u30fc\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u4ee5\u5916\u306b\u306f\u304a\u3044\u3066\u306a\u3044\u3051\u3069\u3001\u30ed\u30b0\u3092\u898b\u308b\u3068\u307e\u305a \/403.php \u306b\u6765\u3066\u3044\u308b\u3088\u3046\u306a\u306e\u3067\u3001\u3072\u3068\u307e\u305a\u306f\u3053\u308c\u3067\u69d8\u5b50\u898b\u3066\u307f\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3042\u3001\u79c1\u81ea\u8eab\u306e\u30a2\u30af\u7981\u306f.htaccess \u66f8\u304d\u63db\u3048\u3066\u89e3\u9664\u3057\u307e\u3057\u305f\u3088\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>SPAM\u306e\u8e0f\u307f\u53f0\u306b\u3055\u308c\u305f\u4ef6\u305d\u306e\u5f8c\u306e\u30ed\u30b0\u3092\u898b\u308b\u3068\u3001403.php\u3078\u306e\u30a2\u30af\u30bb\u30b9\u304c\u307e\u3060\u305f\u304f\u3055\u3093\u6765\u307e\u3059\u3002\u3053\u308c\u306f\u3046\u3063\u3068\u304a\u3057\u3059\u304e\u3002\u3067\u3001chatGPT\u306e\u529b\u3092\u501f\u308a\u307e\u3057\u305f\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[188],"tags":[968,952,969,56,1077],"class_list":["post-9773","post","type-post","status-publish","format-standard","hentry","category-internet","tag-htaccess-2","tag-chatgpt","tag-969","tag-56","tag-1077"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5j0PG-2xD","jetpack_likes_enabled":false,"_links":{"self":[{"href":"https:\/\/takashi.5252.jp\/blog\/wp-json\/wp\/v2\/posts\/9773","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/takashi.5252.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/takashi.5252.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/takashi.5252.jp\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/takashi.5252.jp\/blog\/wp-json\/wp\/v2\/comments?post=9773"}],"version-history":[{"count":5,"href":"https:\/\/takashi.5252.jp\/blog\/wp-json\/wp\/v2\/posts\/9773\/revisions"}],"predecessor-version":[{"id":10263,"href":"https:\/\/takashi.5252.jp\/blog\/wp-json\/wp\/v2\/posts\/9773\/revisions\/10263"}],"wp:attachment":[{"href":"https:\/\/takashi.5252.jp\/blog\/wp-json\/wp\/v2\/media?parent=9773"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/takashi.5252.jp\/blog\/wp-json\/wp\/v2\/categories?post=9773"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/takashi.5252.jp\/blog\/wp-json\/wp\/v2\/tags?post=9773"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}