0

我想隐藏所有细节(表结构、数据库设计等)。我该怎么做,我在谷歌搜索并获得了一些信息。

从此,我更改了 config.inc.php 的内容:

<?php

 /* Servers configuration */
 $i = 0;

 /* Server: localhost [1] */
 $i++;
 $cfg['Servers'][$i]['verbose'] = 'localhost';
 $cfg['Servers'][$i]['host'] = 'localhost';
 $cfg['Servers'][$i]['port'] = '';
 $cfg['Servers'][$i]['socket'] = '';
 $cfg['Servers'][$i]['connect_type'] = 'tcp';
 $cfg['Servers'][$i]['extension'] = 'mysqli';
 $cfg['Servers'][$i]['auth_type'] = 'config';
 $cfg['Servers'][$i]['user'] = 'root';
 $cfg['Servers'][$i]['password'] = '';
 $cfg['Servers'][$i]['AllowNoPassword'] = true;
 $cfg['Servers'][$i]['hide_db'] = 'information_schema';

 /* End of servers configuration */

 $cfg['DefaultLang'] = 'en-utf-8';
 $cfg['ServerDefault'] = 1;
 $cfg['UploadDir'] = '';
 $cfg['SaveDir'] = '';


/* rajk - for blobstreaming */
$cfg['Servers'][$i]['bs_garbage_threshold'] = 50;
$cfg['Servers'][$i]['bs_repository_threshold'] = '32M';   
$cfg['Servers'][$i]['bs_temp_blob_timeout'] = 600;
$cfg['Servers'][$i]['bs_temp_log_threshold'] = '32M';


?>

但是,当我去

http://localhost/phpmyadmin/index.php?db=mysql&token=df40bf81f38ce55621e179517c212d62  

我可以看到所有的信息。

有什么解决办法吗?

4

2 回答 2

2

已经隐藏了。它可用的原因是:

  • 没有 密码。
  • 您尚未退出会话,因此包含您的会话信息的 cookie 已验证,您将自动重定向到信息(数据库、表)。这是为了避免每次刷新时都登录。

另外,检查“allownopassword”条目,如果它设置为 true,它允许没有密码的人登录。尝试将其设置为 false。

在 MySQL 中设置 root 密码(以及 root 密码变量。我强烈建议不要将密码放在 php 文件中。)

如果您从未为 MySQL 服务器设置过 root 密码,则服务器允许您在没有密码的情况下识别为 root。要设置 root 密码,请在 shell 中键入:

$ mysqladmin -u root password NEWPASSWORD



<?php

 /* Servers configuration */
 $i = 0;

 /* Server: localhost [1] */
 $i++;
 $cfg['Servers'][$i]['verbose'] = 'localhost';
 $cfg['Servers'][$i]['host'] = 'localhost';
 $cfg['Servers'][$i]['port'] = '';
 $cfg['Servers'][$i]['socket'] = '';
 $cfg['Servers'][$i]['connect_type'] = 'tcp';
 $cfg['Servers'][$i]['extension'] = 'mysqli';
 $cfg['Servers'][$i]['auth_type'] = 'config';
 $cfg['Servers'][$i]['user'] = 'root'; // If you're going to use ROOT for ALL WORK, set a root password and put it below.
 $cfg['Servers'][$i]['password'] = 'PASSWORD';
 $cfg['Servers'][$i]['AllowNoPassword'] = false; // False!
 $cfg['Servers'][$i]['hide_db'] = 'information_schema';

 /* End of servers configuration */

 $cfg['DefaultLang'] = 'en-utf-8';
 $cfg['ServerDefault'] = 1;
 $cfg['UploadDir'] = '';
 $cfg['SaveDir'] = '';


/* rajk - for blobstreaming */
$cfg['Servers'][$i]['bs_garbage_threshold'] = 50;
$cfg['Servers'][$i]['bs_repository_threshold'] = '32M';   
$cfg['Servers'][$i]['bs_temp_blob_timeout'] = 600;
$cfg['Servers'][$i]['bs_temp_log_threshold'] = '32M';


?>

顺便说一句,config 没有密码保护 phpMyAdmin;任何访问正确 URL 的人都直接登录并可以操纵您的服务器。

制作一个 .htaccess 文件来防止这种情况!

Order Deny,Allow
Deny from All
Allow from YourIPAddress
于 2013-02-10T01:07:16.727 回答
0

编辑 config.inc.php:

$cfg['Servers'][$i]['hide_db'] = '^information_schema|mysql|performance_schema|test$'; 
if(in_array($_GET['db'], array('information_schema', 'mysql', 'performance_schema', 'test'))) {
    exit;
}
于 2014-06-27T17:46:07.610 回答