This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| app-notes:changing-password [2026/08/31 13:58] – [Goal] gray | app-notes:changing-password [2026/09/08 12:57] (current) – [3. Additional information] gray | ||
|---|---|---|---|
| Line 315: | Line 315: | ||
| | | ||
| } | } | ||
| + | # Store password unencrypted | ||
| + | | ||
| + | save = nb_config_get(store_password); | ||
| + | | ||
| + | | ||
| + | | ||
| + | ret = nb_config_done(); | ||
| + | while (ret){ | ||
| + | printf(" | ||
| + | ret = nb_config_done(); | ||
| + | sleep(1); | ||
| + | } | ||
| + | } | ||
| | | ||
| | | ||
| Line 320: | Line 333: | ||
| daten = ''; | daten = ''; | ||
| | | ||
| + | | ||
| } | } | ||
| | | ||
| Line 343: | Line 357: | ||
| {{: | {{: | ||
| + | |||
| + | Change the Telnet port to port number 65023. | ||
| + | |||
| + | {{: | ||
| The website' | The website' | ||
| Line 592: | Line 610: | ||
| | | ||
| } | } | ||
| + | # Store password unencrypted | ||
| + | | ||
| + | save = nb_config_get(store_password); | ||
| + | | ||
| + | | ||
| + | | ||
| + | ret = nb_config_done(); | ||
| + | while (ret){ | ||
| + | printf(" | ||
| + | ret = nb_config_done(); | ||
| + | sleep(1); | ||
| + | } | ||
| + | } | ||
| | | ||
| | | ||
| Line 597: | Line 628: | ||
| daten = ''; | daten = ''; | ||
| | | ||
| + | | ||
| } | } | ||
| | | ||
| | | ||
| + | } | ||
| + | </ | ||
| + | ++++ | ||
| + | |||
| + | If you want to automatically reset passwords to a fixed default password, you can use these two scripts. | ||
| + | |||
| + | The script resets the stored user passwords to a default password every month. | ||
| + | The '' | ||
| + | |||
| + | ++++show code| | ||
| + | <code – Set_a_default_password_every_month.are> | ||
| + | # The script resets the stored user passwords to a default password every month. | ||
| + | |||
| + | nb_config_set(" | ||
| + | last_run_month = ""; | ||
| + | |||
| + | string telnet(ip, port, user, password, cmd) | ||
| + | { | ||
| + | if ((sock = socket(AF_INET, | ||
| + | if (connect(sock, | ||
| + | try { | ||
| + | if ((buf = recv(sock)) == NULL || strlen(buf) < 3) throw NULL; | ||
| + | buf = explode(buf); | ||
| + | if (buf[0] == " | ||
| + | { | ||
| + | if (buf[1] == " | ||
| + | if (send(sock, " | ||
| + | if (send(sock, " | ||
| + | } else { | ||
| + | for (i = 0; i < strlen(buf); | ||
| + | if (buf[i] == " | ||
| + | else if (buf[i] == " | ||
| + | if (send(sock, implode(buf)) == -1) throw NULL; | ||
| + | } | ||
| + | } | ||
| + | if ((buf = recv(sock)) == NULL || strlen(buf) < 1) throw NULL; // user ? | ||
| + | if (send(sock, strcat(user, | ||
| + | if ((buf = recv(sock)) == NULL || strlen(buf) < 1)throw NULL; // password ? | ||
| + | if (send(sock, strcat(password, | ||
| + | while((s = select(sock, | ||
| + | if (s == -1) throw NULL; //ignore all garbage | ||
| + | if (send(sock, strcat(cmd, " | ||
| + | rbuf =""; | ||
| + | while((s = select(sock, | ||
| + | if (s == -1) throw NULL; | ||
| + | else rbuf = strcat(rbuf, | ||
| + | } | ||
| + | rbuf = right(rbuf, strlen(rbuf) - strlen(cmd) - 2); //cut cmd | ||
| + | if (pos = strrchr(rbuf, | ||
| + | rbuf = left(rbuf, pos); | ||
| + | throw rbuf; | ||
| + | } catch (ret) { | ||
| + | close (sock); | ||
| + | return ret; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | while (true){ | ||
| + | now = time(); | ||
| + | dt = localtime(now); | ||
| + | /* Debug: Current Time */ | ||
| + | stamp = strftime(" | ||
| + | printf(" | ||
| + | /* Day and Month as Strings */ | ||
| + | day_str | ||
| + | month_str = strftime(" | ||
| + | /* Debug: Status */ | ||
| + | printf(" | ||
| + | /* Run exactly once on the 1st of the month */ | ||
| + | if (day_str == " | ||
| + | pass = nb_config_get(" | ||
| + | if (pass != '' | ||
| + | command = strcat(" | ||
| + | password = strcat(telnet(" | ||
| + | sleep(1); | ||
| + | for (;password == ""; | ||
| + | | ||
| + | | ||
| + | } | ||
| + | for (i = 0; i < 20; i++){ | ||
| + | user_temp = nb_config_get(sprintf(" | ||
| + | |||
| + | | ||
| + | // who has been added to the system. | ||
| + | // If you want to reset only a specific user, | ||
| + | // you can do so by making this change | ||
| + | // if(user_temp == “< | ||
| + | |||
| + | daten = sprintf(" | ||
| + | | ||
| + | ret = nb_config_done(); | ||
| + | while (ret){ | ||
| + | printf(" | ||
| + | ret = nb_config_done(); | ||
| + | sleep(1); | ||
| + | } | ||
| + | } | ||
| + | # Store password unencrypted | ||
| + | | ||
| + | save = nb_config_get(store_password); | ||
| + | | ||
| + | | ||
| + | | ||
| + | ret = nb_config_done(); | ||
| + | while (ret){ | ||
| + | printf(" | ||
| + | ret = nb_config_done(); | ||
| + | sleep(1); | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | last_run_month = month_str; | ||
| + | printf(" | ||
| + | pass = ''; | ||
| + | daten = ''; | ||
| + | password = ''; | ||
| + | store_encrypt = ''; | ||
| + | } | ||
| + | } | ||
| + | | ||
| + | } | ||
| + | </ | ||
| + | ++++ | ||
| + | |||
| + | The script resets the stored user passwords to a default password every week. | ||
| + | The '' | ||
| + | |||
| + | ++++show code| | ||
| + | <code – Set_a_default_password_every_week.are> | ||
| + | # The script resets the stored user passwords to a default password every week. | ||
| + | |||
| + | nb_config_set(" | ||
| + | last_run_week = ""; | ||
| + | |||
| + | string telnet(ip, port, user, password, cmd) | ||
| + | { | ||
| + | if ((sock = socket(AF_INET, | ||
| + | if (connect(sock, | ||
| + | try { | ||
| + | if ((buf = recv(sock)) == NULL || strlen(buf) < 3) throw NULL; | ||
| + | buf = explode(buf); | ||
| + | if (buf[0] == " | ||
| + | { | ||
| + | if (buf[1] == " | ||
| + | if (send(sock, " | ||
| + | if (send(sock, " | ||
| + | } else { | ||
| + | for (i = 0; i < strlen(buf); | ||
| + | if (buf[i] == " | ||
| + | else if (buf[i] == " | ||
| + | if (send(sock, implode(buf)) == -1) throw NULL; | ||
| + | } | ||
| + | } | ||
| + | if ((buf = recv(sock)) == NULL || strlen(buf) < 1) throw NULL; // user ? | ||
| + | if (send(sock, strcat(user, | ||
| + | if ((buf = recv(sock)) == NULL || strlen(buf) < 1)throw NULL; // password ? | ||
| + | if (send(sock, strcat(password, | ||
| + | while((s = select(sock, | ||
| + | if (s == -1) throw NULL; //ignore all garbage | ||
| + | if (send(sock, strcat(cmd, " | ||
| + | rbuf =""; | ||
| + | while((s = select(sock, | ||
| + | if (s == -1) throw NULL; | ||
| + | else rbuf = strcat(rbuf, | ||
| + | } | ||
| + | rbuf = right(rbuf, strlen(rbuf) - strlen(cmd) - 2); //cut cmd | ||
| + | if (pos = strrchr(rbuf, | ||
| + | rbuf = left(rbuf, pos); | ||
| + | throw rbuf; | ||
| + | } catch (ret) { | ||
| + | close (sock); | ||
| + | return ret; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | while (true){ | ||
| + | now = time(); | ||
| + | dt = localtime(now); | ||
| + | /* Debug: Current Time */ | ||
| + | stamp = strftime(" | ||
| + | printf(" | ||
| + | /* ISO week string (YYYY-WW) and weekday */ | ||
| + | week_str | ||
| + | weekday_str = strftime(" | ||
| + | /* Debug: Status */ | ||
| + | printf(" | ||
| + | /* Run exactly once per week on Monday */ | ||
| + | if (weekday_str == " | ||
| + | pass = nb_config_get(" | ||
| + | if (pass != '' | ||
| + | command = strcat(" | ||
| + | password = strcat(telnet(" | ||
| + | sleep(1); | ||
| + | for (;password == ""; | ||
| + | | ||
| + | | ||
| + | } | ||
| + | for (i = 0; i < 20; i++){ | ||
| + | user_temp = nb_config_get(sprintf(" | ||
| + | | ||
| + | | ||
| + | // who has been added to the system. | ||
| + | // If you want to reset only a specific user, | ||
| + | // you can do so by making this change | ||
| + | // if(user_temp == “< | ||
| + | |||
| + | |||
| + | |||
| + | daten = sprintf(" | ||
| + | | ||
| + | ret = nb_config_done(); | ||
| + | while (ret){ | ||
| + | printf(" | ||
| + | ret = nb_config_done(); | ||
| + | sleep(1); | ||
| + | } | ||
| + | } | ||
| + | # Store password unencrypted | ||
| + | | ||
| + | save = nb_config_get(store_password); | ||
| + | | ||
| + | | ||
| + | | ||
| + | ret = nb_config_done(); | ||
| + | while (ret){ | ||
| + | printf(" | ||
| + | ret = nb_config_done(); | ||
| + | sleep(1); | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | last_run_week = week_str; | ||
| + | printf(" | ||
| + | pass = ''; | ||
| + | daten = ''; | ||
| + | password = ''; | ||
| + | store_encrypt = ''; | ||
| + | } | ||
| + | } | ||
| + | | ||
| } | } | ||
| </ | </ | ||