Bienvenidos a un nuevo post de ByteMind. En este caso os traigo Sipvicious, una utilidad de auditoría para sistemas VoIP basados en el protocolo SIP.
¿Qué es Sipvicious?
Sipvicious es un conjunto de herramientas utilizadas para auditar sistemas de VoIP basados en SIP como puede ser Asterix. Estas herramientas están basadas en Python y funcionan en Python 2.6 y versiones superiores. Podemos ver más información en su blog oficial en el siguiente link.
Esta utilidad se compone de 5 herramientas muy útiles en este tipo de auditorias:
- svmap -> se trata de un escaner de dispositivos SIP. Permite escanear una única IP o una red completa.
- svwar -> escanea una centralita PBX buscando el numero de extensiones existentes y la protección de la cual disponen.
- svcrack -> se encarga de intentar obtener las contraseñas utilizadas en las diferentes extensiones descubiertas. Tiene la posibilidad también de realizar un ataque por diccionario.
- svreport -> se trata de una herramienta de reporte. Permite administrar las sesiones creadas por el resto de herramientas de la suite y exportar los resultados en diferentes formatos como son pdf, xml, csv y texto plano.
- svcrash -> responde a los mensajes SIP obtenidos con svwar y svcrack con un mensaje que provoca que se bloqee al atacante. Se trata de una herramienta muy útil para contrarestar los ataques realizados con esta utilidad.
Descarga de Sipvicious
Para la descarga de esta suite, deberemos de clonar el código en nuestra máquina desde su repositorio en github:
1 |
git clone https://github.com/EnableSecurity/sipvicious.git |
Realizamos la instalación con el script setup.py disponible:
1 2 |
cd sipvicious python3 setup.py install |
Una vez descargado e instalado accedemos al directorio recién creado y tendremos en dicha carpeta las diferentes herramientas:
1 2 3 4 5 6 7 8 9 10 11 12 |
# cd sipvicious/sipvicious root@kali:~/github/sipvicious/sipvicious# ls -l total 116 -rw-r--r-- 1 root root 0 dic 19 13:31 __init__.py -rw-r--r-- 1 root root 133 dic 19 13:33 __init__.pyc drwxr-xr-x 2 root root 4096 dic 19 13:33 libs -rwxr-xr-x 1 root root 25555 dic 19 13:31 svcrack.py -rwxr-xr-x 1 root root 7170 dic 19 13:31 svcrash.py -rwxr-xr-x 1 root root 24789 dic 19 13:31 svmap.py -rwxr-xr-x 1 root root 11204 dic 19 13:31 svreport.py -rwxr-xr-x 1 root root 30098 dic 19 13:31 svwar.py root@kali:~/github/sipvicious/sipvicious# |
¿Cómo utilizar Sipvicious?
Vamos a explicar un poquito como utilizar cada una de las herramientas disponibles.
Empezaremos por svmap y podemos ver la ayuda del mismo con la opción -h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# sipvicious_svmap -h Usage: svmap.py [options] host1 host2 hostrange Scans for SIP devices on a given network examples: svmap.py 10.0.0.1-10.0.0.255 172.16.131.1 sipvicious.org/22 10.0.1.1/241.1.1.1-20 1.1.2-20.* 4.1.*.* svmap.py -s session1 --randomize 10.0.0.1/8 svmap.py --resume session1 -v svmap.py -p5060-5062 10.0.0.3-20 -m INVITE Options: --version show program's version number and exit -h, --help show this help message and exit -v, --verbose Increase verbosity -q, --quiet Quiet mode -p PORT, --port=PORT Destination port or port ranges of the SIP device - eg -p5060,5061,8000-8100 -P PORT, --localport=PORT Source port for our packets -x IP, --externalip=IP IP Address to use as the external ip. Specify this if you have multiple interfaces or if you are behind NAT -b BINDINGIP, --bindingip=BINDINGIP By default we bind to all interfaces. This option overrides that and binds to the specified ip address -t SELECTTIME, --timeout=SELECTTIME This option allows you to trottle the speed at which packets are sent. Change this if you're losing packets. For example try 0.5. -R, --reportback Send the author an exception traceback. Currently sends the command line parameters and the traceback -A, --autogetip Automatically get the current IP address. This is useful when you are not getting any responses back due to SIPVicious not resolving your local IP. -s NAME, --save=NAME save the session. Has the benefit of allowing you to resume a previous scan and allows you to export scans --resume=NAME resume a previous scan -c, --enablecompact enable compact mode. Makes packets smaller but possibly less compatible --randomscan Scan random IP addresses -i scan1, --input=scan1 Scan IPs which were found in a previous scan. Pass the session name as the argument -I scan1, --inputtext=scan1 Scan IPs from a text file - use the same syntax as command line but with new lines instead of commas. Pass the file name as the argument -m METHOD, --method=METHOD Specify the request method - by default this is OPTIONS. -d, --debug Print SIP messages received --first=FIRST Only send the first given number of messages (i.e. usually used to scan only X IPs) -e EXTENSION, --extension=EXTENSION Specify an extension - by default this is not set --randomize Randomize scanning instead of scanning consecutive ip addresses --srv Scan the SRV records for SIP on the destination domain name.The targets have to be domain names - example.org domain1.com --fromname=FROMNAME specify a name for the from header --crashandburn |
Ahora podemos escanear una o varias ips como vemos en el siguiente ejemplo:
1 2 3 4 5 6 7 8 9 10 11 12 |
# sipvicious_svmap 10.0.0.1 | SIP Device | User Agent | Fingerprint | ---------------------------------------------------------------------------------------- | 10.0.0.1:5060 | X-Lite | Asterisk / Linksys/PAP2T-3.1.15(LS) / Asterisk PBX | # ./svmap.py 10.0.0.* | SIP Device | User Agent | Fingerprint | ------------------------------------------------------------------------------------------ | 10.0.0.1:5060 | Asterisk PBX | Asterisk / Linksys/PAP2T-3.1.15(LS) | | 10.0.0.2:5060 | X-Lite | Asterisk / Linksys/PAP2T-3.1.15(LS) / Asterisk PBX | | 10.0.0.3:5060 | Asterisk PBX | Asterisk / Linksys/PAP2T-3.1.15(LS) | |
Una vez obtengamos la lista de máquinas podemos obtener sus extensiones con svwar. Veremos la ayuda con la opción -h:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# sipvicious_svwar -h Usage: svwar.py [options] target examples: svwar.py -e100-999 10.0.0.1 svwar.py -d dictionary.txt 10.0.0.2 Options: --version show program's version number and exit -h, --help show this help message and exit -v, --verbose Increase verbosity -q, --quiet Quiet mode -p PORT, --port=PORT Destination port or port ranges of the SIP device - eg -p5060,5061,8000-8100 -P PORT, --localport=PORT Source port for our packets -x IP, --externalip=IP IP Address to use as the external ip. Specify this if you have multiple interfaces or if you are behind NAT -b BINDINGIP, --bindingip=BINDINGIP By default we bind to all interfaces. This option overrides that and binds to the specified ip address -t SELECTTIME, --timeout=SELECTTIME This option allows you to trottle the speed at which packets are sent. Change this if you're losing packets. For example try 0.5. -R, --reportback Send the author an exception traceback. Currently sends the command line parameters and the traceback -A, --autogetip Automatically get the current IP address. This is useful when you are not getting any responses back due to SIPVicious not resolving your local IP. -s NAME, --save=NAME save the session. Has the benefit of allowing you to resume a previous scan and allows you to export scans --resume=NAME resume a previous scan -c, --enablecompact enable compact mode. Makes packets smaller but possibly less compatible -d DICTIONARY, --dictionary=DICTIONARY specify a dictionary file with possible extension names -m OPTIONS, --method=OPTIONS specify a request method. The default is REGISTER. Other possible methods are OPTIONS and INVITE -e RANGE, --extensions=RANGE specify an extension or extension range example: -e 100-999,1000-1500,9999 -z PADDING, --zeropadding=PADDING the number of zeros used to padd the username. the options "-e 1-9999 -z 4" would give 0001 0002 0003 ... 9999 --force Force scan, ignoring initial sanity checks. -T TEMPLATE, --template=TEMPLATE A format string which allows us to specify a template for the extensions example svwar.py -e 1-999 --template="123%#04i999" would scan between 1230001999 to 1230999999" -D, --enabledefaults Scan for default / typical extensions such as 1000,2000,3000 ... 1100, etc. This option is off by default. Use --enabledefaults to enable this functionality --maximumtime=MAXIMUMTIME Maximum time in seconds to keep sending requests without receiving a response back --domain=DOMAIN force a specific domain name for the SIP message, eg. -d example.org --debug Print SIP messages received -6 scan an IPv6 address |
Y obtendremos el listado de extensiones:
1 2 3 4 5 6 |
# sipvicious_svwar 10.0.0.1 | Extension | Authentication | ------------------------------ | 100 | reqauth | | 101 | reqauth | | 102 | reqauth | |
En este servidor de ejemplo hay configuradas al menos 3 extensiones SIP y cada una requiere de una constraseña para conectarse. Si no especificamos lo contrario, svwar buscará extensiones comprendidas entre 1 y 999.
Si queremos buscar extensiones comprendidas entre un número diferente utilizaremos la opción -e como en el siguiente ejemplo:
1 |
# sipvicious_svwar -e 1000-2000 10.0.0.1 |
Lo siguiente será utilizar svcrack, del cual podemos obtener la ayuda con la opción -h:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# sipvicious_svcrack -h Usage: svcrack.py -u username [options] target examples: svcrack.py -u100 -d dictionary.txt 10.0.0.1 svcrack.py -u100 -r1-9999 -z4 10.0.0.1 Options: --version show program's version number and exit -h, --help show this help message and exit -v, --verbose Increase verbosity -q, --quiet Quiet mode -p PORT, --port=PORT Destination port or port ranges of the SIP device - eg -p5060,5061,8000-8100 -P PORT, --localport=PORT Source port for our packets -x IP, --externalip=IP IP Address to use as the external ip. Specify this if you have multiple interfaces or if you are behind NAT -b BINDINGIP, --bindingip=BINDINGIP By default we bind to all interfaces. This option overrides that and binds to the specified ip address -t SELECTTIME, --timeout=SELECTTIME This option allows you to trottle the speed at which packets are sent. Change this if you're losing packets. For example try 0.5. -R, --reportback Send the author an exception traceback. Currently sends the command line parameters and the traceback -A, --autogetip Automatically get the current IP address. This is useful when you are not getting any responses back due to SIPVicious not resolving your local IP. -s NAME, --save=NAME save the session. Has the benefit of allowing you to resume a previous scan and allows you to export scans --resume=NAME resume a previous scan -c, --enablecompact enable compact mode. Makes packets smaller but possibly less compatible -u USERNAME, --username=USERNAME username to try crack -d DICTIONARY, --dictionary=DICTIONARY specify a dictionary file with passwords -r RANGE, --range=RANGE specify a range of numbers. example: 100-200,300-310,400 -e EXTENSION, --extension=EXTENSION Extension to crack. Only specify this when the extension is different from the username. -z PADDING, --zeropadding=PADDING the number of zeros used to padd the password. the options "-r 1-9999 -z 4" would give 0001 0002 0003 ... 9999 -n, --reusenonce Reuse nonce. Some SIP devices don't mind you reusing the nonce (making them vulnerable to replay attacks). Speeds up the cracking. -T TEMPLATE, --template=TEMPLATE A format string which allows us to specify a template for the extensions example svwar.py -e 1-999 --template="123%#04i999" would scan between 1230001999 to 1230999999" --maximumtime=MAXIMUMTIME Maximum time in seconds to keep sending requests without receiving a response back -D, --enabledefaults Scan for default / typical passwords such as 1000,2000,3000 ... 1100, etc. This option is off by default. Use --enabledefaults to enable this functionality --domain=DOMAIN force a specific domain name for the SIP message, eg. -d example.org --requesturi=REQUESTURI force the first line URI to a specific value; e.g. sip:999@example.org -6 scan an IPv6 address -m METHOD, --method=METHOD |
Utilizaremos svcrack para intentar hallar la clave de una extensión específica, para ello lo haremos como en el siguiente ejemplo:
1 |
# sipvicious_svcrack -e 100 10.0.0.1 |
En el anterior ejemplo realizaremos el ataque contra la extensión número 100. Si no especificamos un diccionario a utilizar, por defecto probará con los números 1 a 999 como contraseña.
Para utilizar un diccionario personalizado, primero crearemos nuestro diccionario y posteriormente realizaremos el ataque de la siguiente forma:
1 |
# sipvicious_svcrack -e 100 -d diccionario.txt 10.0.0.1 |
También podemos utilizar la opción -s para darle un nombre a la sesión y posteriormente poder hacer un reporte de la misma como en el siguiente ejemplo:
1 |
# sipvicious_svcrack -e 100 -d diccionario.txt 10.0.0.1 -s scan1 |
Ahora podemos crear un reporte mediante la herramienta svreport, de la cual podemos obtener la ayuda con la opción -h:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# sipvicious_svreport -h Usage: svreport.py [command] [options] Supported commands: - list: lists all scans - export: exports the given scan to a given format - delete: deletes the scan - stats: print out some statistics of interest - search: search for a specific string in the user agent (svmap) examples: svreport.py list svreport.py export -f pdf -o scan1.pdf -s scan1 svreport.py delete -s scan1 Options: --version show program's version number and exit -h, --help show this help message and exit -v, --verbose Increase verbosity -q, --quiet Quiet mode -t SESSIONTYPE, --type=SESSIONTYPE Type of session. This is usually either svmap, svwar or svcrack. If not set I will try to find the best match -s SESSION, --session=SESSION Name of the session -f FORMAT, --format=FORMAT Format type. Can be stdout, pdf, xml, csv or txt -o OUTPUTFILE, --output=OUTPUTFILE Output filename -n Do not resolve the ip address -c, --count Used togather with 'list' command to count the number of entries |
Podemos obtener un listado de las sesiones existentes con el siguiente comando:
1 |
# sipvicious_svreport list |
Exportar en el formato deseado:
1 |
# sipvicious_svreport export -f pdf -o scan1.pdf -s scan1 |
Y eliminar posteriormente la sesión creada:
1 |
# sipvicious_svreport delete -s scan1 |
Por último tenemos la herramienta svcrash, con la cual obtenemos la ayuda también con la opción -h:
1 2 3 4 5 6 7 8 9 10 11 |
# sipvicious_svcrash -h Usage: svcrash.py [options] Options: --version show program's version number and exit -h, --help show this help message and exit --auto Automatically send responses to attacks --astlog=ASTLOG Path for the asterisk full logfile -d IPADDR specify attacker's ip address -p PORT specify attacker's port -b bruteforce the attacker's port |
Esta última herramienta es muy útil para los administradores de sistemas que puedan observar en sus log que están siendo atacados, y con la cual se puede contrarestar y bloquear al atacante. Para ello os dejo un ejemplo de como realizarlo:
1 |
# sipvicious_svcrash -d atacker_ip |
O podemos contrarestar automáticamente cualquier ataque obtenido utilizando la opción –auto:
1 |
# sipvicious_svcrash --auto |
En los días que corren, los ataques están a la hora del día pero como siempre, manteniendo unas buenas políticas de seguridad y contraseñas podemos evitar que ataques como este surtan efecto o, al menos, hacer que sea más difícil para el atacante obtener resultados y que nos de tiempo a contrarestar los mismos antes de llegar a problemas mayores.
Como siempre menciono, este blog sólo pretende informar y ayudar a entender como funcionan los diferentes ataques que se pueden realizar y no nos hacemos responsables de cualquier acto ilegal realizado con la ayuda de las mismas.
Esto es todo por ahora, dejen sus comentarios, ideas y/o dudas en la sección de más abajo y nos vemos en el siguiente post.
Al ejecutar cualquiera de los comandos descritos me da la siguiente respuesta:
Traceback (most recent call last):
File “./svmap.py”, line 36, in
from .libs.pptable import to_string
ImportError: attempted relative import with no known parent package
sabes porque?
Te agradezco de antemano
Hola Ruben,
Parece que el problema viene por alguna dependencia. Prueba a ejecutar el script setup.py
python3 setup.py install
Y posteriormente prueba de nuevo a ejecutar el script de svmap, en este caso tienes dos formas de poder ejecutarlo:
./svmap.py -h
sipvicious_svmap -h
Prueba a ver si con eso se te soluciona y me dices.
Saludos