URI: 
       Tweaks, automatch is still in development, but working (if slow) - warvox - VoIP based wardialing tool, forked from rapid7/warvox.
   DIR Log
   DIR Files
   DIR Refs
   DIR README
       ---
   DIR commit 2af809ed64362553e2fd7b309fd8da3490351bb6
   DIR parent dbcda197e69a49e32e286c87c4b9516d9718da20
  HTML Author: HD Moore <hd_moore@rapid7.com>
       Date:   Fri, 13 Feb 2009 14:35:18 +0000
       
       Tweaks, automatch is still in development, but working (if slow)
       
       
       Diffstat:
         M bin/automatch.rb                    |      76 +++++++++++++++++++++----------
         M lib/warvox/db.rb                    |      19 +++++--------------
       
       2 files changed, 56 insertions(+), 39 deletions(-)
       ---
   DIR diff --git a/bin/automatch.rb b/bin/automatch.rb
       @@ -15,37 +15,63 @@ require 'warvox'
        # Script
        # 
        
       -names = []
       -inp = ARGV.shift() || exit
       -fd  = File.open(inp, "r")
       -fd.each_line do |line|
       -        data = line.strip.split(/\s+/)
       -        if(data.shift =~ /(\d+)/)
       -                if(data.length < 20)
       -                        puts "[*] Skipping carrier #{$1}..."
       -                        next
       -                end
       -                names << $1
       -        end
       +def usage
       +        $stderr.puts "#{$0} [warvox.db] <db-threshold>"
       +        exit
       +end
       +
       +threads = 2 
       +inp     = ARGV.shift || usage
       +thresh  = (ARGV.shift() || 800).to_i
       +wdb     = WarVOX::DB.new(inp, thresh)
       +
       +# Scrub the carriers out of the pool first
       +car = wdb.find_carriers
       +car.keys.each do |k|
       +        wdb.delete(k)
        end
        
       +groups = 
       +{
       +        "carriers" => car.keys
       +}
        
       -found = {}
       +oset = wdb.keys.sort
       +iset = oset.dup
        
       -names.each do |n1|
       -        puts "[*] Searching for matches to #{n1}"
       -        best = 0
       -        names.each do |n2|
       -                next if found[n2]
       -                data = `ruby t.rb #{inp} #{n1} #{n2} 2>/dev/null`
       -                next if not data
       -                
       -                data.strip!
       -                head,dead = data.split(/\s+/, 2)
       -                next if not head
       +
       +
       +while(not oset.empty?)
       +
       +        k = oset.shift
       +        
       +        found = []
       +        best  = nil
       +        next if not iset.include?(k)
       +        
       +        iset.each do |n|
       +                next if k == n
                        
       -                p head
       +                begin
       +                        res = wdb.find_sig(k,n)
       +                rescue ::WarVOX::DB::Error
       +                end
                        
       +                next if not res
       +                next if res[:len] < 5
       +                found << res
       +        end
       +        
       +        next if found.empty?
       +        
       +        groups[k] = [ ]
       +        found.each do |f|
       +                groups[k] << [ f[:num2], f[:len] ]
                end
       +
       +        $stdout.puts "#{k} " + groups[k].map{|x| "#{x[0]}-#{x[1]}" }.join(" ")
       +        $stdout.flush
       +        
       +        groups[k].unshift(k)
        end
        
   DIR diff --git a/lib/warvox/db.rb b/lib/warvox/db.rb
       @@ -1,17 +1,16 @@
        module WarVOX
       -class DB
       +class DB < ::Hash
                        
                VERSION = '1.0'
                
                class Error < ::RuntimeError
                end
                
       -        attr_accessor :path, :nums, :threshold, :version
       +        attr_accessor :path, :threshold, :version
        
                def initialize(path, threshold=800)
                        self.path      = path
                        self.threshold = threshold
       -                self.nums      = {}
                        self.version   = VERSION
                        
                        File.open(path, "r") do |fd|
       @@ -26,24 +25,16 @@ class DB
                                        
                                        next if bits.empty?
        
       -                                self.nums[name] = []
       +                                self[name] = []
                                        bits.each do |d|
                                                s,l,a = d.split(',')
                                                next if l.to_i < self.threshold
       -                                        self.nums[name] << [s, l.to_i, a.to_i]
       +                                        self[name] << [s, l.to_i, a.to_i]
                                        end
                                end
                        end
                end
                
       -        def [](num)
       -                self.nums[num]
       -        end
       -        
       -        def []=(num,val)
       -                self.nums[num] = val
       -        end
       -        
                #
                # Utility methods
                #
       @@ -137,7 +128,7 @@ class DB
        
                def find_carriers
                        carriers = {}
       -                self.nums.keys.sort.each do |num|
       +                self.keys.sort.each do |num|
                                begin
                                        res = is_carrier?(num)
                                        next if not res