black electronics

5060 - SIP

Pentesting SIP

Pentesting SIP

Session Initiation Protocol (SIP) is a signalling protocol commonly used for Voice over IP (VoIP) communications, responsible for establishing, modifying and terminating communication sessions. SIP services are often exposed by PBXs, VoIP gateways, call management systems or individual phones, and can be abused to enumerate extensions, test authentication and disclose internal network information.

Overview

Session Initiation Protocol (SIP) is a signalling protocol commonly used for Voice over IP (VoIP) communications. SIP is responsible for establishing, modifying and terminating communication sessions, while the actual voice traffic is normally carried separately using protocols such as RTP.

During an infrastructure penetration test we may discover SIP services exposed by PBXs, VoIP gateways, call management systems or individual phones.

SIP commonly uses:

5060 SIP over UDP/TCP
5061 SIP over TLS

Port 5060 shouldn’t be treated as the only place SIP can exist. VoIP systems can be configured to listen on different ports, and we may encounter multiple SIP services within the same environment.

Once a SIP service has been identified, we want to determine what it is, which SIP methods it supports, whether users or extensions can be enumerated, how authentication is configured and what information the service exposes.

Identifying SIP

The first step is normally confirming that the discovered service is actually SIP.

Nmap service detection can provide a quick starting point. You can find a comprehensive Nmap cheat sheet here.

Terminal window
nmap -sU -sV -p 5060 <target>

Because SIP can use both UDP and TCP, it is worth checking both transports where appropriate:

Terminal window
nmap -sU -sS -p 5060,5061 <target>

A SIP response may expose useful information in headers such as:

Server
User-Agent
Allow
Contact
Via
From
To
Call-ID

Depending on the implementation, these may reveal the PBX or SIP software in use, internal hostnames, IP addresses or supported functionality.

That information can then be used to guide the rest of the assessment.

SIP Methods

SIP works using request methods in a similar way to how HTTP has methods such as GET and POST.

Common SIP methods include:

OPTIONS
REGISTER
INVITE
ACK
BYE
CANCEL
SUBSCRIBE
NOTIFY
MESSAGE
INFO

We don’t necessarily expect every SIP server to support every method.

For example, REGISTER is used by SIP clients to register their current location with a registrar, while INVITE is used to initiate a session.

OPTIONS is particularly useful during reconnaissance because it can be used to query the capabilities of a SIP endpoint without attempting to establish a call.

SIPVicious

SIPVicious is a collection of tools designed for auditing SIP-based VoIP systems and can be found here https://github.com/enablesecurity/sipvicious.

The suite contains several useful utilities:

Terminal window
sipvicious_svmap --help
sipvicious_svcrack --help
sipvicious_svcrash --help
sipvicious_svwar --help
sipvicious_svreport --help

These tools perform different parts of the SIP assessment rather than being a single general-purpose scanner.

A rough breakdown is:

svmap Discover SIP devices
svwar Enumerate SIP extensions
svcrack Audit SIP authentication
svreport Manage/report SIPVicious results
svcrash Respond to certain scans from older SIPVicious clients

For normal penetration testing, svmap, svwar and svcrack are generally the ones we’re most interested in.

Discovering SIP Devices with svmap

svmap can be used to identify SIP services within an address range.

For example:

Terminal window
sipvicious_svmap -p5060-5062 <target> -m OPTIONS

Here we are scanning ports 5060 through 5062 and sending an OPTIONS request to identify responsive SIP services.

A network range can also be assessed:

Terminal window
sipvicious_svmap 192.168.1.0/24

If we already know the target SIP port:

Terminal window
sipvicious_svmap -p5060 192.168.1.0/24

The objective isn’t simply to find port 5060 open. We want to identify which systems actually respond as SIP devices and what information those responses provide.

In a VoIP network we may identify:

PBX
SIP Proxy
SIP Registrar
VoIP Gateway
IP Phones
Softphones

Each can expose a different attack surface.

Nmap SIP Enumeration

Nmap also includes SIP-specific NSE scripts.

One useful starting point is identifying the methods supported by the server:

Terminal window
nmap -sU -p 5060 --script sip-methods <target>

The returned methods can provide a better idea of the functionality exposed by the SIP service.

This is useful alongside SIPVicious because it gives us another way of confirming and interrogating the service rather than relying on a single tool.

Extension Enumeration

Once a SIP server has been identified, one of the more interesting questions is whether valid SIP users or extensions can be enumerated.

A VoIP environment may contain extensions such as:

100
101
102
2001
2002
2003

These extensions effectively identify SIP accounts and can provide targets for further authorised authentication testing.

SIPVicious svwar can be used for extension enumeration.

Start by reviewing the available options:

Terminal window
sipvicious_svwar --help

The exact enumeration method and range should be selected according to the target system and engagement scope.

Nmap also provides sip-enum-users:

Terminal window
nmap -sU -p 5060 --script sip-enum-users <target>

By default the script tests extensions from 0 through 999.

We can specify a more appropriate range:

Terminal window
nmap -sU -p 5060 \
--script sip-enum-users \
--script-args 'sip-enum-users.minext=1000,sip-enum-users.maxext=9999' \
<target>

This can be particularly useful when the organisation follows a predictable extension numbering scheme.

Understanding SIP Responses

SIP response codes can reveal whether an extension exists.

Responses may include:

200 Request succeeded
401 Authentication required
403 Request understood but forbidden
404 User/resource not found
407 Proxy authentication required

The important part is not simply memorising these status codes.

We’re looking for differences in behaviour between valid and invalid extensions.

For example, if:

Extension 1234 → 401 Unauthorized
Extension 8372 → 404 Not Found

the server may be giving us enough information to distinguish valid extensions from invalid ones.

That becomes an account enumeration issue.

Nmap’s sip-enum-users performs this type of comparison automatically and even begins by testing a random extension to help identify false positives.

Authentication Testing

Once valid SIP extensions have been identified, the next question is how those accounts authenticate.

SIP commonly uses digest authentication rather than transmitting the password directly.

SIPVicious includes svcrack for authorised password auditing:

Terminal window
sipvicious_svcrack --help

Authentication testing should be performed carefully.

VoIP systems may have account lockout controls, rate limiting or monitoring in place, and a large authentication attack can generate considerable noise.

Rather than immediately throwing a huge password list at every extension, first determine:

  • Which extensions are valid?
  • Is authentication actually required?
  • Are lockouts configured?
  • Is rate limiting present?
  • Are default or predictable credentials likely?
  • Does the engagement permit password guessing?

If password auditing is appropriate, use a controlled password list and rate.

Nmap SIP Authentication Testing

Nmap also includes a sip-brute NSE script for SIP password auditing.

Before using it, remember that this is an intrusive test and should only be performed when password auditing is within scope.

Enumeration and authentication testing are separate stages.

Knowing that extension 1234 exists does not automatically justify attempting thousands of passwords against it.

SIP over TLS

SIP may also be protected using TLS, commonly on TCP/5061.

If port 5061 is exposed, inspect the TLS service as well:

Terminal window
nmap -sV -p 5061 <target>

The certificate itself may provide additional reconnaissance information such as:

Hostnames
Internal domain names
Organisation names
Certificate authority
Additional Subject Alternative Names

TLS protects SIP signalling while it is in transit, but it doesn’t automatically mean the overall VoIP implementation is secure.

Authentication, extension enumeration and access-control issues may still exist above the transport layer.

Information Disclosure

SIP responses can sometimes disclose much more information than expected.

While reviewing responses, look for:

Internal IP addresses
Internal hostnames
SIP domains
Software names
Software versions
Extension numbers
Usernames
PBX identifiers
Network topology information

For example, Via, Contact and routing-related headers may expose addressing information that wasn’t previously known.

This becomes particularly useful during an external assessment where a publicly exposed SIP gateway may unintentionally reveal information about the internal VoIP environment.

UDP and TCP

Don’t assume that testing UDP/5060 is enough.

SIP supports both UDP and TCP, and a target may behave differently depending on the transport being used.

If SIP has been identified, check:

Terminal window
nmap -sU -p 5060 <target>

as well as:

Terminal window
nmap -sT -p 5060 <target>

TLS SIP can then be investigated separately on TCP/5061.

This is especially important where an initial port scan only performed TCP scanning, as UDP SIP services can otherwise be missed completely.

SIP Exploitation with Metasploit

Once the SIP service and underlying product have been identified, it is worth checking whether the platform has any known vulnerabilities or relevant Metasploit modules.

Metasploit contains a number of SIP and VoIP-related auxiliary modules. Start by searching the installed framework:

msfconsole
search sip

You can narrow the search down further:

search type:auxiliary sip
search type:exploit sip
search cisco sip
search asterisk
search freepbx

Don’t search only for sip. Once we have fingerprinted the actual PBX, phone or gateway, searching for the vendor and product name will often produce more useful results.

SIP Extension Enumeration

Metasploit can also be used to enumerate SIP extensions:

use auxiliary/scanner/sip/enumerator
show options
set RHOSTS <target>
set RPORT 5060
run

This can provide another way of identifying valid extensions where the SIP server responds differently for existing and nonexistent users.

SIP OPTIONS Enumeration

The SIP OPTIONS method can be useful for identifying how a server responds and what functionality it advertises.

Metasploit modules vary between versions, so search the installed framework:

search sip

Then inspect anything relevant with:

info <module>
use <module>
show options

This is preferable to blindly copying module names from old write-ups because SIP modules can be added, renamed or removed between Metasploit versions.

Product-Specific Exploitation

SIP itself isn’t usually the thing we are trying to exploit. Once we have identified the underlying product, we should start looking at the PBX, SIP server, gateway or phone implementation.

For example, we may discover:

Asterisk
FreePBX
Cisco Unified Communications
3CX
Avaya
Grandstream
Yealink
Mitel
Kamailio
OpenSIPS

At this point, search Metasploit for the identified technology:

search asterisk
search freepbx
search cisco
search 3cx
search avaya

We should also take any disclosed version information and check it against known vulnerabilities.

For example:

SIP/2.0 200 OK
Server: Asterisk PBX 13.x

This gives us something much more useful to investigate than simply knowing UDP/5060 is open.

Testing Default Credentials

VoIP infrastructure is also worth checking for default credentials, particularly where we have discovered a web management interface alongside SIP.

For example, if scanning reveals:

80/tcp HTTP
443/tcp HTTPS
5060/udp SIP

don’t treat these as unrelated services.

The HTTP interface may be the administrative interface for the same PBX, gateway or IP phone identified through SIP.

Check the exact product documentation for default credentials and test them where credential testing is within scope.

SIP INVITE Testing

INVITE requests can also reveal whether unauthenticated users are able to initiate calls or interact with extensions.

What Should We Look For?

Once SIP has been identified, some of the questions worth answering are:

  • What SIP software or device is exposed?
  • Which SIP methods are available?
  • Can valid extensions be enumerated?
  • Does the service respond differently for valid and invalid users?
  • Is authentication required?
  • Are default or weak credentials in use?
  • Is password guessing rate limited?
  • Are account lockouts configured?
  • Is SIP exposed externally when it should only be internally accessible?
  • Is signalling transmitted without TLS?
  • Do SIP responses expose internal IP addresses or hostnames?
  • Are software versions disclosed?
  • Are unnecessary SIP methods available?
  • Can unauthenticated users interact with functionality that should require authentication?

As with most services, simply finding SIP exposed isn’t automatically a vulnerability.

A properly configured SIP gateway obviously needs to speak SIP.

What matters is what the service allows an unauthenticated or low-privileged user to discover or perform.

SIP testing tends to become much easier once we stop thinking of TCP/UDP 5060 as simply another open port.

The useful information is in how the SIP server responds.

A few carefully selected OPTIONS and REGISTER requests can tell us far more about the environment than simply reporting that a SIP service is listening.

Useful LinksPentest PayloadsCheat Sheets