MD5 Digest Authorisation in SIP with PHP

| md5 | PHP | sip

Today I needed to work out the MD5 Digest hash for SIP authorisation. A quick search on Google revealed instructions on how to generate the hash, and then I made this simple PHP script.

$username = '1234';
$realm    = 'asterisk';
$password = 'PASSWORD';
$uri      = 'sip:';
$nonce    = 'abcdef01';

$str1 = md5("$username:$realm:$password");
$str2 = md5("REGISTER:$uri");

echo md5("$str1:$nonce:$str2");

All of those variables can be pulled out of a packet capture of a SIP REGISTER, and the results can be useful for validating the password a device is sending, is what it is actually sending.

comments powered by Disqus