Intento Hack Asterisk. Fuerza Bruta contra Asterisk

Hoy me encontraba navegando tranquilamente y monitorizando todos los servidores propios, cuando de repente en la consola de asterisk me aparece lo siguiente:

[Feb 26 00:54:13] NOTICE[8658]: chan_sip.c:21821 handle_request_register: Registration from ‘»5465″<sip:5465@81.56.122.35>’ failed for ‘139.153.12.78’ – No matching peer found
[Feb 26 00:54:13] NOTICE[8658]: chan_sip.c:21821 handle_request_register: Registration from ‘»5466″<sip:5466@81.56.122.35>’ failed for ‘139.153.12.78’ – No matching peer found
[Feb 26 00:54:13] NOTICE[8658]: chan_sip.c:21821 handle_request_register: Registration from ‘»5467″<sip:5467@81.56.122.35>’ failed for ‘139.153.12.78’ – No matching peer found
[Feb 26 00:54:13] NOTICE[8658]: chan_sip.c:21821 handle_request_register: Registration from ‘»5468″<sip:5468@81.56.122.35>’ failed for ‘139.153.12.78’ – No matching peer found
[Feb 26 00:54:13] NOTICE[8658]: chan_sip.c:21821 handle_request_register: Registration from ‘»44114411″<sip:44114411@81.56.122.35>’ failed for ‘139.153.12.78’ – No matching peer found
[Feb 26 00:54:13] NOTICE[8658]: chan_sip.c:21821 handle_request_register: Registration from ‘»5469″<sip:5469@81.56.122.35>’ failed for ‘139.153.12.78’ – No matching peer found
[Feb 26 00:54:13] NOTICE[8658]: chan_sip.c:21821 handle_request_register: Registration from ‘»5470″<sip:5470@81.56.122.35>’ failed for ‘139.153.12.78’ – No matching peer found
[Feb 26 00:54:13] NOTICE[8658]: chan_sip.c:21821 handle_request_register: Registration from ‘»44124412″<sip:44124412@81.56.122.35>’ failed for ‘139.153.12.78’ – No matching peer found
[Feb 26 00:54:13] NOTICE[8658]: chan_sip.c:21821 handle_request_register: Registration from ‘»5471″<sip:5471@81.56.122.35>’ failed for ‘139.153.12.78’ – No matching peer found
[Feb 26 00:54:13] NOTICE[8658]: chan_sip.c:21821 handle_request_register: Registration from ‘»5472″<sip:5472@81.56.122.35>’ failed for ‘139.153.12.78’ – No matching peer found
[Feb 26 00:54:13] NOTICE[8658]: chan_sip.c:21821 handle_request_register: Registration from ‘»5473″<sip:5473@81.56.122.35>’ failed for ‘139.153.12.78’ – No matching peer found
[Feb 26 00:54:13] NOTICE[8658]: chan_sip.c:21821 handle_request_register: Registration from ‘»44134413″<sip:44134413@81.56.122.35>’ failed for ‘139.153.12.78’ – No matching peer found
[Feb 26 00:54:13] NOTICE[8658]: chan_sip.c:21821 handle_request_register: Registration from ‘»5474″<sip:5474@81.56.122.35>’ failed for ‘139.153.12.78’ – No matching peer found
[Feb 26 00:54:13] NOTICE[8658]: chan_sip.c:21821 handle_request_register: Registration from ‘»5475″<sip:5475@81.56.122.35>’ failed for ‘139.153.12.78’ – No matching peer found
[Feb 26 00:54:13] NOTICE[8658]: chan_sip.c:21821 handle_request_register: Registration from ‘»5476″<sip:5476@81.56.122.35>’ failed for ‘139.153.12.78’ – No matching peer found
[Feb 26 00:54:13] NOTICE[8658]: chan_sip.c:21821 handle_request_register: Registration from ‘»44144414″<sip:44144414@81.56.122.35>’ failed for ‘139.153.12.78’ – No matching peer found
[Feb 26 00:54:13] NOTICE[8658]: chan_sip.c:21821 handle_request_register: Registration from ‘»5477″<sip:5477@81.56.122.35>’ failed for ‘139.153.12.78’ – No matching peer found
[Feb 26 00:54:13] NOTICE[8658]: chan_sip.c:21821 handle_request_register: Registration from ‘»5478″<sip:5478@81.56.122.35>’ failed for ‘139.153.12.78’ – No matching peer found
[Feb 26 00:54:13] NOTICE[8658]: chan_sip.c:21821 handle_request_register: Registration from ‘»5479″<sip:5479@81.56.122.35>’ failed for ‘139.153.12.78’ – No matching peer found
[Feb 26 00:54:13] NOTICE[8658]: chan_sip.c:21821 handle_request_register: Registration from ‘»5480″<sip:5480@81.56.122.35>’ failed for ‘139.153.12.78’ – No matching peer found
[Feb 26 00:54:13] NOTICE[8658]: chan_sip.c:21821 handle_request_register: Registration from ‘»5481″<sip:5481@81.56.122.35>’ failed for ‘139.153.12.78’ – No matching peer found
[Feb 26 00:54:13] NOTICE[8658]: chan_sip.c:21821 handle_request_register: Registration from ‘»5482″<sip:5482@81.56.122.35>’ failed for ‘139.153.12.78’ – No matching peer found
[Feb 26 00:54:13] NOTICE[8658]: chan_sip.c:21821 handle_request_register: Registration from ‘»5483″<sip:5483@81.56.122.35>’ failed for ‘139.153.12.78’ – No matching peer found
[Feb 26 00:54:13] NOTICE[8658]: chan_sip.c:21821 handle_request_register: Registration from ‘»5484″<sip:5484@81.56.122.35>’ failed for ‘139.153.12.78’ – No matching peer found
[Feb 26 00:54:13] NOTICE[8658]: chan_sip.c:21821 handle_request_register: Registration from ‘»5485″<sip:5485@81.56.122.35>’ failed for ‘139.153.12.78’ – No matching peer found
[Feb 26 00:54:13] NOTICE[8658]: chan_sip.c:21821 handle_request_register: Registration from ‘»5486″<sip:5486@81.56.122.35>’ failed for ‘139.153.12.78’ – No matching peer found
[Feb 26 00:54:13] NOTICE[8658]: chan_sip.c:21821 handle_request_register: Registration from ‘»5487″<sip:5487@81.56.122.35>’ failed for ‘139.153.12.78’ – No matching peer found
[Feb 26 00:54:13] NOTICE[8658]: chan_sip.c:21821 handle_request_register: Registration from ‘»5488″<sip:5488@81.56.122.35>’ failed for ‘139.153.12.78’ – No matching peer found
[Feb 26 00:54:13] NOTICE[8658]: chan_sip.c:21821 handle_request_register: Registration from ‘»5489″<sip:5489@81.56.122.35>’ failed for ‘139.153.12.78’ – No matching peer found
[Feb 26 00:54:13] NOTICE[8658]: chan_sip.c:21821 handle_request_register: Registration from ‘»5490″<sip:5490@81.56.122.35>’ failed for ‘139.153.12.78’ – No matching peer found
[Feb 26 00:54:13] NOTICE[8658]: chan_sip.c:21821 handle_request_register: Registration from ‘»5491″<sip:5491@81.56.122.35>’ failed for ‘139.153.12.78’ – No matching peer found
[Feb 26 00:54:13] NOTICE[8658]: chan_sip.c:21821 handle_request_register: Registration from ‘»5492″<sip:5492@81.56.122.35>’ failed for ‘139.153.12.78’ – No matching peer found
[Feb 26 00:54:13] NOTICE[8658]: chan_sip.c:21821 handle_request_register: Registration from ‘»5493″<sip:5493@81.56.122.35>’ failed for ‘139.153.12.78’ – No matching peer found
[Feb 26 00:54:13] NOTICE[8658]: chan_sip.c:21821 handle_request_register: Registration from ‘»5494″<sip:5494@81.56.122.35>’ failed for ‘139.153.12.78’ – No matching peer found
[Feb 26 00:54:13] NOTICE[8658]: chan_sip.c:21821 handle_request_register: Registration from ‘»5495″<sip:5495@81.56.122.35>’ failed for ‘139.153.12.78’ – No matching peer found

Es obvio que estan atacando a nuestro asterisk con un ataque Brute Force (Fuerza bruta).
Seguro que no es ningúna persona fisica si no cualquier máquina comprometida con software instalado para tal fin
(Encontrar máquinas con asterisk y realizár ataques de fuerza bruta).
Con la cual pueden intentar millones de combinaciones para autentificarse en nuestro Asterisk.

La ip que generaba esto era la: 139.153.12.78 y según he podido averiguar es de una universidad de UK la cual tiene asignado un rango de ips que es el siguiente:

139.153.0.0/16

La solución fué sencilla, para este tema, Iptables como no 😛

iptables -t filter -A INPUT -s 139.153.0.0/16 -j DROP

Todo el tráfico que venga de ese rango, lo dropeará.

Ya he informado a la gente que administra dicha red y se han puesto manos a la obra para solventar el problema.

Saludos.

Share

Asterisk. Audio en un solo sentido llamadas entrantes. Incoming Calls

Hola.

Sigo con mi implementación de asterisk en gentoo y vengo a contar como solucionar un problemita con este…

Actualmente estoy saliendo a la Red Telefonica Básica (RTB), red de telefonia de toda la vida, por un proveedor voip.
Para enrutar llamadas por este, no hubo más problemas. Registrar nuestro asterisk con el proveedor, añadir un canal para este en sip.conf y crear un dialplan para sacar llamadas por ahi y FIN.

El problema no era ese, el problema era al intentar recibir llamadas. Tengo varios numeros DID asignados a varias extensiones de mi asterisk con lo cual es fundamental que puedan entrar llamadas, y estas lo hacian, pero solo tenia audio en 1 sentido (de dentro hacia fuera), el usuario que me llamaba yo no lo podia escuchar, el a mi perfectamente…

*Problema de NAT no era, ya que estaba trabajando fuera de un entorno con NAT
**por lo menos por mi parte, parece ser que por la del operador de números DID no

Lo primero que hice en este caso fué entrar a la consola de asterik:

asterisk -r

Y hacer un debug del protocolo RTP para ver que es lo que estaba pasando con los paquetes….

rtp set debug on

He aqui el resultado:

Got  RTP packet from    192.168.10.15:16406 (type 08, seq 014191, ts 392580221, len 000160)
Sent RTP packet to      46.19.209.78:17962 (type 08, seq 026450, ts 392580216, len 000160)
Got  RTP packet from    192.168.10.15:16406 (type 08, seq 014192, ts 392580381, len 000160)
Sent RTP packet to      46.19.209.78:17962 (type 08, seq 026451, ts 392580376, len 000160)
Got  RTP packet from    192.168.10.15:16406 (type 08, seq 014193, ts 392580541, len 000160)
Sent RTP packet to      46.19.209.78:17962 (type 08, seq 026452, ts 392580536, len 000160)
Got  RTP packet from    192.168.10.15:16406 (type 08, seq 014194, ts 392580701, len 000160)
Sent RTP packet to      46.19.209.78:17962 (type 08, seq 026453, ts 392580696, len 000160)
Got  RTP packet from    192.168.10.15:16406 (type 08, seq 014195, ts 392580861, len 000160)
Sent RTP packet to      46.19.209.78:17962 (type 08, seq 026454, ts 392580856, len 000160)
Got  RTP packet from    192.168.10.15:16406 (type 08, seq 014196, ts 392581021, len 000160)
Sent RTP packet to      46.19.209.78:17962 (type 08, seq 026455, ts 392581016, len 000160)
Got  RTP packet from    192.168.10.15:16406 (type 08, seq 014197, ts 392581181, len 000160)
Sent RTP packet to      46.19.209.78:17962 (type 08, seq 026456, ts 392581176, len 000160)
Got  RTP packet from    192.168.10.15:16406 (type 08, seq 014198, ts 392581341, len 000160)
Sent RTP packet to      46.19.209.78:17962 (type 08, seq 026457, ts 392581336, len 000160)
Got  RTP packet from    192.168.10.15:16406 (type 08, seq 014199, ts 392581501, len 000160)
Sent RTP packet to      46.19.209.78:17962 (type 08, seq 026458, ts 392581496, len 000160)
Got  RTP packet from    192.168.10.15:16406 (type 08, seq 014200, ts 392581661, len 000160)
Sent RTP packet to      46.19.209.78:17962 (type 08, seq 026459, ts 392581656, len 000160)

Me pusé a leer de cabo a rabo el fichero sip.conf que trae asterisk de ejemplo y me encuentro con:

;directmedia=yes                ; Asterisk by default tries to redirect the
; RTP media stream to go directly from
; the caller to the callee.  Some devices do not
; support this (especially if one of them is behind a NAT).
; The default setting is YES. If you have all clients
; behind a NAT, or for some other reason want Asterisk to
; stay in the audio path, you may want to turn this off.

Nos dice que asterisk querrá establecer una conexión DIRECTA con el usuario que llama y el usuario que contesta a la llamada. Esto no es soportable por algunos dispositivos,especialmente si estan detrás de NAT…….. Esta opción es interesante cuando nos encontramos en un entorno LAN sin dispositivos NAT por enmedio, ya que la comunicación se hará directamente entre los 2 interlocutores. Si hay dispositivos NAT por enmedio es MUY recomendable desactivar dicha opción. (por defecto directmedia esta en YES)

Ahi tenia la respuesta…directmedia estaba en yes por defecto…. fuí al fichero sip.conf y añadí:

[general]
directmedia=off

Reinicio asterisk con:

asterisk -r
core restart now

……..Realizo la llamada desde el exterior, descuelgo el telefono que suena y olalalal!!!!! funcióna el audio en 2 sentidos..
Si ahora hacemos un: debug de rtp observamos lo siguiente….

Sent RTP P2P packet to 46.19.209.76:19818 (type 08, len 000160)
Sent RTP P2P packet to 192.168.10.15:16410 (type 08, len 000160)
Sent RTP P2P packet to 46.19.209.76:19818 (type 08, len 000160)
Sent RTP P2P packet to 192.168.10.15:16410 (type 08, len 000160)
Sent RTP P2P packet to 46.19.209.76:19818 (type 08, len 000160)
Sent RTP P2P packet to 192.168.10.15:16410 (type 08, len 000160)
Sent RTP P2P packet to 46.19.209.76:19818 (type 08, len 000160)
Sent RTP P2P packet to 192.168.10.15:16410 (type 08, len 000160)
Sent RTP P2P packet to 46.19.209.76:19818 (type 08, len 000160)
Sent RTP P2P packet to 192.168.10.15:16410 (type 08, len 000160)
Sent RTP P2P packet to 46.19.209.76:19818 (type 08, len 000160)
Sent RTP P2P packet to 192.168.10.15:16410 (type 08, len 000160)
Sent RTP P2P packet to 46.19.209.76:19818 (type 08, len 000160)
Sent RTP P2P packet to 192.168.10.15:16410 (type 08, len 000160)
Sent RTP P2P packet to 46.19.209.76:19818 (type 08, len 000160)
Sent RTP P2P packet to 192.168.10.15:16410 (type 08, len 000160)
Sent RTP P2P packet to 46.19.209.76:19818 (type 08, len 000160)
Sent RTP P2P packet to 192.168.10.15:16410 (type 08, len 000160)
Sent RTP P2P packet to 46.19.209.76:19818 (type 08, len 000160)
Sent RTP P2P packet to 192.168.10.15:16410 (type 08, len 000160)
Sent RTP P2P packet to 46.19.209.76:19818 (type 08, len 000160)
Sent RTP P2P packet to 192.168.10.15:16410 (type 08, len 000160)
Sent RTP P2P packet to 46.19.209.76:19818 (type 08, len 000160)
Sent RTP P2P packet to 192.168.10.15:16410 (type 08, len 000160)

Esto es todo por hoy, espero que mis cabezazos contra la pared impidan que otros se los de por esto jeje.

Un saludo.

Share

[Asterisk] No se registran los usuarios SIP

Hola.

Ayer publiqué una receta para instalar asterisk en gentoo de un plumazo, ya que me tope con la instalación de asterisk en un pc gentoo.

Horas más tarde esto se complicó un poco y misteriosamente los clientes SIP no conectaban con asterisk :S :S :S .

Estube haciendo las pruebas con Sjphone en la misma máquina que corria Asterisk pero nada…

Lo primero que hicé fué ver si verdaderamente el daemon de asterisk estaba escuchando en el puerto 5060, que lo pude corroborar enseguida:

netstat -tupl:

4257/asterisk
udp        0      0 *:5060                  *:*

Asterisk si estaba escuchando en el puerto 5060, osea todo estaba correcto… o casi todo..

Empecé un fichero ‘sip.conf‘ y ‘extensions.conf‘ totalmente desde 0 pero tampoco era la solución….

Cuando de repente se me ocurrió teclear »dmesg» para ver los mensajes del sistema y me encuentro con esto:

[   88.492694] nf_ct_sip: dropping packetIN= OUT=lo SRC=127.0.0.1 DST=127.0.0.1 LEN=449 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=UDP SPT=1000 DPT=5060 LEN=429 UID=0 GID=0
[   88.993099] nf_ct_sip: dropping packetIN= OUT=lo SRC=127.0.0.1 DST=127.0.0.1 LEN=449 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=UDP SPT=1000 DPT=5060 LEN=429 UID=0 GID=0
[   89.992296] nf_ct_sip: dropping packetIN= OUT=lo SRC=127.0.0.1 DST=127.0.0.1 LEN=449 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=UDP SPT=1000 DPT=5060 LEN=429 UID=0 GID=0
[   91.992871] nf_ct_sip: dropping packetIN= OUT=lo SRC=127.0.0.1 DST=127.0.0.1 LEN=449 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=UDP SPT=1000 DPT=5060 LEN=429 UID=0 GID=0

Nf_sip estaba dropeando paquetes con destino al puerto 5060… Entonces supusé que ese era el problema…

LA SOLUCIÓN (1) – La sencilla

echo «blacklist nf_nat_sip» >> /etc/modprobe.d/blacklist.conf

echo «blacklist nf_conntrack_sip» >> /etc/modprobe.d/blacklist.conf

reboot

Esto lo que hará es meter en la «lista negra» blacklist, los modulos nf_nat_sip y nf_conntrack_sip para que el kernel no los carge al inicio del sistema…

Esta solución funcionaria si dichos modulos estan seleccionados en el archivo .config del kernel como modulos…

¿¿La SOLUCIÓN (2)?? – Si NO los tenemos cmo modulos (<M>)

Ir a –> /usr/src/linux

Editar el archivo: .config

Cambiar las lineas:

CONFIG_NF_CONNTRACK_SIP

CONFIG_NF_NAT_SIP

###Por estas:

# CONFIG_NF_CONNTRACK_SIP is not set

# CONFIG_NF_NAT_SIP is not set

Guardar los cambios en .config

make && make modules_install && make install

cp arch/x86/boot/bzImage /boot/NOMBREKERNEL

reboot

– – NOMBREKERNEL: se sustituye por la imagen del kernel donde apunte grub (grub.conf)


Con esto desabilitamos totalmente la carga de los modulos CONFIG_NF_CONNTRACK_SIP y CONF_NAT_SIP en el kernel y se solucionaria nuestro problema.

Un saludo y espero que sirva de ayuda.

Bye!

Share

Instalar Asterisk en Gentoo. !! De un Plumazo !!

Hola.

Hoy he tenido que realizár una instalación de asterisk sobre una pc con gentoo. Ha sido sencillo, he tenido que desenmascarar todo lo relacionado con asterisk y emerger asterisk.

Para los más perezosos se lo dejo a golpe de copy & paste 😛

emerge –sync
echo «net-misc/asterisk ~x86» >> /etc/portage/package.keywords
echo «net-misc/asterisk-addons ~x86» >> /etc/portage/package.keywords
echo «net-misc/asterisk-core-sounds ~x86» >> /etc/portage/package.keywords
echo «net-misc/asterisk-extra-sounds ~x86» >> /etc/portage/package.keywords
echo «net-misc/asterisk-moh-opsound ~x86» >> /etc/portage/package.keywords
echo «net-misc/asterisk-extra-sounds alaw g722 g729 ulaw wav» >> /etc/portage/package.use
echo «net-misc/asterisk-moh-opsound alaw g722 g729 ulaw wav» >> /etc/portage/package.use
echo «net-misc/asterisk-core-sounds alaw g722 g729 ulaw wav» >> /etc/portage/package.use
emerge net-misc/asterisk net-misc/asterisk-addons

Solamente…Copiar & pegar y listo!

Un saludo.

Share

[Asterisk] Asterisk. Peer, User y Friend. Apuntes

Hola.

Lo que hoy publicaré quizá le sirva de ayuda a más de uno.

Son simplemente apuntes de Asterisk para una fácil comprensión de:

User

Peer

Friend

A simple vista parece sencillo:

User: Llamada que se autentifica con nuestra PBX (Centralita).  -Llamada ENTRANTE

Friend: Llamada entrante y saliente. Un usuario de tipo ‘Friend’ podria realizár llamadas y recibir llamadas.

Peer: En principio, es una llamada SALIENTE.

Cuando la llamada hacia nosotros se realiza desde un telefono normal (PSTN normal, linea de telefono normal) y va «directo» hacia nuestro Asterisk, seria Peer, sin duda.

(*) Pero cuando la llamada proviene de algun proxy sip, bien un proveedor sip externo o un terminal IP como pueda ser un Adaptador ATA tambien entraria en la sección de llamada ‘Peer‘.

Los conceptos se podian resumir (sin tener encuenta la excepción (*) ).  En que:

– Los ‘Users‘ son los que nos llaman, y nosotros llamamos a los ‘Peers‘.  Friend seria recibir y enviar llamadas.

Como para algunos puede ser algo confuso, les explicaré mejor esto, con unos ejemplos «»»gráficos»»»».

ejemplo

Perdonar por el pequeño fallo en la imagen ‘rutamos‘, seria «ENRUTAMOS«

En resumen, una llamada saliente siempre es tipo “peer”, una
llamada entrante puede ser tipo “user”, o tipo “peer” cuando la llamada entrante procede de un proxy.

Cuando hablamos de que «provenga de un proxy» puede ser que la llamada venga de un proveedor SIP o que la llamada provenga de un terminal IP como cualquier equipo ATA. (observar ejemplo)

Ojalá les sirva.

Un saludo.

Share

Tormentas Broadcast (ARP Storm). Descubriendo el pc infectado

Hola.

En este articulo les enseñaré como descubrir el dispositivo que tantas peticiones  broadcast esta generando y tanto dolor de cabeza nos esta creando.

No vamos a utilizar ningún software milagroso ni nada excepciónal, nos valdremos de nuestro entorno bash, tcpdump y algo de ingenio con bash scripting…..

1 – Nuestro primer objetivo es ver el tráfico arp de nuestra red con tcpdump…
Sigue leyendo

Share