LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   tcpdump into a file correctly (https://www.linuxquestions.org/questions/linux-newbie-8/tcpdump-into-a-file-correctly-4175446718/)

eeluve 01-22-2013 04:54 AM

tcpdump into a file correctly
 
What I do want is something like:
Code:

tcpdump -i igb0 'tcp[13] & 2 != 0' -w tcpdump.txt
as you of course know, it wont work.
If I pipe into a file using bash, tcpdstat is obviously not fine with the file format. Help me a bit please.

unSpawn 01-22-2013 06:38 AM

Quote:

Originally Posted by eeluve (Post 4875308)
What I do want is something like:
Code:

tcpdump -i igb0 'tcp[13] & 2 != 0' -w tcpdump.txt
as you of course know, it wont work.

Apart from explicitly setting snaplen to zero and tacking on the BPF last as seems customary, why shouldn't it work? If you run it verbosely, without resolving any addresses and ports and without writing to a file what does it say?

eeluve 01-22-2013 06:53 AM

Without writing to a file everything is ok. But the exact problem is - I want to write it to a file in the order tcpdstat expects it(the order -w option meant to create, maybe im wrong). I believe its not hard, I just don't know how. And maybe another question by the way, I know about snort and stuff, but if I would make a little script for an easy hand-check, how could I make a process(utility with given arguments) to run for several seconds, count until some of the values reached the sought-for point and finish its job? I have tried with "read", "at", "sleep", combinig sed+awk, but unsuccessfully.

unSpawn 01-22-2013 07:24 AM

Quote:

Originally Posted by eeluve (Post 4875367)
I want to write it to a file in the order tcpdstat expects it

I don't get what you're saying. There is nothing that suggests either tcpdump writes packets to file or that tcpdstat reads packets from file in any order other than FIFO.

eeluve 01-22-2013 09:37 AM

I could've given you a link, but its russian. And I'm home now, and no google cloud ;) sorry, I'll try to translate and clarificate better tomorrow. But it is exactly what im talking about. I even got an idea, what exactly I have explained wrong
Quote:

tcpdump.txt
must've been .pcap.
"tcpdstat - Get protocol statistics from tcpdump pcap files". And please, if someone could throw some notes on the second part of the question?

NevemTeve 01-22-2013 10:15 AM

It is quite okay, just try to understand that the output of option '-w' is not a human readable text-file.

unSpawn 01-22-2013 11:41 AM

Quote:

Originally Posted by eeluve (Post 4875478)
I could've given you a link

Sure, just post the link.


Quote:

Originally Posted by eeluve
make a little script for an easy hand-check, how could I make a process (utility with given arguments) to run for several seconds, count until some of the values reached the sought-for point and finish its job? I have tried with "read", "at", "sleep", combinig sed+awk, but unsuccessfully.

It kind of depends on what "sought-for point" means. If "sought-for point" means a packet counter then there's 'tcpdump -c' or 'tshark -c', elif it means input bytes there's 'cut -b' or 'dd count=' or 'od -N', elif it's a simple counter your could ((N++)) in BASH. Else if it means some combination, like \( total pkt count and 3 SYN ACKs and within 10 seconds \) then you best explain what you're trying to accomplish: (pseudo) script welcome.

eeluve 01-22-2013 11:50 PM

Thank you, even tho I'm not the best explainer out there, the info you gave me is exactly what I've been seeking for. And if you still want the link, here goes http://www.bit-team.com/index.php?showtopic=3930 Short story is, he explains how to use all these utilities for good taking cisco as example. But he is talking superficially, so I kind of interpret it for myself.

linosaurusroot 01-23-2013 01:38 PM

Quote:

Originally Posted by NevemTeve (Post 4875501)
It is quite okay, just try to understand that the output of option '-w' is not a human readable text-file.

What's been created with tcpdump -w gets read with tcpdump -r.


All times are GMT -5. The time now is 11:04 AM.