Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2224594
  • 博文数量: 533
  • 博客积分: 8689
  • 博客等级: 中将
  • 技术积分: 7046
  • 用 户 组: 普通用户
  • 注册时间: 2010-11-26 10:00
文章分类

全部博文(533)

文章存档

2024年(2)

2023年(4)

2022年(16)

2014年(90)

2013年(76)

2012年(125)

2011年(184)

2010年(37)

分类: LINUX

2011-07-30 08:34:17

mysql 协议分析软件 mysqlsniffer
2010年01月29日 星期五 14:51
wget

tar -xvzf mysqlsniffer.tgz

yum install ibpcap-devel 

编译:
gcc -O2 -lpcap -o mysqlsniffer mysqlsniffer.c packet_handlers.c misc.c

用法:
[root@ha2 mysqlsniffer]# ./mysqlsniffer 
mysqlsniffer v1.2 - Watch MySQL traffic on a TCP/IP network

Usage: mysqlsniffer [OPTIONS] INTERFACE

OPTIONS:
--port N        Listen for MySQL on port number N (default 3306)
--verbose       Show extra packet information
--tcp-ctrl      Show TCP control packets (SYN, FIN, RST, ACK)
--net-hdrs      Show major IP and TCP header values
--no-mysql-hdrs Do not show MySQL header (packet ID and length)
--state         Show state
--v40           MySQL server is version 4.0
--dump          Dump all packets in hex
--help          Print this

Original source code and more information at:


可以过滤下:

./mysqlsniffer eth1 | grep 'COM_QUERY'

网上有人直接tcpdump来捕捉,方法如下:
tcpdump -i eth1 -s 0 -l -w - dst port 3306 | strings | perl -e '
while(<>) { chomp; next if /^[^ ]+[ ]*$/;
if(/^(SELECT|UPDATE|DELETE|INSERT|SET|COMMIT|ROLLBACK|CREATE|DROP|ALTER)/i) {
if (defined $q) { print "$qn"; }
$q=$_;
} else {
$_ =~ s/^[ t]+//; $q.=" $_";
}
}'



阅读(1350) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~