More Related Content
Similar to WordPress安全運用の基礎 (20)
WordPress安全運用の基礎
- 2. 自己紹介
● hiro345
twitter: @hiro345
● blog: http://www.sssg.org/blogs/hiro345/
●
執筆
@IT ... Java, Eclipse, Android, C
日経Linux ... Raspberry Pi, Java, Dart
日経ソフトウェア ... Java
Java World, WEB+DB Press など
- 6. 事例
● 第三者によるユーザーサイトの改ざん被害に関するご報告 -
2013年08月29日 10時57分 / 新着情報 / お知らせ -
レンタルサーバーならロリポップ!
http://lolipop.jp/info/news/4149/
– 被害
● サイトタイトルに「Hacked by Krad Xin」が含まれるものに変更された
● サイトのキャッチコピーが「BD GREY HAT HACKERS」と変更された
● サイトの表示が文字化けして読めなくなった
● サービスに登録されている個人情報にアクセスされた形跡はなく情報の流出はない
– 原因
● サーバー側のディレクトリパーミッションが不適切だった
● FollowSymLinks の設定を有効にできる状態であった
● 同一サーバー上のユーザー領域を辿り、他のユーザーの wp-config.php の内容を
参照できた
● 他のユーザが使っているデータベースの更新を実行できた
- 8. WordPressの動作に必要な環境
●
サーバ(サービス提供側)
– OS: Linux
– Web Server: Apache HTTP Server
– Runtime: PHP
– DB Server: MySQL
●
クライアント(サービス利用側)
– Web Brower: Internet Explorer, Firefox, Chrome, Safari
– セキュリティの観点からは利用する JavaScript Engine も
チェックが必要
- 13. 設定例
■コアの自動更新を指定(定数で指定)
define( 'WP_AUTO_UPDATE_CORE', true );
備考)
・true – 開発版、マイナー、メジャーアップグレードをすべて有効化
・false – 開発版、マイナー、メジャーアップグレードをすべて無効化
・minor – マイナーアップグレードのみ有効化(開発版・メジャーアップグレードを無効化)
■コアの自動更新の明示的な指定(フィルタで指定)
add_filter( 'allow_dev_auto_core_updates', '__return_true' );
add_filter( 'allow_minor_auto_core_updates', '__return_true' );
add_filter( 'allow_major_auto_core_updates', '__return_true' );
■コア、プラグイン、テーマ、翻訳の自動更新無効の明示的な指定(フィルタで指定)
add_filter( 'auto_update_core', '__return_false' );
add_filter( 'auto_update_plugin', '__return_false' );
add_filter( 'auto_update_theme', '__return_false' );
add_filter( 'auto_update_translation', '__return_false' );
■自動更新の無効化(定数で指定)
define( 'AUTOMATIC_UPDATER_DISABLED', true );
■自動更新の無効化(フィルタで指定)
add_filter( 'automatic_updater_disabled', '__return_true' );
- 16. パスワードジェネレータ
<?php
class GenPassword {
public $signs = [
'!', '"', '#', '$', '%', '&', ''', '(', ')', '*', '+', ',', '-', '.',
'/', ':', ';', '<', '=', '>', '?', '@', '[', '', ']', '^', '_', '`',
'{', '|', '}', '~', ];
public function getPass($n) {
if ($n < 8) {
$n = 8;
}
return $this->getPassword(1, 1, 3, $n - 5);
}
public function getPassword($s, $n, $A, $a) {
if ($s < 0) $s = 0;
if ($n < 0) $n = 0;
if ($A < 0) $A = 0;
if ($a < 0) $a = 0;
$length = $s + $n + $A + $a;
if ($length < 8) {
$s = 1;
$n = 1;
$A = 3;
$a = 3;
}
$ar = array();
$p = 0;
for ($i = 0; $i < $s; $i++) {
$ar[$p] = $this->getSign();
$p++;
}
public function getSign() {
$index = $this->randomNumber(count($this->signs));
$salt_value = $this->signs[$index];
return $salt_value;
}
public function randomNumber($max = 0x7FFFFFFF) {
if (0x7FFFFFFF < $max) {
$max = 0x7FFFFFFF;
}
$bytes = openssl_random_pseudo_bytes(4);
if ($bytes === false || strlen($bytes) !== 4) {
throw new RuntimeException('randomNumber error');
}
$val = unpack('Nint', $bytes)['int'] & 0x7FFFFFFF;
$fp = (float) $val / 0x7FFFFFFF;
return (int) round($max * $fp);
}
}
$app = new GenPassword();
$s = $app->getPass(8);
for ($i = 0 ; $i<count($s) ; $i++) {
echo $s[$i];
}
echo "n";
for ($i = 0; $i < $n; $i++) {
$ar[$p] = $this->getChar(ord('0'), 9);
$p++;
}
for ($i = 0; $i < $A; $i++) {
$ar[$p] = $this->getChar(ord('A'), 25);
$p++;
}
for ($i = 0; $i < $a; $i++) {
$ar[$p] = $this->getChar(ord('a'), 25);
$p++;
}
shuffle($ar);
return $ar;
}
public function getChar($base, $length) {
$index = $this->randomNumber($length);
$value = $base + $index;
return chr($value);
}