Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/lib/msf/core/auxiliary/iax2.rb
Views: 11784
# -*- coding: binary -*-12module Msf34###5#6# This module provides methods for working with the IAX2 protocol7#8###9module Auxiliary::IAX21011#12# Initializes an instance of an auxiliary module that uses IAX213#1415def initialize(info = {})16super1718register_options(19[20OptAddress.new('IAX_HOST', [true, 'The IAX2 server to communicate with']),21OptPort.new('IAX_PORT', [true, 'The IAX2 server port', 4569]),22OptString.new('IAX_USER', [false, 'An optional IAX2 username']),23OptString.new('IAX_PASS', [false, 'An optional IAX2 password']),24OptString.new('IAX_CID_NAME', [false, 'The default caller ID name', '']),25OptString.new('IAX_CID_NUMBER', [true, 'The default caller ID number', '15555555555'])26], Msf::Auxiliary::IAX2 )2728register_advanced_options(29[30OptBool.new('IAX_DEBUG', [false, 'Enable IAX2 debugging messages', false])31], Msf::Auxiliary::IAX2 )3233end3435def connect36@iax.shutdown if @iax37@iax = Rex::Proto::IAX2::Client.new(38:server_host => datastore['IAX_HOST'],39:username => datastore['IAX_USER'],40:password => datastore['IAX_PASS'],41:caller_name => datastore['IAX_CID_NAME'],42:caller_number => datastore['IAX_CID_NUMBER'],43:debugging => datastore['IAX_DEBUG'],44:context => {45'Msf' => framework,46'MsfExploit' => self47}48)49@iax_reg = @iax.create_call()50r = @iax_reg.register51if not r52@iax.shutdown53@iax = nil54raise RuntimeError, "Failed to register with the server"55end56end5758def create_call59if not @iax60raise RuntimeError, "No active IAX2 connection"61end62@iax.create_call63end6465def cleanup66super67@iax.shutdown if @iax68end6970# General purpose phone number mangling routines71# Convert 123456XXXX to an array of expanded numbers72def crack_phone_range(range)73crack_phone_ranges([range])74end7576def crack_phone_ranges(masks)77res = {}78masks.each do |mask|79mask = mask.strip8081if(mask.index(':'))82next if mask.index('X')83rbeg,rend = mask.split(':').map{|c| c.gsub(/[^\d]/, '').to_i }84rbeg.upto(rend) do |n|85res[n.to_s] = {}86end87next88end8990incdigits = 091mask.each_char do |c|92incdigits += 1 if c =~ /^[X#]$/i93end9495max = (10**incdigits)-19697(0..max).each do |num|98number = mask.dup # copy the mask99numstr = sprintf("%0#{incdigits}d", num) # stringify our incrementing number100j = 0 # index for numstr101for i in 0..number.length-1 do # step through the number (mask)102if number[i].chr =~ /^[X#]$/i103number[i] = numstr[j] # replaced masked indexes with digits from incrementing number104j += 1105end106end107res[number] = {}108end109110end111112return res.keys.sort113end114115end116end117118119120