MySql隐藏真实版本号

黑客通常会根据已知的漏洞来发动攻击,而对mysql的版本号进行加固处理,可以使攻击者无法准确了解数据库系统的弱点,增加攻击难度,防止黑客利用已知的漏洞攻击系统。

1.查看mysql版本号的两种方式

1.1外部探测

使用telnet命令:

[root@upm-bj-bigdata-host-1 ~]# telnet XX.XX.XXX.XX 3306

Trying XX.XX.XXX.XX...

Connected to XX.XX.XXX.XX.

Escape character is '^]'.

J

5.7.25  f   dr0..!2UR *zsZo%Imysql_native_passwordConnection closed by foreign host.

 

使用nmap命令:

[root@upm-bj-bigdata-host-1 ~]# nmap -T4 -sC -sV -p 3306 XX.XX.XXX.XX

Starting Nmap 6.40 ( http://nmap.org ) at 2024-02-21 14:43 CST

Nmap scan report for XX.XX.XXX.XX

Host is up (0.00014s latency).

PORT     STATE SERVICE VERSION

3306/tcp open  mysql   MySQL 5.7.25

| mysql-info: Protocol: 10

| Version: 5.7.25

| Thread ID: 13

| Some Capabilities: Long Passwords, Connect with DB, Compress, ODBC, Transactions, Secure Connection

| Status: Autocommit

|_Salt: s\x14rN B?m

Service detection performed. Please report any incorrect results at http://nmap.org/submit/ .

Nmap done: 1 IP address (1 host up) scanned in 2.15 seconds

 

1.2.在数据库服务器上查看版本号

#无需登录数据库查看

[root@upm-bj-bigdata-host-3 ~]# mysql -V

mysql  Ver 14.14 Distrib 5.7.25for linux-glibc2.12 (x86_64) using  EditLine wrapper

 

 

#登录数据库查看

[root@upm-bj-bigdata-host-3 ~]# mysql -hxx.xx.xxx.xx -P3306 -uxx -pxx

mysql: [Warning] Using a password on the command line interface can be insecure.

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 14

Server version: 5.7.25 MySQL Community Server (GPL)

 

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

 

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

 

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

 

mysql> select version();

+-----------+

| version() |

+-----------+

| 5.7.25    |

+-----------+

1 row in set (0.00 sec)

 

2.MySql版本号处理方式

2.1.只想对外部探测隐藏mysql真实版本信息,只需修改mysqld二进制文件

#先找到mysqld二进制文件,然后备份

[root@upm-bj-bigdata-host-3 ~]# whereis mysqld

mysqld: /usr/local/mysql/bin/mysqld

[root@upm-bj-bigdata-host-3 ~]# cp /usr/local/mysql/bin/mysqld /usr/local/mysql/bin/mysqld.bak

#使用vi命令,同时在命令编辑器中使用“/”命令查找“5.7.25”然后回车,找到版本号,“i”开启插入模式,将版本修改成预期版本号,然后退出编辑模式保存(“esc”->":wq"

[root@upm-bj-bigdata-host-3 ~]# vi /usr/local/mysql/bin/mysqld

#修改完成之后重启数据库,在进行外部探测发现显示的已经是修改后的版本号

[root@upm-bj-bigdata-host-3 ~]# /etc/init.d/mysqld restart

 

2.2.需要隐藏数据库服务器上可以查询到的版本信息,还需修改mysql文件:

#先找到mysql二进制文件,然后备份

[root@upm-bj-bigdata-host-3 ~]# whereis mysql

mysql: /usr/lib64/mysql /usr/local/mysql /usr/local/mysql/bin/mysql

[root@upm-bj-bigdata-host-3 ~]# cp /usr/local/mysql/bin/mysql /usr/local/mysql/bin/mysql.bak

#使用vi命令,同时在命令编辑器中使用“/”命令查找“5.7.25”然后回车,找到版本号,“i”开启插入模式,将版本修改成预期版本号,然后退出编辑模式保存(“esc”->":wq"

[root@upm-bj-bigdata-host-3 ~]# vi /usr/local/mysql/bin/mysql

#修改完成之后重启数据库,在进行数据库版本号查询时已经是修改后的版本号

[root@upm-bj-bigdata-host-3 ~]# /etc/init.d/mysqld restart

[root@upm-bj-bigdata-host-3 ~]# mysql -V

mysql  Ver 14.14 Distrib 5.7.44for linux-glibc2.12 (x86_64) using  EditLine wrapper

 

 

注意:

  1. mysql和mysqld二进制文件中的版本号不能删减或者修改其他信息,否则会导致服务不能启动,所以在修改前一定要备份。
  2. 可以根据想要验证漏洞的版本来修改,比如想要验证升级到5.7.44版本漏洞扫出的情况,则可将版本号修改为5.7.44。
  3. 经过5.7.25版本的测试,版本号修改为5.7.44 或者 8.0.36 数据库服务均可以正常启动,且系统运行正常。

参考:https://www.php.cn/faq/500881.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章