使用tcpdump命令抓取sql

#!/bin/bash

#this script used montor mysql network traffic.echo sql

tcpdump -i eth0 -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|CALL)/i) { if (defined $q) { print "$q\n"; } $q=$_; } else { $_ =~ s/^[ \t]+//; $q.=" $_"; } }'

 

posted on 2021-06-21 19:48  今宵别梦涵  阅读(172)  评论(0编辑  收藏  举报

导航