Asterisk Hacking And Securing Computer Science Essay

Published: Last Edited:

This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.

Asterisk is an open-source PBX that has VoIP capabilities. However, this hardly explains what Asterisk is or what it does. So let's delve a little more deeply into PBXes, VoIP, and Asterisk. [3]

2 What Is a PBX?

Asterisk, first and foremost, is a Private Branch Exchange (PBX). A private branch exchange (PBX) is a telephone exchange that serves a particular business or office, as opposed to one that a common carrier or telephone company operates for many businesses or for the general public. [2]

3. What Is VoIP?

Voice over Internet Protocol is one of the new buzzwords of the media today. VoIP is a method to carry a two-way conversation over an Internet Protocol-based network. The major benefit of VoIP is the mobility. Phone calls can be sent and received wherever a data connection is available, whether it is a residential broadband connection, the office network, or a WiFi connection at a local drinking establishment. [3]

4. The History of Asterisk

Mark Spencer, the creator of Asterisk, has created numerous popular open-source tools including GAIM, l2tpd, the L2TP tunneling protocol daemon etc. Asterisk's first major milestone was reached on September 23, 2004, when Mark Spencer released Asterisk 1.0 at the first Astricon, the official Asterisk user and developer's conference. Asterisk 1.0 was the first stable, open-source,VoIP-capable PBX on the market. [3]

The latest release of Asterisk, Asterisk, was released September 03, 2009. [4]

5. What is SIPVicious?

SIPVicious suite is a set of tools that can be used to audit SIP based VoIP systems. [5]

Detail of SIPVicious

It currently consists of four tools:

svmap - this is a sip scanner. Lists SIP devices found on an IP range

svwar - identifies active extensions on a PBX

svcrack - an online password cracker for SIP PBX

svreport - manages sessions and exports reports to various formats


It is a network scanner for SIP. Similar to nmap - it will scan for devices on ports specified by passing the right command line options. Once svmap finds a device that supports SIP, it will extract information from the response and identify the type of device. Anyone running this tool will typically end up with a list of IP addresses of SIP devices and the names for those devices.

A penetration tester or security auditor will probably find this tool particularly useful especially during reconnaissance. With the IP address, device name and possibly version at hand, he or she can then target security weaknesses specific to that device. A security administrator or security analyst can also make use of svmap to list different active SIP user-agents on the network. Based on this information, the security administrator then has the ability to identify rogue and vulnerable devices which can cause a security concern.

Svmap works by sending a UDP packet containing a SIP request to a range of specified IP addresses, and listing those that send back a valid SIP response. Since UDP is a connectionless protocol, this method can be relatively fast. [5]


It is a free SIP PBX extension line scanner. In concept it works similar to traditional wardialers by guessing a range of extensions or a given list of extensions. [7]

Svwar can:

identify extensions on PBXs and through SIP proxies

Scan for large ranges of numeric extensions

Scan for extensions using a file containing a list of possible extension names

Use different SIP request methods for scanning since not all PBX servers behave the same

resume previous scans


The purpose of svcrack is very straightforward. This tool will launch a password guessing attack extensions on the SIP registrar. [5]

feature: scan multiple users

feature: intelligent scan - sequentially perform the following attacks:

username and modifications of that as password

numeric bruteforce

dictionary attack

alphanumeric bruteforce [9]

6. How to protect the Asterisk server?

Configuration Detail:

Server side configuration

Installing Asterisk:

Linux Package Requirements:

To compile Asterisk, we must needed the GCC compiler (version 3.x or later) and its dependencies on our system. Asterisk also requires bison, a parser generator program that replaces yacc, and ncurses for CLI functionality. The cryptographic library in Asterisk requires OpenSSL and its development packages. Here is a list of all necessary packages [1]:

1. gcc

5. OpenSSL (optional)

2. ncurses-devel

6. newt-devel (optional)

3. libtermcap-devel

7. zlib-devel (optional)

4. GCC C++

Obtaining the Source Code

To obtain the latest release source code via wget, enter the following commands on the Command line:

# cd /usr/src/

# wget

# wget

Extracting the Source Code

The packages we downloaded from the FTP server are compressed archives containing the source code; thus, we needed to extract them before compiling. We used the following commands:

# cd /usr/src/

# tar zxvf libpri-1.4-current.tar.gz

# tar zxvf asterisk-

Compiling libpri

libpri should be compiled and installed before Asterisk, as it will be detected and used when Asterisk is compiled. Here are the commands:

# cd /usr/src/libpri-1.4

# make clean

# make

# make install

Compiling Asterisk

Asterisk is compiled with gcc through the use of the GNU make program. To get started compiling Asterisk, simply run the following commands:

# cd /usr/src/asterisk-

# make clean

# ./configure

# make menuselect

# make install

# make samples

# make config

Loading Asterisk Quickly

If we run 'make config' in the Asterisk source directories, then the initialization script used to control Asterisk will be copied to /etc/rc.d/init.d/. The script can be used to easily load and unload Asterisk. It will also run the 'chkconfig' command, so Asterisk will be started automatically upon system boot. The following shows their usage:

# service asterisk start

Initial Configuration of Asterisk

Defining the SIP device in Asterisk:

Edit the file sip.conf to create some SIP users.

Figure 1: shows command to open the sip.conf file to configure

Figure 2: shows the SIP extensions we have created- 1001, 1002 and 1003.

Create Simple Dial plan:

To make a simple dial plan just edit the file extensions.conf.

Figure 3: shows command to open the estensions.conf file to configure

Figure 4: shows the dialplan we used to make call among the SIP users.

Now restart the asterisk service:

#Service asterisk restart

Client side configuration

Install Python

Choose a Python Installlation

Visit the official website of the Python Programming Language ( , ). All official distributions of Python can be found here, including a windows .msi installer for Python.

Click on the "Download" link. This will bring you to a list of files. Each of these files is a distribution of Python for a different platform.

Find the installer for your platform. There are numerous versions of Python available for Windows environments. Should you not be able to determine the specifications of your machine, you should download the standard binary installer.

Choose the "Python Windows Installer" link for a standard environment, the "Python AMD64 Installer" for computers running 64-bit Windows or the "Python Windows Itanium Installer" for Intel Itanium computers.

Click the link. You can either download the file and run the file, or run it automatically. It's preferable to download the file so you have it for future use.

Run the Installer

Step 1

Run the installer from the download dialog. Find the msi file with Windows explorer and run it. An installer program will pop up. Click "Install For All Users" and click "Next."

Step 2

Choose into which directory the Python should install. Keeping the default "C:\Python25" is recommended since there will be times when it will be useful to type the full path to the python interpreter from the command-line. In that case a short directory name on the C:\ drive is easier.

Step 3

Choose the features we want to install and then click "Next" to start the installation. Wait a few minutes for the installation process to be completed. After it's done, click "Finish" and to close the installer.

Step 4

Go to "Programs -> Python 2.5 -> Python" from the Start menu to test Python out. This will bring up a black and white command-line window with an interactive Python command prompt. Once we see that Python has been installed correctly, close the command line window.

Step 5

Start a command prompt by going to "Start -> Run." When the dialog pops up, type "cmd" into the text field and hit OK. Running python a program from the command line is a useful way to see output and pass parameters.

Step 6

Change to your Python directory. If you accepted the default Python directory, type "cd C:\Python25" into the command prompt and hit enter. If you changed the directory, change "C:\Python25" to the directory in which you installed Python. Type "python" and hit enter to start the python command line prompt.

Install SIPVicious

Downloading SIPVicious on the Windows Machine

On the Attacker Machine, open a Web browser and go to

On the right side of the page, click "Download SIPVicious".

On the next page, click

Save the file on our desktop.

On our desktop, double-click the file and click "Extract All…". In the "Extract Compressed (Zipped) Folders" box, click Extract.

A sipvicious-0.2.4 folder appears on our desktop.

Configure SoftPhone (Zoiper)

We have found some softphones available on the internet, which are free to download; for example X-Lite, Zoiper. And for our task we have used Zoiper as our sip client. To configure just run Zoiper and then click on the settings tab:

Click on 'settings' tab

Figure 5: shows initial state (GUI) of the zoiper softphone.

Now add a new SIP account. Provide the information listed below:

Domain: IP address of the Asterisk server

Username: provide a previously created sip user extension number

Password: provide password for that user

Figure 6: shows configuring the zoiper.

Now click 'OK' to add the new SIP account.

Click here to register

Figure 7: shows how to register a sip user.

Now click on the 'Register' button to register the SIP account to the Asterisk server.

Figure 8: shows after the sip user register.

In the same way we registered the other SIP accounts.

How to make a call:

Write desired extension here

Press the 'call' button

Figure 9: shows how to make a call

To make a call just write the desired extension in the 'Phone to dial' box and press the 'Call' button.

Now to receive call presses the 'Accept' button.

Figure 10: shows receiver's end incoming call window.

And then the call will be established.

Press this button to hang up the call

Figure 11: shows current call statues.

This is the way how a SIP user can communicate with another one.

Attack Asterisk Server

Setting Up

1. Turn on the PBX server

2. Turn on the machine where installed Python. This machine will be the Attacker Machine.


SIPVicious works on any system that supports python 2.4 or greater [6].

Operating System

It was tested on the following systems:

1. Linux

3. Windows

2. Mac OS X

4. FreeBSD 6.2

Scanning for PBX Servers with svmap

1. On the Attacker Machine, go to the CLI prompt, go to the 'sipvicious-0.2.4' directory and run the following command:

Figure12: We see the Asterisk Server.

Enumerating SIP Extensions with svwar

Now in the Command Prompt window, type this command, and then press the Enter key: -e 1000-a005 -v

Figure13: We see here sip active extension.

Cracking SIP Passwords with svcrack

Now in the Command Prompt window, type this command, and then press the Enter key: -u 1003 -d dictionary.txt

Figure14: shows the password of a selective sip extensive.

From fig: we can see that the password has been revealed from the dictionary file.

Now as we have already got the available extensions on the Asterisk server and required passwords, so it is just a matter of time to make a free phone call!

To make a call to the PSTN numbers the Asterisk server is needed to be configured with an FXO card (e.g digium ax-400p) and to compile the dahdi driver for it. But in our experiment environment we don't have that hardware. So the free phone call is limited only within the registered SIP users.

Flow chart:

Scan network for Asterisk server

Scan the server for available extensions

Extension password protected?

Hack password

Log in from a SIP client



Securing Asterisk Server