
本文共 7445 字,大约阅读时间需要 24 分钟。
���������������
������
MySQL Sniffer ��������������� MySQL ������������������������������������ MySQLServer ������������������������������������������������������������������������������������������ IP��������� Database��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� Atlas ���������������Atlas ������������������������������MySQL���������������������������������������������������������������������vc-mysql-sniffer��������� tshark ��� -e mysql.query ��������������� MySQL ���������
������
���������github ���������
���������
1���������������������
Centos���
yum install cmakeyum install libpcap-develyum install glib2-develyum install libnet-devel
Ubuntu���
apt-get install cmakeapt-get install libpcap-devapt-get install glib2.0-devapt-get install libnet-devapt-get install build-essential
2���������������
git clone https://github.com/Qihoo360/mysql-sniffer.gitcd mysql-sniffermkdir projcd projcmake ../make ���bin���������������������:mysql-sniffer
������ubuntu������������������������
/usr/include/glib-2.0/glib/gtypes.h:32:24: fatal error: glibconfig.h: No such file or directory
������������
cp /usr/lib/x86_64-linux-gnu/glib-2.0/include/glibconfig.h /usr/include/glib-2.0/
���������make������������������
/bin/ld: /root/mysql-sniffer/lib/libgthread-2.0.a(gthread-impl.o): undefined reference to symbol 'pthread_setspecific@@GLIBC_2.2.5'/usr/lib64/libpthread.so.0: error adding symbols: DSO missing from command linecollect2: error: ld returned 1 exit status
���������pthread ��������� Linux ��������������������������������������������������� libpthread.a������������������pthread_create()��������������������������� pthread_atfork()������������fork��������������������������������������������������������������� -lpthread���������
������������rdynamic���������������������proj/bin/CMakeFiles/mysql-sniffer.dir/link.txt������������������������-lpthread���������make������������
/bin/c++ -DENABLE_TCPREASM -O3 -Wall -DENABLE_TCPREASM -O2 -rdynamic CMakeFiles/mysql-sniffer.dir/main.c.o CMakeFiles/mysql-sniffer.dir/mysql-dissector.c.o CMakeFiles/mysql-sniffer.dir/util.c.o CMa keFiles/mysql-sniffer.dir/session.cpp.o CMakeFiles/mysql-sniffer.dir/sniff-config.cpp.o CMakeFiles/mysql-sniffer.dir/sniff-log.cpp.o -o mysql-sniffer -L/root/mysql-sniffer/lib -Wl,-rpath,/root/mysql -sniffer/lib -Wl,-Bstatic -lnidstcpreasm -lnet -lpcap -lglib-2.0 -lgthread-2.0 -Wl,-Bdynamic -lrt -Wl,-Bstatic -lnet -lpcap -lglib-2.0 -lgthread-2.0 -Wl,-Bdynamic -lrt -lpthread
���������������
1 root@db-test2:~# mysql-sniffer -h 2 Usage mysql-sniffer [-d] -i eth0 -p 3306,3307,3308 -l /var/log/mysql-sniffer/ -e stderr 3 [-d] -i eth0 -r 3000-4000 4 -d daemon mode. # 5 -s how often to split the log file(minute, eg. 1440). if less than 0, split log everyday 6 -i interface. Default to eth0 #��������� 7 -p port, default to 3306. Multiple ports should be splited by ','. eg. 3306,3307 8 this option has no effect when -f is set. #���������������������,������������������-f������������ 9 -r port range, Don't use -r and -p at the same time #������������������������-p������������10 -l query log DIRECTORY. Make sure that the directory is accessible. Default to stdout. #���������������������11 -e error log FILENAME or 'stderr'. if set to /dev/null, runtime error will not be recorded12 -f filename. use pcap file instead capturing the network interface13 -w white list. dont capture the port. Multiple ports should be splited by ','.#���������������14 -t truncation length. truncate long query if it's longer than specified length. Less than 0 means no truncation #���������������������SQL15 -n keeping tcp stream count, if not set, default is 65536. if active tcp count is larger than the specified count, mysql-sniffer will remove the oldest one #���������������������
������
��������������������������������������������� IP��������� Database������������������������������������������������������
1. ������������������������������������������������-i ������������������-p ���������������������
[root@localhost ~]# mysql-sniffer -i enp3s0 -p 33062017-03-03 16:27:56 zhoujy 192.168.200.64 NULL 0ms 1 select @@version_comment limit 12017-03-03 16:27:56 zhoujy 192.168.200.64 NULL 0ms 1 select USER()2017-03-03 16:28:00 zhoujy 192.168.200.64 NULL 0ms 1 SELECT DATABASE()2017-03-03 16:28:00 zhoujy 192.168.200.64 xx 0ms 0 use xx2017-03-03 16:28:03 zhoujy 192.168.200.64 xx 0ms 8 select * from xx2017-03-03 16:28:13 zhoujy 192.168.200.64 xx 0ms 3 select user,host from mysql.user2017-03-03 16:28:24 zhoujy 192.168.200.64 xx 0ms 2 show grants for root@localhost2017-03-03 16:28:33 zhoujy 192.168.200.64 xx 18ms 1 select now()2017-03-03 16:28:41 zhoujy 192.168.200.64 xx 32ms 1 select 1+1
2. ������������������������������������������������-l ��������������������������������������������� port.log ���������
[root@localhost ~]# mysql-sniffer -i enp3s0 -p 3306 -l /tmp/
3. ���������������������������������������������������-l ���������������������������-p������������������������������������������������������������������������ port.log ���������
[root@localhost ~]# mysql-sniffer -i enp3s0 -p 3306,3307,3307 -l /tmp/
4. ������������������������������������������������������������-l ���������������������������-r ��������������������������������������������� port.log ���������
[root@localhost ~]# mysql-sniffer -i enp3s0 -r 3306-3309 -l /tmp/
5. ���������������������������������������������������������������������������������������:-l ���������������������������-r ��������������������� -w ��������������������������������������������������������������� port.log ���������
[root@localhost ~]# mysql-sniffer -i enp3s0 -r 3306-3311 -w 3307,3309 -l /tmp/
6. ��������������������� daemon ���������������-d���������������������������-l ���������������������������-p ��������������� -n ������������������������������������������������ port.log ���������
[root@localhost tmp]# mysql-sniffer -i enp3s0 -p 3306 -l /tmp/ -d
7. ������������������������������������������ SQL���-p ��������������� -t ������SQL������������������ SQL������n���������(��������� SQL ���������������)���
[root@localhost ~]# mysql-sniffer -i enp3s0 -p 3306 -t 102017-03-03 17:05:49 zhoujy 192.168.200.64 NULL 0ms 1 select @@v...2017-03-03 17:05:49 zhoujy 192.168.200.64 NULL 0ms 1 select USE...2017-03-03 17:05:50 zhoujy 192.168.200.64 NULL 0ms 1 select 111...
������
������������������������������mysql-sniffer���������������������������������mysql���������������������������������������������MySQL���������general_log������������������������������������������������������������������������������������������������������������������SQL���������������������������������������������������������������mark���������
������������
发表评论
最新留言
关于作者
