Jump to navigation Jump to search

Decryption methods


VoIPmonitor version >= 27 can decrypt any application by using ssl key logger which logs keys directly by injecting openssl library (tested with openssl >= 1.0.1). Ssl key logger is a small library which uses LD_PRELOAD to intercept session keys. Those keys are then sent over UDP to the voipmonitor sniffer. The behaviour of applications (like asterisk / kamailio / freeswitch and all software using openssl) is not affected or changed - it only logs keys.

VoIPmonitor receiving those keys can receive keys from multiple sources at once (in case you are running more servers or multiple SIP proxies on one or more hosts)

This library is located in voipmonitor source tree: tools/ssl_keylogger/sslkeylog/sslkeylog.c


Compiling sslkeylogger

cd /usr/local/src
git clone voipmonitor-git
cd voipmonitor-git/tools/ssl_keylogger/

running keylogger

Testing keylogger

You should always test if the library / keylogger is working by this command:

env SSLKEYLOG_UDP='' LD_PRELOAD="/usr/local/src/voipmonitor-git/tools/ssl_keylogger/" openssl

The output should show similar output:

* SSL KEYLOG : OK detect pointer to function SSL_new : 0x7fe9d6e96540
* SSL KEYLOG : OK detect pointer to function SSL_CTX_set_keylog_callback : 0x7fe9d6e97870
* SSL KEYLOG : log to :
OpenSSL> root@voipmonitor

If you see SSL KEYLOG messages - the keylog is working


Asterisk binary is directly linking with libssl so we just need to preload our sslkeylog

env SSLKEYLOG_UDP='' LD_PRELOAD="/usr/local/src/voipmonitor-git/tools/ssl_keylogger/" asterisk -vvvgcd

edit your /etc/init.d/asterisk and put the env SSLKEYLOG_UDP='' LD_PRELOAD="/usr/local/src/voipmonitor-git/tools/ssl_keylogger/" appropriately so the asterisk will start with the preloaded key logger

SSLKEYLOG_UDP parameter tells to what IP and port keys should be sent (this is voipmonitor IP and port) - in this example it runs on the same host as asterisk (


Kamailio uses module (which is linked to thus the LD_PRELOAD needs to load first

env SSLKEYLOG_UDP='' LD_PRELOAD="/usr/local/src/voipmonitor-git/tools/ssl_keylogger/ /usr/local/lib64/" kamailio 

In this example, our system uses compiled openssl from sources, thus the path to the libssl is /usr/local/lib64/ (on debian stock library is located in /usr/lib/x86_64-linux-gnu/

You need to modify your kamailio start scripts

On debian modify /etc/init.d/kamailio

env SSLKEYLOG_UDP='' LD_PRELOAD="/usr/local/src/voipmonitor-git/tools/ssl_keylogger/ /usr/local/lib64/" start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- $OPTIONS || log_failure_msg " already running"


We experienced non-working keylogger with default systemd's service file settings. Please change following systemd options (and then reload the systemd with 'systemctl daemon-reload')

ExecStart=env SSLKEYLOG_UDP='' LD_PRELOAD='/usr/local/src/voipmonitor-git/tools/ssl_keylogger/'  /usr/bin/freeswitch $FREESWITCH_PARAMS

Then in the /etc/sysconfig/freeswitch change the params (and restart the freeswitch service):

FREESWITCH_PARAMS="-rp -nonat -u freeswitch -g daemon -certs /etc/freeswitch/ssl"

Additionally there is necessary to change DEBUG in keylogger - disable it or redirect to syslog instead of stdout, in eylogger sources add following to redirect to sysog:


or disable debug at all (and recompile the keylogger after changes)

#define DEBUG 0

configuring voipmonitor

Lets assume that SIP proxy is running on

edit : /etc/voipmonitor.conf 

enabling ssl_sessionkey UDP receiver

ssl_sessionkey_udp = yes
ssl_sessionkey_udp_port = 1234
ssl_sessionkey_udp_ip =  (this is not mandatory)
ssl_sessionkey_udp_maxwait_ms = 10000

enabling ssl decryption

ssl = yes
ssl_ipport =
ssl_ipport =

ssl_ipport can be specified multiple times in case voipmonitor should decrypt multiple SIP proxies - for example if you have more tcp tls servers and voipmonitor instance should decrypt more of them

Run the voipmonitor in usual way.


Since version 11 VoIPmonitor sniffer is able to decode and decrypt TLS SIP protocol by providing private key.

Please note that the sniffer only supports TLS layer and SSLv3 (not SSLv1 or SSLv2) layer which you can verify in CLIENT HELLO packet in wireshark where you can see SSL or TLS in header.

Decrypted SIP packets are converted to virtual UDP packets with the same ethernet headers replacing the IP TCP layer with UDP so you will not see the TCP stream in stored pcap files.

TLS feature is still in beta - if you will have any problems which are reproducible we need to see pcap file with the TLS packets (no need for RTP) and of course the private key.

Please note that TLS where cipher suite is set to Diffie–Hellman key exchange is not possible to decrypt by using only private key. In this case you have to use the above method with ssl key logger or change the cipher suite to use anything else than diffie hellman cipher suites.

VoIPmonitor is able to decrypt SRTP.


add to the voipmonitor.conf

ssl = yes
ssl_ipport = : 5061 /etc/private.key

where is server with TLS port 5061. Private key is in /etc/private.key and it is in PEM format (starting with -----BEGIN RSA PRIVATE KEY-----)

Testing TLS decryption


(tested with 16.xx)

Generate key:

openssl req -new -x509 -days 365 -nodes -out /etc/asterisk/keys/asterisk.pem -keyout /etc/asterisk/keys/asterisk.pem


callerid="500" <500>

start asterisk:

env SSLKEYLOG_UDP='' LD_PRELOAD=/usr/local/src/voipmonitor-git/tools/ssl_keylogger/ /usr/sbin/asterisk -vvvgcd

pjsua console SIP client

For easy testing, the fastest way to send REGISTER packet or call is to use pjsip pjsua binary (with compiled openssl support) pjsua is automatically compiled when compiling pjsip library 10.0.01 is the asterisk IP

pjsua --id "sip:500@;transport=tls" --registrar "sip:;transport=tls" --username "500" --password "ko0R9onX" --realm "*" "sip:1234@"   --use-tls --no-udp


for testing purpose there is no need to have voipmonitor.conf - just run the voipmonitort with this:

voipmonitor   -c -k -v1,pcap_stat_period=10,ssl_sessionkey,dump_sip_line \

ssl_sessionkey,dump_sip_line options will print SSL keys and decrypted SIP packets to the output:

If everything works it should looks like this:

voipmonitor-static[639]: calls[0,r:0][0,r:0] PS[C:-/- r:-/- S:-/- SR:- SM:- R:-/- A:61] SQLq[C:0] heap[0|0|0] [0.1Mb/s] tarQ[0] t0CPU[1.9%] t1CPU[0.4%] t2CPU[pb:0.4/S:-0.6%]
set clientrandom with type SERVER_HANDSHAKE_TRAFFIC_SECRET
| dd 1d 0e 0a 26 2f af bd 3d 85 83 f0 cd 3b a3 ff | |....&/..=....;..|
| bf 39 b3 df 05 36 8f 45 c2 b4 e4 c8 fb 86 11 7d | |.9...6.E.......}|
| a7 de ed 6e a8 b5 c0 b9 e4 94 43 2e 99 66 3d 5a | |...n......C..f=Z|
| 14 c8 8f 57 01 4a 2c 2c b8 3c e6 7b 1f e8 e7 b8 | |...W.J,,.<.{....|
| 94 7e c4 29 ab e7 99 eb b3 fc 77 ab 2a c6 9f e8 | |.~.)......w.*...|
set clientrandom with type CLIENT_HANDSHAKE_TRAFFIC_SECRET
| dd 1d 0e 0a 26 2f af bd 3d 85 83 f0 cd 3b a3 ff | |....&/..=....;..|
| bf 39 b3 df 05 36 8f 45 c2 b4 e4 c8 fb 86 11 7d | |.9...6.E.......}|
| 64 7e 7f 93 31 e3 8d 7d 6c 69 a2 73 7b ef ee d3 | |d~..1..}li.s{...|
| a7 ff 54 1b 45 1a b9 fa dd f5 31 31 7e 06 3f 3d | |..T.E.....11~.?=|
| 2e fc da c9 05 bf e8 53 12 37 b8 2b 68 ad da 14 | |.......S.7.+h...|
set clientrandom with type EXPORTER_SECRET
| dd 1d 0e 0a 26 2f af bd 3d 85 83 f0 cd 3b a3 ff | |....&/..=....;..|
| bf 39 b3 df 05 36 8f 45 c2 b4 e4 c8 fb 86 11 7d | |.9...6.E.......}|
| 6e 88 72 28 5c 52 50 ff c9 31 ca d9 37 76 83 4c | |n.r(\RP..1..7v.L|
| a8 32 00 d3 59 c5 dc b9 94 ac 07 ea 91 42 b3 39 | |.2..Y........B.9|
| 28 37 8c 03 3a 03 21 9f ed 9f 79 0e 10 90 45 11 | |(7..:.!...y...E.|
set clientrandom with type SERVER_TRAFFIC_SECRET_0
| dd 1d 0e 0a 26 2f af bd 3d 85 83 f0 cd 3b a3 ff | |....&/..=....;..|
| bf 39 b3 df 05 36 8f 45 c2 b4 e4 c8 fb 86 11 7d | |.9...6.E.......}|
| 06 2d 04 60 b4 e2 a4 8b 2f 32 d2 8d a0 b5 06 e6 | |.-.`..../2......|
| 33 5a e3 af 53 c8 52 6d 7f ad 0d 63 f9 28 20 e9 | |3Z..S.Rm...c.( .|
| a5 47 2a ff b2 e4 e5 5f 1d 28 c2 c2 21 f9 26 05 | |.G*...._.(..!.&.|
set clientrandom with type CLIENT_TRAFFIC_SECRET_0
| dd 1d 0e 0a 26 2f af bd 3d 85 83 f0 cd 3b a3 ff | |....&/..=....;..|
| bf 39 b3 df 05 36 8f 45 c2 b4 e4 c8 fb 86 11 7d | |.9...6.E.......}|
| b2 61 3c 2f 85 b4 06 27 3f bd be b5 6c c5 b6 69 | |.a</...'?...l..i|
| b7 78 7d 0c e6 b5 5f a7 ea 77 08 f6 c6 3e 06 95 | |.x}..._..w...>..|
| bc 78 68 0f 3b 17 ec 7b 4d 2d 68 dc f6 e4 6d de | |.xh.;..{M-h...m.|
find clientrandom for all type
| dd 1d 0e 0a 26 2f af bd 3d 85 83 f0 cd 3b a3 ff | |....&/..=....;..|
| bf 39 b3 df 05 36 8f 45 c2 b4 e4 c8 fb 86 11 7d | |.9...6.E.......}|
* clientrandom found
1 ->
REGISTER;transport=tls SIP/2.0....