| Nuke the old/busted scripts - warvox - VoIP based wardialing tool, forked from … | |
| Log | |
| Files | |
| Refs | |
| README | |
| --- | |
| commit 8b9384948db26895e2737f227c906c39d285edc9 | |
| parent 8d14632cd039331d86cc8de8edddd180a20b5435 | |
| Author: HD Moore <[email protected]> | |
| Date: Sat, 6 Aug 2011 04:06:26 +0000 | |
| Nuke the old/busted scripts | |
| Diffstat: | |
| D bin/automatch.rb | 93 -----------------------------… | |
| D bin/create_flow.rb | 24 ------------------------ | |
| D bin/create_flowdb.rb | 40 -----------------------------… | |
| D bin/create_matches.rb | 82 -----------------------------… | |
| D bin/create_media.rb | 86 ------------------------------ | |
| D bin/create_media_groups.rb | 47 -----------------------------… | |
| D bin/create_samples.rb | 28 ---------------------------- | |
| D bin/create_sig.rb | 38 -----------------------------… | |
| D bin/create_ui.rb | 176 -----------------------------… | |
| D bin/link_maltego.rb | 159 -----------------------------… | |
| D bin/search_carriers.rb | 29 ----------------------------- | |
| D bin/search_sig.rb | 80 -----------------------------… | |
| D bin/search_tones.rb | 52 -----------------------------… | |
| D bin/warvox.agi | 25 ------------------------- | |
| M lib/warvox.rb | 1 - | |
| 15 files changed, 0 insertions(+), 960 deletions(-) | |
| --- | |
| diff --git a/bin/automatch.rb b/bin/automatch.rb | |
| @@ -1,93 +0,0 @@ | |
| -#!/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> <fuzz>" | |
| - exit | |
| -end | |
| - | |
| -threads = 2 | |
| -inp = ARGV.shift || usage | |
| -thresh = (ARGV.shift() || 800).to_i | |
| -fuzz = (ARGV.shift() || 100).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, | |
| - "unique" => [] | |
| -} | |
| - | |
| -oset = wdb.keys.sort | |
| -iset = oset.dup | |
| - | |
| - | |
| -$stdout.puts car.keys.map{|x| "#{x}-100" }.join(" ") | |
| -$stdout.flush | |
| - | |
| -while(not oset.empty?) | |
| - | |
| - s = Time.now | |
| - k = oset.shift | |
| - | |
| - found = {} | |
| - next if not iset.include?(k) | |
| - | |
| - iset.each do |n| | |
| - next if k == n | |
| - | |
| - begin | |
| - res = wdb.find_sig(k,n,{ :fuzz => fuzz }) | |
| - rescue ::WarVOX::DB::Error | |
| - end | |
| - | |
| - next if not res | |
| - next if res[:len] < 5 | |
| - if(not found[n] or found[n][:len] < res[:len]) | |
| - found[n] = res | |
| - end | |
| - end | |
| - | |
| - if(found.empty?) | |
| - next | |
| - end | |
| - | |
| - groups[k] = [ [k, 0] ] | |
| - found.keys.sort.each do |n| | |
| - groups[k] << [n, found[n][:len]] | |
| - end | |
| - | |
| - $stdout.puts groups[k].map{|x| "#{x[0]}-#{x[1]}" }.join(" ") | |
| - $stdout.flush | |
| - | |
| - groups[k].unshift(k) | |
| - | |
| - # Remove matches from the search listing | |
| - iset.delete(k) | |
| - found.keys.each do |k| | |
| - iset.delete(k) | |
| - end | |
| -end | |
| -iset.each do |k| | |
| - puts "#{k}-0" | |
| -end | |
| diff --git a/bin/create_flow.rb b/bin/create_flow.rb | |
| @@ -1,24 +0,0 @@ | |
| -#!/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} [audio.raw]" | |
| - exit | |
| -end | |
| - | |
| -raw = WarVOX::Audio::Raw.from_file(ARGV.shift || usage) | |
| -puts raw.to_flow | |
| diff --git a/bin/create_flowdb.rb b/bin/create_flowdb.rb | |
| @@ -1,40 +0,0 @@ | |
| -#!/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} [/path/to/audio/] [output.db]" | |
| - exit | |
| -end | |
| - | |
| -src = ARGV.shift || usage | |
| -dst = ARGV.shift || usage | |
| -db = File.new(dst, "w") | |
| -dir = Dir.new(src) | |
| -cnt = 0 | |
| - | |
| -set = dir.entries.sort.grep(/\.raw/) | |
| -set.each do |ent| | |
| - next if not ent =~ /\.raw/ | |
| - puts "[*] [#{sprintf("%.5d/%.5d", cnt+1, set.length)}] Processing #{en… | |
| - raw = WarVOX::Audio::Raw.from_file( File.join(src, ent) ) | |
| - db.write( ent.gsub(/\.raw|\.gz/, '') + " " + raw.to_flow + "\n" ) | |
| - cnt += 1 | |
| -end | |
| - | |
| -db.close | |
| - | |
| -puts "[*] Wrote #{cnt} database entries into #{dst}" | |
| diff --git a/bin/create_matches.rb b/bin/create_matches.rb | |
| @@ -1,82 +0,0 @@ | |
| -#!/usr/bin/env ruby | |
| - | |
| -# | |
| -# Given the path to a signature file, determine the closests matching signatur… | |
| -# within the same directory, creating a .match file. | |
| -# | |
| - | |
| - | |
| -def is_bad_sig?(sig) | |
| - return true if sig == 0 | |
| - false | |
| -end | |
| - | |
| -def load_signature(data) | |
| - data.split("\n").map { |line| | |
| - line.strip.to_i | |
| - }.reject {|sig| is_bad_sig?(sig) } | |
| -end | |
| - | |
| -inp = ARGV.shift || exit(1) | |
| -ind = ARGV.shift | |
| -dir = File.expand_path(inp) + "/" | |
| -set = {} | |
| - | |
| -d = Dir.new(dir) | |
| -d.entries.each do |ent| | |
| - next if ent !~ /\.sigs$/ | |
| - name,trash = ent.split('.', 2) | |
| - data = File.read(File.join(dir, ent)) | |
| - set[name] = load_signature(data) | |
| - | |
| - if set.keys.length % 500 == 0 | |
| - puts "[*] Loaded #{set.keys.length} signatures..." … | |
| - end | |
| -end | |
| -d.close | |
| - | |
| -puts "[*] Finished loading #{set.keys.length} signatures..." | |
| - | |
| -max = 10 | |
| -cnt = 0 | |
| -stime = Time.now.to_f | |
| - | |
| -targs = ind ? [ind] : set.keys.sort | |
| - | |
| -while targs.length > 0 | |
| - jobs = [] | |
| - | |
| - while jobs.length < max | |
| - targ = targs.shift | |
| - break if not targ | |
| - pid = fork | |
| - | |
| - if pid | |
| - jobs << pid | |
| - next | |
| - end | |
| - | |
| - mine = targ | |
| - msig = set[targ] | |
| - | |
| - exit(0) if msig.length == 0 | |
| - | |
| - res = [] | |
| - set.each_pair do |n,sig| | |
| - next if n == mine | |
| - hits = (msig & sig).length | |
| - res << [ ( hits / msig.length.to_f ) * 100.0, hits, n ] | |
| - end | |
| - | |
| - File.open(File.join(dir, mine + ".matches"), "w") do |fd| | |
| - res.sort{|a,b| b[0] <=> a[0] }.each do |r| | |
| - fd.puts "#{"%.2f" % r[0]}\t#{r[2]}" | |
| - end | |
| - end | |
| - | |
| - exit(0) | |
| - end | |
| - jobs.each {|j| Process.waitpid(j) } | |
| - cnt += jobs.length | |
| - puts "[*] Processed #{cnt}/#{set.keys.length} in #{Time.now.to_f - sti… | |
| -end | |
| diff --git a/bin/create_media.rb b/bin/create_media.rb | |
| @@ -1,86 +0,0 @@ | |
| -#!/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} [/path/to/raw/data/] <destination dir> " | |
| - exit | |
| -end | |
| - | |
| -require "fileutils" | |
| -require "tempfile" | |
| - | |
| -src = ARGV.shift || usage | |
| -dst = ARGV.shift || File.join(File.dirname(base), '..', 'data', 'media') | |
| - | |
| -FileUtils.mkdir_p(dst) | |
| - | |
| -calls = [] | |
| -dir = Dir.new(src) | |
| -dir.entries.sort.each do |ent| | |
| - | |
| - path = File.join(src, ent) | |
| - next if ent !~ /(.*)\.raw\.gz$/m | |
| - num = $1 | |
| - | |
| - next if File.exist?(File.join(dst, num + ".mp3")) | |
| - | |
| - puts "Processing #{num}..." | |
| - | |
| - # Decompress the audio file | |
| - rawfile = Tempfile.new("rawfile") | |
| - datfile = Tempfile.new("datfile") | |
| - | |
| - cnt = 0 | |
| - raw = WarVOX::Audio::Raw.from_file(path) | |
| - rawfile.write(raw.samples.pack('v*')) | |
| - datfile.write(raw.samples.map{|val| cnt +=1; "#{cnt} #{val}"}.join("\n… | |
| - rawfile.flush | |
| - datfile.flush | |
| - | |
| - # Plot samples to a graph | |
| - plotter = Tempfile.new("gnuplot") | |
| - | |
| - plotter.puts("set ylabel \"Signal\"") | |
| - plotter.puts("set xlabel \"Time\"") | |
| - | |
| - plotter.puts("set terminal png medium size 640,480 transparent") | |
| - plotter.puts("set output \"#{dst}/#{num}_big.png\"") | |
| - plotter.puts("plot \"#{datfile.path}\" using 1:2 title \"#{num}\" with… | |
| - | |
| - plotter.puts("set output \"#{dst}/#{num}_big_dots.png\"") | |
| - plotter.puts("plot \"#{datfile.path}\" using 1:2 title \"#{num}\" with… | |
| - | |
| - plotter.puts("set terminal png small size 160,120 transparent") | |
| - plotter.puts("set format x ''") | |
| - plotter.puts("set format y ''") | |
| - plotter.puts("set output \"#{dst}/#{num}.png\"") | |
| - plotter.puts("plot \"#{datfile.path}\" using 1:2 title \"#{num}\" with… | |
| - plotter.flush | |
| - | |
| - system("gnuplot #{plotter.path}") | |
| - File.unlink(plotter.path) | |
| - File.unlink(datfile.path) | |
| - plotter.close | |
| - datfile.close | |
| - | |
| - # Generate a MP3 audio file | |
| - system("sox -s -2 -r 8000 -t raw -c 1 #{rawfile.path} #{dst}/#{num}.wa… | |
| - system("lame #{dst}/#{num}.wav #{dst}/#{num}.mp3 >/dev/null 2>&1") | |
| - File.unlink("#{dst}/#{num}.wav") | |
| - File.unlink(rawfile.path) | |
| - rawfile.close | |
| -end | |
| diff --git a/bin/create_media_groups.rb b/bin/create_media_groups.rb | |
| @@ -1,47 +0,0 @@ | |
| -#!/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' | |
| - | |
| -# | |
| -# Script | |
| -# | |
| - | |
| -def usage | |
| - $stderr.puts "#{$0} [groups_file] [media_source] [destination]" | |
| - exit | |
| -end | |
| - | |
| - | |
| -group = ARGV.shift || usage() | |
| -src = ARGV.shift || usage() | |
| -dst = ARGV.shift || usage() | |
| - | |
| - | |
| -File.readlines(group).each do |line| | |
| - line.strip! | |
| - line.gsub!(/\-\d+/, '') | |
| - bits = line.split(/\s+/) | |
| - | |
| - | |
| - gdir = File.join(dst, bits[0]) | |
| - FileUtils.mkdir_p(gdir) | |
| - puts "Processing #{bits[0]}..." | |
| - bits.each do |num| | |
| - system("cp #{src}/#{num}.* #{gdir}") | |
| - end | |
| - | |
| -end | |
| - | |
| - | |
| - | |
| -FileUtils.mkdir_p(dst) | |
| diff --git a/bin/create_samples.rb b/bin/create_samples.rb | |
| @@ -1,28 +0,0 @@ | |
| -#!/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} [audio.raw]" | |
| - exit | |
| -end | |
| - | |
| -cnt = 0 | |
| -raw = WarVOX::Audio::Raw.from_file(ARGV.shift || usage) | |
| -raw.samples.each do |val| | |
| - puts "#{cnt} #{val}" | |
| - cnt += 1 | |
| -end | |
| diff --git a/bin/create_sig.rb b/bin/create_sig.rb | |
| @@ -1,38 +0,0 @@ | |
| -#!/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 'yaml' | |
| - | |
| -# | |
| -# Script | |
| -# | |
| - | |
| -def usage | |
| - $stderr.puts "#{$0} [raw-file] <skip-count> <length-count>" | |
| - exit(1) | |
| -end | |
| - | |
| -inp = ARGV.shift() || usage() | |
| -skp = (ARGV.shift() || 0).to_i | |
| -len = (ARGV.shift() || 0).to_i | |
| - | |
| -raw = WarVOX::Audio::Raw.from_file(File.expand_path(inp)) | |
| -raw.samples = (raw.samples[skp, raw.samples.length]||[]) if skp > 0 | |
| -raw.samples = (raw.samples[0, len]||[]) if len > 0 | |
| - | |
| -if(raw.samples.length == 0) | |
| - $stderr.puts "Error: the sample length is too short to create a signat… | |
| - exit(1) | |
| -end | |
| - | |
| - | |
| -$stdout.puts raw.to_freq_sig_txt | |
| diff --git a/bin/create_ui.rb b/bin/create_ui.rb | |
| @@ -1,176 +0,0 @@ | |
| -#!/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 | |
| -# | |
| -require "fileutils" | |
| -require "tempfile" | |
| - | |
| -def usage | |
| - "#{$0} src/ dst/" | |
| - exit(0) | |
| -end | |
| - | |
| -src = ARGV.shift || usage | |
| -dst = ARGV.shift || usage | |
| - | |
| - | |
| -FileUtils.mkdir_p(dst) | |
| -FileUtils.copy(File.join(base, "ui", "player.swf"), File.join(dst, "player.swf… | |
| -FileUtils.copy(File.join(base, "ui", "styles.css"), File.join(dst, "styles.css… | |
| - | |
| -calls = [] | |
| -dir = Dir.new(src) | |
| -dir.entries.sort.each do |ent| | |
| - | |
| - path = File.join(src, ent) | |
| - next if ent !~ /(.*)\.raw.gz$/m | |
| - num = $1 | |
| - | |
| - calls << num | |
| - if(File.exists?(File.join(dst, "#{num}.html"))) | |
| - puts "Skipping #{num}..." | |
| - next | |
| - end | |
| - | |
| - puts "Processing #{num}..." | |
| - | |
| - # Decompress the audio file | |
| - rawfile = Tempfile.new("rawfile") | |
| - system("zcat #{path} > #{rawfile.path}") | |
| - | |
| - # Generate data samples | |
| - system("ruby #{base}/bin/sampler.rb #{rawfile.path} > #{dst}/#{num}.da… | |
| - | |
| - # Plot samples to a graph | |
| - plotter = Tempfile.new("gnuplot") | |
| - | |
| - | |
| - plotter.puts("set ylabel \"Frequency\"") | |
| - plotter.puts("set xlabel \"Time\"") | |
| - | |
| - plotter.puts("set terminal png medium size 640,480 transparent") | |
| - plotter.puts("set output \"#{dst}/#{num}_big.png\"") | |
| - plotter.puts("plot \"#{dst}/#{num}.dat\" using 1:2 title \"#{num}\" wi… | |
| - | |
| - plotter.puts("set terminal png small size 160,120 transparent") | |
| - plotter.puts("set format x ''") | |
| - plotter.puts("set format y ''") | |
| - plotter.puts("set output \"#{dst}/#{num}.png\"") | |
| - plotter.puts("plot \"#{dst}/#{num}.dat\" using 1:2 title \"#{num}\" wi… | |
| - | |
| - plotter.flush | |
| - system("gnuplot #{plotter.path}") | |
| - File.unlink(plotter.path) | |
| - File.unlink("#{dst}/#{num}.dat") | |
| - plotter.close | |
| - | |
| - # Detect the carrier | |
| - carrier = `ruby #{base}/bin/detect_carrier.rb #{rawfile.path}` | |
| - eout = File.new(File.join(dst, "#{num}.info"), "w") | |
| - eout.write("#{num} #{carrier}") | |
| - eout.close | |
| - | |
| - | |
| - # Generate a MP3 audio file | |
| - system("sox -s -2 -r 8000 -t raw -c 1 #{rawfile.path} #{dst}/#{num}.wa… | |
| - system("lame #{dst}/#{num}.wav #{dst}/#{num}.mp3 >/dev/null 2>&1") | |
| - File.unlink("#{dst}/#{num}.wav") | |
| - File.unlink(rawfile.path) | |
| - rawfile.close | |
| - | |
| - # Generate the HTML | |
| - html = %Q{ | |
| -<html> | |
| - <head> | |
| - <title>Analysis of #{num}</title> | |
| - <link rel="stylesheet" href="styles.css" type="text/css" /> | |
| - </head> | |
| -<body> | |
| - | |
| -<center> | |
| - | |
| -<h1>#{num}</h1> | |
| -<img src="#{num}_big.png"><br/><br/> | |
| -<object class="playerpreview" type="application/x-shockwave-flash" data="playe… | |
| - <param name="movie" value="player.swf" /> | |
| - <param name="FlashVars" value="mp3=#{num}.mp3&showstop=1&showvolum… | |
| -</object> | |
| - | |
| -<p>#{num} - #{carrier}</p> | |
| -<p><a href="index.html"><<< Back</a></p> | |
| - | |
| -</center> | |
| -</body> | |
| -</html> | |
| - } | |
| - | |
| - eout = File.new(File.join(dst, "#{num}.html"), "w") | |
| - eout.write(html) | |
| - eout.close | |
| - | |
| -# break if calls.length > 10 | |
| -end | |
| - | |
| -# Create the final output web page | |
| -eout = File.new(File.join(dst, "index.html"), "w") | |
| - | |
| -html = %Q{ | |
| -<html> | |
| - <head> | |
| - <title>Call Analysis</title> | |
| - <link rel="stylesheet" href="styles.css" type="text/css" /> | |
| - </head> | |
| -<body> | |
| -<center> | |
| - | |
| -<h1>Results for #{calls.length} Calls</h1> | |
| -<table align="center" border=0 cellspacing=0 cellpadding=6> | |
| -} | |
| - | |
| -max = 6 | |
| -cnt = 0 | |
| -calls.sort.each do |num| | |
| - if(cnt == max) | |
| - html << %Q{</tr>\n} | |
| - cnt = 0 | |
| - end | |
| - | |
| - if(cnt == 0) | |
| - html << %Q{<tr>} | |
| - end | |
| - | |
| - live = ( File.read(File.join(dst, "#{num}.info")) =~ /CARRIER/ ) ? "ca… | |
| - html << %Q{<td class="#{live}"><a href="#{num}.html"><img src="#{num}.… | |
| - cnt += 1 | |
| -end | |
| - | |
| -while(cnt < max) | |
| - html << "<td> </td>" | |
| - cnt += 1 | |
| -end | |
| -html << "</tr>\n" | |
| - | |
| -html << %Q{ | |
| -</table> | |
| -</center> | |
| -</body> | |
| -</html> | |
| -} | |
| - | |
| - | |
| -eout.write(html) | |
| -eout.close | |
| - | |
| -puts "Completed" | |
| diff --git a/bin/link_maltego.rb b/bin/link_maltego.rb | |
| @@ -1,159 +0,0 @@ | |
| -#!/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 'rexml/document' | |
| - | |
| -# | |
| -# Script | |
| -# | |
| - | |
| -# | |
| -# http://ctas.paterva.com/view/Specification | |
| -# | |
| - | |
| -def xml_results_empty | |
| - root = REXML::Element.new('MaltegoMessage') | |
| - xml2 = root.add_element('MaltegoTransformResponseMessage') | |
| - xml2.add_element('Entities') | |
| - root | |
| -end | |
| - | |
| -def xml_results_matches(res) | |
| - root = REXML::Element.new('MaltegoMessage') | |
| - xml2 = root.add_element('MaltegoTransformResponseMessage') | |
| - xml3 = xml2.add_element('Entities') | |
| - | |
| - res.each_key do |k| | |
| - num_area = k[0,3] | |
| - num_city = k[3,3] | |
| - num_last = k[6,4] | |
| - | |
| - num = num_area + " " + num_city + " " + num_last | |
| - | |
| - val = REXML::Element.new('Value') | |
| - val.add_text(num) | |
| - | |
| - adf = REXML::Element.new('AdditionalFields') | |
| - | |
| - adf_area = REXML::Element.new('Field') | |
| - adf_area.add_attribute('Name', 'areacode') | |
| - adf_area.add_text( REXML::Text.new( num_area.to_s ) ) | |
| - adf << adf_area | |
| - | |
| - adf_city = REXML::Element.new('Field') | |
| - adf_city.add_attribute('Name', 'citycode') | |
| - adf_city.add_text( REXML::Text.new( num_city.to_s ) ) | |
| - adf << adf_city | |
| - | |
| - adf_last = REXML::Element.new('Field') | |
| - adf_last.add_attribute('Name', 'lastnumbers') | |
| - adf_last.add_text( REXML::Text.new( num_last.to_s ) ) | |
| - adf << adf_last | |
| - | |
| - adf_info = REXML::Element.new('Field') | |
| - adf_info.add_attribute('Name', 'additional') | |
| - adf_info.add_text( REXML::Text.new( "Sig: " + res[k][:… | |
| - adf << adf_info | |
| - | |
| - | |
| - wgt = REXML::Element.new('Weight') | |
| - wgt.add_text( REXML::Text.new( [res[k][:len] * 10, 100].min.t… | |
| - | |
| - ent = REXML::Element.new('Entity') | |
| - ent.add_attribute('Type', 'PhoneNumber') | |
| - | |
| - ent << val | |
| - ent << wgt | |
| - ent << adf | |
| - | |
| - xml3 << ent | |
| - end | |
| - root | |
| -end | |
| - | |
| - | |
| -# Only report each percentage once | |
| -@progress_done = {} | |
| - | |
| -def report_progress(pct) | |
| - return if @progress_done[pct] | |
| - $stderr.puts "%#{pct}" | |
| - $stderr.flush | |
| - @progress_done[pct] = true | |
| -end | |
| - | |
| -def usage | |
| - $stderr.puts "#{$0} [target] [params]" | |
| - exit | |
| -end | |
| - | |
| -# | |
| -# Parse input | |
| -# | |
| - | |
| -params = {} | |
| -target = ARGV.shift || usage() | |
| -(ARGV.shift || usage()).split('#').each do |param| | |
| - k,v = param.split('=', 2) | |
| - params[k] = v | |
| -end | |
| - | |
| -# XXX: Problematic right now | |
| -# target_number = params['areacode'] + params['citycode'] + params['lastnumber… | |
| - | |
| -target_number = target.scan(/\d+/).join | |
| -if(target_number.length != 10) | |
| - $stderr.puts "D: Only 10 digit US numbers are currently supported" | |
| - $stdout.puts xml_results_empty().to_s | |
| - exit | |
| -end | |
| - | |
| - | |
| -# | |
| -# Search database | |
| -# | |
| - | |
| -carriers = {} | |
| - | |
| -data_root = File.join(File.dirname(base), '..', 'data') | |
| -wdb = WarVOX::DB.new(nil) | |
| - | |
| -Dir.new(data_root).entries.grep(/\.db$/).each do |db| | |
| - $stderr.puts "D: Loading #{db}..." | |
| - wdb.import(File.join(data_root, db)) | |
| -end | |
| - | |
| -# No matching number | |
| -if(not wdb[target_number]) | |
| - $stderr.puts "D: Target #{target_number} (#{target}) is not in the War… | |
| - $stdout.puts xml_results_empty().to_s | |
| - exit | |
| -end | |
| - | |
| -found = {} | |
| -cnt = 0 | |
| -wdb.each_key do |n| | |
| - cnt += 1 | |
| - | |
| - report_progress(((cnt / wdb.keys.length.to_f) * 100).to_i.to_s) | |
| - | |
| - next if target_number == n | |
| - begin | |
| - res = wdb.find_sig(target_number, n, { :fuzz => 100 }) | |
| - rescue ::WarVOX::DB::Error | |
| - end | |
| - next if not res | |
| - next if res[:len] < 5 | |
| - found[n] = res | |
| -end | |
| - | |
| -$stdout.puts xml_results_matches(found).to_s | |
| diff --git a/bin/search_carriers.rb b/bin/search_carriers.rb | |
| @@ -1,29 +0,0 @@ | |
| -#!/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/bin/search_sig.rb b/bin/search_sig.rb | |
| @@ -1,80 +0,0 @@ | |
| -#!/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 | |
| -# | |
| - | |
| -inp = ARGV.shift() | |
| -sig = ARGV.join(' ') | |
| - | |
| -min_len = 800 | |
| - | |
| -# Load the signature from the command line | |
| - | |
| -info1 = [] | |
| -bits = sig.split(/\s+/) | |
| -head = bits.shift | |
| -bits.each do |s| | |
| - inf = s.split(",") | |
| - info1 << [inf[0], inf[1].to_i, inf[2].to_i] | |
| -end | |
| - | |
| -# Search for matching numbers | |
| - | |
| -fd = File.open(inp, "r") | |
| -fd.each_line do |line| | |
| - data = line.strip.split(/\s+/) | |
| - name = data.shift | |
| - | |
| - # Bump the leading silence off | |
| - data.shift if data[0] =~ /^L/ | |
| - | |
| - fnd = nil | |
| - info2 = [] | |
| - data.each do |d| | |
| - s,l,a = d.split(",") | |
| - next if l.to_i < min_len | |
| - info2 << [s, l.to_i, a.to_i] | |
| - end | |
| - | |
| - fuzz = 100 #XXX read from sig | |
| - idx2 = 0 | |
| - fnd = nil | |
| - r = 0 | |
| - | |
| - sig = info1 | |
| - | |
| - while (idx2 < info2.length) | |
| - c = 0 | |
| - 0.upto(sig.length-1) do |si| | |
| - break if not info2[idx2+si] | |
| - break if not ( | |
| - sig[si][0] == info2[idx2+si][0] and | |
| - info2[idx2 + si][1] > sig[si][1]-fuzz and | |
| - info2[idx2 + si][1] < sig[si][1]+fuzz | |
| - ) | |
| - c += 1 | |
| - end | |
| - | |
| - if (c > r) | |
| - r = c | |
| - fnd = sig[0, r] | |
| - end | |
| - idx2 += 1 | |
| - end | |
| - | |
| - if(fnd and r == sig.length) | |
| - puts "MATCHED: #{name} #{r}" | |
| - end | |
| -end | |
| diff --git a/bin/search_tones.rb b/bin/search_tones.rb | |
| @@ -1,52 +0,0 @@ | |
| -#!/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 "kissfft" | |
| - | |
| -# | |
| -# Script | |
| -# | |
| - | |
| -def usage | |
| - $stderr.puts "#{$0} [audio.raw] <min-power>" | |
| - exit | |
| -end | |
| - | |
| -raw = WarVOX::Audio::Raw.from_file(ARGV.shift || usage) | |
| -min = (ARGV.shift || 1).to_f | |
| -res = KissFFT.fftr(8192, 8000, 1, raw.samples) | |
| - | |
| -tones = {} | |
| -res.each do |x| | |
| - rank = x.sort{|a,b| a[1].to_i <=> b[1].to_i }.reverse | |
| - rank[0..10].each do |t| | |
| - f = t[0].round | |
| - p = t[1].round | |
| - next if f == 0 | |
| - next if p < min | |
| - tones[ f ] ||= [] | |
| - tones[ f ] << t | |
| - end | |
| -end | |
| - | |
| - | |
| -tones.keys.sort.each do |t| | |
| - next if tones[t].length < 2 | |
| - puts "#{t}hz" | |
| - tones[t].each do |x| | |
| - puts "\t#{x[0]}hz @ #{x[1]}" | |
| - end | |
| -end | |
| - | |
| - | |
| - | |
| - | |
| diff --git a/bin/warvox.agi b/bin/warvox.agi | |
| @@ -1,25 +0,0 @@ | |
| -#!/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,Answer() | |
| -# exten => _777.,2,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 | |
| diff --git a/lib/warvox.rb b/lib/warvox.rb | |
| @@ -7,7 +7,6 @@ require 'warvox/config' | |
| require 'warvox/jobs' | |
| require 'warvox/phone' | |
| require 'warvox/audio' | |
| -require 'warvox/db' | |
| # Global configuration | |
| module WarVOX |