Repository navigation
telnet_opener: newer-firmware root password, and don't crash on reboot - #14
Conversation
Two things break telnet_opener on Xiongmai firmware built from 2021 on: - The stock telnet root password is no longer xmhdipc but Hp#!8CocD_g (seen on HI3516EV300_85H50AI 000529B2 build 2021-03-03 and a 2024 GK7201V200 build). Both are now tried, in a TELNET_CREDENTIALS table, by a new telnet_login() helper the backup path uses; the "telnet open" message and the README list both. - After the enable-telnet upload, the updater reboots the camera itself, so the follow-up DVRIP login can hit a dropped/empty connection. dvrip.login() raises on that (TypeError from data["Ret"] on a None reply) rather than returning False, which aborted the whole run with a traceback even though telnet came up fine. That login is now guarded.
PR Summary by QodoSupport newer Xiongmai telnet passwords and self-rebooting cameras
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
Code Review by Qodo
1.
|
DVRIPCam.connect() raises SomethingIsWrongWithCamera (a bare Exception, not an OSError) when the post-upload socket connect fails, which is exactly the mid-reboot case the guard is for. Without it in the tuple the exception escaped and the telnet probe never ran.
|
Fixed in ae07e25: |
Enabling telnet on a recent Xiongmai camera with
telnet_opener.py <ip>hit two problems. Found while restoring telnet on anHI3516EV300_85H50AI(000529B2, build 2021-03-03).1. Root password changed on newer firmware
The stock telnet login is no longer
root/xmhdipc. Builds from 2021 on useroot/Hp#!8CocD_g(confirmed on this000529B22021-03-03 build, and the same password is on a 2024GK7201V200build). The backup path hard-codedxmhdipc, so it would sit at the password prompt and fail.TELNET_CREDENTIALStable and atelnet_login()helper that tries each credential and returns the connected socket at the shell prompt (orNone).do_backup_via_telnet()uses it instead of hard-codedroot/xmhdipc.2. Traceback when the updater reboots on its own
After the SkipCheck InstallDesc upload, the camera's updater reboots the box by itself. The follow-up
DVRIPCam.login()then meets a dropped/silent connection, anddvrip.pyraises (TypeError: 'NoneType' object is not subscriptablefromdata["Ret"]) rather than returningFalse. That aborted the whole run with a traceback even though telnet was about to come up. That reboot-login is now wrapped, and reported as the camera already rebooting.Testing
On a live
000529B22021-03-03 unit:telnet_login()triesxmhdipc, falls through, logs in withHp#!8CocD_g, and runs a command.python3 telnet_opener.py <ip>with no flags now enables persistent telnet (telnetctrl=1in the env, verified withXmEnv -r) and returns cleanly across the self-reboot.python3 -c "import ast; ast.parse(...)"passes; no new imports or names for the CI ruff check.No behaviour change for older
xmhdipccameras: that credential is tried first.