- Labornetzteil AliExpress         
Ergebnis 1 bis 10 von 36

Thema: html code für User Login + password (esp8266 + Arduino IDE)

Hybrid-Darstellung

Vorheriger Beitrag Vorheriger Beitrag   Nächster Beitrag Nächster Beitrag
  1. #1
    HaWe
    Gast
    das sind doch keine Fehler, es läuft trotzdem.

  2. #2
    Erfahrener Benutzer Robotik Einstein
    Registriert seit
    18.03.2018
    Beiträge
    2.648
    Moment ... jetzt ... Anmeldung hat funkt.

    Wenn ich auf den Server gehe, kommt die Seite, dann gebe ich Passwort "manfred" ein und bekomme diese Ausgabe:

    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<<<
    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<<<
    y
    strupwd     >>>y<<<
    website_upwd>>>yy<<<
    y
    strupwd     >>>yy<<<
    website_upwd>>>yy<<<
    GET /?uname=&upwd=yy HTTP/1.1
    Dann kommt die richtige Seite, weil angemeldet und bei Klicken auf Logout kehrt er zurück zur Login-Seite.
    Geändert von Moppi (19.08.2018 um 11:38 Uhr)

  3. #3
    HaWe
    Gast
    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)

  4. #4
    Erfahrener Benutzer Robotik Einstein
    Registriert seit
    18.03.2018
    Beiträge
    2.648
    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

  5. #5
    HaWe
    Gast
    ja, den Verdacht hatte ich ja auch schon, aber wie kann man das ändern`?

  6. #6
    Erfahrener Benutzer Robotik Einstein
    Registriert seit
    18.03.2018
    Beiträge
    2.648
    Änderungen:

    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;
    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.
    Geändert von Moppi (19.08.2018 um 17:02 Uhr)

  7. #7
    HaWe
    Gast
    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...

Ähnliche Themen

  1. html-Code für nodeMCU mit Arduino IDE + Wifi libs
    Von HaWe im Forum Arduino -Plattform
    Antworten: 7
    Letzter Beitrag: 14.08.2018, 18:30
  2. Pegelwandler RX/TX Arduino ESP8266
    Von Cysign im Forum Elektronik
    Antworten: 3
    Letzter Beitrag: 05.02.2018, 23:29
  3. ESP8266 boards per per Arduino-IDE programmieren?
    Von HaWe im Forum Arduino -Plattform
    Antworten: 27
    Letzter Beitrag: 10.06.2017, 15:19
  4. arduino ide mit esp8266
    Von NotEvil im Forum NodeMCU-Board und ESP8266, ESP32-Serie
    Antworten: 4
    Letzter Beitrag: 12.01.2017, 14:17
  5. HTML-Code (scripts)
    Von Technik =) im Forum Umfragen
    Antworten: 6
    Letzter Beitrag: 10.10.2008, 09:21

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •  

Solar Speicher und Akkus Tests