bp2008 / DahuaSunriseSunset

A Windows Service which changes the profile of dahua cameras between Night and Day at each sunset and sunrise.
GNU General Public License v2.0
19 stars 8 forks source link

Exception while running on Dahua EZ-IP cameras #7

Open vascojdb opened 3 years ago

vascojdb commented 3 years ago

Hi, I have 10 Dahua EZ-IP IPC-D20B20-ZS cameras, and unfortunately It seems your tool gives me an exception:

Exception thrown attempting web request (http://192.168.0.130/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[0].Config[0]=1): The request was aborted: The operation has timed out.

Opening that link on a browser returns a 404 error page (generated by the camera, not the browser)

I tried to sniff the browser data being changed while sapping the Day/Night options via the web interface and I got this:

Message: POST
To: 192.168.0.130:80/RPC2
Authorization: Basic Authentication (user+pass)
Body: JSON with contents: {"method":"configManager.setConfig","params":{"name":"VideoInMode","table":[{"Config":[X],"Mode":0}],"options":[]},"id":0,"session":"528b19ba62cb02611358896"}

Where [X] is 1 or 0 depending on the day or night profile, the session ID its generated somewhere.

Has anyone contacted you related to any API changes? Since I am not able to find the cgi-bin directory.

Thank you so much for the information

bp2008 commented 3 years ago

I don't know anything about that camera. Couldn't find it via google. It could be that the camera for some reason just doesn't support any of the usual APIs designed for 3rd-party use.

While it is possible to implement something that uses their internal API to basically impersonate a web browser and log in, send the command, and log out, that is not something this app supports.

Has anyone contacted you related to any API changes?

No.

rapi3 commented 3 years ago

This camera it is a Huawei product sold under Dahua name and yes it have all the backdoor required to be sold outside China. https://breakingdefense.com/2019/07/hunting-huaweis-hidden-back-doors/

vascojdb commented 3 years ago

Thank you for the fast answer. I actually managed to find a python script called DahuaRpc wrapper which implements an RPC protocol wrapper (https://gist.github.com/gxfxyz/48072a72be3a169bc43549e676713201), and I have managed to change the configuration on the cameras. Apparently these cameras use the API via RPC protocol.

vascojdb commented 3 years ago

Unfortunatly I know nothing of C++/C# to be able to implement this on a fork of your project, so I am afraid I will have to just make a python script on my end :(

rapi3 commented 3 years ago

here you can find something that can be useful if you change to use the RPC protocol wrapper you found it: https://github.com/mcw0/Tools