Ask Your Question

Extract http objects to files with python

asked 2019-12-04 14:33:04 +0000

Colibri gravatar image

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?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-12-04 18:37:06 +0000

grahamb gravatar image

updated 2019-12-05 08:55:01 +0000

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.

edit flag offensive delete link more


Would you please give the full command?

Colibri gravatar imageColibri ( 2019-12-04 20:22:08 +0000 )edit

As in tshark or python?

grahamb gravatar imagegrahamb ( 2019-12-04 20:36:14 +0000 )edit

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

Colibri gravatar imageColibri ( 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 gravatar imagegrahamb ( 2019-12-05 08:54:50 +0000 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2019-12-04 14:33:04 +0000

Seen: 923 times

Last updated: Dec 05 '19