Add matching - warvox - VoIP based wardialing tool, forked from rapid7/warvox.
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
       ---
 (DIR) commit efec78a965e0462c2d4463a976a53b9f36c5ccb5
 (DIR) parent 1c72c5640233622b887af0192605704f9f4d7b61
 (HTM) Author: HD Moore <hd_moore@rapid7.com>
       Date:   Thu,  4 Aug 2011 19:37:10 +0000
       
       Add matching
       
       
       Diffstat:
         M web/app/controllers/analyze_contro… |       7 +++++++
         M web/app/helpers/analyze_helper.rb   |      20 ++++++++++++++++++++
         M web/app/models/dial_result.rb       |       6 ++++--
         M web/app/views/analyze/view.html.erb |       5 ++++-
         A web/app/views/analyze/view_matches… |     108 +++++++++++++++++++++++++++++++
       
       5 files changed, 143 insertions(+), 3 deletions(-)
       ---
 (DIR) diff --git a/web/app/controllers/analyze_controller.rb b/web/app/controllers/analyze_controller.rb
       @@ -137,5 +137,12 @@ class AnalyzeController < ApplicationController
        
            send_data(cdata, :type => ctype, :disposition => 'inline')
          end
       +  
       +  
       +  def view_matches
       +          @result = DialResult.find(params[:dial_result_id])
       +          @job_id = @result.dial_job_id
       +        @results = @result.matches.select{|x| x.matchscore.to_f > 10.0 }
       +  end  
        end
        
 (DIR) diff --git a/web/app/helpers/analyze_helper.rb b/web/app/helpers/analyze_helper.rb
       @@ -1,2 +1,22 @@
        module AnalyzeHelper
       +
       +
       +def fwd_match_html(pct)
       +        %Q|<span class="fwd_match_span" style='padding-right: 150px; border: 1px solid black; padding-left: 10px; padding-top: 3px; padding-bottom: 3px; background-color: #{pct_to_color(pct)}; color:white; font-weight: bold;'>
       +        
       +        #{"%.3f" % pct.to_f}% Match
       +        
       +        </span>
       +        
       +        |
       +end
       +
       +def rev_match_html(pct)
       +        %Q|<span class="rev_match_span" style='padding-left: #{ (pct.to_i * 2).to_i }px; background-color: #{pct_to_color(pct)};'>#{pct}%</span>|
       +end
       +
       +def pct_to_color(pct)
       +        "#" + "80" + (pct.to_i * 2.55).to_i.to_s(16).rjust(2, "0") + "80"
       +end
       +
        end
 (DIR) diff --git a/web/app/models/dial_result.rb b/web/app/models/dial_result.rb
       @@ -8,14 +8,16 @@ class DialResult < ActiveRecord::Base
                        '        (( icount(\'#{fprint}\'::int[] & dial_results.fprint::int[]) / icount(\'#{fprint}\'::int[])::float ) * 100.0 ) AS matchscore ' +
                        'FROM dial_results ' +
                        'WHERE icount(dial_results.fprint) > 0 AND ' + 
       -                'dial_results.dial_job_id = \'#{dial_job_id}\' ' +
       +                'dial_results.dial_job_id = \'#{dial_job_id}\' AND ' +
       +                'dial_results.id != \'#{id}\' ' +
                        'ORDER BY matchscore DESC'
        
                has_many :matches_all_jobs, :class_name => 'DialResult', :finder_sql =>
                        'SELECT dial_results.*,  ' +
                        '        (( icount(\'#{fprint}\'::int[] & dial_results.fprint::int[]) / icount(\'#{fprint}\'::int[])::float ) * 100.0 ) AS matchscore ' +
                        'FROM dial_results ' +
       -                'WHERE icount(dial_results.fprint) > 0 ' +
       +                'WHERE icount(dial_results.fprint) > 0 AND ' +
       +                'dial_results.id != \'#{id}\' ' +                
                        'ORDER BY matchscore DESC'
                                
        end
 (DIR) diff --git a/web/app/views/analyze/view.html.erb b/web/app/views/analyze/view.html.erb
       @@ -53,7 +53,10 @@
                                col = ("%.2x" % (255 - str)) * 3
                        %>
                                <div style="color: #<%= col%>;"><%=h name%> (<%=h sid %>@<%=h mat %>)</div>
       -                <% end %>                        
       +                <% end %>                
       +                <% if dial_result.fprint %>
       +                        <a href="<%=view_matches_path(dial_result.id)%>">View Matches</a>
       +                <% end %>        
                </td>
          </tr>
        <% end %>
 (DIR) diff --git a/web/app/views/analyze/view_matches.html.erb b/web/app/views/analyze/view_matches.html.erb
       @@ -0,0 +1,108 @@
       +<%  dial_result = @result %>
       +
       +<h1 class='title'><%= @result.number %> (<a href="<%=view_analyze_path(dial_result.dial_job_id)%>">Back to Job</a>)</h1>
       +<table class='table_scaffold' width='100%'>
       +  <tr>
       +    <th>Number</th>
       +          <th>Signal</th>
       +  </tr>
       +
       +
       +  <tr>
       +    <td align='center'>
       +        
       +                <object
       +                        type="application/x-shockwave-flash"
       +                        data="/images/musicplayer.swf?song_url=<%=resource_analyze_path(@job_id, dial_result.id, "mp3")%>" 
       +                        width="20"
       +                        height="17"
       +                        style="margin-bottom: -5px;"
       +                        >
       +                        <param name="movie" value="/musicplayer.swf?song_url=<%=resource_analyze_path(@job_id, dial_result.id, "mp3")%>"></param>
       +                        <param name="wmode" value="transparent"></param>
       +                </object>
       +                
       +                <b><%= dial_result.number %></b>
       +                <hr width='100%' size='1'/>
       +                CallerID: <%= dial_result.cid%><br/>
       +                Provider: <%=h dial_result.provider.name %><br/>
       +                Audio: <%=h dial_result.seconds %> Seconds<br/>
       +                Ringer: <%=h dial_result.ringtime %> Seconds<br/>
       +                <% if(dial_result.dtmf and dial_result.dtmf.length > 0) %>
       +                        DTMF: <%=h dial_result.dtmf %><br/>
       +                <% end %>
       +                <% if(dial_result.mf and dial_result.mf.length > 0) %>
       +                        MF: <%=h dial_result.mf %><br/>
       +                <% end %>                                        
       +        </td>
       +          <td align='center'>
       +                <b><%=h dial_result.line_type.upcase %></b><br/>
       +                <a href="<%=resource_analyze_path(@job_id, dial_result.id, "big_sig_dots")%>" rel="lightbox"><img src="<%=resource_analyze_path(@job_id, dial_result.id, "small_sig")%>" /></a>
       +                <a href="<%=resource_analyze_path(@job_id, dial_result.id, "big_freq")%>" rel="lightbox"><img src="<%=resource_analyze_path(@job_id, dial_result.id, "small_freq")%>" /></a><br/>
       +                <% (dial_result.signatures||"").split("\n").each do |s| 
       +                        sid,mat,name = s.split(':', 3)
       +                        str = [mat.to_i * 6.4, 255].min
       +                        col = ("%.2x" % (255 - str)) * 3
       +                %>
       +                        <div style="color: #<%= col%>;"><%=h name%> (<%=h sid %>@<%=h mat %>)</div>
       +                <% end %>                                
       +        </td>
       +  </tr>
       +</table><br/><br/>
       +
       +<h1 class='title'>Matches for <%= @result.number %></h1>
       +
       +<table class='table_scaffold' width='100%'>
       +  <tr>
       +    <th>Number</th>
       +          <th>Signal</th>
       +  </tr>
       +
       +<%  @results.each do |dial_result| %>
       +  <tr>
       +    <td align='center'>
       +        
       +                <br/><%= raw(fwd_match_html(dial_result.matchscore)) %><br/><br/>
       +                
       +                <object
       +                        type="application/x-shockwave-flash"
       +                        data="/images/musicplayer.swf?song_url=<%=resource_analyze_path(@job_id, dial_result.id, "mp3")%>" 
       +                        width="20"
       +                        height="17"
       +                        style="margin-bottom: -5px;"
       +                        >
       +                        <param name="movie" value="/musicplayer.swf?song_url=<%=resource_analyze_path(@job_id, dial_result.id, "mp3")%>"></param>
       +                        <param name="wmode" value="transparent"></param>
       +                </object>
       +                
       +                <b><%= dial_result.number %></b>
       +                <hr width='100%' size='1'/>
       +                CallerID: <%= dial_result.cid%><br/>
       +                Provider: <%=h dial_result.provider.name %><br/>
       +                Audio: <%=h dial_result.seconds %> Seconds<br/>
       +                Ringer: <%=h dial_result.ringtime %> Seconds<br/>
       +                <% if(dial_result.dtmf and dial_result.dtmf.length > 0) %>
       +                        DTMF: <%=h dial_result.dtmf %><br/>
       +                <% end %>
       +                <% if(dial_result.mf and dial_result.mf.length > 0) %>
       +                        MF: <%=h dial_result.mf %><br/>
       +                <% end %>                                        
       +        </td>
       +          <td align='center'>
       +                <b><%=h dial_result.line_type.upcase %></b><br/>
       +                <a href="<%=resource_analyze_path(@job_id, dial_result.id, "big_sig_dots")%>" rel="lightbox"><img src="<%=resource_analyze_path(@job_id, dial_result.id, "small_sig")%>" /></a>
       +                <a href="<%=resource_analyze_path(@job_id, dial_result.id, "big_freq")%>" rel="lightbox"><img src="<%=resource_analyze_path(@job_id, dial_result.id, "small_freq")%>" /></a><br/>
       +                <% (dial_result.signatures||"").split("\n").each do |s| 
       +                        sid,mat,name = s.split(':', 3)
       +                        str = [mat.to_i * 6.4, 255].min
       +                        col = ("%.2x" % (255 - str)) * 3
       +                %>
       +                        <div style="color: #<%= col%>;"><%=h name%> (<%=h sid %>@<%=h mat %>)</div>
       +                <% end %>                        
       +                <% if dial_result.fprint %>
       +                        <a href="<%=view_matches_path(dial_result.id)%>">View Matches</a>
       +                <% end %>                
       +        </td>
       +  </tr>
       +<% end %>
       +</table>