Python Script: Python Script To get Audio from VOIP Packet Capture (PCAP) file HD

05.08.2014
Python Script: Python Script To get Audio from VOIP Packet Capture (PCAP) file Python is a great choice for a language as it’s easy to learn and has a wealth of great packages available to it. In this case, I’m utilizing the Python package: PyShark to act as a wrapper for thsark. If you don’t know what tshark is, it’s a command line version of Wireshark. If you don’t know what wireshark is, well it’s a wonderful GUI application that records and analyzes packet captures (links on these below.) Before Python, I used a bash script to call tshark functions on the pcap (link below.) While Wireshark is useful in many cases, it’s not very programable. If you had a Virtual Machine running as a test asterix/freeswitch box in a VOIP/SIP test environment, you won’t have a visual front end. But you can write a script to kick off the recording of packet captures, along with the removal of audio from the packets to RAW form. Once you have audio in RAW form, you can simply use sox or other audio conversion utilities to convert the file to a wav, mp3, etc. The code for this is up at: https://github.com/wbwarnerb/ExercisesFor_Python3_book Specifically these links for this particular code exercise: https://github.com/wbwarnerb/ExercisesFor_Python3_book/blob/master/audio_scraper.py https://github.com/wbwarnerb/ExercisesFor_Python3_book/blob/master/menu.py Links: Bash script version: http://sdet.us/converting-rtp-in-pcap-to-audio-wav-files/ (same thing but without Python) Wireshark: https://www.wireshark.org/ Wireshark being Used with VOIP (demo): https://www.youtube.com/watch?v=iFQKB0MQ-dY tshark: https://www.wireshark.org/docs/wsug_html_chunked/AppToolstshark.html

Похожие видео