Skip to content

Instantly share code, notes, and snippets.

@suchasplus
Created December 28, 2015 06:41
Show Gist options
  • Save suchasplus/7a78bc982bb41e2b56a1 to your computer and use it in GitHub Desktop.
Save suchasplus/7a78bc982bb41e2b56a1 to your computer and use it in GitHub Desktop.
dump sql via tcpdump
#!/bin/bash
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.=" $_";
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment