1

I am trying to capture mysql traffic and pass those traffic to strings command as follows:

tcpdump -i any -s 0 -l -w - dst port 3306 | strings

This is working as expected and printing all mysql queries like

select * from mytables
show databases

But when i am trying to redirect the output to a file, its not printing the output to /tmp/out file:

tcpdump -i any -s 0 -l -w - dst port 3306 | strings > /tmp/out

Can someone explain me the behaviour of above command and why it is not redirecting the output to file.

1 Answers1

2

I got the solution:

Actually strings command is buffering. I disabled the buffering by using

stdbuf -i0 -o0 -e0 command

So after changing the whole command to the following, output started going to /tmp/final file.

tcpdump -i any -s 0 -l -w - dst port 3306 | stdbuf -i0 -o0 -e0 strings > /tmp/final 

References