10
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

個人情報を抜かれる危険性を認識したのでApacheの設定を見直した

Last updated at Posted at 2021-07-29

概要

アクセス履歴を見たところ次のような履歴を見つけた

GET /composer.json
GET /.git/.env
GET /.git/config
GET /.idea/workspace.xml
GET /.settings/org.eclipse.core.resources.prefs
GET /nbproject/private/private.xml
GET /administrator/phpmyadmin/index.php
POST /vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php

Git、IntelliJ、NetBeans、Eclipseのファイルを開こうとしたり、phpMyAdminの管理画面を探したり、PHPUnitの脆弱性から何か悪い事をしようと考えているのは明らか。基本的にはドキュメントルートとプロジェクトのルートは別のため/.gitや/vendorにアクセスされる事はないが、一部ドキュメントルートとプロジェクトルートが同じプロジェクトがあったので見直した。

作業内容

各ディレクトリに.htaccessを設置

  • .git
  • .idea
  • .settings
  • nbproject
  • vendor

内容はアクセス禁止

.htaccess
AllowOverride none
Require all denied

httpd.confとドキュメントルートの.htaccessに記述

アクセスされたくないディレクトリやファイルへのアクセスは404リダイレクトするよう追記
※phpMyAdminを使うURLの時はvendorをアクセスできるようにしておかないと使えません

.htaccess
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /

  # ドットから始まるディレクトリとファイルへのアクセス禁止
  RedirectMatch 404 /\..*$

  # vendorとnbproject(netBeans)へのアクセス禁止
  RedirectMatch 404 /(vendor|nbproject)/

  # .iml(IntelliJ)ファイルへのアクセス禁止
  RedirectMatch 404 .*\.iml

  # composer関連へのアクセス禁止
  RedirectMatch 404 composer\.(phar|json|lock)

</IfModule>

個人的なテスト用のディレクトリに.htaccessを設置

ローカルアドレスで私のパソコンからのみとした

.htaccess
Order Allow,Deny
Allow from 127.0.0.1
Allow from 192.168.0.11

残作業

悪意のあるURLで接続を試みてきたら、数週間IPアドレスをバンする

追記:PHP 不正なURLで接続してきたIPアドレスを.htaccessにDeny fromに書き込む

10
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?