First time here? Check out the FAQ!
THIS IS A TEST INSTANCE. Feel free to ask and answer questions, but take care to avoid triggering too many notifications.
0

Extract http objects to files with python

I know it's easy to extract http objects to files. But I have many pcap files so wish to do it with python script. How can I do it with python?

Colibri's avatar
1
Colibri
asked 2019-12-04 14:33:04 +0000
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

0

Use tshark, calling it from python and using the --export-objects <protocol>,<destdir> argument to specify which protocol objects, "http" in your case and the destination directory. The python code will also have to provide the name of the capture file to read as a -r argument.

See the tshark man page for more info on using it.

grahamb's avatar
23.8k
grahamb
answered 2019-12-04 18:37:06 +0000, updated 2019-12-05 08:55:01 +0000
edit flag offensive 0 remove flag delete link

Comments

Would you please give the full command?

Colibri's avatar Colibri (2019-12-04 20:22:08 +0000) edit

As in tshark or python?

grahamb's avatar grahamb (2019-12-04 20:36:14 +0000) edit

Got it, need two - for the parameters. Many thanks

Colibri's avatar Colibri (2019-12-05 00:23:30 +0000) edit

For tshark use a command similar to:

tshark -r "NameOfCaptureFile" --export-objects "http,PathToDestinationDirectory"

Your Python code will have to arrange such a command line substituting in the capture file name and the output directory. You'll have to write that Python code yourself.

grahamb's avatar grahamb (2019-12-05 08:54:50 +0000) edit
add a comment see more comments

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss.

Add Answer