Bump the mp3 quality a bit, allow iaxrecord to work when there is no ring (aka dialing extensions through asterix), add an AGI script to allow asterix to fake dial an existing job (replays the mp3s from the previous run). Tweaks some of the fallback sigs. - warvox - VoIP based wardialing tool, forked from rapid7/warvox.
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
       ---
 (DIR) commit 6b0626b2db5bb3e7bc048b961a32de39c56fe929
 (DIR) parent 39e637f7729852d500d1037f0b2d6071a3a1f36c
 (HTM) Author: HD Moore <hd_moore@rapid7.com>
       Date:   Sun, 24 May 2009 19:12:32 +0000
       
       Bump the mp3 quality a bit, allow iaxrecord to work when there is no ring (aka dialing extensions through asterix), add an AGI script to allow asterix to fake dial an existing job (replays the mp3s from the previous run). Tweaks some of the fallback sigs.
       
       
       
       Diffstat:
         A bin/warvox.agi                      |      24 ++++++++++++++++++++++++
         M etc/sigs/99.default.rb              |      25 +++++++++++++++++++++++++
         M lib/warvox/jobs/analysis.rb         |       5 ++++-
         M src/iaxrecord/iaxrecord.c           |      29 ++++++++++++++++++++++-------
       
       4 files changed, 75 insertions(+), 8 deletions(-)
       ---
 (DIR) diff --git a/bin/warvox.agi b/bin/warvox.agi
       @@ -0,0 +1,24 @@
       +#!/usr/bin/env ruby
       +
       +#
       +# This script can be used to redial an existing job through Asterix.
       +# To use this script, add an entry to extensions.conf:
       +#
       +# exten => _777.,1,agi,warvox.agi|/warvox/data/20
       +#
       +
       +base = ARGV.shift
       +conf = {}
       +while(line = $stdin.gets)
       +        line = line.strip
       +        break if line == ""
       +        if(line =~ /^agi_([^:]+):\s(.*)/)
       +                conf[$1] = $2
       +        end
       +end
       +
       +targ = conf['extension'].sub(/^777/, '')
       +
       +$stdout.puts "EXEC MP3Player #{File.join(base,"#{targ}.mp3")}"
       +$stdout.flush
       +$stdin.gets
 (DIR) diff --git a/etc/sigs/99.default.rb b/etc/sigs/99.default.rb
       @@ -1,6 +1,31 @@
        #
        # WarVOX Fallback Signatures
        #
       +#
       +
       +#
       +# Initialize some local variables out of data
       +#
       +freq = data[:freq]
       +fcnt = data[:fcnt]
       +maxf = data[:maxf]
       +
       +# Look for voice mail by detecting the 1000hz BEEP
       +# If the call length was too short to catch the beep,
       +# this signature can fail. For non-US numbers, the beep
       +# is often a different frequency entirely.
       +if(fcnt[1000] >= 1.0)
       +        @line_type = 'voicemail'
       +        break                                
       +end
       +
       +# Look for voicemail by detecting a peak frequency of
       +# 1000hz. Not as accurate, but thats why this is in
       +# the fallback script.
       +if(maxf > 995 and maxf < 1005)
       +        @line_type = 'voicemail'
       +        break        
       +end
        
        #
        # Fall back to 'voice' if nothing else has been matched
 (DIR) diff --git a/lib/warvox/jobs/analysis.rb b/lib/warvox/jobs/analysis.rb
       @@ -294,7 +294,10 @@ class Analysis < Base
        
                        # Generate a MP3 audio file
                        system("sox -s -2 -r 8000 -t raw -c 1 #{rawfile.path} #{bname}.wav")
       -                system("lame #{bname}.wav #{bname}.mp3 >/dev/null 2>&1")
       +                
       +                # Default samples at 8k, bump it to 32k to get better quality
       +                system("lame -b 32 #{bname}.wav #{bname}.mp3 >/dev/null 2>&1")
       +                
                        File.unlink("#{bname}.wav")
                        File.unlink(rawfile.path)
                        rawfile.close
 (DIR) diff --git a/src/iaxrecord/iaxrecord.c b/src/iaxrecord/iaxrecord.c
       @@ -29,6 +29,7 @@ int audio       = 0;
        int busy        = 0;
        int fail        = 1;
        int done        = 0;
       +int ansd        = 0;
        
        float silence_threshold = 0.0f;
        int call_state  = 0;
       @@ -52,6 +53,7 @@ void usage(char **argv) {
        int state_event_callback(struct iaxc_ev_call_state call) {
                if(call.state & IAXC_CALL_STATE_BUSY) busy = 1;
                if(call.state & IAXC_CALL_STATE_COMPLETE) fail = 0;
       +
                call_state = call.state;
        /*
                if(debug) {
       @@ -88,13 +90,24 @@ int state_event_callback(struct iaxc_ev_call_state call) {
        }
        
        int audio_event_callback( struct iaxc_ev_audio audio) {
       -        if(call_state & IAXC_CALL_STATE_COMPLETE) {
       -                if(call_trace == -1) call_trace = open(iax_out, O_CREAT|O_TRUNC|O_WRONLY, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
       -                if(call_trace != -1) {
       -                        if(debug) printf("audio data: format=%d encoded=%d size=%d state=%d\n", audio.format, audio.encoded, audio.size, call_state);
       -                        write(call_trace, audio.data, audio.size);
       -                        call_bytes += audio.size;
       -                }
       +
       +        /* We have been recording rings, dump the file and reopen */
       +        if(call_trace != -1 && !fail && !ansd) {
       +                close(call_trace);
       +                unlink(iax_out);
       +                call_trace = -1;
       +                call_bytes  = 0;
       +                ansd = 1;
       +        }
       +        
       +        if(call_trace == -1) {
       +                call_trace = open(iax_out, O_CREAT|O_TRUNC|O_WRONLY, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
       +        }
       +
       +        if(call_trace != -1){
       +                if(debug) printf("audio data: format=%d encoded=%d size=%d state=%d\n", audio.format, audio.encoded, audio.size, call_state);
       +                write(call_trace, audio.data, audio.size);
       +                call_bytes += audio.size;
                }
                return 0;
        }
       @@ -251,6 +264,8 @@ int main(int argc, char **argv) {
                
                if(! etime) time(&etime);
                
       +        if(call_bytes > 0 && fail == 1) fail = 0;
       +        
                fprintf(stdout, "COMPLETED %s BYTES=%d FILE=%s FAIL=%d BUSY=%d RINGTIME=%d\n", 
                        iax_num, 
                        call_bytes,