當(dāng)前位置:首頁(yè) > IT技術(shù) > 數(shù)據(jù)庫(kù) > 正文

MySQL安裝控制插件(Connection-Control)--可有效的防止客戶端暴力登錄的風(fēng)險(xiǎn)(攻擊)
2021-10-20 10:42:28

插件介紹

MySQL 5.7.17 以后提供了Connection-Control插件用來(lái)控制客戶端在登錄操作連續(xù)失敗一定次數(shù)后的響應(yīng)的延遲。該插件可有效的防止客戶端暴力登錄的風(fēng)險(xiǎn)(攻擊)。該插件包含以下2個(gè)組件

  • CONNECTION_CONTROL:用來(lái)控制登錄失敗的次數(shù)及延遲響應(yīng)時(shí)間
  • CONNECTION_CONTROL_FAILED_LOGIN_ATTEMPTS:該表將登錄失敗的操作記錄至IS庫(kù)中

插件安裝

-- 配置文件增加以下配置
[mysqld]
plugin-load-add									= connection_control.so
connection-control                             	= FORCE
connection-control-failed-login-attempts       	= FORCE
connection_control_min_connection_delay			= 1000
connection_control_max_connection_delay			= 86400
connection_control_failed_connections_threshold	= 3


-- 插件動(dòng)態(tài)安裝啟用
mysql> INSTALL PLUGIN CONNECTION_CONTROL SONAME 'connection_control.so';
mysql> INSTALL PLUGIN CONNECTION_CONTROL_FAILED_LOGIN_ATTEMPTS SONAME 'connection_control.so';

-- 驗(yàn)證是否正常安裝
mysql> SELECT PLUGIN_NAME, PLUGIN_STATUS 
FROM INFORMATION_SCHEMA.PLUGINS
WHERE PLUGIN_NAME LIKE 'connection%';

mysql> SHOW PLUGINS;

插件配置

-- 查看默認(rèn)相關(guān)變量
mysql> show variables like 'connection_control%';
+-------------------------------------------------+------------+
| Variable_name                                   | Value      |
+-------------------------------------------------+------------+
| connection_control_failed_connections_threshold | 3          |
| connection_control_max_connection_delay         | 2147483647 |
| connection_control_min_connection_delay         | 1000       |
+-------------------------------------------------+------------+

-- 定制化配置
mysql> SET GLOBAL connection_control_failed_connections_threshold = 3;
mysql> SET GLOBAL connection_control_min_connection_delay = 1000;
mysql> SET GLOBAL connection_control_max_connection_delay = 86400;

-- 查看修改后的配置
mysql> show variables like 'connection_control%';
+-------------------------------------------------+-------+
| Variable_name                                   | Value |
+-------------------------------------------------+-------+
| connection_control_failed_connections_threshold | 3     |
| connection_control_max_connection_delay         | 86400 |
| connection_control_min_connection_delay         | 1000  |
+-------------------------------------------------+-------+
  • connection_control_failed_connections_threshold
    • 失敗嘗試的次數(shù),默認(rèn)為3,表示當(dāng)連接失敗3次后啟用連接控制,0表示不開(kāi)啟
  • connection_control_max_connection_delay
    • 響應(yīng)延遲的最大時(shí)間,默認(rèn)約25天
  • connection_control_min_connection_delay
    • 響應(yīng)延遲的最小時(shí)間,默認(rèn)1000微秒,1秒
-- 該表記錄登錄失敗的用戶及失敗次數(shù),當(dāng)用戶登錄成功后,登錄失敗的記錄則會(huì)被刪除。
-- 重新配置connection_control_failed_connections_threshold變量,該表記錄會(huì)被刪除(重置)
-- 如果使用不存在的用戶登錄,則該表記錄用戶名為空,但會(huì)記錄具體登錄的IP
use information_schema;
select * from connection_control_failed_login_attempts;

-- 連接控制的使用次數(shù)(可用戶判斷是否存在暴力登錄嘗試)
-- 重新配置connection_control_failed_connections_threshold變量,該表記錄會(huì)被刪除(重置)
mysql> show global status like 'Connection_control_delay_generated';
+------------------------------------+-------+
| Variable_name                      | Value |
+------------------------------------+-------+
| Connection_control_delay_generated | 5     |
+------------------------------------+-------+

本文摘自 :https://www.cnblogs.com/

開(kāi)通會(huì)員,享受整站包年服務(wù)立即開(kāi)通 >