Skip to content

Instantly share code, notes, and snippets.

@pablomelo
Created March 4, 2017 20:25
Show Gist options
  • Select an option

  • Save pablomelo/f194d20b31ff1dd789fc2684972a7d99 to your computer and use it in GitHub Desktop.

Select an option

Save pablomelo/f194d20b31ff1dd789fc2684972a7d99 to your computer and use it in GitHub Desktop.
#!/bin/sh
sudo 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)/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