Methods to hide the mysql version: 1. Check the current mysql version through the "mysql -uroot -p> select version();" command; 2. Start the MySQL service and add a firewall policy; 3. Back up the file "mysqld .bak"; 4. Open the "/usr/sbin/mysqld" file and replace the version information in it.
## The operating environment of this tutorial: CentOS 7.6 system, MySQL5. 7 version, Dell G3 computer.
In the project, Party A conducted a security scan on the server and found that there were many MySQL low version vulnerabilities and required them to be repaired. However, considering the impact on the business, it is inconvenient to directly upgrade the current version, and our business is deployed in an intranet environment and has network access restrictions, so the actual security risks are relatively small. Here we try to find other ways to circumvent it, that is, modify the MySQL version number and hide its true version information.
The test process is recorded as follows, Risk operations, for reference only.
mysql -uroot -pAa123456.
mysql> use mysql;mysql> select user,host from user;mysql> update user set host='%' where user='root';mysql> flush privileges;mysql> select user,host from user;
2. 编辑二进制文件,替换其中的版本信息 如果只想对外部探测 MySQL 的真实版本信息进行隐藏,只需改 /usr/sbin/mysqld 文件。 ❗️❗️❗️注意:版本号不可为空或删减其他信息,否则可能导致服务无法启用!
vi /usr/bin/mysql# 搜索关键字“Linux”快速定位,修改版本号,建议改为官网最新的稳定版本^@fwrite^@\0^@\t^@\n^@\\^@ERROR^@ %d (%s)^@ at line %lu^@ in file: '%s'^@ERROR %d (%s): ^@ERROR %d: ^@ERROR: ^@UNKNOWN USER^@MysqlClient^@LOGNAME^@LOGIN^@SUDO_USER^@Linux^@5.7.22^@x86_64^@Show warnings enabled.^@Show warnings disabled.^@Aborted^@Bye^@Writing history-file %s# 参考案例:^@fwrite^@\0^@\t^@\n^@\\^@ERROR^@ %d (%s)^@ at line %lu^@ in file: '%s'^@ERROR %d (%s): ^@ERROR %d: ^@ERROR: ^@UNKNOWN USER^@MysqlClient^@LOGNAME^@LOGIN^@SUDO_USER^@Linux^@5.7.37^@x86_64^@Show warnings enabled.^@Show warnings disabled.^@Aborted^@Bye^@Writing history-file %s
Copy after login
vi /usr/sbin/mysqld
# 搜索关键字“--language”快速定位,修改版本号,建议改为官网最新的稳定版本
H^P1öéz¬,ÿ1Òëõ^@^@Hì^HHÄ^HÃ^@^@^@^@^@^@^@^@^@^@^@^A^@^B^@^@^@^@^@^@^@^@^@^@^@^@^@%s: %s^@MYSQL_AUDIT_GENERAL_ERROR^@OFF^@BOTH^@NO_AUTO_CLEAR^@NO_INTERNAL_LOOKUP^@Unknown^@tcp^@MYSQL_TCP_PORT^@/var/lib/mysql/mysql.sock^@MYSQL_UNIX_PORT^@Unable to delete pid file: %s^@%.3f^@.lower-test^@.LOWER-TEST^@Can't create test file %s^@Shutting down slave threads^@'--lc-messages-dir'^@--language/-l^@--binlog_max_flush_queue_time^@5.7.22^@Linux^@%s Ver %s for %s on %s (%s)
# 参考案例:
H^P1öéz¬,ÿ1Òëõ^@^@Hì^HHÄ^HÃ^@^@^@^@^@^@^@^@^@^@^@^A^@^B^@^@^@^@^@^@^@^@^@^@^@^@^@%s: %s^@MYSQL_AUDIT_GENERAL_ERROR^@OFF^@BOTH^@NO_AUTO_CLEAR^@NO_INTERNAL_LOOKUP^@Unknown^@tcp^@MYSQL_TCP_PORT^@/var/lib/mysql/mysql.sock^@MYSQL_UNIX_PORT^@Unable to delete pid file: %s^@%.3f^@.lower-test^@.LOWER-TEST^@Can't create test file %s^@Shutting down slave threads^@'--lc-messages-dir'^@--language/-l^@--binlog_max_flush_queue_time^@5.7.37^@Linux^@%s Ver %s for %s on %s (%s)
Copy after login
3. 重启服务
systemctl restart mysqld
systemctl status mysqldnetstat -nplt |grep mysqld
Copy after login
4. 确认版本
mysql -V
mysql -h 192.168.64.147 -uroot -pAa123456.
mysql> select version();mysql> \q
vi /usr/bin/mysql# 搜索关键字“-MariaDB”快速定位,修改版本号,建议改为官网最新的稳定版本^@KILL %s%lu^@ERROR^@ at line %lu^@ in file: '%s'^@ERROR %d (%s)^@ERROR %d^@Linux^@5.5.68-MariaDB^@readline^@x86_64^@vi^@EDITOR^@VISUAL^@Command '%.40s' failed^@Show warnings disabled.^@Show warnings enabled.^@Usage: \! shell-command^@Charset changed^@Charset is not found^@show databases^@show tables^@%.64s.%.64s^@*** NONE ***^@Connection id: %lu^@Current database: %.128s# 参考案例:^@KILL %s%lu^@ERROR^@ at line %lu^@ in file: '%s'^@ERROR %d (%s)^@ERROR %d^@Linux^@10.7.3-MariaDB^@readline^@x86_64^@vi^@EDITOR^@VISUAL^@Command '%.40s' failed^@Show warnings disabled.^@Show warnings enabled.^@Usage: \! shell-command^@Charset changed^@Charset is not found^@show databases^@show tables^@%.64s.%.64s^@*** NONE ***^@Connection id: %lu^@Current database: %.128s
Copy after login
vi /usr/libexec/mysqld
# 同样通过搜索关键字“-MariaDB”快速定位,修改版本号,建议改为官网最新的稳定版本^@CLOSE_CONNECTION^@unauthenticated^@unconnected^@Error in accept^@5.5.68-MariaDB^@x86_64^@Linux^@%s Ver %s for %s on %s (%s)# 参考案例:^@CLOSE_CONNECTION^@unauthenticated^@unconnected^@Error in accept^@10.7.3-MariaDB^@x86_64^@Linux^@%s Ver %s for %s on %s (%s)
Copy after login
3. 重启服务
systemctl restart mariadb
systemctl status mariadbnetstat -nplt |grep mysqld
Copy after login
4. 确认版本
mysql -V
mysql -h 192.168.64.147 -uroot -pAa123456.
MariaDB [(none)]> select version();MariaDB [(none)]> \q
mysql -h 127.0.0.1 -uroot
MariaDB [(none)]> show global variables like '%max_connect_errors%';MariaDB [(none)]> set global max_connect_errors=1000;MariaDB [(none)]> show global variables like '%max_connect_errors%';MariaDB [(none)]> flush hosts;MariaDB [(none)]> \q
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn