Skip to content

Instantly share code, notes, and snippets.

@gil-obradors
Forked from 62mkv/check-auth.py
Created April 17, 2019 18:59
Show Gist options
  • Save gil-obradors/47e6ce0a4b660225c380d9752385936d to your computer and use it in GitHub Desktop.
Save gil-obradors/47e6ce0a4b660225c380d9752385936d to your computer and use it in GitHub Desktop.
Python script to calculate SIP REGISTER Digest authentication (in order to check password validity)
from md5 import md5
# header from 401 response on REGISTER
# Authorization: Digest username="883140776410950", realm="gw_youmagic", algorithm=MD5, uri="sip:GW_Youmagic", nonce="1476157437:0a1418a40f8ee1c9a55f1587ab931c14", response="3ff479ccc24874f66aae45dac889d099"
login = '883140776410950'
uri = 'sip:GW_Youmagic'
nonce = '1476157437:0a1418a40f8ee1c9a55f1587ab931c14'
realm = 'gw_youmagic'
password = '----------'
str1 = md5("{}:{}:{}".format(login,realm,password)).hexdigest()
str2 = md5("REGISTER:{}".format(uri)).hexdigest()
str3 = md5("{}:{}:{}".format(str1,nonce,str2)).hexdigest()
print str3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment