-
-
Save suapapa/ea3c0753dd39e2423adec438c4d2c897 to your computer and use it in GitHub Desktop.
Extract RTP from pcap to raw and convert to wav
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
pcap_file="voip.pcap"; #nama file pcap | |
audio_output="suara.wav"; #output audio | |
raw_file="suara.raw"; #nama raw file hasil extract | |
if [ $EUID -ne 0 ]; then | |
echo "This script must be run as root"; | |
exit 1; | |
fi | |
if [ -x /usr/bin/tshark ]; then | |
ssrc=$(tshark -n -r $pcap_file -R rtp -T fields -e rtp.ssrc -Eseparator=, | sort -u | awk 'FNR ==1 {print}') | |
echo "SSRC: "; | |
echo $ssrc; | |
tshark -n -r $pcap_file -R rtp -R "rtp.ssrc == $ssrc" -T fields -e rtp.payload | tee payloads; | |
else | |
echo "tshark tidak ditemukan"; | |
fi | |
for payload in `cat payloads`; | |
do | |
IFS=:; | |
for byte in $payload; | |
do | |
printf "\\x$byte" >> $raw_file; | |
done; | |
done | |
if [ -x /usr/bin/sox ]; then | |
echo 'sox has converted pcap to wav file'; | |
sox -t raw -r 8000 -v 4 -c 1 -U $raw_file $audio_output; | |
else | |
echo "sox tidak ditemukan"; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment