码迷,mamicode.com
首页 > 数据库 > 详细

用wireshark查看 tcpdump 抓取的mysql交互数据

时间:2015-09-09 19:12:29      阅读:226      评论:0      收藏:0      [点我收藏+]

标签:

 用tcpdump  抓取 mysql客户端与服务器端的交互

1开启tcpdump

 tcpdump -i eth0 -s 3000 port 3306 -w ~/sql.pcap

 

先故意输入一个错误的密码

[root@localhost ~]# mysql -h192.168.100.206 -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user ‘root‘@‘192.168.11.201‘ (using password: YES)

输入正确的密码进入并进行一系列操作

[root@localhost ~]# mysql -h192.168.100.206 -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 442447
Server version: 5.5.25-log Source distribution

Copyright (c) 2000, 2013, 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> use jwbx;
Database changed
mysql> select * from jwbx_customer limit 10;

 

用wireshark 打开sql.pcap 文件

技术分享

 

输入的错误密码

Request   6 0.001146 192.168.11.201 192.168.100.206 MySQL 128 Login Request user=root

Response 8 0.001636 192.168.100.206 192.168.11.201 MySQL 147 Response Error 1045

技术分享

 

 

登陆成功

17 4.953321 192.168.11.201 192.168.100.206 MySQL 128 Login Request user=root

来自服务器端的问候

15 4.952968 192.168.100.206 192.168.11.201 MySQL 148 Server Greeting proto=10 version=5.5.25-log

技术分享

服务器端的状态

技术分享

访问

select @@version_comment limit 1  返回 Source distribution

SELECT DATABASE() 

USE DataBase 返回数据库名

访问的sql

技术分享

Return

技术分享

 

技术分享

 

同样可以在抓取程序访问mysql的数据,可以查看执行了哪些sql语句

也可以不用wireshark 方式如下:

#tcpdump -i any -A -s 3000 port 3306 >~/sql.log
#grep "select * from " ~/
sql.log|head

备注:-A 以ASCII格式打印出所有分组,并将链路层的头最小化。向mysql服务端传输的sql语句就是以ASCII码形式进行传输。我们就可以使用-A参数查看传输的具体sql语句。

 

用wireshark查看 tcpdump 抓取的mysql交互数据

标签:

原文地址:http://www.cnblogs.com/wangxusummer/p/4795423.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!