| Carrier detectino - warvox - VoIP based wardialing tool, forked from rapid7/war… | |
| Log | |
| Files | |
| Refs | |
| README | |
| --- | |
| commit dbcda197e69a49e32e286c87c4b9516d9718da20 | |
| parent 60be9accc104b2d63ff2ab74bf586b4ce054a524 | |
| Author: HD Moore <[email protected]> | |
| Date: Fri, 13 Feb 2009 07:02:57 +0000 | |
| Carrier detectino | |
| Diffstat: | |
| A bin/search_carriers.rb | 29 +++++++++++++++++++++++++++++ | |
| M lib/warvox/db.rb | 39 +++++++++++++++++++++++++++++… | |
| 2 files changed, 68 insertions(+), 0 deletions(-) | |
| --- | |
| diff --git a/bin/search_carriers.rb b/bin/search_carriers.rb | |
| @@ -0,0 +1,29 @@ | |
| +#!/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' | |
| + | |
| +# | |
| +# Script | |
| +# | |
| + | |
| +def usage | |
| + $stderr.puts "#{$0} [warvox.db] <db-threshold>" | |
| + exit | |
| +end | |
| + | |
| +inp = ARGV.shift || usage | |
| +thresh = (ARGV.shift() || 800).to_i | |
| +wdb = WarVOX::DB.new(inp, thresh) | |
| +res = wdb.find_carriers | |
| +res.keys.sort.each do |k| | |
| + puts "#{k}\t" + res[k].map{|x| sprintf("%d@%d",x[1],x[2]) }.join(", ") | |
| +end | |
| diff --git a/lib/warvox/db.rb b/lib/warvox/db.rb | |
| @@ -20,6 +20,11 @@ class DB | |
| next if line.empty? | |
| bits = line.split(/\s+/) | |
| name = bits.shift | |
| + | |
| + # Remove leading silence | |
| + bits.shift if bits[0][0,1] == "L" | |
| + | |
| + next if bits.empty? | |
| self.nums[name] = [] | |
| bits.each do |d| | |
| @@ -43,6 +48,7 @@ class DB | |
| # Utility methods | |
| # | |
| + # Find the largest pattern shared between two samples | |
| def find_sig(num1, num2, opts={}) | |
| fuzz = opts[:fuzz] || 100 | |
| @@ -53,6 +59,10 @@ class DB | |
| if ( not (info1 and info2 and not (info1.empty? or info2.empty… | |
| raise Error, "The database must contain both numbers" | |
| end | |
| + | |
| + # Remove the silence prefix from both samples | |
| + info1.shift if info1[0][0] == "L" | |
| + info2.shift if info2[0][0] == "L" | |
| min_sig = 2 | |
| idx = 0 | |
| @@ -108,6 +118,35 @@ class DB | |
| :sig => sig | |
| } | |
| end | |
| + | |
| + def is_carrier?(num) | |
| + data = self[num] | |
| + raise Error, "The specified number does not exist: #{num}" if … | |
| + tone = [] | |
| + | |
| + min_len = 10000 | |
| + | |
| + data.each do |rec| | |
| + next if rec[0] != "H" | |
| + next if rec[1] < min_len | |
| + tone << rec | |
| + end | |
| + | |
| + (tone.empty? or tone.length == 1) ? false : tone | |
| + end | |
| + | |
| + def find_carriers | |
| + carriers = {} | |
| + self.nums.keys.sort.each do |num| | |
| + begin | |
| + res = is_carrier?(num) | |
| + next if not res | |
| + carriers[num] = res | |
| + rescue Error | |
| + end | |
| + end | |
| + carriers | |
| + end | |
| end | |
| end |