forked from mcktr/check_tr64_fritz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetSecurityPort
executable file
·34 lines (25 loc) · 890 Bytes
/
getSecurityPort
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
find_xml_value()
{
xml=$1
value=$2
echo "${xml}" | sed -ne "/<${value}>/s#\s*<[^>]*>\s*##gp"
}
usage()
{
echo "getSecurityPort <HOST>"
echo " <HOST> = IP of your Fritz!Box"
}
HOSTNAME=$1
if [ -z ${HOSTNAME} ]; then
usage
exit 0
fi
queryResult=$(curl "http://${HOSTNAME}:49000/upnp/control/deviceinfo" \
-s \
-H "Content-Type: text/xml; charset='utf-8'" \
-H "SOAPACTION: urn:dslforum-org:service:DeviceInfo:1#GetSecurityPort" \
-d "<?xml version='1.0'?> <s:Envelope xmlns:s='http://schemas.xmlsoap.org/soap/envelope/' s:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'> <s:Body> <u:GetSecurityPort xmlns:u='urn:dslforum-org:service:DeviceInfo:1'> </u:GetSecurityPort> </s:Body> </s:Envelope>")
securityPort=$(find_xml_value "${queryResult}" "NewSecurityPort")
echo "Your Fritz!Box Security Port (for TR-064 over SSL) is: ${securityPort}"
exit 0