TCP flow extraction
Asked Answered
tcp
I

5

6

I need to extract TCP Flows with their content from dump file and then save their flow into other file each flow separately

In answered 6/9, 2009 at 6:55 Comment(0)
Q
7

You definitely want to use Bro, more specifically, its contents.bro policy. For example, given a trace that contains HTTP requests, running the following ...

bro -r http.trace -f 'tcp and port 80' contents

... produces files

contents.[senderIP].[senderPort]-[destIP].[destPort]
contents.[destIP].[destPort]-[senderIP].[senderPort] 

for each connection, each containing the unidirectional content of the flow.

The flow reassembly is highly robust, the process scales to very large files, and everything is customizable to your needs.

Quenchless answered 23/12, 2010 at 7:36 Comment(2)
This somehow doesn't work. I cannot find contents.bro anywhere.Clevelandclevenger
In recent Bro releases, look for scripts/base/protocols/conn/contents.bro.Quenchless
R
6

If you're only doing a few, Wireshark can do this.

Steps:

  1. Open up the capture in Wireshark.
  2. Click on a packet from the TCP connection you're interested in
  3. Analyze -> Follow TCP Stream
  4. Click 'Raw'
  5. Select (from the popup menu) one of 'Entire Conversation' or one of the two directions.
  6. Click 'Save As'

Alternate steps, for HTTP only:

  1. Open up the capture
  2. Select File -> Export -> Objects -> HTTP
  3. A dialog will open showing all the HTTP objects in the capture. You can save some or all of them.

This is with Wireshark 1.2.1 on Linux/GTK. The 'follow TCP stream' option has been moved around between versions, so it may be somewhere else if you have an older version. But its always been called Follow TCP Stream so you should be able to find it.

Quick searching also reveals several other options if Wireshark doesn't work for you: ngrep, tcpick, chaosreader, and tcpflow.

Roxieroxine answered 6/9, 2009 at 6:57 Comment(0)
V
4
tcpflow -r my_dump_file.pcap -o output_dir/

It will extract each tcp flow, separately, into a file under output_dir. Each flow in its own file.

Here's the manpage with more options

Vindictive answered 10/5, 2016 at 9:55 Comment(1)
You need to add -a to unzip gzipped dataBoynton
V
1

Wire shark maybe? It can be used to filter sessions and I think you can then save them seperatly.

Vituperate answered 6/9, 2009 at 6:57 Comment(0)
T
0

You could also have a look at NetFlow and related tools.

Tetanic answered 6/9, 2009 at 7:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.