#!/bin/sh # Niels Elgaard Larsen, licence:GPL # - No STUN # - Missing a "tag" # Register and display INVITE and other packages. port=5170 nreq=42 gw=gw1.musimi.dk #gw=musimi.dk # New Nusimi phoneno=369xxxxx user=$phoneno ## Apparently always the phone no. realm=musimi.dk pw=yourPassword username="ElgaardBot User" thishost=213.xxx.yyy.zzz # Your external IP #==END of CONFIGURATION =============== hn=$(hostname -i|cut -d " " --fields=1) branch=z9hG4bK77$RANDOM$(date "+%s") cid=$RANDOM@$thishost function register() { echo "REGISTER sip:$gw SIP/2.0" echo "Via: SIP/2.0/UDP $thishost:$port;branch=$branch" echo "Request-URI:sip:musimi.dk" echo "From: \"$username\" " echo "To: \"$username\" " echo "Contact: \"$username\" " echo "User-Agent: elgaardBot/0.1" if [ x$1 != x ] then printf 'Authorization: Digest username="%s", realm="musimi.dk", nonce="%s", uri="sip:%s", cnonce="abcdefghi", nc="00000001", response="%s", opaque=""\n' $user $2 $gw $1 fi echo "Expires: 3600" echo "Call-ID:$cid" echo "Content-Length: 0" echo "CSeq:$nreq REGISTER" echo "Event: registration" echo "Allow-Events: presence" echo "Allow: INVITE,NOTIFY,MESSAGE,INFO,SUBSCRIBE,OPTIONS,BYE,CANCEL,NOTIFY,ACK,REFER" } nonce=$(register | nc -q 5 -u -p $port $gw 5060 | grep -i WWW-Authenticate:| cut -d\" -f4 ) A1=$(echo -n "$user":"$realm":"$pw"|openssl md5) A2=$(echo -n "REGISTER":"sip:$gw"|openssl md5) res=$(echo -n "$A1":"$nonce":"$A2"|openssl md5) let "nreq=nreq+1" register $res $nonce | nc -q 5 -u -p $port $gw 5060 nc -l -u -p $port