tchellomello / python-amcrest

A Python 2.7/3.x module for Amcrest and Dahua Cameras using the SDK HTTP API.
GNU General Public License v2.0
216 stars 76 forks source link

Please support privacy mode on/off #166

Closed sidamos closed 3 years ago

sidamos commented 4 years ago

My Amcrest IP2M-841B-V3 has a privacy mode. I guess, other cameras have that also.

I have captured the REST calls from the web interface and the Android app. Could not find similar CGI calls, yet.

Privacy mode on (Web):

POST /RPC2 HTTP/1.1^M
Host: 192.168.0.2^M
Connection: keep-alive^M
Content-Length: 213^M
Accept: application/json, text/javascript, */*; q=0.01^M
DNT: 1^M
X-Requested-With: XMLHttpRequest^M
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36^M
Content-Type: application/x-www-form-urlencoded; charset=UTF-8^M
Origin: http://192.168.0.2^M
Referer: http://192.168.0.2/^M
Accept-Encoding: gzip, deflate^M
Accept-Language: de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7^M
Cookie: secure; username=admin; DhWebClientSessionID=d4baee7485d55a42d924c631ceff6c81^M
^M
{"method":"configManager.setConfig","params":{"name":"LeLensMask","table":[{"Enable":true,"LastPosition":[-0.9555555555555556,0.035,0.0078125]}],"options":[]},"id":255,"session":"d4baee7485d55a42d924c631ceff6c81"}

HTTP/1.1 200 OK^M
X-XSS-Protection: 1;mode=block^M
X-Frame-Options: SAMEORIGIN^M
Content-Security-Policy: script-src 'self' 'unsafe-inline' 'unsafe-eval'^M
Strict-Transport-Security: max-age=604800; includeSubDomains^M
CONNECTION: Keep-Alive^M
Set-Cookie:secure; HttpOnly^M
CONTENT-LENGTH: 96^M
^M
{"id":255,"params":{"options":null},"result":true,"session":"d4baee7485d55a42d924c631ceff6c81"}

Privacy mode off (Web):

POST /RPC2 HTTP/1.1^M
Host: 192.168.0.2^M
Connection: keep-alive^M
Content-Length: 214^M
Accept: application/json, text/javascript, */*; q=0.01^M
DNT: 1^M
X-Requested-With: XMLHttpRequest^M
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36^M
Content-Type: application/x-www-form-urlencoded; charset=UTF-8^M
Origin: http://192.168.0.2^M
Referer: http://192.168.0.2/^M
Accept-Encoding: gzip, deflate^M
Accept-Language: de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7^M
Cookie: secure; username=admin; DhWebClientSessionID=8c92af61fadebdaeb0cd584e4bce7a84^M
^M
{"method":"configManager.setConfig","params":{"name":"LeLensMask","table":[{"Enable":false,"LastPosition":[-0.9555555555555556,0.035,0.0078125]}],"options":[]},"id":242,"session":"8c92af61fadebdaeb0cd584e4bce7a84"}

HTTP/1.1 200 OK^M
X-XSS-Protection: 1;mode=block^M
X-Frame-Options: SAMEORIGIN^M
Content-Security-Policy: script-src 'self' 'unsafe-inline' 'unsafe-eval'^M
Strict-Transport-Security: max-age=604800; includeSubDomains^M
CONNECTION: Keep-Alive^M
Set-Cookie:secure; HttpOnly^M
CONTENT-LENGTH: 96^M
^M
{"id":242,"params":{"options":null},"result":true,"session":"8c92af61fadebdaeb0cd584e4bce7a84"}

Privacy mode on (App):

{ "id" : 44564, "method" : "configManager.getConfig", "params" : { "channel" : 0, "name" : "LeLensMask" }, "session" : 2147464963 }
{"id":44564,"params":{"table":{"Enable":true,"LastPosition":[-0.9555555582046509,0.03500000014901161,0.00781250]}},"result":true,"session":2147464963}
{ "id" : 45076, "method" : "configManager.setConfig", "params" : { "channel" : 0, "name" : "LeLensMask", "table" : { "Enable" : false, "LastPosition" : [ -0.9555555582046509, 0.03500000014901161, 0.007812500000000000 ] } }, "session" : 2147464963 }

Privacy mode off (App):

{ "id" : 44564, "method" : "configManager.getConfig", "params" : { "channel" : 0, "name" : "LeLensMask" }, "session" : 2147464963 }
{"id":44564,"params":{"table":{"Enable":true,"LastPosition":[-0.9555555582046509,0.03500000014901161,0.00781250]}},"result":true,"session":2147464963}
{ "id" : 45076, "method" : "configManager.setConfig", "params" : { "channel" : 0, "name" : "LeLensMask", "table" : { "Enable" : false, "LastPosition" : [ -0.9555555582046509, 0.03500000014901161, 0.007812500000000000 ] } }, "session" : 2147464963 }
sidamos commented 4 years ago

Found out the cgi-bin commands for that:

/cgi-bin/configManager.cgi?action=getConfig&name=LeLensMask
/cgi-bin/configManager.cgi?action=setConfig&LeLensMask[0].Enable=true
/cgi-bin/configManager.cgi?action=setConfig&LeLensMask[0].Enable=false 
pjrt commented 3 years ago

So one issue here is that this API is undocumented. I would love for this to be added added anyways.

https://drive.google.com/file/d/1VM2Tb-q4PhmZuvLxSk5OwWInbFxUuTR-/view