das sind doch keine Fehler, es läuft trotzdem.
das sind doch keine Fehler, es läuft trotzdem.
Moment ... jetzt ... Anmeldung hat funkt.
Wenn ich auf den Server gehe, kommt die Seite, dann gebe ich Passwort "manfred" ein und bekomme diese Ausgabe:
Bei Eingabe von "yy":Code:strupwd >>><<< website_upwd>>>yy<<< G strupwd >>><<< website_upwd>>>yy<<< E strupwd >>><<< website_upwd>>>yy<<< T strupwd >>><<< website_upwd>>>yy<<< strupwd >>><<< website_upwd>>>yy<<< / strupwd >>><<< website_upwd>>>yy<<< ? strupwd >>><<< website_upwd>>>yy<<< u strupwd >>><<< website_upwd>>>yy<<< n strupwd >>><<< website_upwd>>>yy<<< a strupwd >>><<< website_upwd>>>yy<<< m strupwd >>><<< website_upwd>>>yy<<< e strupwd >>><<< website_upwd>>>yy<<< = strupwd >>><<< website_upwd>>>yy<<< & strupwd >>><<< website_upwd>>>yy<<< u strupwd >>><<< website_upwd>>>yy<<< p strupwd >>><<< website_upwd>>>yy<<< w strupwd >>><<< website_upwd>>>yy<<< d strupwd >>><<< website_upwd>>>yy<<< = strupwd >>><<< website_upwd>>>yy<<< m strupwd >>>m<<< website_upwd>>>yy<<< a strupwd >>>ma<<< website_upwd>>>yy<<< n strupwd >>>man<<< website_upwd>>>yy<<< f strupwd >>>manf<<< website_upwd>>>yy<<< r strupwd >>>manfr<<< website_upwd>>>yy<<< e strupwd >>>manfre<<< website_upwd>>>yy<<< d strupwd >>>manfred<<< website_upwd>>>yy<<< strupwd >>>manfred<<< website_upwd>>>yy<<< H strupwd >>>manfred<<< website_upwd>>>yy<<< T strupwd >>>manfred<<< website_upwd>>>yy<<< T strupwd >>>manfred<<< website_upwd>>>yy<<< P strupwd >>>manfred<<< website_upwd>>>yy<<< / strupwd >>>manfred<<< website_upwd>>>yy<<< 1 strupwd >>>manfred<<< website_upwd>>>yy<<< . strupwd >>>manfred<<< website_upwd>>>yy<<< 1 strupwd >>>manfred<<< website_upwd>>>yy<<< strupwd >>>manfred<<< website_upwd>>>yy<<<
Dann kommt die richtige Seite, weil angemeldet und bei Klicken auf Logout kehrt er zurück zur Login-Seite.Code:strupwd >>><<< website_upwd>>>yy<<< G strupwd >>><<< website_upwd>>>yy<<< E strupwd >>><<< website_upwd>>>yy<<< T strupwd >>><<< website_upwd>>>yy<<< strupwd >>><<< website_upwd>>>yy<<< / strupwd >>><<< website_upwd>>>yy<<< ? strupwd >>><<< website_upwd>>>yy<<< u strupwd >>><<< website_upwd>>>yy<<< n strupwd >>><<< website_upwd>>>yy<<< a strupwd >>><<< website_upwd>>>yy<<< m strupwd >>><<< website_upwd>>>yy<<< e strupwd >>><<< website_upwd>>>yy<<< = strupwd >>><<< website_upwd>>>yy<<< & strupwd >>><<< website_upwd>>>yy<<< u strupwd >>><<< website_upwd>>>yy<<< p strupwd >>><<< website_upwd>>>yy<<< w strupwd >>><<< website_upwd>>>yy<<< d strupwd >>><<< website_upwd>>>yy<<< = strupwd >>><<< website_upwd>>>yy<<< y strupwd >>>y<<< website_upwd>>>yy<<< y strupwd >>>yy<<< website_upwd>>>yy<<< GET /?uname=&upwd=yy HTTP/1.1
Geändert von Moppi (19.08.2018 um 11:38 Uhr)
ja,
so sollte es auch sein.
auf user name wird noch nicht geprüft in dieser debug-Version, hier werden noch alle möglichen Eingaben akzeptiert.
yy
ist dann auch das korrekte Passwort für alle User.
allerdings wird eben auch
yy67
als korrekt akzeptiert, was nicht sein dürfte (IMO)
- - - Aktualisiert - - -
PS,
Finden kann er hier uname und struname auch noch nicht im html string, da dort ja '?uname=' steht und nicht '&uname=', was aber nachrangig ist, da ja auch noch nicht darauf geprüft wird.
- - - Aktualisiert - - -
PS,
hier ist die neue cstringarg Version mit testcode, wo auch ?varname= neben &varname= akzeptiert wird:
Code:int16_t strstrpos(char * haystack, char * needle) // find 1st occurance of substr in str { char *p = strstr(haystack, needle); if (p) return p - haystack; return -1; // Not found = -1. } //---------------------------------------------------------------------------- const int MAXLEN = 1024; const int TOKLEN = 64; char * cstringarg( char* haystack, char* vname, char* sarg ) { int i=0, pos=-1; unsigned char ch=0xff; char kini[3] = "&"; // start of varname: '&': char kequ[3] = "="; // end of varname, start of argument: '=' char needle[TOKLEN]=""; // complete pattern: &varname=abc1234 strcpy(sarg,""); strcpy(needle, kini); strcat(needle, vname); strcat(needle, kequ); pos = strstrpos(haystack, needle); if(pos==-1) { needle[0]='?'; pos = strstrpos(haystack, needle); if(pos==-1) return sarg; } pos=pos+strlen(vname)+2; // start of value = kini+vname+kequ while( (ch!='&')&&(ch!='\0') ) { ch=haystack[pos+i]; if( (ch=='&')||(ch==';')||(ch==' ')||(ch=='\0') ||(ch=='\n') ||(i+pos>=strlen(haystack))||(i>TOKLEN-1) ) { sarg[i]='\0'; return sarg; } if( (ch!='&') ) { sarg[i]=ch; i++; } } return sarg; } void setup() { Serial.begin(115200); Serial.println(); Serial.println("Test mit cstringarg()"); Serial.println(); char htmlstring[1024]="html teststring evtl mit Fehlern ?upwd0=QMARKupwd0&upwd1=testupwd1&upwd2=testupwd2 &upwd13=testupwd13&upwd224=testupwd224 EndeTststring"; char argstring[64]=""; cstringarg(htmlstring, "upwd0", argstring); Serial.print("upwd0 >>"); Serial.print(argstring); Serial.println("<< soll: >>QMARKupwd0<<"); cstringarg(htmlstring, "upwd1", argstring); Serial.print("upwd1 >>"); Serial.print(argstring); Serial.println("<< soll: >>testupwd1<<"); cstringarg(htmlstring, "upwd2", argstring); Serial.print("upwd2 >>"); Serial.print(argstring); Serial.println("<< soll: >>testupwd2<<"); cstringarg(htmlstring, "upwd13", argstring); Serial.print("upwd13 >>"); Serial.print(argstring); Serial.println("<< soll: >>testupwd13<<"); cstringarg(htmlstring, "upwd224", argstring); Serial.print("upwd224 >>"); Serial.print(argstring); Serial.println("<< soll: >>testupwd224<<"); cstringarg(htmlstring, "upwd9", argstring); Serial.print("upwd9 >>"); Serial.print(argstring); Serial.println("<< soll: >><< (// not found)"); } void loop() { }
Geändert von HaWe (19.08.2018 um 13:58 Uhr)
So wie ich das sehe wird in einer Schleife der String zusammengesetzt vom Parameter upwd. Und nach jedem Zeichen wird geprüft, ob das Password stimmt. Irgendwann gibt es eine Übereinstimmung und die restlichen Zeichen des gesendeten Passwords werden nicht mehr berücksichtigt. Erst muss der gesamte String zusammen sein, von upwd. Dann erst darf geprüft werden.
Hier sieht man das:
Code:strupwd >>><<< website_upwd>>>yy<<< y strupwd >>>y<<< website_upwd>>>yy<<< y strupwd >>>yy<<< website_upwd>>>yy<<< GET /?uname=&upwd=yy11111111111111 HTTP/1.1
ja, den Verdacht hatte ich ja auch schon, aber wie kann man das ändern`?
Änderungen:
Dann funktioniert es. Allerdings wahrscheinlich nur, weil nach dem Password der String auch endet. Sollte nach &upwd=yy noch was stehen wie: &upwd=yy&name=uschi könnte es sein, dass es wieder nicht funktioniert. Das habe ich nicht probiert.Code:if ( client.available() ) { char c = client.read(); .... }else stringok = true; if ( stringok && (strlen(strupwd) == strlen(website_upwd)) && (strcmp(website_upwd, strupwd) == 0) ) { authorized = true; //debug //Serial.print("check: authorized="); Serial.println(authorized); readString = "", stringok = false; return; } void handleNotAuthorized() { .... bool stringok = false;
Geändert von Moppi (19.08.2018 um 17:02 Uhr)
außerhalb von handleNotAuthorized() testen? oder ist da dein Code irgendwie durcheinander?
Könntest du evtl bitte mal den kompletten Code posten?
- - - Aktualisiert - - -
klappt nicht bei mir, oder dein Code ist unvollständig...
Lesezeichen