centos安装MySQL Sniffer对MySQL进行抓包
- 开发技术
- 2022-10-14
- 642
- 0
1、安装依赖包
yum install cmake
yum install libpcap-devel
yum install glib2-devel
yum install libnet-devel
2、下载软件并编译安装,安装失败请参考文字底部
git clone https://github.com/Qihoo360/mysql-sniffer.git
cd mysql-sniffer
mkdir proj
cd proj
cmake ../
make
3、安装成功会在当前bin目录下有mysql-sniffer文件,使用改文件监听3306
cd bin
# eth0是网卡名称每台服务器可能不一样
./mysql-sniffer -i eth0 -p 3306
make时候碰到Linking CXX executable mysql-sniffer错误
#修改mysql-sniffer/proj/src/CMakeLists.txt文件
vi ../src/CMakeLists.txt
#修改前
TARGET_LINK_LIBRARIES(mysql-sniffer optimized
libnidstcpreasm.a
libnet.a
libpcap.a
libglib-2.0.a
libgthread-2.0.a
librt.so)
TARGET_LINK_LIBRARIES(mysql-sniffer debug
libnidstcpreasm-dbg.a
libnet.a
libpcap.a
libglib-2.0.a
libgthread-2.0.a
librt.so)
#修改后,多加了两行libpthread.so.0,然后重写make就安装成功了
TARGET_LINK_LIBRARIES(mysql-sniffer optimized
libnidstcpreasm.a
libpthread.so.0
libnet.a
libpcap.a
libglib-2.0.a
libgthread-2.0.a
librt.so)
TARGET_LINK_LIBRARIES(mysql-sniffer debug
libnidstcpreasm-dbg.a
libpthread.so.0
libnet.a
libpcap.a
libglib-2.0.a
libgthread-2.0.a
librt.so)
抓取不到sql
PHP使用PDO,PDO::ATTR_EMULATE_PREPARES 需要改为 true。