Module: Msf::Auxiliary::IAX2

Defined in:
lib/msf/core/auxiliary/iax2.rb

Overview

This module provides methods for working with the IAX2 protocol

Instance Method Summary collapse

Instance Method Details

#cleanupObject



66
67
68
69
# File 'lib/msf/core/auxiliary/iax2.rb', line 66

def cleanup
  super
  @iax.shutdown if @iax
end

#connectObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/msf/core/auxiliary/iax2.rb', line 36

def connect
  @iax.shutdown if @iax
  @iax = Rex::Proto::IAX2::Client.new(
    :server_host    => datastore['IAX_HOST'],
    :username       => datastore['IAX_USER'],
    :password       => datastore['IAX_PASS'],
    :caller_name    => datastore['IAX_CID_NAME'],
    :caller_number  => datastore['IAX_CID_NUMBER'],
    :debugging      => datastore['IAX_DEBUG'],
    :context        => {
      'Msf'        => framework,
      'MsfExploit' => self
    }
  )
  @iax_reg = @iax.create_call()
  r = @iax_reg.register
  if not r
    @iax.shutdown
    @iax = nil
    raise RuntimeError, "Failed to register with the server"
  end
end

#crack_phone_range(range) ⇒ Object

General purpose phone number mangling routines Convert 123456XXXX to an array of expanded numbers



73
74
75
# File 'lib/msf/core/auxiliary/iax2.rb', line 73

def crack_phone_range(range)
  crack_phone_ranges([range])
end

#crack_phone_ranges(masks) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/msf/core/auxiliary/iax2.rb', line 77

def crack_phone_ranges(masks)
  res = {}
  masks.each do |mask|
    mask = mask.strip

    if(mask.index(':'))
      next if mask.index('X')
      rbeg,rend = mask.split(':').map{|c| c.gsub(/[^\d]/, '').to_i }
      rbeg.upto(rend) do |n|
        res[n.to_s] = {}
      end
      next
    end

    incdigits = 0
    mask.each_char do |c|
      incdigits += 1 if c =~ /^[X#]$/i
    end

    max = (10**incdigits)-1

    (0..max).each do |num|
      number = mask.dup # copy the mask
      numstr = sprintf("%0#{incdigits}d", num) # stringify our incrementing number
      j = 0 # index for numstr
      for i in 0..number.length-1 do # step through the number (mask)
        if number[i].chr =~ /^[X#]$/i
          number[i] = numstr[j] # replaced masked indexes with digits from incrementing number
          j += 1
        end
      end
      res[number] = {}
    end

  end

  return res.keys.sort
end

#create_callObject



59
60
61
62
63
64
# File 'lib/msf/core/auxiliary/iax2.rb', line 59

def create_call
  if not @iax
    raise RuntimeError, "No active IAX2 connection"
  end
  @iax.create_call
end

#initialize(info = {}) ⇒ Object

Initializes an instance of an auxiliary module that uses IAX2



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/msf/core/auxiliary/iax2.rb', line 16

def initialize(info = {})
  super

  register_options(
    [
      OptAddress.new('IAX_HOST', [true, 'The IAX2 server to communicate with']),
      OptPort.new('IAX_PORT',    [true, 'The IAX2 server port', 4569]),
      OptString.new('IAX_USER',  [false, 'An optional IAX2 username']),
      OptString.new('IAX_PASS',  [false, 'An optional IAX2 password']),
      OptString.new('IAX_CID_NAME',  [false, 'The default caller ID name', '']),
      OptString.new('IAX_CID_NUMBER',  [true, 'The default caller ID number', '15555555555'])
    ], Msf::Auxiliary::IAX2 )

  register_advanced_options(
    [
      OptBool.new('IAX_DEBUG', [false, 'Enable IAX2 debugging messages', false])
    ], Msf::Auxiliary::IAX2 )

end