Ich habe mit der Hilfe von euch ( https://forum.ubuntuusers.de/topic/nc-spoof-http-header/ ) und ip-phone-forum.de ein Script gebaut welches unter Ubuntub Mate 16.04 im Terminal funktioniert:
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 35 36 37 38 39 40 41 42 43 44 45 | #! /bin/sh BODY="dst=https%3A%2F%2Fconnect.meinhotspot.com%2Fde%2Fclient%2Fredirect&popup=true&username=XX%XXXX%XXXX%XXXX%XXXX%XXXX&password=XX%XXXX%XXXX%XXXX%XXXX%XXXX&mac=XX%XXXX%XXXX%XXXX%XXXX%XXXX" wget -q -O- login.meinhotspot.com/login | grep 'Sie wurden soeben auf dem Hotspot eingeloggt und werden weitergeleitet.' rc=$? if [ $rc -ne 0 ] then echo "POST /login HTTP/1.1\r\nHost: login.meinhotspot.com\r\nUser-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\nAccept-Language: en-US,en;q=0.5\r\nAccept-Encoding: gzip, deflate, br\r\nReferer: https://connect.meinhotspot.com/en/client/welcome\r\nConnection: Close\r\nUpgrade-Insecure-Requests: 1\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: ${#BODY}\r\n\r\n${BODY}" | nc login.meinhotspot.com 80 else time=`wget -q -O- login.meinhotspot.com/status | grep "s</td" | sed 's/<[^>]*>//g' | sed 's/\t//g' | cut -f3 -d"/"` echo $time | grep "h" rc=$? if [ $rc -eq 0 ] then hour=`echo $time | cut -f1 -d"h"` echo $time | grep "m" rc=$? if [ $rc -eq 0 ] then minute=$((`echo $time | cut -f2 -d"h" | cut -f1 -d"m"`+$hour*60)) else minute=$(($hour*60)) fi else echo $time | grep "m" rc=$? if [ $rc -eq 0 ] then minute=`echo $time | cut -f1 -d"m"` else minute=1 fi fi if [ $minute -lt 5 ] then echo "weniger als 5 Minuten" wget -qO- login.meinhotspot.com/logout &>/dev/null #BODY_LEN=$( echo -n ${BODY} | wc -c ) #echo $BODY_LEN #echo ${#BODY} sleep 1 echo "POST /login HTTP/1.1\r\nHost: login.meinhotspot.com\r\nUser-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\nAccept-Language: en-US,en;q=0.5\r\nAccept-Encoding: gzip, deflate, br\r\nReferer: https://connect.meinhotspot.com/en/client/welcome\r\nConnection: Close\r\nUpgrade-Insecure-Requests: 1\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: ${#BODY}\r\n\r\n${BODY}" | nc login.meinhotspot.com 80 else echo "mehr als 5 Minuten" fi fi |
Führe ich es allerdings in der Fritz!Box aus habe ich folgendes Problem: Führe ich folgendes als #/bin/sh Script aus (Telnet auf die Fritz!Box und dort das Script ausgeführt):
1 2 3 | wget -q -O- login.meinhotspot.com/login | grep 'Sie wurden soeben auf dem Hotspot eingeloggt und werden weitergeleitet.' rc=$? echo $? |
Bekomme ich als Rückgabe 0
Führe ich die gleichen Befehle einfach in der Konsole (per Telnet verbunden) bekomme ich als Rückgabe 1 Korrekt war im Testfall 1, warum spuckt das Script das falsche Ergebnis aus?