#!/usr/bin/perl # (c) 2008 torh@bogus.net # # quick hack, needed to remove noise from RTP audio packets during a # security test. # $|=1; $MAXREAD=12; use Getopt::Long; GetOptions("f","h","i=s" => \$infile,"o=s" => \$outfile); if($opt_h) { print < -o || (c) 2008 torh\@bogus.net -h : this -f : force overwrite existing file -i : inputfile -o : outputfile To use this tool, you need to acquire a RTP stream first; the easiest way to do this is to capture UDP packets to/from port 5200 using tcpdump or Wireshark and then "Follow UDP stream" using the latter tool. Save the stream as raw and point this tool at that file (-i), then load the result (-o) in audacity as A-Law, mono, 8000Hz. EOM exit; } print "$0 - a tool to convert nortel audio dumps - (c) 2008 torh\@bogus.net\n"; die "STOP: Need -i \n" unless($infile); die "STOP: Need -o \n" unless($outfile); if(-e $outfile) { die "STOP: Outfile exists. Force (-f) to override." unless($opt_f); } open(IN,"<$infile"); open(OUT,">$outfile"); binmode(IN); # read the first 32 bytes of the file to determine packet header $r=sysread(IN,$buf,12); die "FAIL: Failed to read header, only $r bytes read (needed 12).\n" unless $r==12; $ha = unpack("C",substr($buf,0,1)); $hb = unpack("C",substr($buf,1,1)); $ta = unpack("C",substr($buf,10,1)); $tb = unpack("C",substr($buf,11,1)); printf "header: %.2x%.2x xxxx xxxx xxxx xxxx ", $ha,$hb; printf "%.2x%.2x\n",$ta,$tb; $foo=0; while(sysread(IN,$buf,$MAXREAD)) { for($i=0;$i<$MAXREAD;$i++) { ## find RTP header and strip it if((unpack("C",substr($buf,$i,1)) == $ha) && (unpack("C",substr($buf,$i+1,1)) == $hb) && (unpack("C",substr($buf,$i+10,1)) == $ta) && (unpack("C",substr($buf,$i+11,1)) == $tb)) { print "header found, skipping to data" unless $foo; $foo=1; print "."; $i=$i+12; } print OUT substr($buf,$i,1); } } close(IN); close(OUT); print "DONE.\n"