pkt2flow icon indicating copy to clipboard operation
pkt2flow copied to clipboard

how to run pkt2flow from python

Open fbinishaq opened this issue 10 years ago • 3 comments

Hello,

how can I use pkt2flow in python scripts? I am generating the pcap file from python script and I want to get tcp sessions from that pcap file using a python script as well pkt2flow

Thanks,

fbinishaq avatar Jan 21 '15 09:01 fbinishaq

Unfortunately, you can not use pkt2flow in python directly. Instead, you can write the pcap file to disk, and invoke pkt2flow using subprocess module in python to process the pcap file. May this help u.

caesar0301 avatar Jan 21 '15 14:01 caesar0301

I tried to invoke but i failed. Do you have any idea how to do it?

Many thanks,

Sent from my iPhone

On Jan 21, 2015, at 6:11 PM, Xiaming [email protected] wrote:

Unfortunately, you can not use pkt2flow in python directly. Instead, you can write the pcap file to disk, and invoke pkt2flow using subprocess module in python to process the pcap file. May this help u.

— Reply to this email directly or view it on GitHub.

fbinishaq avatar Jan 21 '15 14:01 fbinishaq

Give a try

cmd = '/path/to/pkt2flow -o flows {0}'.format(pcap_file_name)
Popen(cmd, shell=True, stdout=PIPE).communicate()

Good luck! :+1:

caesar0301 avatar Jan 22 '15 02:01 caesar0301