667bdrm / sofiactl

sofiactl is an open source cross-platform tool and sdk to control Sofia powered Hi35xx DVR devices
78 stars 22 forks source link

How to restore config? #1

Open andreybavt opened 5 years ago

andreybavt commented 5 years ago

Hello,

I played with ConfigSet method and I think I broke the camera configuration on HI3516. Now if I call sofiactl.pl --user admin --host 192.168.1.10 --port 34567 --command ConfigGet --co AVEnc I get a response that doesn't contain some of the fields, for example Encode:

'Encode' => undef,
'VideoColor' => undef,
'VideoWidget' => undef,

Do you know if there's a way to restore this configuration to get camera back to life? P.S. I have telnet access to the camera, but I couldn't find where this configuration is stored.

Thanks

667bdrm commented 5 years ago

Hello. If you have made config export before, you could try to use vendor ui to restore configuration or reset to factory settings. All tool supported commands has been developed by analysis of original CMS software communication, so that functionality should be available in CMS. On my devices I was able to mount filesystem using NFS. Configuration files are kept in same JSON format as it exported.

Here is described how to mount NFS. You must be logged in as root: https://felipe.astroza.cl/hacking-hi3518-based-ip-camera/

Also here is a instruction that I've used to restore forgotten password through configuration files replacement. Similar methods could be used to restore settings. There could be some differences for your device, like paths, device names, etc.

On server:

  1. apt-get install nfs-common nfs-server -y
  2. mkdir -p /home/nfs
  3. chmod 777 /home/nfs
  4. add to /etc/exports

/home/nfs *(rw,sync,no_root_squash,fsid=0,crossmnt,no_subtree_check)

  1. service rpcnind start

On DVR/IPC:

  1. telnet as root / xc3511 (or other)

  2. mkdir -p /var/tmp/nfs

  3. mount -t nfs 192.168.14.121:/home/nfs -o nolock /var/tmp/nfs

  4. Copy following files to nfs

cp /mnt/mtd/Config/Account1 /var/tmp/nfs cp /mnt/mtd/Config/Account2 /var/tmp/nfs

  1. Change password hash for the needed user to the hash of the known password on the host machine

  2. Update account files

cat /var/tmp/nfs/Account1 > /mnt/mtd/Config/Account1 cat /var/tmp/nfs/Account2 > /mnt/mtd/Config/Account2

  1. Determine Sofia lanuch script (dvrHelper /lib/modules /var/Sofia 127.0.0.1 9578 1)

cat /etc/init.d/rcS

  1. Find Sofia process id

ps

  1. Kill Sofia

kill <sofiapid>

  1. Execute Sofia launch script

dvrHelper /lib/modules /var/Sofia 127.0.0.1 9578 1

  1. Try to authenticate to specified user by known password
JoeLoginIsAlreadyTaken commented 5 years ago

I had the same problem with my IVG-85HG50PYA-S, while trying to switch the IR Filter manually.

After i had written "Camera.Param" into just "Camera", die 'Camera param.'-Section in the Frontend was no longer accessible. All the other functions where still working.

Unfortunately i had no prior export of the whole configuration. This is what i did:

I exported the configuration from the cameras web Frontend (or CMS Tool). This File ist a ZIP-File.

Then i did the same with a different Camera, but with a similar Chip (Hi3516V100 instead of Hi3516V300), and other sensor. The i have copied the files "json/Camera" and json/Camera2 over the broken ones from my IVG-85HG50PYA-S. Re-Zipped the files and imported these File (rename to .cfg) on my IVG-85HG50PYA-S.

After that everything was working again.

Maybe this will held others.

BTW: IR Filter switching can be done by changing the DayNightColor Parameter. --command ConfigGet --co Camera.Param[0].DayNightColor

667bdrm commented 4 years ago

Also there are another way to factory reset using commands extracted from OEM ResetACTool.exe:

  1. connect telnet as root. Telnet is opened by default on old devices, on new devices try to activate telnet with this tool https://github.com/Snawoot/hisilicon-dvr-telnet (ResetACTool.exe doing same)

  2. Backup existing /mnt/mtd/Config/* (or better backup all mtdblock partitions, see https://github.com/667bdrm/sofiactl/issues/8#issuecomment-691716034)

  3. Execute following to reset only user accounts to default:

rm -rf /mnt/mtd/Config/Account* reboot;exit

  1. Execute following to reset all configuration to default:

rm -rf /mnt/mtd/Config/* reboot;exit

The commands fro 3 and 4 is cutted out from ResetACTool.exe, I didn't tested it on real devices. The telnet activation just tested on new XM ipcam.

667bdrm commented 3 years ago

Also new version has OPDefaultConfig command