I capture everything on port 25 into a pcap file using
An example output of this script is shown below:
In the script above,
I think the
...but I'm not sure how to get the asked 04 Sep '12, 12:42 DigiAngel edited 04 Sep '12, 15:31 helloworld |
3 Answers:
You need to parse the output of the first tshark command. It will print out the stream number (tcp.stream). Then loop over those stream numbers. Reagards answered 04 Sep '12, 14:36 Kurt Knochner ♦ Yea it's the looping part I'm getting stuck on ;) (04 Sep '12, 14:50) DigiAngel can you please post the output of the first tshark command? (04 Sep '12, 14:58) Kurt Knochner ♦ Sep 4, 2012 05:53:47.577902000 ip ip 138 MAIL FROM:[email protected] SIZE=14138\x0d\x0a Sep 4, 2012 05:53:48.358362000 ip ip 138 Sep 4, 2012 05:53:49.907442000 ip ip 139 RCPT TO:[email protected]\x0d\x0a So in this case, the sessions I want to see in their entirety are 138 and 139. Thanks for looking all. (04 Sep '12, 15:45) DigiAngel |
If you have a command like
The trick is using back-ticks (`) around the first command, and using Bash's "for var in set; do;done" to loop over it. For a trivial example of it in action, look at this:
And for substituting a command in there, think about
You may run into punctuation-soup when trying to embed all of this into a single command, so the more you can put into separate scripts, the better off you'll probably be. answered 05 Sep '12, 06:00 zachad edited 06 Sep '12, 12:27 helloworld Thank you....I will give this a shot and show my results. (06 Sep '12, 06:58) DigiAngel |
So...looks like this is it, where $1 is the search item and $2 is the pcap file. Thanks of the help all! for stream in answered 06 Sep '12, 13:58 DigiAngel |
One thing that sticks out to me is the usage of a variable inside a single-quoted string (i.e.,
'tcp.stream == $variable'
). The single-quotes prevent the variable from being expanded in bash. Assuming you meant to expand that variable, you need to use double-quotes instead.Another: do you really need to use
sudo
in your firsttshark
commmand? Most users resort tosudo
only whentshark
can't access the capture interfaces on their host, but you're only reading in a pcap file (thus no capture interfaces would be accessed...I would hope).Yea that's a good point with sudo. And agreed..it's double quote nice catch.