#!/bin/bash URL=http://fritz.box USERPASSLOGIN=0 USERE=fritzuser PASSE=fritzpass PASS=fritzpass TELEFONBUCH7=2 FILE7="@/tmp/tellows_7.xml" TELEFONBUCH89=3 FILE89="@/tmp/tellows_8-9.xml" wget -q -O /tmp/tellows_7.xml "tellows Download LINK" wget -q -O /tmp/tellows_8-9.xml "tellows Download LINK" if [ $USERPASSLOGIN == 1 ] ; then CURLUSERPASSSTRING="--user ${USER}:${PASSE}" else CURLUSERPASSSTRING="--user :${PASS}" PASSE=$PASS fi _CHALLENGE=`curl -s -k \ ${CURLUSERPASSSTRING} \ "${URL}/login_sid.lua" | \ grep Challenge | sed -e 's/.*//' | sed -e 's/<\/Challenge>.*//'` if [ -z "${_CHALLENGE}" ] ; then echo "Error getting challenge using ${URL}" >&2 else # echo "Received Challenge \"${_CHALLENGE}\"" >&2 # build md5 from challenge key and password _MD5=`echo -n ${_CHALLENGE}"-"${PASSE} | \ iconv -f ISO8859-1 -t UTF-16LE | \ md5sum -b | awk '{print substr($0,1,32)}'` # assemble challenge key and md5 _RESPONSE=${_CHALLENGE}"-"${_MD5} # get sid for later use _SID=`curl -i -s -k \ ${CURLUSERPASSSTRING} \ -d 'response='${_RESPONSE} \ -d 'page=' \ -d 'username='${USER} \ ${URL}/login_sid.lua | \ grep SID | sed -e 's/.*//' | sed -e 's/<\/SID>.*//'` if ! curl -s -k \ ${CURLUSERPASSSTRING} \ --form 'sid='${_SID} \ --form 'PhonebookId='${TELEFONBUCH7} \ --form 'PhonebookImportFile='${FILE7} \ ${URL}/cgi-bin/firmwarecfg >TMP1 ; then echo "Error 7" >&2 fi sleep 10 if ! curl -s -k \ ${CURLUSERPASSSTRING} \ --form 'sid='${_SID} \ --form 'PhonebookId='${TELEFONBUCH89} \ --form 'PhonebookImportFile='${FILE89} \ ${URL}/cgi-bin/firmwarecfg >TMP1 ; then echo "Error 89" >&2 fi fi