Some cli tools - warvox - VoIP based wardialing tool, forked from rapid7/warvox.
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
       ---
 (DIR) commit dd99a0b18c1af6a006281f0ad3d5e70cb78bbe7a
 (DIR) parent d997b94f7515ada2a46c18eb3247edb9facf51fc
 (HTM) Author: HD Moore <hd_moore@rapid7.com>
       Date:   Sun,  7 Aug 2011 00:34:17 +0000
       
       Some cli tools
       
       
       Diffstat:
         A bin/audio_raw_to_fprint.rb          |      38 +++++++++++++++++++++++++++++++
         A bin/audio_raw_to_wav.rb             |      38 +++++++++++++++++++++++++++++++
         A bin/audio_trim.rb                   |      61 +++++++++++++++++++++++++++++++
         A bin/export_audio.rb                 |      69 ++++++++++++++++++++++++++++++
         A bin/identify_matches.rb             |      79 +++++++++++++++++++++++++++++++
       
       5 files changed, 285 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/bin/audio_raw_to_fprint.rb b/bin/audio_raw_to_fprint.rb
       @@ -0,0 +1,38 @@
       +#!/usr/bin/env ruby
       +###################
       +
       +#
       +# Load the library path
       +# 
       +base = __FILE__
       +while File.symlink?(base)
       +        base = File.expand_path(File.readlink(base), File.dirname(base))
       +end
       +$:.unshift(File.join(File.expand_path(File.dirname(base)), '..', 'lib'))
       +
       +require 'warvox'
       +
       +def usage
       +        $stderr.puts "Usage: #{$0} <input.raw> <output.txt>"
       +        exit
       +end
       +
       +#
       +# Script
       +#
       +
       +inp = ARGV.shift
       +out = ARGV.shift
       +
       +if (inp and inp == "-h") or not inp
       +        usage()
       +end
       +
       +raw = WarVOX::Audio::Raw.from_file(inp)
       +if out 
       +        ::File.open(out, "wb") do |fd|
       +                fd.write( "{" + raw.to_freq_sig.map{|x| x.to_s}.join(",") + "}" )
       +        end
       +else 
       +        $stdout.write( "{" + raw.to_freq_sig.map{|x| x.to_s}.join(",") + "}" )
       +end
 (DIR) diff --git a/bin/audio_raw_to_wav.rb b/bin/audio_raw_to_wav.rb
       @@ -0,0 +1,38 @@
       +#!/usr/bin/env ruby
       +###################
       +
       +#
       +# Load the library path
       +# 
       +base = __FILE__
       +while File.symlink?(base)
       +        base = File.expand_path(File.readlink(base), File.dirname(base))
       +end
       +$:.unshift(File.join(File.expand_path(File.dirname(base)), '..', 'lib'))
       +
       +require 'warvox'
       +
       +def usage
       +        $stderr.puts "Usage: #{$0} <input.raw> <output.wav>"
       +        exit
       +end
       +
       +#
       +# Script
       +#
       +
       +inp = ARGV.shift
       +out = ARGV.shift
       +
       +if (inp and inp == "-h") or not inp
       +        usage()
       +end
       +
       +raw = WarVOX::Audio::Raw.from_file(inp)
       +if out 
       +        ::File.open(out, "wb") do |fd|
       +                fd.write(raw.to_wav)
       +        end
       +else 
       +        $stdout.write(raw.to_wav)
       +end
 (DIR) diff --git a/bin/audio_trim.rb b/bin/audio_trim.rb
       @@ -0,0 +1,61 @@
       +#!/usr/bin/env ruby
       +###################
       +
       +#
       +# Load the library path
       +# 
       +base = __FILE__
       +while File.symlink?(base)
       +        base = File.expand_path(File.readlink(base), File.dirname(base))
       +end
       +$:.unshift(File.join(File.expand_path(File.dirname(base)), '..', 'lib'))
       +
       +require 'warvox'
       +
       +def usage
       +        $stderr.puts "Usage: #{$0} [offset] [length] <input.raw> <output.raw>"
       +        exit
       +end
       +
       +#
       +# Script
       +#
       +
       +off = ARGV.shift 
       +len = ARGV.shift
       +inp = ARGV.shift
       +out = ARGV.shift
       +
       +if (off and off == "-h") or not off
       +        usage()
       +end
       +
       +buf = ''
       +ifd = nil
       +
       +if inp 
       +        ifd = ::File.open(inp, "rb")
       +else 
       +        $stdin.binmode
       +        ifd = $stdin
       +end
       +
       +ofd = nil
       +
       +if out 
       +        ofd = ::File.open(out, "wb")
       +else 
       +        $stdout.binmode
       +        ofd = $stdout
       +end
       +
       +
       +buf = ifd.read
       +off = off.to_i * 16000
       +len = (len.to_i > 0) ? len.to_i : (buf.length / 16000).to_i 
       +
       +ofd.write( buf[off, len * 16000] )
       +exit(0)
       +
       +
       +
 (DIR) diff --git a/bin/export_audio.rb b/bin/export_audio.rb
       @@ -0,0 +1,69 @@
       +#!/usr/bin/env ruby
       +###################
       +
       +#
       +# Load the library path
       +# 
       +base = __FILE__
       +while File.symlink?(base)
       +        base = File.expand_path(File.readlink(base), File.dirname(base))
       +end
       +$:.unshift(File.join(File.expand_path(File.dirname(base)), '..', 'lib'))
       +
       +require 'warvox'
       +require 'fileutils'
       +
       +
       +ENV['RAILS_ENV'] ||= 'production'
       +
       +$:.unshift(File.join(File.expand_path(File.dirname(base)), '..', 'web'))
       +require 'config/boot'
       +require 'config/environment'
       +
       +def usage
       +        $stderr.puts "Usage: #{$0} [Output Dir] [Job ID] <Type>"
       +        exit
       +end
       +
       +#
       +# Script
       +#
       +
       +dir = ARGV.shift
       +job = ARGV.shift
       +typ = ARGV.shift
       +
       +if(job and job == "-h")
       +        usage()
       +end
       +
       +if(not job)
       +        $stderr.puts "Listing all available jobs"
       +        $stderr.puts "=========================="
       +        DialJob.find(:all).each do |j|
       +                puts "#{j.id}\t#{j.started_at} --> #{j.completed_at}"
       +        end
       +        exit
       +end
       +
       +
       +::FileUtils.mkdir_p(dir)
       +
       +begin
       +        cnt = 0
       +        job = DialJob.find(job.to_i)
       +        job.dial_results.each do |r|
       +                next if not r.number
       +                next if r.audio.to_s.length == 0
       +                out = ::File.join(dir, "#{r.number}.raw")
       +                ::File.open(out, "wb") do |fd|
       +                        fd.write( r.audio )
       +                end
       +                cnt += 1
       +        end
       +        $stderr.puts "Wrote #{cnt} audio files to #{dir}"
       +rescue ActiveRecord::RecordNotFound
       +        $stderr.puts "Job not found"
       +        exit
       +end
       +
 (DIR) diff --git a/bin/identify_matches.rb b/bin/identify_matches.rb
       @@ -0,0 +1,79 @@
       +#!/usr/bin/env ruby
       +###################
       +
       +#
       +# Load the library path
       +# 
       +base = __FILE__
       +while File.symlink?(base)
       +        base = File.expand_path(File.readlink(base), File.dirname(base))
       +end
       +$:.unshift(File.join(File.expand_path(File.dirname(base)), '..', 'lib'))
       +
       +require 'warvox'
       +
       +ENV['RAILS_ENV'] ||= 'production'
       +
       +$:.unshift(File.join(File.expand_path(File.dirname(base)), '..', 'web'))
       +require 'config/boot'
       +require 'config/environment'
       +
       +def usage
       +        $stderr.puts "Usage: #{$0} [job|all] <fprint>"
       +        exit
       +end
       +
       +#
       +# Script
       +#
       +
       +job = ARGV.shift
       +fp  = ARGV.shift
       +
       +if(job and job == "-h")
       +        usage()
       +end
       +
       +if(not job)
       +        $stderr.puts "Listing all available jobs"
       +        $stderr.puts "=========================="
       +        DialJob.find(:all).each do |j|
       +                puts "#{j.id}\t#{j.started_at} --> #{j.completed_at}"
       +        end
       +        exit
       +end
       +
       +fp  = $stdin.read.strip if fp == "-"
       +job = nil if job.downcase == "all"
       +
       +if not fp 
       +        usage()
       +end
       +
       +
       +begin
       +        res = nil
       +        job = DialJob.find(job.to_i) if job
       +        if job
       +                res = DialResult.find_by_sql "SELECT dial_results.*,  " +
       +                        " (( icount('#{fp}'::int[] & dial_results.fprint::int[]) / icount('#{fp}'::int[])::float ) * 100.0 ) AS matchscore " +
       +                        "FROM dial_results " +
       +                        "WHERE " +
       +                        " icount(dial_results.fprint) > 0 AND " + 
       +                        " dial_results.dial_job_id = '#{job.id}' " +
       +                        "ORDER BY matchscore DESC"
       +        else
       +                res = DialResult.find_by_sql "SELECT dial_results.*,  " +
       +                        " (( icount('#{fp}'::int[] & dial_results.fprint::int[]) / icount('#{fp}'::int[])::float ) * 100.0 ) AS matchscore " +
       +                        "FROM dial_results " +
       +                        "WHERE " +
       +                        " icount(dial_results.fprint) > 0 " +
       +                        "ORDER BY matchscore DESC"
       +        end
       +        res.each do |r|
       +                $stdout.puts "#{"%.2f" % r.matchscore}\t#{r.dial_job_id}\t#{r.number}"
       +        end
       +rescue ActiveRecord::RecordNotFound
       +        $stderr.puts "Job not found"
       +        exit
       +end