Skip to content

Instantly share code, notes, and snippets.

@gnilchee
Created October 20, 2016 21:35
Show Gist options
  • Save gnilchee/da6f77bd2e882b49d704b27d3fa74cd3 to your computer and use it in GitHub Desktop.
Save gnilchee/da6f77bd2e882b49d704b27d3fa74cd3 to your computer and use it in GitHub Desktop.
Simple way to view all unencrypted MySQL traffic from client host
tcpdump -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 "$q\n"; }
$q=$_;
} else {
$_ =~ s/^[ \t]+//; $q.=" $_";
}
}' | tee -a /tmp/out.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment