用wireshark查看 tcpdump 抓取的mysql互動資料

來源:互聯網
上載者:User

標籤:

 用tcpdump  抓取 mysql用戶端與伺服器端的互動

1開啟tcpdump

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

 

先故意輸入一個錯誤的密碼

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

輸入正確的密碼進入並進行一系列操作

[[email protected] ~]# mysql -h192.168.100.206 -uroot -pEnter password:Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 442447Server version: 5.5.25-log Source distributionCopyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.mysql> use jwbx;Database changedmysql> 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互動資料

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.