2 #modify next two line for your DSP-W215
5 #do not modify after this line if you don't know what you are doing
8 echo -e "\nUsage: $(basename $0) [OPTION]"
10 echo -e "\t--getstate"
12 echo -e "\t--noise SoundType(1-6) Volume(0-100) Duration(??)"
18 echo -n "$data" | openssl dgst "-md5" -hmac "$key" -binary | xxd -ps -u
21 contentType="Content-Type: text/xml; charset=utf-8"
22 soapLogin="SOAPAction: \"http://purenetworks.com/HNAP1/Login\""
26 head="<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body>"
27 end="</soap:Body></soap:Envelope>"
29 message="<Login xmlns=\"http://purenetworks.com/HNAP1/\"><Action>request</Action><Username>admin</Username><LoginPassword>$password</LoginPassword><Captcha/></Login>"
30 loginrequest="$head$message$end"
32 ret=`curl -s -X POST -H "$contentType" -H "$soapLogin" --data-binary "$loginrequest" http://$IP/HNAP1`
35 opt=`echo -n "$ret" | grep -Po "(?<=<$1>).*(?=</$1>)"`
45 challenge=`getResult Challenge`
46 cookie="Cookie: uid=`getResult Cookie`"
47 publickey="`getResult PublicKey`$PIN"
48 privatekey=`hash_hmac "$challenge" "$publickey"`
49 password=`hash_hmac "$challenge" "$privatekey"`
51 auth_str="$timestamp\"http://purenetworks.com/HNAP1/Login\""
52 auth=`hash_hmac "$auth_str" "$privatekey"`
53 hnap_auth="HNAP_AUTH: $auth $timestamp"
55 message="<Login xmlns=\"http://purenetworks.com/HNAP1/\"><Action>login</Action><Username>admin</Username><LoginPassword>$password</LoginPassword><Captcha/></Login>"
57 login="$head$message$end"
60 mret=`curl -s -X POST -H "$contentType" -H "$soapLogin" -H "$hnap_auth" -H "$cookie" --data-binary "$login" http://$IP/HNAP1`